aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-11-26 14:28:06 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-06 01:16:21 -0500
commit8a9947552d43b0d20d5fa23ac0ba435d526be454 (patch)
tree086844a62f549e488ebeecc196e1d4726a1d4598 /drivers/i2c/i2c-core.c
parentff179c8cf5caa17bf3d407edbb5872aa2eee6900 (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/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c4
1 files changed, 2 insertions, 2 deletions
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);