media: marvel-ccic: fix some issues when getting pm_runtime
[ Upstream commit e7c617cab7a522fba5b20f9033ee98565b6f3546 ] Calling pm_runtime_get_sync() is bad, since even when it returns an error, pm_runtime_put*() should be called. So, use instead pm_runtime_resume_and_get(). While here, ensure that the error condition will be checked during clock enable an media open() calls. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
ccf0a291f7
commit
ff7e4b94db
@@ -918,6 +918,7 @@ static int mclk_enable(struct clk_hw *hw)
|
|||||||
struct mcam_camera *cam = container_of(hw, struct mcam_camera, mclk_hw);
|
struct mcam_camera *cam = container_of(hw, struct mcam_camera, mclk_hw);
|
||||||
int mclk_src;
|
int mclk_src;
|
||||||
int mclk_div;
|
int mclk_div;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clock the sensor appropriately. Controller clock should
|
* Clock the sensor appropriately. Controller clock should
|
||||||
@@ -931,7 +932,9 @@ static int mclk_enable(struct clk_hw *hw)
|
|||||||
mclk_div = 2;
|
mclk_div = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_runtime_get_sync(cam->dev);
|
ret = pm_runtime_resume_and_get(cam->dev);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
clk_enable(cam->clk[0]);
|
clk_enable(cam->clk[0]);
|
||||||
mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div);
|
mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div);
|
||||||
mcam_ctlr_power_up(cam);
|
mcam_ctlr_power_up(cam);
|
||||||
@@ -1611,7 +1614,9 @@ static int mcam_v4l_open(struct file *filp)
|
|||||||
ret = sensor_call(cam, core, s_power, 1);
|
ret = sensor_call(cam, core, s_power, 1);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
pm_runtime_get_sync(cam->dev);
|
ret = pm_runtime_resume_and_get(cam->dev);
|
||||||
|
if (ret < 0)
|
||||||
|
goto out;
|
||||||
__mcam_cam_reset(cam);
|
__mcam_cam_reset(cam);
|
||||||
mcam_set_config_needed(cam, 1);
|
mcam_set_config_needed(cam, 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user