[media] s5p-fimc: Add clk_prepare/unprepare for sclk_cam clocks
Add clk_prepare(), clk_unprepare() calls for the sclk_cam clocks to ensure the driver works on platforms with the common clocks API enabled. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
8b164105d8
commit
0e23cbbe47
1 changed files with 40 additions and 21 deletions
|
@ -708,37 +708,56 @@ static int fimc_md_create_links(struct fimc_md *fmd)
|
|||
/*
|
||||
* The peripheral sensor clock management.
|
||||
*/
|
||||
static int fimc_md_get_clocks(struct fimc_md *fmd)
|
||||
{
|
||||
char clk_name[32];
|
||||
struct clk *clock;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FIMC_MAX_CAMCLKS; i++) {
|
||||
snprintf(clk_name, sizeof(clk_name), "sclk_cam%u", i);
|
||||
clock = clk_get(NULL, clk_name);
|
||||
if (IS_ERR(clock)) {
|
||||
v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s",
|
||||
clk_name);
|
||||
return -ENXIO;
|
||||
}
|
||||
fmd->camclk[i].clock = clock;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fimc_md_put_clocks(struct fimc_md *fmd)
|
||||
{
|
||||
int i = FIMC_MAX_CAMCLKS;
|
||||
|
||||
while (--i >= 0) {
|
||||
if (IS_ERR_OR_NULL(fmd->camclk[i].clock))
|
||||
if (IS_ERR(fmd->camclk[i].clock))
|
||||
continue;
|
||||
clk_unprepare(fmd->camclk[i].clock);
|
||||
clk_put(fmd->camclk[i].clock);
|
||||
fmd->camclk[i].clock = NULL;
|
||||
fmd->camclk[i].clock = ERR_PTR(-EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
static int fimc_md_get_clocks(struct fimc_md *fmd)
|
||||
{
|
||||
struct device *dev = NULL;
|
||||
char clk_name[32];
|
||||
struct clk *clock;
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < FIMC_MAX_CAMCLKS; i++)
|
||||
fmd->camclk[i].clock = ERR_PTR(-EINVAL);
|
||||
|
||||
if (fmd->pdev->dev.of_node)
|
||||
dev = &fmd->pdev->dev;
|
||||
|
||||
for (i = 0; i < FIMC_MAX_CAMCLKS; i++) {
|
||||
snprintf(clk_name, sizeof(clk_name), "sclk_cam%u", i);
|
||||
clock = clk_get(dev, clk_name);
|
||||
|
||||
if (IS_ERR(clock)) {
|
||||
dev_err(&fmd->pdev->dev, "Failed to get clock: %s\n",
|
||||
clk_name);
|
||||
ret = PTR_ERR(clock);
|
||||
break;
|
||||
}
|
||||
ret = clk_prepare(clock);
|
||||
if (ret < 0) {
|
||||
clk_put(clock);
|
||||
fmd->camclk[i].clock = ERR_PTR(-EINVAL);
|
||||
break;
|
||||
}
|
||||
fmd->camclk[i].clock = clock;
|
||||
}
|
||||
if (ret)
|
||||
fimc_md_put_clocks(fmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __fimc_md_set_camclk(struct fimc_md *fmd,
|
||||
struct fimc_sensor_info *s_info,
|
||||
bool on)
|
||||
|
|
Loading…
Reference in a new issue