Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 866cf12a authored by Guenter Roeck's avatar Guenter Roeck
Browse files

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: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Acked-by: default avatarJean Delvare <khali@linux-fr.org>
parent 20fcfe17
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -152,11 +152,10 @@ static int adm1275_probe(struct i2c_client *client,
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[] = {
+2 −3
Original line number Diff line number Diff line
@@ -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[] = {
+2 −1
Original line number Diff line number Diff line
@@ -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[] = {
+2 −1
Original line number Diff line number Diff line
@@ -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[] = {
+2 −1
Original line number Diff line number Diff line
@@ -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[] = {
Loading