mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
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: 4c2e5156d9
("media: imx-jpeg: Add pm-runtime support for imx-jpeg")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
parent
c07e734b7a
commit
61fe43dc9f
2 changed files with 10 additions and 29 deletions
|
@ -2472,19 +2472,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev)
|
||||||
jpeg->mode = mode;
|
jpeg->mode = mode;
|
||||||
|
|
||||||
/* Get clocks */
|
/* Get clocks */
|
||||||
jpeg->clk_ipg = devm_clk_get(dev, "ipg");
|
ret = devm_clk_bulk_get_all(&pdev->dev, &jpeg->clks);
|
||||||
if (IS_ERR(jpeg->clk_ipg)) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "failed to get clock: ipg\n");
|
dev_err(dev, "failed to get clock\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);
|
|
||||||
goto err_clk;
|
goto err_clk;
|
||||||
}
|
}
|
||||||
|
jpeg->num_clks = ret;
|
||||||
|
|
||||||
ret = mxc_jpeg_attach_pm_domains(jpeg);
|
ret = mxc_jpeg_attach_pm_domains(jpeg);
|
||||||
if (ret < 0) {
|
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);
|
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = clk_prepare_enable(jpeg->clk_ipg);
|
ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "failed to enable clock: ipg\n");
|
dev_err(dev, "failed to enable clock\n");
|
||||||
goto err_ipg;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
ret = clk_prepare_enable(jpeg->clk_per);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(dev, "failed to enable clock: per\n");
|
|
||||||
goto err_per;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_per:
|
|
||||||
clk_disable_unprepare(jpeg->clk_ipg);
|
|
||||||
err_ipg:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mxc_jpeg_runtime_suspend(struct device *dev)
|
static int mxc_jpeg_runtime_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
|
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
|
||||||
|
|
||||||
clk_disable_unprepare(jpeg->clk_ipg);
|
clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks);
|
||||||
clk_disable_unprepare(jpeg->clk_per);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,8 @@ struct mxc_jpeg_dev {
|
||||||
spinlock_t hw_lock; /* hardware access lock */
|
spinlock_t hw_lock; /* hardware access lock */
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
struct mutex lock; /* v4l2 ioctls serialization */
|
struct mutex lock; /* v4l2 ioctls serialization */
|
||||||
struct clk *clk_ipg;
|
struct clk_bulk_data *clks;
|
||||||
struct clk *clk_per;
|
int num_clks;
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
void __iomem *base_reg;
|
void __iomem *base_reg;
|
||||||
|
|
Loading…
Reference in a new issue