[PATCH v1] drivers/magnetometer/ak8975: check the return value of ak8975_set_mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check the return value of ak8975_set_mode(). When it fails to write the
register, the error should at least be propagated to the caller.
Currently function ak8975_remove() returns the success value 0
no matter the execution fails or not, which will silently leave the
error unhandled.

Signed-off-by: Li Zhong <floridsleeves@xxxxxxxxx>
---
 drivers/iio/magnetometer/ak8975.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 2432e697150c..e08f10fe16d0 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -1022,16 +1022,17 @@ static int ak8975_remove(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
 	struct ak8975_data *data = iio_priv(indio_dev);
+	int err = 0;
 
 	pm_runtime_get_sync(&client->dev);
 	pm_runtime_put_noidle(&client->dev);
 	pm_runtime_disable(&client->dev);
 	iio_device_unregister(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
-	ak8975_set_mode(data, POWER_DOWN);
+	err = ak8975_set_mode(data, POWER_DOWN);
 	ak8975_power_off(data);
 
-	return 0;
+	return err;
 }
 
 static int ak8975_runtime_suspend(struct device *dev)
-- 
2.25.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux