diff options
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index bea4c5021d26..c16a448dfd0d 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1005,6 +1005,14 @@ static int i2c_do_del_adapter(struct i2c_driver *driver, | |||
1005 | static int __unregister_client(struct device *dev, void *dummy) | 1005 | static int __unregister_client(struct device *dev, void *dummy) |
1006 | { | 1006 | { |
1007 | struct i2c_client *client = i2c_verify_client(dev); | 1007 | struct i2c_client *client = i2c_verify_client(dev); |
1008 | if (client && strcmp(client->name, "dummy")) | ||
1009 | i2c_unregister_device(client); | ||
1010 | return 0; | ||
1011 | } | ||
1012 | |||
1013 | static int __unregister_dummy(struct device *dev, void *dummy) | ||
1014 | { | ||
1015 | struct i2c_client *client = i2c_verify_client(dev); | ||
1008 | if (client) | 1016 | if (client) |
1009 | i2c_unregister_device(client); | 1017 | i2c_unregister_device(client); |
1010 | return 0; | 1018 | return 0; |
@@ -1059,8 +1067,12 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
1059 | mutex_unlock(&adap->userspace_clients_lock); | 1067 | mutex_unlock(&adap->userspace_clients_lock); |
1060 | 1068 | ||
1061 | /* Detach any active clients. This can't fail, thus we do not | 1069 | /* Detach any active clients. This can't fail, thus we do not |
1062 | checking the returned value. */ | 1070 | * check the returned value. This is a two-pass process, because |
1071 | * we can't remove the dummy devices during the first pass: they | ||
1072 | * could have been instantiated by real devices wishing to clean | ||
1073 | * them up properly, so we give them a chance to do that first. */ | ||
1063 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); | 1074 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); |
1075 | res = device_for_each_child(&adap->dev, NULL, __unregister_dummy); | ||
1064 | 1076 | ||
1065 | #ifdef CONFIG_I2C_COMPAT | 1077 | #ifdef CONFIG_I2C_COMPAT |
1066 | class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, | 1078 | class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, |