diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-01-14 16:03:49 -0500 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-01-14 16:03:49 -0500 |
commit | 5219bf884b6e2b54e734ca1799b6f0014bb2b4b7 (patch) | |
tree | b3ea8be732ccca2152d642a7ead63270a592c8e1 | |
parent | 891cc2283216bf76f387546f0e220caf8ce9fbf9 (diff) |
i2c: Unregister dummy devices last on adapter removal
Remove real devices first and dummy devices last. This gives device
driver which instantiated dummy devices themselves a chance to clean
them up before we do.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Hans Verkuil <hverkuil@xs4all.nl>
Cc: stable@kernel.org
-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 c7db6980e3a3..b916675605b4 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1021,6 +1021,14 @@ static int i2c_do_del_adapter(struct i2c_driver *driver, | |||
1021 | static int __unregister_client(struct device *dev, void *dummy) | 1021 | static int __unregister_client(struct device *dev, void *dummy) |
1022 | { | 1022 | { |
1023 | struct i2c_client *client = i2c_verify_client(dev); | 1023 | struct i2c_client *client = i2c_verify_client(dev); |
1024 | if (client && strcmp(client->name, "dummy")) | ||
1025 | i2c_unregister_device(client); | ||
1026 | return 0; | ||
1027 | } | ||
1028 | |||
1029 | static int __unregister_dummy(struct device *dev, void *dummy) | ||
1030 | { | ||
1031 | struct i2c_client *client = i2c_verify_client(dev); | ||
1024 | if (client) | 1032 | if (client) |
1025 | i2c_unregister_device(client); | 1033 | i2c_unregister_device(client); |
1026 | return 0; | 1034 | return 0; |
@@ -1075,8 +1083,12 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
1075 | mutex_unlock(&adap->userspace_clients_lock); | 1083 | mutex_unlock(&adap->userspace_clients_lock); |
1076 | 1084 | ||
1077 | /* Detach any active clients. This can't fail, thus we do not | 1085 | /* Detach any active clients. This can't fail, thus we do not |
1078 | checking the returned value. */ | 1086 | * check the returned value. This is a two-pass process, because |
1087 | * we can't remove the dummy devices during the first pass: they | ||
1088 | * could have been instantiated by real devices wishing to clean | ||
1089 | * them up properly, so we give them a chance to do that first. */ | ||
1079 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); | 1090 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); |
1091 | res = device_for_each_child(&adap->dev, NULL, __unregister_dummy); | ||
1080 | 1092 | ||
1081 | #ifdef CONFIG_I2C_COMPAT | 1093 | #ifdef CONFIG_I2C_COMPAT |
1082 | class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, | 1094 | class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, |