Commit f2ece53b authored by Martin Kepplinger's avatar Martin Kepplinger
Browse files

media: i2c: hi846: track the powered state



Add a powered state to the driver and track the state there.
Don't try to do any powering twice unnecessarily.
Signed-off-by: Martin Kepplinger's avatarMartin Kepplinger <martin.kepplinger@puri.sm>
parent 77c8fc1d
Pipeline #73012 passed with stage
in 70 minutes and 14 seconds
......@@ -1358,6 +1358,7 @@ struct hi846 {
struct mutex mutex; /* protect cur_mode, streaming and chip access */
const struct hi846_mode *cur_mode;
bool streaming;
bool powered;
u16 debug_address;
struct hi846_reg_list *debug_regs;
......@@ -1839,7 +1840,10 @@ err_rpm_put:
static int hi846_power_on(struct hi846 *hi846)
{
int ret;
int ret = 0;
if (hi846->powered)
return 0;
ret = regulator_bulk_enable(HI846_NUM_SUPPLIES, hi846->supplies);
if (ret < 0)
......@@ -1858,6 +1862,8 @@ static int hi846_power_on(struct hi846 *hi846)
gpiod_set_value_cansleep(hi846->rst_gpio, 0);
usleep_range(30, 60);
hi846->powered = true;
return 0;
err_reg:
......@@ -1868,6 +1874,9 @@ err_reg:
static void hi846_power_off(struct hi846 *hi846)
{
if (!hi846->powered)
return;
if (hi846->rst_gpio)
gpiod_set_value_cansleep(hi846->rst_gpio, 1);
......@@ -1876,6 +1885,8 @@ static void hi846_power_off(struct hi846 *hi846)
clk_disable_unprepare(hi846->clock);
regulator_bulk_disable(HI846_NUM_SUPPLIES, hi846->supplies);
hi846->powered = false;
}
static int __maybe_unused hi846_suspend(struct device *dev)
......
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