[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1516711841-25234-3-git-send-email-aisheng.dong@nxp.com>
Date: Tue, 23 Jan 2018 20:50:41 +0800
From: Dong Aisheng <aisheng.dong@....com>
To: <linux-clk@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-imx@....com>,
<aisheng.dong@...eaurora.org>, <linux-fbdev@...r.kernel.org>,
<yamada.masahiro@...ionext.com>, <sboyd@...eaurora.org>,
<hdegoede@...hat.com>, <b.zolnierkie@...sung.com>,
Dong Aisheng <aisheng.dong@....com>
Subject: [RFC PATCH 2/2] video: simplefb: switch to use clk_bulk API to simplify clock operations
Switching to use clk_bulk API to simplify clock operations.
Cc: Hans de Goede <hdegoede@...hat.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Cc: linux-fbdev@...r.kernel.org
Cc: Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc: Stephen Boyd <sboyd@...eaurora.org>
Signed-off-by: Dong Aisheng <aisheng.dong@....com>
---
drivers/video/fbdev/simplefb.c | 70 ++++++++----------------------------------
1 file changed, 13 insertions(+), 57 deletions(-)
diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index a3c44ec..3ce2e5b 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -181,8 +181,7 @@ struct simplefb_par {
u32 palette[PSEUDO_PALETTE_SIZE];
#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
bool clks_enabled;
- unsigned int clk_count;
- struct clk **clks;
+ struct clk_bulk *clk_bulk;
#endif
#if defined CONFIG_OF && defined CONFIG_REGULATOR
bool regulators_enabled;
@@ -214,37 +213,13 @@ static int simplefb_clocks_get(struct simplefb_par *par,
struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
- struct clk *clock;
- int i;
if (dev_get_platdata(&pdev->dev) || !np)
return 0;
- par->clk_count = of_clk_get_parent_count(np);
- if (!par->clk_count)
- return 0;
-
- par->clks = kcalloc(par->clk_count, sizeof(struct clk *), GFP_KERNEL);
- if (!par->clks)
- return -ENOMEM;
-
- for (i = 0; i < par->clk_count; i++) {
- clock = of_clk_get(np, i);
- if (IS_ERR(clock)) {
- if (PTR_ERR(clock) == -EPROBE_DEFER) {
- while (--i >= 0) {
- if (par->clks[i])
- clk_put(par->clks[i]);
- }
- kfree(par->clks);
- return -EPROBE_DEFER;
- }
- dev_err(&pdev->dev, "%s: clock %d not found: %ld\n",
- __func__, i, PTR_ERR(clock));
- continue;
- }
- par->clks[i] = clock;
- }
+ par->clk_bulk = of_clk_bulk_get_all(np);
+ if (IS_ERR(par->clk_bulk) && PTR_ERR(par->clk_bulk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
return 0;
}
@@ -252,45 +227,26 @@ static int simplefb_clocks_get(struct simplefb_par *par,
static void simplefb_clocks_enable(struct simplefb_par *par,
struct platform_device *pdev)
{
- int i, ret;
+ int ret;
+
+ ret = clk_bulk_enable_all(par->clk_bulk);
+ if (ret)
+ dev_warn(&pdev->dev, "failed to enable clocks\n");
- for (i = 0; i < par->clk_count; i++) {
- if (par->clks[i]) {
- ret = clk_prepare_enable(par->clks[i]);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: failed to enable clock %d: %d\n",
- __func__, i, ret);
- clk_put(par->clks[i]);
- par->clks[i] = NULL;
- }
- }
- }
par->clks_enabled = true;
}
static void simplefb_clocks_destroy(struct simplefb_par *par)
{
- int i;
-
- if (!par->clks)
- return;
+ if (par->clks_enabled)
+ clk_bulk_disable_all(par->clk_bulk);
- for (i = 0; i < par->clk_count; i++) {
- if (par->clks[i]) {
- if (par->clks_enabled)
- clk_disable_unprepare(par->clks[i]);
- clk_put(par->clks[i]);
- }
- }
-
- kfree(par->clks);
+ of_clk_bulk_put_all(par->clk_bulk);
}
#else
static int simplefb_clocks_get(struct simplefb_par *par,
struct platform_device *pdev) { return 0; }
-static void simplefb_clocks_enable(struct simplefb_par *par,
- struct platform_device *pdev) { }
+static int simplefb_clocks_enable(struct simplefb_par *par) { }
static void simplefb_clocks_destroy(struct simplefb_par *par) { }
#endif
--
2.7.4
Powered by blists - more mailing lists