Skip to content

Commit 536bbca

Browse files
adrianareusjic23
authored andcommitted
iio: light: pa12203001: Poweroff chip if register fails
Make sure we poweroff the chip if for any reason iio_register returns an error. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent a84ef0d commit 536bbca

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎drivers/iio/light/pa12203001.c‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,23 @@ static int pa12203001_probe(struct i2c_client *client,
381381
return ret;
382382

383383
ret = pm_runtime_set_active(&client->dev);
384-
if (ret < 0) {
385-
pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
386-
return ret;
387-
}
384+
if (ret < 0)
385+
goto out_err;
388386

389387
pm_runtime_enable(&client->dev);
390388
pm_runtime_set_autosuspend_delay(&client->dev,
391389
PA12203001_SLEEP_DELAY_MS);
392390
pm_runtime_use_autosuspend(&client->dev);
393391

394-
return iio_device_register(indio_dev);
392+
ret = iio_device_register(indio_dev);
393+
if (ret < 0)
394+
goto out_err;
395+
396+
return 0;
397+
398+
out_err:
399+
pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
400+
return ret;
395401
}
396402

397403
static int pa12203001_remove(struct i2c_client *client)

0 commit comments

Comments
 (0)