[i2c] [PATCH] i2c: Declare more i2c_adapter parent devices

Jean Delvare khali at linux-fr.org
Thu Jan 4 17:48:09 CET 2007


Declare the parent device of i2c_adapter devices each time we can
easily do so. It makes the i2c_adapter appear at the right place in
the device tree, rather than as a platform device.

The remaining i2c bus drivers (one dozen) will need to be fixed one by
one, most likely by turning them info platform drivers.

Signed-off-by: Jean Delvare <khali at linux-fr.org>
---
Note: this applies on top of David Brownell's recent patchset preparing
the removal of i2c_adapter.dev, which will hit -mm really soon now, and
is also available here:
http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/

 drivers/acpi/i2c_ec.c                             |    1 +
 drivers/i2c/busses/i2c-amd756-s4882.c             |    2 ++
 drivers/i2c/busses/i2c-ibm_iic.c                  |    1 +
 drivers/i2c/busses/i2c-mv64xxx.c                  |    1 +
 drivers/i2c/busses/scx200_acb.c                   |    7 ++++---
 drivers/ieee1394/pcilynx.c                        |    1 +
 drivers/media/dvb/b2c2/flexcop-i2c.c              |    1 +
 drivers/media/dvb/dvb-usb/dvb-usb-i2c.c           |    1 +
 drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c |    1 +
 drivers/media/video/cafe_ccic.c                   |    1 +
 drivers/media/video/pvrusb2/pvrusb2-i2c-core.c    |    1 +
 drivers/media/video/usbvision/usbvision-i2c.c     |    1 +
 drivers/media/video/w9968cf.c                     |    1 +
 drivers/media/video/zoran_card.c                  |    1 +
 drivers/video/matrox/i2c-matroxfb.c               |    1 +
 15 files changed, 19 insertions(+), 3 deletions(-)

--- linux-2.6.20-rc3.orig/drivers/acpi/i2c_ec.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/acpi/i2c_ec.c	2007-01-04 17:35:48.000000000 +0100
@@ -340,6 +340,7 @@ static int acpi_ec_hc_add(struct acpi_de
 	smbus->adapter.owner = THIS_MODULE;
 	smbus->adapter.algo = &acpi_ec_smbus_algorithm;
 	smbus->adapter.algo_data = smbus;
+	smbus->adapter.class_dev.dev = &device->dev;
 
 	if (i2c_add_adapter(&smbus->adapter)) {
 		ACPI_DEBUG_PRINT((ACPI_DB_WARN,
--- linux-2.6.20-rc3.orig/drivers/i2c/busses/i2c-amd756-s4882.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/i2c/busses/i2c-amd756-s4882.c	2007-01-04 17:35:48.000000000 +0100
@@ -184,12 +184,14 @@ static int __init amd756_s4882_init(void
 	s4882_algo[0].smbus_xfer = amd756_access_virt0;
 	s4882_adapter[0] = amd756_smbus;
 	s4882_adapter[0].algo = s4882_algo;
+	s4882_adapter[0].class_dev.dev = amd756_smbus.class_dev.dev;
 	for (i = 1; i < 5; i++) {
 		s4882_algo[i] = *(amd756_smbus.algo);
 		s4882_adapter[i] = amd756_smbus;
 		sprintf(s4882_adapter[i].name,
 			"SMBus 8111 adapter (CPU%d)", i-1);
 		s4882_adapter[i].algo = s4882_algo+i;
+		s4882_adapter[i].class_dev.dev = amd756_smbus.class_dev.dev;
 	}
 	s4882_algo[1].smbus_xfer = amd756_access_virt1;
 	s4882_algo[2].smbus_xfer = amd756_access_virt2;
--- linux-2.6.20-rc3.orig/drivers/i2c/busses/i2c-ibm_iic.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/i2c/busses/i2c-ibm_iic.c	2007-01-04 17:35:48.000000000 +0100
@@ -727,6 +727,7 @@ static int __devinit iic_probe(struct oc
 	
 	/* Register it with i2c layer */
 	adap = &dev->adap;
+	adap->class_dev.dev = &ocp->dev;
 	strcpy(adap->name, "IBM IIC");
 	i2c_set_adapdata(adap, dev);
 	adap->id = I2C_HW_OCP;
--- linux-2.6.20-rc3.orig/drivers/i2c/busses/i2c-mv64xxx.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/i2c/busses/i2c-mv64xxx.c	2007-01-04 17:35:48.000000000 +0100
@@ -520,6 +520,7 @@ mv64xxx_i2c_probe(struct platform_device
 		rc = -ENXIO;
 		goto exit_unmap_regs;
 	}
+	drv_data->adapter.class_dev.dev = &pd->dev;
 	drv_data->adapter.id = I2C_HW_MV64XXX;
 	drv_data->adapter.algo = &mv64xxx_i2c_algo;
 	drv_data->adapter.owner = THIS_MODULE;
--- linux-2.6.20-rc3.orig/drivers/i2c/busses/scx200_acb.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/i2c/busses/scx200_acb.c	2007-01-04 17:35:48.000000000 +0100
@@ -430,7 +430,7 @@ static __init int scx200_acb_probe(struc
 }
 
 static __init struct scx200_acb_iface *scx200_create_iface(const char *text,
-		int index)
+		struct device *dev, int index)
 {
 	struct scx200_acb_iface *iface;
 	struct i2c_adapter *adapter;
@@ -448,6 +448,7 @@ static __init struct scx200_acb_iface *s
 	adapter->id = I2C_HW_SMBUS_SCX200;
 	adapter->algo = &scx200_acb_algorithm;
 	adapter->class = I2C_CLASS_HWMON;
+	adapter->class_dev.dev = dev;
 
 	mutex_init(&iface->mutex);
 
@@ -488,7 +489,7 @@ static __init int scx200_create_pci(cons
 	struct scx200_acb_iface *iface;
 	int rc;
 
-	iface = scx200_create_iface(text, 0);
+	iface = scx200_create_iface(text, &pdev->dev, 0);
 
 	if (iface == NULL)
 		return -ENOMEM;
@@ -526,7 +527,7 @@ static int __init scx200_create_isa(cons
 	struct scx200_acb_iface *iface;
 	int rc;
 
-	iface = scx200_create_iface(text, index);
+	iface = scx200_create_iface(text, NULL, index);
 
 	if (iface == NULL)
 		return -ENOMEM;
--- linux-2.6.20-rc3.orig/drivers/ieee1394/pcilynx.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/ieee1394/pcilynx.c	2007-01-04 17:35:48.000000000 +0100
@@ -1434,6 +1434,7 @@ static int __devinit add_card(struct pci
                 i2c_adapter_data = bit_data;
                 i2c_ad->algo_data = &i2c_adapter_data;
                 i2c_adapter_data.data = lynx;
+		i2c_ad->class_dev.dev = &dev->dev;
 
 		PRINTD(KERN_DEBUG, lynx->id,"original eeprom control: %d",
 		       reg_read(lynx, SERIAL_EEPROM_CONTROL));
--- linux-2.6.20-rc3.orig/drivers/media/dvb/b2c2/flexcop-i2c.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/dvb/b2c2/flexcop-i2c.c	2007-01-04 17:35:48.000000000 +0100
@@ -190,6 +190,7 @@ int flexcop_i2c_init(struct flexcop_devi
 	fc->i2c_adap.class	    = I2C_CLASS_TV_DIGITAL;
 	fc->i2c_adap.algo       = &flexcop_algo;
 	fc->i2c_adap.algo_data  = NULL;
+	fc->i2c_adap.class_dev.dev  = fc->dev;
 
 	if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0)
 		return ret;
--- linux-2.6.20-rc3.orig/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c	2007-01-04 17:35:48.000000000 +0100
@@ -27,6 +27,7 @@ int dvb_usb_i2c_init(struct dvb_usb_devi
 #endif
 	d->i2c_adap.algo      = d->props.i2c_algo;
 	d->i2c_adap.algo_data = NULL;
+	d->i2c_adap.class_dev.dev = &d->udev->dev;
 
 	i2c_set_adapdata(&d->i2c_adap, d);
 
--- linux-2.6.20-rc3.orig/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	2007-01-04 17:35:48.000000000 +0100
@@ -1690,6 +1690,7 @@ static int ttusb_probe(struct usb_interf
 #endif
 	ttusb->i2c_adap.algo              = &ttusb_dec_algo;
 	ttusb->i2c_adap.algo_data         = NULL;
+	ttusb->i2c_adap.class_dev.dev	  = &udev->dev;
 
 	result = i2c_add_adapter(&ttusb->i2c_adap);
 	if (result) {
--- linux-2.6.20-rc3.orig/drivers/media/video/cafe_ccic.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/video/cafe_ccic.c	2007-01-04 17:35:48.000000000 +0100
@@ -549,6 +549,7 @@ static int cafe_smbus_setup(struct cafe_
 	adap->client_unregister = cafe_smbus_detach;
 	adap->algo = &cafe_smbus_algo;
 	strcpy(adap->name, "cafe_ccic");
+	adap->class_dev.dev = &cam->pdev->dev;
 	i2c_set_adapdata(adap, cam);
 	ret = i2c_add_adapter(adap);
 	if (ret)
--- linux-2.6.20-rc3.orig/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	2007-01-04 17:35:48.000000000 +0100
@@ -977,6 +977,7 @@ void pvr2_i2c_core_init(struct pvr2_hdw 
 	memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap));
 	memcpy(&hdw->i2c_algo,&pvr2_i2c_algo_template,sizeof(hdw->i2c_algo));
 	strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name));
+	hdw->i2c_adap.class_dev.dev = &hdw->usb_dev->dev;
 	hdw->i2c_adap.algo = &hdw->i2c_algo;
 	hdw->i2c_adap.algo_data = hdw;
 	hdw->i2c_pend_mask = 0;
--- linux-2.6.20-rc3.orig/drivers/media/video/usbvision/usbvision-i2c.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/video/usbvision/usbvision-i2c.c	2007-01-04 17:35:48.000000000 +0100
@@ -258,6 +258,7 @@ int usbvision_init_i2c(struct usb_usbvis
 	sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name),
 		" #%d", usbvision->vdev->minor & 0x1f);
 	PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name);
+	usbvision->i2c_adap.class_dev.dev = &usbvision->dev->dev;
 
 	i2c_set_adapdata(&usbvision->i2c_adap, usbvision);
 	i2c_set_clientdata(&usbvision->i2c_client, usbvision);
--- linux-2.6.20-rc3.orig/drivers/media/video/w9968cf.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/video/w9968cf.c	2007-01-04 17:35:48.000000000 +0100
@@ -1573,6 +1573,7 @@ static int w9968cf_i2c_init(struct w9968
 
 	memcpy(&cam->i2c_adapter, &adap, sizeof(struct i2c_adapter));
 	strcpy(cam->i2c_adapter.name, "w9968cf");
+	cam->i2c_adapter.class_dev.dev = &cam->usbdev->dev;
 	i2c_set_adapdata(&cam->i2c_adapter, cam);
 
 	DBG(6, "Registering I2C adapter with kernel...")
--- linux-2.6.20-rc3.orig/drivers/media/video/zoran_card.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/media/video/zoran_card.c	2007-01-04 17:35:48.000000000 +0100
@@ -843,6 +843,7 @@ zoran_register_i2c (struct zoran *zr)
 		sizeof(I2C_NAME(&zr->i2c_adapter)) - 1);
 	i2c_set_adapdata(&zr->i2c_adapter, zr);
 	zr->i2c_adapter.algo_data = &zr->i2c_algo;
+	zr->i2c_adapter.class_dev.dev = &zr->pci_dev->dev;
 	return i2c_bit_add_bus(&zr->i2c_adapter);
 }
 
--- linux-2.6.20-rc3.orig/drivers/video/matrox/i2c-matroxfb.c	2007-01-04 17:28:25.000000000 +0100
+++ linux-2.6.20-rc3/drivers/video/matrox/i2c-matroxfb.c	2007-01-04 17:35:48.000000000 +0100
@@ -115,6 +115,7 @@ static int i2c_bus_reg(struct i2c_bit_ad
 		minfo->fbcon.node);
 	i2c_set_adapdata(&b->adapter, b);
 	b->adapter.algo_data = &b->bac;
+	b->adapter.class_dev.dev = &ACCESS_FBINFO(pcidev)->dev;
 	b->bac = matrox_i2c_algo_template;
 	b->bac.data = b;
 	err = i2c_bit_add_bus(&b->adapter);


-- 
Jean Delvare



More information about the i2c mailing list