Commit de59cf9e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Cc: Jean Delvare <khali@linux-fr.org>
parent e1c489b0
...@@ -287,7 +287,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -287,7 +287,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
* chips. * chips.
*/ */
int i2c_add_driver(struct i2c_driver *driver) int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
{ {
struct list_head *item; struct list_head *item;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
...@@ -296,6 +296,7 @@ int i2c_add_driver(struct i2c_driver *driver) ...@@ -296,6 +296,7 @@ int i2c_add_driver(struct i2c_driver *driver)
down(&core_lists); down(&core_lists);
/* add the driver to the list of i2c drivers in the driver core */ /* add the driver to the list of i2c drivers in the driver core */
driver->driver.owner = owner;
driver->driver.bus = &i2c_bus_type; driver->driver.bus = &i2c_bus_type;
driver->driver.probe = i2c_device_probe; driver->driver.probe = i2c_device_probe;
driver->driver.remove = i2c_device_remove; driver->driver.remove = i2c_device_remove;
...@@ -319,6 +320,7 @@ int i2c_add_driver(struct i2c_driver *driver) ...@@ -319,6 +320,7 @@ int i2c_add_driver(struct i2c_driver *driver)
up(&core_lists); up(&core_lists);
return res; return res;
} }
EXPORT_SYMBOL(i2c_register_driver);
int i2c_del_driver(struct i2c_driver *driver) int i2c_del_driver(struct i2c_driver *driver)
{ {
...@@ -1132,7 +1134,6 @@ EXPORT_SYMBOL_GPL(i2c_bus_type); ...@@ -1132,7 +1134,6 @@ EXPORT_SYMBOL_GPL(i2c_bus_type);
EXPORT_SYMBOL(i2c_add_adapter); EXPORT_SYMBOL(i2c_add_adapter);
EXPORT_SYMBOL(i2c_del_adapter); EXPORT_SYMBOL(i2c_del_adapter);
EXPORT_SYMBOL(i2c_add_driver);
EXPORT_SYMBOL(i2c_del_driver); EXPORT_SYMBOL(i2c_del_driver);
EXPORT_SYMBOL(i2c_attach_client); EXPORT_SYMBOL(i2c_attach_client);
EXPORT_SYMBOL(i2c_detach_client); EXPORT_SYMBOL(i2c_detach_client);
......
...@@ -291,9 +291,14 @@ struct i2c_client_address_data { ...@@ -291,9 +291,14 @@ struct i2c_client_address_data {
extern int i2c_add_adapter(struct i2c_adapter *); extern int i2c_add_adapter(struct i2c_adapter *);
extern int i2c_del_adapter(struct i2c_adapter *); extern int i2c_del_adapter(struct i2c_adapter *);
extern int i2c_add_driver(struct i2c_driver *); extern int i2c_register_driver(struct module *, struct i2c_driver *);
extern int i2c_del_driver(struct i2c_driver *); extern int i2c_del_driver(struct i2c_driver *);
static inline int i2c_add_driver(struct i2c_driver *driver)
{
return i2c_register_driver(THIS_MODULE, driver);
}
extern int i2c_attach_client(struct i2c_client *); extern int i2c_attach_client(struct i2c_client *);
extern int i2c_detach_client(struct i2c_client *); extern int i2c_detach_client(struct i2c_client *);
......
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