Commit 820783a6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

i2c: add driver model support to i2c adapter drivers

parent a6934054
...@@ -531,10 +531,12 @@ static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -531,10 +531,12 @@ static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_
return -ENODEV; return -ENODEV;
} }
/* set up the driverfs linkage to our parent device */
ali15x3_adapter.dev.parent = &dev->dev;
sprintf(ali15x3_adapter.name, "SMBus ALI15X3 adapter at %04x", sprintf(ali15x3_adapter.name, "SMBus ALI15X3 adapter at %04x",
ali15x3_smba); ali15x3_smba);
i2c_add_adapter(&ali15x3_adapter); return i2c_add_adapter(&ali15x3_adapter);
return 0;
} }
static void __devexit ali15x3_remove(struct pci_dev *dev) static void __devexit ali15x3_remove(struct pci_dev *dev)
......
...@@ -375,6 +375,9 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -375,6 +375,9 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport); printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport);
#endif #endif
/* set up the driverfs linkage to our parent device */
amd756_adapter.dev.parent = &pdev->dev;
sprintf(amd756_adapter.name, sprintf(amd756_adapter.name,
"SMBus AMD75x adapter at %04x", amd756_ioport); "SMBus AMD75x adapter at %04x", amd756_ioport);
......
...@@ -363,6 +363,9 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -363,6 +363,9 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo = &smbus_algorithm;
smbus->adapter.algo_data = smbus; smbus->adapter.algo_data = smbus;
/* set up the driverfs linkage to our parent device */
smbus->adapter.dev.parent = &dev->dev;
error = i2c_add_adapter(&smbus->adapter); error = i2c_add_adapter(&smbus->adapter);
if (error) if (error)
goto out_release_region; goto out_release_region;
...@@ -389,7 +392,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev) ...@@ -389,7 +392,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev)
} }
static struct pci_driver amd8111_driver = { static struct pci_driver amd8111_driver = {
.name = "amd8111 smbus 2.0", .name = "amd8111 smbus",
.id_table = amd8111_ids, .id_table = amd8111_ids,
.probe = amd8111_probe, .probe = amd8111_probe,
.remove = __devexit_p(amd8111_remove), .remove = __devexit_p(amd8111_remove),
......
...@@ -672,9 +672,12 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id ...@@ -672,9 +672,12 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
return -ENODEV; return -ENODEV;
} }
/* set up the driverfs linkage to our parent device */
i801_adapter.dev.parent = &dev->dev;
sprintf(i801_adapter.name, "SMBus I801 adapter at %04x", sprintf(i801_adapter.name, "SMBus I801 adapter at %04x",
i801_smba); i801_smba);
i2c_add_adapter(&i801_adapter); return i2c_add_adapter(&i801_adapter);
} }
static void __devexit i801_remove(struct pci_dev *dev) static void __devexit i801_remove(struct pci_dev *dev)
......
...@@ -473,6 +473,9 @@ static int __devinit piix4_probe(struct pci_dev *dev, const struct pci_device_id ...@@ -473,6 +473,9 @@ static int __devinit piix4_probe(struct pci_dev *dev, const struct pci_device_id
if (retval) if (retval)
return retval; return retval;
/* set up the driverfs linkage to our parent device */
piix4_adapter.dev.parent = &dev->dev;
sprintf(piix4_adapter.name, "SMBus PIIX4 adapter at %04x", sprintf(piix4_adapter.name, "SMBus PIIX4 adapter at %04x",
piix4_smba); piix4_smba);
......
...@@ -87,6 +87,16 @@ int i2c_add_adapter(struct i2c_adapter *adap) ...@@ -87,6 +87,16 @@ int i2c_add_adapter(struct i2c_adapter *adap)
init_MUTEX(&adap->bus); init_MUTEX(&adap->bus);
init_MUTEX(&adap->list); init_MUTEX(&adap->list);
/* Add the adapter to the driver core.
* If the parent pointer is not set up,
* we add this adapter to the legacy bus.
*/
if (adap->dev.parent == NULL)
adap->dev.parent = &legacy_bus;
sprintf(adap->dev.bus_id, "i2c-%d", i);
strcpy(adap->dev.name, "i2c controller");
device_register(&adap->dev);
/* inform drivers of new adapters */ /* inform drivers of new adapters */
for (j=0;j<I2C_DRIVER_MAX;j++) for (j=0;j<I2C_DRIVER_MAX;j++)
if (drivers[j]!=NULL && if (drivers[j]!=NULL &&
...@@ -154,6 +164,9 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -154,6 +164,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
i2cproc_remove(i); i2cproc_remove(i);
/* clean up the sysfs representation */
device_unregister(&adap->dev);
adapters[i] = NULL; adapters[i] = NULL;
DEB(printk(KERN_DEBUG "i2c-core.o: adapter unregistered: %s\n",adap->name)); DEB(printk(KERN_DEBUG "i2c-core.o: adapter unregistered: %s\n",adap->name));
......
...@@ -231,12 +231,14 @@ struct i2c_adapter { ...@@ -231,12 +231,14 @@ struct i2c_adapter {
int timeout; int timeout;
int retries; int retries;
struct device dev; /* the adapter device */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/* No need to set this when you initialize the adapter */ /* No need to set this when you initialize the adapter */
int inode; int inode;
#endif /* def CONFIG_PROC_FS */ #endif /* def CONFIG_PROC_FS */
}; };
#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
/*flags for the driver struct: */ /*flags for the driver struct: */
#define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */ #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment