[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1519055046-2399-8-git-send-email-m.purski@samsung.com>
Date: Mon, 19 Feb 2018 16:44:05 +0100
From: Maciej Purski <m.purski@...sung.com>
To: linux-media@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-clk@...r.kernel.org
Cc: Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Inki Dae <inki.dae@...sung.com>,
Joonyoung Shim <jy0922.shim@...sung.com>,
Seung-Woo Kim <sw0312.kim@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
David Airlie <airlied@...ux.ie>, Kukjin Kim <kgene@...nel.org>,
Krzysztof Kozlowski <krzk@...nel.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Andrzej Pietrasiewicz <andrzej.p@...sung.com>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
Kamil Debski <kamil@...as.org>,
Jeongtae Park <jtp.park@...sung.com>,
Andrzej Hajda <a.hajda@...sung.com>,
Russell King <linux@...linux.org.uk>,
Sylwester Nawrocki <s.nawrocki@...sung.com>,
Thibault Saunier <thibault.saunier@....samsung.com>,
Javier Martinez Canillas <javier@....samsung.com>,
Hans Verkuil <hansverk@...co.com>,
Hoegeun Kwon <hoegeun.kwon@...sung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Maciej Purski <m.purski@...sung.com>
Subject: [PATCH 7/8] [media] exynos-gsc: Use clk bulk API
Using bulk clk functions simplifies the driver's code. Use devm_clk_bulk
functions instead of iterating over an array of clks.
Signed-off-by: Maciej Purski <m.purski@...sung.com>
---
drivers/media/platform/exynos-gsc/gsc-core.c | 55 ++++++++++------------------
drivers/media/platform/exynos-gsc/gsc-core.h | 2 +-
2 files changed, 20 insertions(+), 37 deletions(-)
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c
index 17854a3..fa7e993 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -1149,7 +1149,6 @@ static int gsc_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
const struct gsc_driverdata *drv_data = of_device_get_match_data(dev);
int ret;
- int i;
gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL);
if (!gsc)
@@ -1187,25 +1186,19 @@ static int gsc_probe(struct platform_device *pdev)
return -ENXIO;
}
- for (i = 0; i < gsc->num_clocks; i++) {
- gsc->clock[i] = devm_clk_get(dev, drv_data->clk_names[i]);
- if (IS_ERR(gsc->clock[i])) {
- dev_err(dev, "failed to get clock: %s\n",
- drv_data->clk_names[i]);
- return PTR_ERR(gsc->clock[i]);
- }
- }
+ gsc->clocks = devm_clk_bulk_alloc(dev, gsc->num_clocks,
+ drv_data->clk_names);
+ if (IS_ERR(gsc->clocks))
+ return PTR_ERR(gsc->clocks);
- for (i = 0; i < gsc->num_clocks; i++) {
- ret = clk_prepare_enable(gsc->clock[i]);
- if (ret) {
- dev_err(dev, "clock prepare failed for clock: %s\n",
- drv_data->clk_names[i]);
- while (--i >= 0)
- clk_disable_unprepare(gsc->clock[i]);
- return ret;
- }
- }
+ ret = devm_clk_bulk_get(dev, gsc->num_clocks,
+ gsc->clocks);
+ if (ret)
+ return ret;
+
+ ret = clk_bulk_prepare_enable(gsc->num_clocks, gsc->clocks);
+ if (ret)
+ return ret;
ret = devm_request_irq(dev, res->start, gsc_irq_handler,
0, pdev->name, gsc);
@@ -1239,15 +1232,14 @@ static int gsc_probe(struct platform_device *pdev)
err_v4l2:
v4l2_device_unregister(&gsc->v4l2_dev);
err_clk:
- for (i = gsc->num_clocks - 1; i >= 0; i--)
- clk_disable_unprepare(gsc->clock[i]);
+ clk_bulk_disable_unprepare(gsc->num_clocks, gsc->clocks);
+
return ret;
}
static int gsc_remove(struct platform_device *pdev)
{
struct gsc_dev *gsc = platform_get_drvdata(pdev);
- int i;
pm_runtime_get_sync(&pdev->dev);
@@ -1255,8 +1247,7 @@ static int gsc_remove(struct platform_device *pdev)
v4l2_device_unregister(&gsc->v4l2_dev);
vb2_dma_contig_clear_max_seg_size(&pdev->dev);
- for (i = 0; i < gsc->num_clocks; i++)
- clk_disable_unprepare(gsc->clock[i]);
+ clk_bulk_disable_unprepare(gsc->num_clocks, gsc->clocks);
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
@@ -1307,18 +1298,12 @@ static int gsc_runtime_resume(struct device *dev)
{
struct gsc_dev *gsc = dev_get_drvdata(dev);
int ret = 0;
- int i;
pr_debug("gsc%d: state: 0x%lx\n", gsc->id, gsc->state);
- for (i = 0; i < gsc->num_clocks; i++) {
- ret = clk_prepare_enable(gsc->clock[i]);
- if (ret) {
- while (--i >= 0)
- clk_disable_unprepare(gsc->clock[i]);
- return ret;
- }
- }
+ ret = clk_bulk_prepare_enable(gsc->num_clocks, gsc->clocks);
+ if (ret)
+ return ret;
gsc_hw_set_sw_reset(gsc);
gsc_wait_reset(gsc);
@@ -1331,14 +1316,12 @@ static int gsc_runtime_suspend(struct device *dev)
{
struct gsc_dev *gsc = dev_get_drvdata(dev);
int ret = 0;
- int i;
ret = gsc_m2m_suspend(gsc);
if (ret)
return ret;
- for (i = gsc->num_clocks - 1; i >= 0; i--)
- clk_disable_unprepare(gsc->clock[i]);
+ clk_bulk_disable_unprepare(gsc->num_clocks, gsc->clocks);
pr_debug("gsc%d: state: 0x%lx\n", gsc->id, gsc->state);
return ret;
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h
index 715d9c9d..08ff7b9 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/exynos-gsc/gsc-core.h
@@ -334,7 +334,7 @@ struct gsc_dev {
struct gsc_variant *variant;
u16 id;
int num_clocks;
- struct clk *clock[GSC_MAX_CLOCKS];
+ struct clk_bulk_data *clocks;
void __iomem *regs;
wait_queue_head_t irq_queue;
struct gsc_m2m_device m2m;
--
2.7.4
Powered by blists - more mailing lists