diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-11-26 14:28:06 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-06 01:16:21 -0500 |
commit | 8a9947552d43b0d20d5fa23ac0ba435d526be454 (patch) | |
tree | 086844a62f549e488ebeecc196e1d4726a1d4598 /drivers/i2c | |
parent | ff179c8cf5caa17bf3d407edbb5872aa2eee6900 (diff) |
[PATCH] i2c: Drop i2c_driver.flags, 2 of 3
Just about every i2c chip driver sets the I2C_DF_NOTIFY flag, so we
can simply make it the default and drop the flag. If any driver really
doesn't want to be notified when i2c adapters are added, that driver
can simply omit to set .attach_adapter. This approach is also more
robust as it prevents accidental NULL pointer dereferences.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/chips/ds1337.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/ds1374.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/eeprom.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/isp1301_omap.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/m41t00.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/max6875.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/pca9539.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/pcf8574.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/pcf8591.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/rtc8564.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/tps65010.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/x1205.c | 1 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 4 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 1 |
14 files changed, 2 insertions, 15 deletions
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 18228957606c..65146cbc8390 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -54,7 +54,6 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, | |||
54 | static struct i2c_driver ds1337_driver = { | 54 | static struct i2c_driver ds1337_driver = { |
55 | .owner = THIS_MODULE, | 55 | .owner = THIS_MODULE, |
56 | .name = "ds1337", | 56 | .name = "ds1337", |
57 | .flags = I2C_DF_NOTIFY, | ||
58 | .attach_adapter = ds1337_attach_adapter, | 57 | .attach_adapter = ds1337_attach_adapter, |
59 | .detach_client = ds1337_detach_client, | 58 | .detach_client = ds1337_detach_client, |
60 | .command = ds1337_command, | 59 | .command = ds1337_command, |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index da488b735abf..5a270d60b699 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -235,7 +235,6 @@ static struct i2c_driver ds1374_driver = { | |||
235 | .owner = THIS_MODULE, | 235 | .owner = THIS_MODULE, |
236 | .name = DS1374_DRV_NAME, | 236 | .name = DS1374_DRV_NAME, |
237 | .id = I2C_DRIVERID_DS1374, | 237 | .id = I2C_DRIVERID_DS1374, |
238 | .flags = I2C_DF_NOTIFY, | ||
239 | .attach_adapter = ds1374_attach, | 238 | .attach_adapter = ds1374_attach, |
240 | .detach_client = ds1374_detach, | 239 | .detach_client = ds1374_detach, |
241 | }; | 240 | }; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 4baf573fa04f..9bb1f8b3f38c 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -71,7 +71,6 @@ static struct i2c_driver eeprom_driver = { | |||
71 | .owner = THIS_MODULE, | 71 | .owner = THIS_MODULE, |
72 | .name = "eeprom", | 72 | .name = "eeprom", |
73 | .id = I2C_DRIVERID_EEPROM, | 73 | .id = I2C_DRIVERID_EEPROM, |
74 | .flags = I2C_DF_NOTIFY, | ||
75 | .attach_adapter = eeprom_attach_adapter, | 74 | .attach_adapter = eeprom_attach_adapter, |
76 | .detach_client = eeprom_detach_client, | 75 | .detach_client = eeprom_detach_client, |
77 | }; | 76 | }; |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index d2a100d77839..4f472ba66a02 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -1636,7 +1636,6 @@ static struct i2c_driver isp1301_driver = { | |||
1636 | .name = "isp1301_omap", | 1636 | .name = "isp1301_omap", |
1637 | .id = 1301, /* FIXME "official", i2c-ids.h */ | 1637 | .id = 1301, /* FIXME "official", i2c-ids.h */ |
1638 | .class = I2C_CLASS_HWMON, | 1638 | .class = I2C_CLASS_HWMON, |
1639 | .flags = I2C_DF_NOTIFY, | ||
1640 | .attach_adapter = isp1301_scan_bus, | 1639 | .attach_adapter = isp1301_scan_bus, |
1641 | .detach_client = isp1301_detach_client, | 1640 | .detach_client = isp1301_detach_client, |
1642 | }; | 1641 | }; |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 3df309ae44a6..13e67836b348 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -214,7 +214,6 @@ static struct i2c_driver m41t00_driver = { | |||
214 | .owner = THIS_MODULE, | 214 | .owner = THIS_MODULE, |
215 | .name = M41T00_DRV_NAME, | 215 | .name = M41T00_DRV_NAME, |
216 | .id = I2C_DRIVERID_STM41T00, | 216 | .id = I2C_DRIVERID_STM41T00, |
217 | .flags = I2C_DF_NOTIFY, | ||
218 | .attach_adapter = m41t00_attach, | 217 | .attach_adapter = m41t00_attach, |
219 | .detach_client = m41t00_detach, | 218 | .detach_client = m41t00_detach, |
220 | }; | 219 | }; |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index b376a006883c..7e61019e72dd 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -69,7 +69,6 @@ static int max6875_detach_client(struct i2c_client *client); | |||
69 | static struct i2c_driver max6875_driver = { | 69 | static struct i2c_driver max6875_driver = { |
70 | .owner = THIS_MODULE, | 70 | .owner = THIS_MODULE, |
71 | .name = "max6875", | 71 | .name = "max6875", |
72 | .flags = I2C_DF_NOTIFY, | ||
73 | .attach_adapter = max6875_attach_adapter, | 72 | .attach_adapter = max6875_attach_adapter, |
74 | .detach_client = max6875_detach_client, | 73 | .detach_client = max6875_detach_client, |
75 | }; | 74 | }; |
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 59a930346229..26feb7a4f942 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c | |||
@@ -40,7 +40,6 @@ static int pca9539_detach_client(struct i2c_client *client); | |||
40 | static struct i2c_driver pca9539_driver = { | 40 | static struct i2c_driver pca9539_driver = { |
41 | .owner = THIS_MODULE, | 41 | .owner = THIS_MODULE, |
42 | .name = "pca9539", | 42 | .name = "pca9539", |
43 | .flags = I2C_DF_NOTIFY, | ||
44 | .attach_adapter = pca9539_attach_adapter, | 43 | .attach_adapter = pca9539_attach_adapter, |
45 | .detach_client = pca9539_detach_client, | 44 | .detach_client = pca9539_detach_client, |
46 | }; | 45 | }; |
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index c323c2de236c..2fae640cf329 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c | |||
@@ -68,7 +68,6 @@ static struct i2c_driver pcf8574_driver = { | |||
68 | .owner = THIS_MODULE, | 68 | .owner = THIS_MODULE, |
69 | .name = "pcf8574", | 69 | .name = "pcf8574", |
70 | .id = I2C_DRIVERID_PCF8574, | 70 | .id = I2C_DRIVERID_PCF8574, |
71 | .flags = I2C_DF_NOTIFY, | ||
72 | .attach_adapter = pcf8574_attach_adapter, | 71 | .attach_adapter = pcf8574_attach_adapter, |
73 | .detach_client = pcf8574_detach_client, | 72 | .detach_client = pcf8574_detach_client, |
74 | }; | 73 | }; |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index ce420a67560b..8750f71278e1 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -91,7 +91,6 @@ static struct i2c_driver pcf8591_driver = { | |||
91 | .owner = THIS_MODULE, | 91 | .owner = THIS_MODULE, |
92 | .name = "pcf8591", | 92 | .name = "pcf8591", |
93 | .id = I2C_DRIVERID_PCF8591, | 93 | .id = I2C_DRIVERID_PCF8591, |
94 | .flags = I2C_DF_NOTIFY, | ||
95 | .attach_adapter = pcf8591_attach_adapter, | 94 | .attach_adapter = pcf8591_attach_adapter, |
96 | .detach_client = pcf8591_detach_client, | 95 | .detach_client = pcf8591_detach_client, |
97 | }; | 96 | }; |
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 26e498d921da..e586f75dd024 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c | |||
@@ -362,7 +362,6 @@ static struct i2c_driver rtc8564_driver = { | |||
362 | .owner = THIS_MODULE, | 362 | .owner = THIS_MODULE, |
363 | .name = "RTC8564", | 363 | .name = "RTC8564", |
364 | .id = I2C_DRIVERID_RTC8564, | 364 | .id = I2C_DRIVERID_RTC8564, |
365 | .flags = I2C_DF_NOTIFY, | ||
366 | .attach_adapter = rtc8564_probe, | 365 | .attach_adapter = rtc8564_probe, |
367 | .detach_client = rtc8564_detach, | 366 | .detach_client = rtc8564_detach, |
368 | .command = rtc8564_command | 367 | .command = rtc8564_command |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 280dd7a45db6..439bf6ceb789 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -639,7 +639,6 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus) | |||
639 | static struct i2c_driver tps65010_driver = { | 639 | static struct i2c_driver tps65010_driver = { |
640 | .owner = THIS_MODULE, | 640 | .owner = THIS_MODULE, |
641 | .name = "tps65010", | 641 | .name = "tps65010", |
642 | .flags = I2C_DF_NOTIFY, | ||
643 | .attach_adapter = tps65010_scan_bus, | 642 | .attach_adapter = tps65010_scan_bus, |
644 | .detach_client = __exit_p(tps65010_detach_client), | 643 | .detach_client = __exit_p(tps65010_detach_client), |
645 | }; | 644 | }; |
diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c index 7da366cdc18c..c5ff2cee15ae 100644 --- a/drivers/i2c/chips/x1205.c +++ b/drivers/i2c/chips/x1205.c | |||
@@ -107,7 +107,6 @@ static int x1205_command(struct i2c_client *client, unsigned int cmd, | |||
107 | static struct i2c_driver x1205_driver = { | 107 | static struct i2c_driver x1205_driver = { |
108 | .owner = THIS_MODULE, | 108 | .owner = THIS_MODULE, |
109 | .name = "x1205", | 109 | .name = "x1205", |
110 | .flags = I2C_DF_NOTIFY, | ||
111 | .attach_adapter = &x1205_attach, | 110 | .attach_adapter = &x1205_attach, |
112 | .detach_client = &x1205_detach, | 111 | .detach_client = &x1205_detach, |
113 | }; | 112 | }; |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 82ea1b7ec914..ad68ac00d910 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -197,7 +197,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
197 | /* inform drivers of new adapters */ | 197 | /* inform drivers of new adapters */ |
198 | list_for_each(item,&drivers) { | 198 | list_for_each(item,&drivers) { |
199 | driver = list_entry(item, struct i2c_driver, list); | 199 | driver = list_entry(item, struct i2c_driver, list); |
200 | if (driver->flags & I2C_DF_NOTIFY) | 200 | if (driver->attach_adapter) |
201 | /* We ignore the return code; if it fails, too bad */ | 201 | /* We ignore the return code; if it fails, too bad */ |
202 | driver->attach_adapter(adap); | 202 | driver->attach_adapter(adap); |
203 | } | 203 | } |
@@ -309,7 +309,7 @@ int i2c_add_driver(struct i2c_driver *driver) | |||
309 | pr_debug("i2c-core: driver [%s] registered\n", driver->name); | 309 | pr_debug("i2c-core: driver [%s] registered\n", driver->name); |
310 | 310 | ||
311 | /* now look for instances of driver on our adapters */ | 311 | /* now look for instances of driver on our adapters */ |
312 | if (driver->flags & I2C_DF_NOTIFY) { | 312 | if (driver->attach_adapter) { |
313 | list_for_each(item,&adapters) { | 313 | list_for_each(item,&adapters) { |
314 | adapter = list_entry(item, struct i2c_adapter, list); | 314 | adapter = list_entry(item, struct i2c_adapter, list); |
315 | driver->attach_adapter(adapter); | 315 | driver->attach_adapter(adapter); |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 8af0bd1424d2..9da51eb37c06 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -484,7 +484,6 @@ static struct i2c_driver i2cdev_driver = { | |||
484 | .owner = THIS_MODULE, | 484 | .owner = THIS_MODULE, |
485 | .name = "dev_driver", | 485 | .name = "dev_driver", |
486 | .id = I2C_DRIVERID_I2CDEV, | 486 | .id = I2C_DRIVERID_I2CDEV, |
487 | .flags = I2C_DF_NOTIFY, | ||
488 | .attach_adapter = i2cdev_attach_adapter, | 487 | .attach_adapter = i2cdev_attach_adapter, |
489 | .detach_adapter = i2cdev_detach_adapter, | 488 | .detach_adapter = i2cdev_detach_adapter, |
490 | .detach_client = i2cdev_detach_client, | 489 | .detach_client = i2cdev_detach_client, |