iio: accel: kxcjk-1013: power off device if probe fails
When the device is initialized in probe, it is also powered on. If there is an error after the initialization, the device will remain powered on. Power off the device in case probe fails after device initialization. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Suggested-by: Daniel Baluta <daniel.baluta@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
fbd123e913
commit
9d02daf738
1 changed files with 12 additions and 6 deletions
|
@ -1240,21 +1240,25 @@ static int kxcjk1013_probe(struct i2c_client *client,
|
|||
KXCJK1013_IRQ_NAME,
|
||||
indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto err_poweroff;
|
||||
|
||||
data->dready_trig = devm_iio_trigger_alloc(&client->dev,
|
||||
"%s-dev%d",
|
||||
indio_dev->name,
|
||||
indio_dev->id);
|
||||
if (!data->dready_trig)
|
||||
return -ENOMEM;
|
||||
if (!data->dready_trig) {
|
||||
ret = -ENOMEM;
|
||||
goto err_poweroff;
|
||||
}
|
||||
|
||||
data->motion_trig = devm_iio_trigger_alloc(&client->dev,
|
||||
"%s-any-motion-dev%d",
|
||||
indio_dev->name,
|
||||
indio_dev->id);
|
||||
if (!data->motion_trig)
|
||||
return -ENOMEM;
|
||||
if (!data->motion_trig) {
|
||||
ret = -ENOMEM;
|
||||
goto err_poweroff;
|
||||
}
|
||||
|
||||
data->dready_trig->dev.parent = &client->dev;
|
||||
data->dready_trig->ops = &kxcjk1013_trigger_ops;
|
||||
|
@ -1263,7 +1267,7 @@ static int kxcjk1013_probe(struct i2c_client *client,
|
|||
iio_trigger_get(indio_dev->trig);
|
||||
ret = iio_trigger_register(data->dready_trig);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto err_poweroff;
|
||||
|
||||
data->motion_trig->dev.parent = &client->dev;
|
||||
data->motion_trig->ops = &kxcjk1013_trigger_ops;
|
||||
|
@ -1312,6 +1316,8 @@ static int kxcjk1013_probe(struct i2c_client *client,
|
|||
iio_trigger_unregister(data->dready_trig);
|
||||
if (data->motion_trig)
|
||||
iio_trigger_unregister(data->motion_trig);
|
||||
err_poweroff:
|
||||
kxcjk1013_set_mode(data, STANDBY);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue