Commit 61fe43dc authored by Ming Qian's avatar Ming Qian Committed by Mauro Carvalho Chehab

media: imx-jpeg: Apply clk_bulk api instead of operating specific clk

using the api of clk_bulk can simplify the code.
and the clock of the jpeg codec may be changed,
the clk_bulk api can be compatible with the future change.

Fixes: 4c2e5156 ("media: imx-jpeg: Add pm-runtime support for imx-jpeg")
Signed-off-by: default avatarMing Qian <ming.qian@nxp.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent c07e734b
......@@ -2472,19 +2472,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev)
jpeg->mode = mode;
/* Get clocks */
jpeg->clk_ipg = devm_clk_get(dev, "ipg");
if (IS_ERR(jpeg->clk_ipg)) {
dev_err(dev, "failed to get clock: ipg\n");
ret = PTR_ERR(jpeg->clk_ipg);
goto err_clk;
}
jpeg->clk_per = devm_clk_get(dev, "per");
if (IS_ERR(jpeg->clk_per)) {
dev_err(dev, "failed to get clock: per\n");
ret = PTR_ERR(jpeg->clk_per);
ret = devm_clk_bulk_get_all(&pdev->dev, &jpeg->clks);
if (ret < 0) {
dev_err(dev, "failed to get clock\n");
goto err_clk;
}
jpeg->num_clks = ret;
ret = mxc_jpeg_attach_pm_domains(jpeg);
if (ret < 0) {
......@@ -2581,32 +2574,20 @@ static int mxc_jpeg_runtime_resume(struct device *dev)
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(jpeg->clk_ipg);
if (ret < 0) {
dev_err(dev, "failed to enable clock: ipg\n");
goto err_ipg;
}
ret = clk_prepare_enable(jpeg->clk_per);
ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks);
if (ret < 0) {
dev_err(dev, "failed to enable clock: per\n");
goto err_per;
dev_err(dev, "failed to enable clock\n");
return ret;
}
return 0;
err_per:
clk_disable_unprepare(jpeg->clk_ipg);
err_ipg:
return ret;
}
static int mxc_jpeg_runtime_suspend(struct device *dev)
{
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
clk_disable_unprepare(jpeg->clk_ipg);
clk_disable_unprepare(jpeg->clk_per);
clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks);
return 0;
}
......
......@@ -120,8 +120,8 @@ struct mxc_jpeg_dev {
spinlock_t hw_lock; /* hardware access lock */
unsigned int mode;
struct mutex lock; /* v4l2 ioctls serialization */
struct clk *clk_ipg;
struct clk *clk_per;
struct clk_bulk_data *clks;
int num_clks;
struct platform_device *pdev;
struct device *dev;
void __iomem *base_reg;
......
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