Commit 64007dd6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

i2c: add initial driver model support for i2c drivers.

parent 89563a9e
......@@ -53,6 +53,16 @@ static void i2cproc_remove(int bus);
#endif /* CONFIG_PROC_FS */
int i2c_device_probe(struct device *dev)
{
return -ENODEV;
}
int i2c_device_remove(struct device *dev)
{
return 0;
}
/* ---------------------------------------------------
* registering functions
* ---------------------------------------------------
......@@ -205,6 +215,16 @@ int i2c_add_driver(struct i2c_driver *driver)
DEB(printk(KERN_DEBUG "i2c-core.o: driver %s registered.\n",driver->name));
/* add the driver to the list of i2c drivers in the driver core */
driver->driver.name = driver->name;
driver->driver.bus = &i2c_bus_type;
driver->driver.probe = i2c_device_probe;
driver->driver.remove = i2c_device_remove;
res = driver_register(&driver->driver);
if (res)
goto out_unlock;
/* now look for instances of driver on our adapters
*/
if (driver->flags& (I2C_DF_NOTIFY|I2C_DF_DUMMY)) {
......@@ -236,6 +256,8 @@ int i2c_del_driver(struct i2c_driver *driver)
goto out_unlock;
}
driver_unregister(&driver->driver);
/* Have a look at each adapter, if clients of this driver are still
* attached. If so, detach them to be able to kill the driver
* afterwards.
......
......@@ -143,7 +143,10 @@ struct i2c_driver {
* with the device.
*/
int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
struct device_driver driver;
};
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
extern struct bus_type i2c_bus_type;
......
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