aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-12-06 18:33:15 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-06 01:16:24 -0500
commitde59cf9ed44f64991e52a9de6094729537f0420c (patch)
tree038f6fb83228d09812f729d19fb7bdc8a324dd55
parente1c489b0e4fbb1687f8227fe78b4769c123768c1 (diff)
[PATCH] I2C: Make i2c_add_driver automatically set the proper module owner
This prevents i2c drivers from messing up and forgetting to set the module owner of their driver. It also reduces the size of their drivers by one line :) Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Cc: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/i2c/i2c-core.c5
-rw-r--r--include/linux/i2c.h7
2 files changed, 9 insertions, 3 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 4ce5f0f32fba..c23443ee1b33 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -287,7 +287,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
287 * chips. 287 * chips.
288 */ 288 */
289 289
290int i2c_add_driver(struct i2c_driver *driver) 290int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
291{ 291{
292 struct list_head *item; 292 struct list_head *item;
293 struct i2c_adapter *adapter; 293 struct i2c_adapter *adapter;
@@ -296,6 +296,7 @@ int i2c_add_driver(struct i2c_driver *driver)
296 down(&core_lists); 296 down(&core_lists);
297 297
298 /* add the driver to the list of i2c drivers in the driver core */ 298 /* add the driver to the list of i2c drivers in the driver core */
299 driver->driver.owner = owner;
299 driver->driver.bus = &i2c_bus_type; 300 driver->driver.bus = &i2c_bus_type;
300 driver->driver.probe = i2c_device_probe; 301 driver->driver.probe = i2c_device_probe;
301 driver->driver.remove = i2c_device_remove; 302 driver->driver.remove = i2c_device_remove;
@@ -319,6 +320,7 @@ int i2c_add_driver(struct i2c_driver *driver)
319 up(&core_lists); 320 up(&core_lists);
320 return res; 321 return res;
321} 322}
323EXPORT_SYMBOL(i2c_register_driver);
322 324
323int i2c_del_driver(struct i2c_driver *driver) 325int i2c_del_driver(struct i2c_driver *driver)
324{ 326{
@@ -1132,7 +1134,6 @@ EXPORT_SYMBOL_GPL(i2c_bus_type);
1132 1134
1133EXPORT_SYMBOL(i2c_add_adapter); 1135EXPORT_SYMBOL(i2c_add_adapter);
1134EXPORT_SYMBOL(i2c_del_adapter); 1136EXPORT_SYMBOL(i2c_del_adapter);
1135EXPORT_SYMBOL(i2c_add_driver);
1136EXPORT_SYMBOL(i2c_del_driver); 1137EXPORT_SYMBOL(i2c_del_driver);
1137EXPORT_SYMBOL(i2c_attach_client); 1138EXPORT_SYMBOL(i2c_attach_client);
1138EXPORT_SYMBOL(i2c_detach_client); 1139EXPORT_SYMBOL(i2c_detach_client);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 75aa18e865da..7863a59bd598 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -291,9 +291,14 @@ struct i2c_client_address_data {
291extern int i2c_add_adapter(struct i2c_adapter *); 291extern int i2c_add_adapter(struct i2c_adapter *);
292extern int i2c_del_adapter(struct i2c_adapter *); 292extern int i2c_del_adapter(struct i2c_adapter *);
293 293
294extern int i2c_add_driver(struct i2c_driver *); 294extern int i2c_register_driver(struct module *, struct i2c_driver *);
295extern int i2c_del_driver(struct i2c_driver *); 295extern int i2c_del_driver(struct i2c_driver *);
296 296
297static inline int i2c_add_driver(struct i2c_driver *driver)
298{
299 return i2c_register_driver(THIS_MODULE, driver);
300}
301
297extern int i2c_attach_client(struct i2c_client *); 302extern int i2c_attach_client(struct i2c_client *);
298extern int i2c_detach_client(struct i2c_client *); 303extern int i2c_detach_client(struct i2c_client *);
299 304