Commit cbe0b3af authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: ov8865: Disable only enabled regulators on error path

If powering on the sensor failed, the entire power-off sequence was run
independently of how far the power-on sequence proceeded before the error.
This lead to disabling regulators and/or clock that was not enabled.

Fix this by disabling only clocks and regulators that were enabled
previously.

Fixes: 11c0d8fd ("media: i2c: Add support for the OV8865 image sensor")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 6ab70300
...@@ -2407,27 +2407,27 @@ static int ov8865_sensor_power(struct ov8865_sensor *sensor, bool on) ...@@ -2407,27 +2407,27 @@ static int ov8865_sensor_power(struct ov8865_sensor *sensor, bool on)
if (ret) { if (ret) {
dev_err(sensor->dev, dev_err(sensor->dev,
"failed to enable DOVDD regulator\n"); "failed to enable DOVDD regulator\n");
goto disable; return ret;
} }
ret = regulator_enable(sensor->avdd); ret = regulator_enable(sensor->avdd);
if (ret) { if (ret) {
dev_err(sensor->dev, dev_err(sensor->dev,
"failed to enable AVDD regulator\n"); "failed to enable AVDD regulator\n");
goto disable; goto disable_dovdd;
} }
ret = regulator_enable(sensor->dvdd); ret = regulator_enable(sensor->dvdd);
if (ret) { if (ret) {
dev_err(sensor->dev, dev_err(sensor->dev,
"failed to enable DVDD regulator\n"); "failed to enable DVDD regulator\n");
goto disable; goto disable_avdd;
} }
ret = clk_prepare_enable(sensor->extclk); ret = clk_prepare_enable(sensor->extclk);
if (ret) { if (ret) {
dev_err(sensor->dev, "failed to enable EXTCLK clock\n"); dev_err(sensor->dev, "failed to enable EXTCLK clock\n");
goto disable; goto disable_dvdd;
} }
gpiod_set_value_cansleep(sensor->reset, 0); gpiod_set_value_cansleep(sensor->reset, 0);
...@@ -2436,14 +2436,16 @@ static int ov8865_sensor_power(struct ov8865_sensor *sensor, bool on) ...@@ -2436,14 +2436,16 @@ static int ov8865_sensor_power(struct ov8865_sensor *sensor, bool on)
/* Time to enter streaming mode according to power timings. */ /* Time to enter streaming mode according to power timings. */
usleep_range(10000, 12000); usleep_range(10000, 12000);
} else { } else {
disable:
gpiod_set_value_cansleep(sensor->powerdown, 1); gpiod_set_value_cansleep(sensor->powerdown, 1);
gpiod_set_value_cansleep(sensor->reset, 1); gpiod_set_value_cansleep(sensor->reset, 1);
clk_disable_unprepare(sensor->extclk); clk_disable_unprepare(sensor->extclk);
disable_dvdd:
regulator_disable(sensor->dvdd); regulator_disable(sensor->dvdd);
disable_avdd:
regulator_disable(sensor->avdd); regulator_disable(sensor->avdd);
disable_dovdd:
regulator_disable(sensor->dovdd); regulator_disable(sensor->dovdd);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment