diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-08-26 08:12:38 -0700 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-10-24 11:09:33 -0700 |
commit | 866cf12a0eab65f94e40608bdd21ca8dea4d0ac2 (patch) | |
tree | 4f419b461893f90d6e9a54f0852c3bd1a6254666 | |
parent | 20fcfe172190704918969695a16cf621e2f4ce25 (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>
-rw-r--r-- | drivers/hwmon/pmbus/adm1275.c | 5 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/lm25066.c | 5 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/max16064.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/max34440.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/max8688.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus.c | 5 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus.h | 2 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/ucd9000.c | 5 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/ucd9200.c | 5 |
10 files changed, 18 insertions, 21 deletions
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index c936e278230..424d0d711cc 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c @@ -152,11 +152,10 @@ err_mem: static int adm1275_remove(struct i2c_client *client) { const struct pmbus_driver_info *info = pmbus_get_driver_info(client); - int ret; - ret = pmbus_do_remove(client); + pmbus_do_remove(client); kfree(info); - return ret; + return 0; } static const struct i2c_device_id adm1275_id[] = { diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index ac254fba551..2107f413e4f 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) { const struct pmbus_driver_info *info = pmbus_get_driver_info(client); const struct lm25066_data *data = to_lm25066_data(info); - int ret; - ret = pmbus_do_remove(client); + pmbus_do_remove(client); kfree(data); - return ret; + return 0; } static const struct i2c_device_id lm25066_id[] = { diff --git a/drivers/hwmon/pmbus/max16064.c b/drivers/hwmon/pmbus/max16064.c index e50b296e8db..1d77cf4d2d4 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, static int max16064_remove(struct i2c_client *client) { - return pmbus_do_remove(client); + pmbus_do_remove(client); + return 0; } static const struct i2c_device_id max16064_id[] = { diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c index fda621d2e45..c824365e4aa 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, static int max34440_remove(struct i2c_client *client) { - return pmbus_do_remove(client); + pmbus_do_remove(client); + return 0; } static const struct i2c_device_id max34440_id[] = { diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c index c3e72f1a3cf..e148e2c5a75 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, static int max8688_remove(struct i2c_client *client) { - return pmbus_do_remove(client); + pmbus_do_remove(client); + return 0; } static const struct i2c_device_id max8688_id[] = { diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c index 73de9f1f319..1dfba447749 100644 --- a/drivers/hwmon/pmbus/pmbus.c +++ b/drivers/hwmon/pmbus/pmbus.c @@ -187,13 +187,12 @@ out: static int pmbus_remove(struct i2c_client *client) { - int ret; const struct pmbus_driver_info *info; info = pmbus_get_driver_info(client); - ret = pmbus_do_remove(client); + pmbus_do_remove(client); kfree(info); - return ret; + return 0; } /* diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 8751f4073ec..cfa912d0f0b 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); bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, struct pmbus_driver_info *info); -int pmbus_do_remove(struct i2c_client *client); +void pmbus_do_remove(struct i2c_client *client); const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client); diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 397fc59b568..36f287076ee 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1764,7 +1764,7 @@ out_data: } EXPORT_SYMBOL_GPL(pmbus_do_probe); -int pmbus_do_remove(struct i2c_client *client) +void pmbus_do_remove(struct i2c_client *client) { struct pmbus_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); @@ -1774,7 +1774,6 @@ int pmbus_do_remove(struct i2c_client *client) kfree(data->booleans); kfree(data->sensors); kfree(data); - return 0; } EXPORT_SYMBOL_GPL(pmbus_do_remove); diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index d0ddb60155c..640a9c9de7f 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c @@ -239,13 +239,12 @@ out: static int ucd9000_remove(struct i2c_client *client) { - int ret; struct ucd9000_data *data; data = to_ucd9000_data(pmbus_get_driver_info(client)); - ret = pmbus_do_remove(client); + pmbus_do_remove(client); kfree(data); - return ret; + return 0; } diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index c65e9da707c..6e1c1a80ab8 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c @@ -171,13 +171,12 @@ out: static int ucd9200_remove(struct i2c_client *client) { - int ret; const struct pmbus_driver_info *info; info = pmbus_get_driver_info(client); - ret = pmbus_do_remove(client); + pmbus_do_remove(client); kfree(info); - return ret; + return 0; } |