Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adriana Reus and committed by
Jonathan Cameron
536bbca7 a84ef0d1

+11 -5
+11 -5
drivers/iio/light/pa12203001.c
··· 381 381 return ret; 382 382 383 383 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; 388 386 389 387 pm_runtime_enable(&client->dev); 390 388 pm_runtime_set_autosuspend_delay(&client->dev, 391 389 PA12203001_SLEEP_DELAY_MS); 392 390 pm_runtime_use_autosuspend(&client->dev); 393 391 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; 395 401 } 396 402 397 403 static int pa12203001_remove(struct i2c_client *client)