mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-28 20:37:27 +00:00
[media] s5p-fimc: Check return value of clk_enable/clk_set_rate
clk_set_rate(), clk_enable() functions can fail, so check the return values to avoid surprises. While at it use ERR_PTR() value to indicate an invalid clock. 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
7b43a6f3f5
commit
b71b56b264
@ -808,11 +808,11 @@ static void fimc_clk_put(struct fimc_dev *fimc)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_FIMC_CLOCKS; i++) {
|
||||
if (IS_ERR_OR_NULL(fimc->clock[i]))
|
||||
if (IS_ERR(fimc->clock[i]))
|
||||
continue;
|
||||
clk_unprepare(fimc->clock[i]);
|
||||
clk_put(fimc->clock[i]);
|
||||
fimc->clock[i] = NULL;
|
||||
fimc->clock[i] = ERR_PTR(-EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -820,14 +820,19 @@ static int fimc_clk_get(struct fimc_dev *fimc)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < MAX_FIMC_CLOCKS; i++)
|
||||
fimc->clock[i] = ERR_PTR(-EINVAL);
|
||||
|
||||
for (i = 0; i < MAX_FIMC_CLOCKS; i++) {
|
||||
fimc->clock[i] = clk_get(&fimc->pdev->dev, fimc_clocks[i]);
|
||||
if (IS_ERR(fimc->clock[i]))
|
||||
if (IS_ERR(fimc->clock[i])) {
|
||||
ret = PTR_ERR(fimc->clock[i]);
|
||||
goto err;
|
||||
}
|
||||
ret = clk_prepare(fimc->clock[i]);
|
||||
if (ret < 0) {
|
||||
clk_put(fimc->clock[i]);
|
||||
fimc->clock[i] = NULL;
|
||||
fimc->clock[i] = ERR_PTR(-EINVAL);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -921,8 +926,14 @@ static int fimc_probe(struct platform_device *pdev)
|
||||
ret = fimc_clk_get(fimc);
|
||||
if (ret)
|
||||
return ret;
|
||||
clk_set_rate(fimc->clock[CLK_BUS], drv_data->lclk_frequency);
|
||||
clk_enable(fimc->clock[CLK_BUS]);
|
||||
|
||||
ret = clk_set_rate(fimc->clock[CLK_BUS], drv_data->lclk_frequency);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = clk_enable(fimc->clock[CLK_BUS]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, res->start, fimc_irq_handler,
|
||||
0, dev_name(&pdev->dev), fimc);
|
||||
@ -956,6 +967,7 @@ err_pm:
|
||||
err_sd:
|
||||
fimc_unregister_capture_subdev(fimc);
|
||||
err_clk:
|
||||
clk_disable(fimc->clock[CLK_BUS]);
|
||||
fimc_clk_put(fimc);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user