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

media: marvel-ccic: fix some issues when getting pm_runtime

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>

+7 -2
+7 -2
drivers/media/platform/marvell-ccic/mcam-core.c
··· 918 918 struct mcam_camera *cam = container_of(hw, struct mcam_camera, mclk_hw); 919 919 int mclk_src; 920 920 int mclk_div; 921 + int ret; 921 922 922 923 /* 923 924 * Clock the sensor appropriately. Controller clock should ··· 932 931 mclk_div = 2; 933 932 } 934 933 935 - pm_runtime_get_sync(cam->dev); 934 + ret = pm_runtime_resume_and_get(cam->dev); 935 + if (ret < 0) 936 + return ret; 936 937 clk_enable(cam->clk[0]); 937 938 mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div); 938 939 mcam_ctlr_power_up(cam); ··· 1614 1611 ret = sensor_call(cam, core, s_power, 1); 1615 1612 if (ret) 1616 1613 goto out; 1617 - pm_runtime_get_sync(cam->dev); 1614 + ret = pm_runtime_resume_and_get(cam->dev); 1615 + if (ret < 0) 1616 + goto out; 1618 1617 __mcam_cam_reset(cam); 1619 1618 mcam_set_config_needed(cam, 1); 1620 1619 }