aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-08-26 11:12:38 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-10-24 14:09:33 -0400
commit866cf12a0eab65f94e40608bdd21ca8dea4d0ac2 (patch)
tree4f419b461893f90d6e9a54f0852c3bd1a6254666 /drivers/hwmon
parent20fcfe172190704918969695a16cf621e2f4ce25 (diff)
hwmon: (pmbus) Don't return errors from driver remove functions
Driver remove functions have an error return value, but rarely return an error in practice. If a driver does return an error from its remove function, the driver won't be unloaded and is expected to stay alive. pmbus_do_remove() is defined as returning an int, but always returns 0 (no error). Calling code passes that return value on to high level driver remove functions, but does not evaluate it and removes driver data even if pmbus_do_remove() returned an error (which it in practice never does). Even if this code could never cause a real problem, it is nevertheless conceptually wrong. To reduce confusion and simplify the code, change pmbus_do_remove() to be a void function, and have PMBus client drivers always return zero in their driver remove functions. Reported-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus/adm1275.c5
-rw-r--r--drivers/hwmon/pmbus/lm25066.c5
-rw-r--r--drivers/hwmon/pmbus/max16064.c3
-rw-r--r--drivers/hwmon/pmbus/max34440.c3
-rw-r--r--drivers/hwmon/pmbus/max8688.c3
-rw-r--r--drivers/hwmon/pmbus/pmbus.c5
-rw-r--r--drivers/hwmon/pmbus/pmbus.h2
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c3
-rw-r--r--drivers/hwmon/pmbus/ucd9000.c5
-rw-r--r--drivers/hwmon/pmbus/ucd9200.c5
10 files changed, 18 insertions, 21 deletions
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index c936e2782309..424d0d711ccb 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -152,11 +152,10 @@ err_mem:
152static int adm1275_remove(struct i2c_client *client) 152static int adm1275_remove(struct i2c_client *client)
153{ 153{
154 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 154 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
155 int ret;
156 155
157 ret = pmbus_do_remove(client); 156 pmbus_do_remove(client);
158 kfree(info); 157 kfree(info);
159 return ret; 158 return 0;
160} 159}
161 160
162static const struct i2c_device_id adm1275_id[] = { 161static const struct i2c_device_id adm1275_id[] = {
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index ac254fba551b..2107f413e4fc 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -309,11 +309,10 @@ static int lm25066_remove(struct i2c_client *client)
309{ 309{
310 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 310 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
311 const struct lm25066_data *data = to_lm25066_data(info); 311 const struct lm25066_data *data = to_lm25066_data(info);
312 int ret;
313 312
314 ret = pmbus_do_remove(client); 313 pmbus_do_remove(client);
315 kfree(data); 314 kfree(data);
316 return ret; 315 return 0;
317} 316}
318 317
319static const struct i2c_device_id lm25066_id[] = { 318static const struct i2c_device_id lm25066_id[] = {
diff --git a/drivers/hwmon/pmbus/max16064.c b/drivers/hwmon/pmbus/max16064.c
index e50b296e8db4..1d77cf4d2d44 100644
--- a/drivers/hwmon/pmbus/max16064.c
+++ b/drivers/hwmon/pmbus/max16064.c
@@ -105,7 +105,8 @@ static int max16064_probe(struct i2c_client *client,
105 105
106static int max16064_remove(struct i2c_client *client) 106static int max16064_remove(struct i2c_client *client)
107{ 107{
108 return pmbus_do_remove(client); 108 pmbus_do_remove(client);
109 return 0;
109} 110}
110 111
111static const struct i2c_device_id max16064_id[] = { 112static const struct i2c_device_id max16064_id[] = {
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index fda621d2e458..c824365e4aa4 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -224,7 +224,8 @@ static int max34440_probe(struct i2c_client *client,
224 224
225static int max34440_remove(struct i2c_client *client) 225static int max34440_remove(struct i2c_client *client)
226{ 226{
227 return pmbus_do_remove(client); 227 pmbus_do_remove(client);
228 return 0;
228} 229}
229 230
230static const struct i2c_device_id max34440_id[] = { 231static const struct i2c_device_id max34440_id[] = {
diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c
index c3e72f1a3cfb..e148e2c5a756 100644
--- a/drivers/hwmon/pmbus/max8688.c
+++ b/drivers/hwmon/pmbus/max8688.c
@@ -182,7 +182,8 @@ static int max8688_probe(struct i2c_client *client,
182 182
183static int max8688_remove(struct i2c_client *client) 183static int max8688_remove(struct i2c_client *client)
184{ 184{
185 return pmbus_do_remove(client); 185 pmbus_do_remove(client);
186 return 0;
186} 187}
187 188
188static const struct i2c_device_id max8688_id[] = { 189static const struct i2c_device_id max8688_id[] = {
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index 73de9f1f3194..1dfba4477498 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -187,13 +187,12 @@ out:
187 187
188static int pmbus_remove(struct i2c_client *client) 188static int pmbus_remove(struct i2c_client *client)
189{ 189{
190 int ret;
191 const struct pmbus_driver_info *info; 190 const struct pmbus_driver_info *info;
192 191
193 info = pmbus_get_driver_info(client); 192 info = pmbus_get_driver_info(client);
194 ret = pmbus_do_remove(client); 193 pmbus_do_remove(client);
195 kfree(info); 194 kfree(info);
196 return ret; 195 return 0;
197} 196}
198 197
199/* 198/*
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index 8751f4073ec2..cfa912d0f0b0 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -361,7 +361,7 @@ bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
361bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); 361bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
362int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 362int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
363 struct pmbus_driver_info *info); 363 struct pmbus_driver_info *info);
364int pmbus_do_remove(struct i2c_client *client); 364void pmbus_do_remove(struct i2c_client *client);
365const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client 365const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
366 *client); 366 *client);
367 367
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 397fc59b5682..36f287076ee2 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1764,7 +1764,7 @@ out_data:
1764} 1764}
1765EXPORT_SYMBOL_GPL(pmbus_do_probe); 1765EXPORT_SYMBOL_GPL(pmbus_do_probe);
1766 1766
1767int pmbus_do_remove(struct i2c_client *client) 1767void pmbus_do_remove(struct i2c_client *client)
1768{ 1768{
1769 struct pmbus_data *data = i2c_get_clientdata(client); 1769 struct pmbus_data *data = i2c_get_clientdata(client);
1770 hwmon_device_unregister(data->hwmon_dev); 1770 hwmon_device_unregister(data->hwmon_dev);
@@ -1774,7 +1774,6 @@ int pmbus_do_remove(struct i2c_client *client)
1774 kfree(data->booleans); 1774 kfree(data->booleans);
1775 kfree(data->sensors); 1775 kfree(data->sensors);
1776 kfree(data); 1776 kfree(data);
1777 return 0;
1778} 1777}
1779EXPORT_SYMBOL_GPL(pmbus_do_remove); 1778EXPORT_SYMBOL_GPL(pmbus_do_remove);
1780 1779
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
index d0ddb60155c9..640a9c9de7f8 100644
--- a/drivers/hwmon/pmbus/ucd9000.c
+++ b/drivers/hwmon/pmbus/ucd9000.c
@@ -239,13 +239,12 @@ out:
239 239
240static int ucd9000_remove(struct i2c_client *client) 240static int ucd9000_remove(struct i2c_client *client)
241{ 241{
242 int ret;
243 struct ucd9000_data *data; 242 struct ucd9000_data *data;
244 243
245 data = to_ucd9000_data(pmbus_get_driver_info(client)); 244 data = to_ucd9000_data(pmbus_get_driver_info(client));
246 ret = pmbus_do_remove(client); 245 pmbus_do_remove(client);
247 kfree(data); 246 kfree(data);
248 return ret; 247 return 0;
249} 248}
250 249
251 250
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c
index c65e9da707cc..6e1c1a80ab85 100644
--- a/drivers/hwmon/pmbus/ucd9200.c
+++ b/drivers/hwmon/pmbus/ucd9200.c
@@ -171,13 +171,12 @@ out:
171 171
172static int ucd9200_remove(struct i2c_client *client) 172static int ucd9200_remove(struct i2c_client *client)
173{ 173{
174 int ret;
175 const struct pmbus_driver_info *info; 174 const struct pmbus_driver_info *info;
176 175
177 info = pmbus_get_driver_info(client); 176 info = pmbus_get_driver_info(client);
178 ret = pmbus_do_remove(client); 177 pmbus_do_remove(client);
179 kfree(info); 178 kfree(info);
180 return ret; 179 return 0;
181} 180}
182 181
183 182