Message ID | 1521600894-29919-5-git-send-email-aisheng.dong@nxp.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Hi Dong,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on v4.16-rc6 next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Dong-Aisheng/clk-new-APIs-to-handle-all-available-clocks/20180323-185821
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
smatch warnings:
drivers/video/fbdev/simplefb.c:222 simplefb_clocks_get() warn: unsigned 'par->clk_count' is never less than zero.
vim +222 drivers/video/fbdev/simplefb.c
193
194 #if defined CONFIG_OF && defined CONFIG_COMMON_CLK
195 /*
196 * Clock handling code.
197 *
198 * Here we handle the clocks property of our "simple-framebuffer" dt node.
199 * This is necessary so that we can make sure that any clocks needed by
200 * the display engine that the bootloader set up for us (and for which it
201 * provided a simplefb dt node), stay up, for the life of the simplefb
202 * driver.
203 *
204 * When the driver unloads, we cleanly disable, and then release the clocks.
205 *
206 * We only complain about errors here, no action is taken as the most likely
207 * error can only happen due to a mismatch between the bootloader which set
208 * up simplefb, and the clock definitions in the device tree. Chances are
209 * that there are no adverse effects, and if there are, a clean teardown of
210 * the fb probe will not help us much either. So just complain and carry on,
211 * and hope that the user actually gets a working fb at the end of things.
212 */
213 static int simplefb_clocks_get(struct simplefb_par *par,
214 struct platform_device *pdev)
215 {
216 struct device_node *np = pdev->dev.of_node;
217
218 if (dev_get_platdata(&pdev->dev) || !np)
219 return 0;
220
221 par->clk_count = clk_bulk_get_all(&pdev->dev, &par->clks);
> 222 if ((par->clk_count < 0) && (par->clk_count == -EPROBE_DEFER))
223 return -EPROBE_DEFER;
224
225 return 0;
226 }
227
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index a3c44ec..3c8124e 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -182,7 +182,7 @@ struct simplefb_par { #if defined CONFIG_OF && defined CONFIG_COMMON_CLK bool clks_enabled; unsigned int clk_count; - struct clk **clks; + struct clk_bulk_data *clks; #endif #if defined CONFIG_OF && defined CONFIG_REGULATOR bool regulators_enabled; @@ -214,37 +214,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_count = clk_bulk_get_all(&pdev->dev, &par->clks); + if ((par->clk_count < 0) && (par->clk_count == -EPROBE_DEFER)) + return -EPROBE_DEFER; return 0; } @@ -252,45 +228,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_prepare_enable(par->clk_count, par->clks); + 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_unprepare(par->clk_count, par->clks); - 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); + clk_bulk_put_all(par->clk_count, par->clks); } #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
Switching to use clk_bulk API to simplify clock operations. Cc: Hans de Goede <hdegoede@redhat.com> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Cc: linux-fbdev@vger.kernel.org Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com> --- v1->v2: * switch to clk_bulk_get_all from of_clk_bulk_get_all --- drivers/video/fbdev/simplefb.c | 69 ++++++++---------------------------------- 1 file changed, 13 insertions(+), 56 deletions(-)