Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932115AbdDMT5v (ORCPT ); Thu, 13 Apr 2017 15:57:51 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:33498 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085AbdDMT5s (ORCPT ); Thu, 13 Apr 2017 15:57:48 -0400 MIME-Version: 1.0 In-Reply-To: <1491931159.31718.16.camel@nxp.com> References: <1491969809-20154-1-git-send-email-aisheng.dong@nxp.com> <1491969809-20154-2-git-send-email-aisheng.dong@nxp.com> <1491931159.31718.16.camel@nxp.com> From: Geert Uytterhoeven Date: Thu, 13 Apr 2017 21:57:46 +0200 X-Google-Sender-Auth: Z6lkZnYgsl6yfEppzrC0eMZopc0 Message-ID: Subject: Re: [RFC PATCH 1/3] clk: add clk_bulk_get accessories To: Leonard Crestez Cc: Dong Aisheng , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Sascha Hauer , Mark Brown , yibin.gong@nxp.com, "Rafael J. Wysocki" , Viresh Kumar , Michael Turquette , Stephen Boyd , Shawn Guo , Fabio Estevam , anson.huang@nxp.com, ping.bai@nxp.com, octavian.purdila@nxp.com, linux-clk Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1469 Lines: 48 On Tue, Apr 11, 2017 at 7:19 PM, Leonard Crestez wrote: > On Wed, 2017-04-12 at 12:03 +0800, Dong Aisheng wrote: >> +/** >> + * clk_bulk_enable - ungate a bulk of clocks >> + * @num_clks: the number of clk_bulk_data >> + * @clks: the clk_bulk_data table being ungated >> + * >> + * clk_bulk_enable must not sleep >> + * Returns 0 on success, -EERROR otherwise. >> + */ >> +int clk_bulk_enable(int num_clks, struct clk_bulk_data *clks) >> +{ >> + int ret; >> + int i; >> + >> + for (i = 0; i < num_clks; i++) { >> + ret = clk_enable(clks[i].clk); >> + if (ret) { >> + pr_err("Failed to enable clk '%s': %d\n", >> + clks[i].id, ret); >> + goto err; >> + } >> + } >> + >> + return 0; >> + >> +err: >> + while (--i >= 0) >> + clk_put(clks[i].clk); > > Shouldn't this be clk_disable? > > And you can probably use clk_bulk_disable(i, clks) instead To avoid nasty surprises, clk_bulk_disable() should loop over all clocks in reverse order. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds