From patchwork Sun Aug 13 14:18:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 9897867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E859602CA for ; Sun, 13 Aug 2017 14:21:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14BA52097A for ; Sun, 13 Aug 2017 14:21:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09770283ED; Sun, 13 Aug 2017 14:21:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 17C572097A for ; Sun, 13 Aug 2017 14:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e0kjykyGD4JUG5R/Xz7QbCcS9JWS8rz7d7tH3Nrkd/4=; b=ajktXRwmGH753u +qNfQLy2InUwY2ByAFkdFd1f6ggee2kmSa988JrPrCSYi763MIiBPGzwJvwbjaCzsv/PROm3el1vg HsqsUk3OHiyZWUC9vh0ukFjpTwtfArDbMpPH8oBuOpjWHf4L2zVerzez2zcXCI2FFVRLW7v4JiEPg 4d3PhEpLZuu9rIl0kc7NpIYy78J8ihqyqjPw0dQnGuXkXYpPI8InrLb5g9A0OcSY4fcdoqzdh1xmh ciT4KT5elYM2X1uf56pViCb9pb4vsGller7GxRha+RjgBaqOcv2JcaAf+b0y22VvKrSBTXFvLTG8U sKUZWOvDDkJnDJPgWetg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dgtl7-0003jN-SX; Sun, 13 Aug 2017 14:20:53 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dgtl4-0003ho-9g for linux-arm-kernel@lists.infradead.org; Sun, 13 Aug 2017 14:20:51 +0000 Received: from dragon (li411-102.members.linode.com [106.187.91.102]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27CC323966; Sun, 13 Aug 2017 14:20:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27CC323966 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shawnguo@kernel.org Date: Sun, 13 Aug 2017 22:18:53 +0800 From: Shawn Guo To: Stephen Boyd Subject: Re: [PATCH] clk: bulk: call of_clk_get() when id is NULL Message-ID: <20170813141851.GD31819@dragon> References: <1502243442-28055-1-git-send-email-shawnguo@kernel.org> <20170809173318.GD2146@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170809173318.GD2146@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170813_072050_425597_CF0E4CD2 X-CRM114-Status: GOOD ( 18.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Michael Turquette , Shawn Guo , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Stephen, On Wed, Aug 09, 2017 at 10:33:18AM -0700, Stephen Boyd wrote: > > diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c > > index c834f5abfc49..65cee595a67e 100644 > > --- a/drivers/clk/clk-bulk.c > > +++ b/drivers/clk/clk-bulk.c > > @@ -39,7 +39,10 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, > > clks[i].clk = NULL; > > > > for (i = 0; i < num_clks; i++) { > > - clks[i].clk = clk_get(dev, clks[i].id); > > + if (clks[i].id) > > + clks[i].clk = clk_get(dev, clks[i].id); > > + else if (dev->of_node) > > + clks[i].clk = of_clk_get(dev->of_node, i); > > This seems a little too magical. The omission of an id in an > array of clks would mean that only that one clk is acquired > through of_clk_get(). We could have a mixture of ids and no ids > for some device, and then do very odd things. > > How about we add a flag to clk_bulk_data that indicates we want > it to use of_clk_get() instead of clk_get() for all of the clks? > Then the id is ignored for the entire function. I have sent v2 to add a flag to clk_bulk_data to address your comments. But I just found it might not be what you want exactly, because the current bulk clk APIs defines clk_bulk_data in a different way from what you are asking here. It seems that you think clk_bulk_data represents all the clocks that bulk APIs manage, but actually it only represents one of the multiple clocks. Callers need to prepare an array of clk_bulk_data to represent multiple clocks. That said, the flag we add to clk_bulk_data only affects one clock instead of all clocks. I feel this is something we can improve. clk_bulk_data can be used to represent all clocks, something like below. In this case, bulk clk APIs do not need to take num_clks as a separate parameter, and callers do not need to maintain multiple clk_bulk_data instances. Since we do not have any in tree users of bulk clk APIs yet, we can make this semantic change quickly. Thoughts? diff --git a/include/linux/clk.h b/include/linux/clk.h index 31fee2e8d4a2..ddc4812758f6 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -80,8 +80,10 @@ struct clk_notifier_data { /** * struct clk_bulk_data - Data used for bulk clk operations. * - * @id: clock consumer ID - * @clk: struct clk * to store the associated clock + * @ids: array of clock consumer IDs which should be provided by caller. + * @clks: array of struct clk * to store the associated clocks, which will be + * allocated by clk_bulk_get() and freed by clk_bulk_put(). + * @num_clks: number of clocks that caller wants bulk API to manage. * @flags: bulk clk operation flags * * The CLK APIs provide a series of clk_bulk_() API calls as @@ -93,8 +95,9 @@ struct clk_notifier_data { * clk_bulk_get() API will call of_clk_get() to find clock by index. */ struct clk_bulk_data { - const char *id; - struct clk *clk; + const char **ids; + struct clk **clks; + unsigned int num_clks; unsigned long flags; };