提交 66687e6a 编写于 作者: C Cristina Opriceana 提交者: Greg Kroah-Hartman

iio: magnetometer: mag3110: Place driver on standby on error

Place driver on standby mode on error in order to prevent wasting
power. Move standby function above to be seen by the new call.
Signed-off-by: NCristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 aa5587f3
...@@ -321,6 +321,12 @@ static const struct iio_info mag3110_info = { ...@@ -321,6 +321,12 @@ static const struct iio_info mag3110_info = {
static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0}; static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0};
static int mag3110_standby(struct mag3110_data *data)
{
return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
data->ctrl_reg1 & ~MAG3110_CTRL_AC);
}
static int mag3110_probe(struct i2c_client *client, static int mag3110_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -360,12 +366,12 @@ static int mag3110_probe(struct i2c_client *client, ...@@ -360,12 +366,12 @@ static int mag3110_probe(struct i2c_client *client,
ret = i2c_smbus_write_byte_data(client, MAG3110_CTRL_REG2, ret = i2c_smbus_write_byte_data(client, MAG3110_CTRL_REG2,
MAG3110_CTRL_AUTO_MRST_EN); MAG3110_CTRL_AUTO_MRST_EN);
if (ret < 0) if (ret < 0)
return ret; goto standby_on_error;
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = iio_triggered_buffer_setup(indio_dev, NULL,
mag3110_trigger_handler, NULL); mag3110_trigger_handler, NULL);
if (ret < 0) if (ret < 0)
return ret; goto standby_on_error;
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret < 0) if (ret < 0)
...@@ -374,15 +380,11 @@ static int mag3110_probe(struct i2c_client *client, ...@@ -374,15 +380,11 @@ static int mag3110_probe(struct i2c_client *client,
buffer_cleanup: buffer_cleanup:
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
standby_on_error:
mag3110_standby(iio_priv(indio_dev));
return ret; return ret;
} }
static int mag3110_standby(struct mag3110_data *data)
{
return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
data->ctrl_reg1 & ~MAG3110_CTRL_AC);
}
static int mag3110_remove(struct i2c_client *client) static int mag3110_remove(struct i2c_client *client)
{ {
struct iio_dev *indio_dev = i2c_get_clientdata(client); struct iio_dev *indio_dev = i2c_get_clientdata(client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册