From patchwork Sun Jan 10 12:30:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Remi Pommarel X-Patchwork-Id: 565358 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id ACFF61402B4 for ; Sun, 10 Jan 2016 23:31:58 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIF8G-0005Fb-21; Sun, 10 Jan 2016 12:30:04 +0000 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIF8B-0005AF-Mp; Sun, 10 Jan 2016 12:30:00 +0000 Received: from mfilter17-d.gandi.net (mfilter17-d.gandi.net [217.70.178.145]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 16C17A80CF; Sun, 10 Jan 2016 13:29:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter17-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter17-d.gandi.net (mfilter17-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id iAENJfgAjpUN; Sun, 10 Jan 2016 13:29:33 +0100 (CET) X-Originating-IP: 81.57.43.44 Received: from localhost (mon75-1-81-57-43-44.fbx.proxad.net [81.57.43.44]) (Authenticated sender: repk@triplefau.lt) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id CD124A80C8; Sun, 10 Jan 2016 13:29:29 +0100 (CET) Date: Sun, 10 Jan 2016 13:30:14 +0100 From: Remi Pommarel To: Martin Sperl Subject: Re: [PATCH 2/5] clk: bcm2835: enable management of PCM clock Message-ID: <20160110123014.GA1764@cruxbox> References: <1452331558-2520-1-git-send-email-kernel@martin.sperl.org> <1452331558-2520-3-git-send-email-kernel@martin.sperl.org> <4332640.jBKM55TPAo@wuerfel> <4B891DE1-6340-4D3D-BEE3-F61D9A5D289B@martin.sperl.org> <20160110115858.GV6588@sirena.org.uk> <39E8C95F-C7DC-46C3-B29A-93A865485942@martin.sperl.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <39E8C95F-C7DC-46C3-B29A-93A865485942@martin.sperl.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-20160110_042959_917593_EFCF489B X-CRM114-Status: GOOD ( 17.34 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [217.70.183.195 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.195 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , ALSA Development Mailing List , Russell King , Arnd Bergmann , Stephen Warren , Michael Turquette , Lee Jones , Takashi Iwai , Jaroslav Kysela , Eric Anholt , Mark Brown , Geert Uytterhoeven , linux-rpi-kernel@lists.infradead.org, lFlorian Meier , Matthias Reichl , linux-clk , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org On Sun, Jan 10, 2016 at 01:17:17PM +0100, Martin Sperl wrote: > > > > Presumably just making the code not rely on having a define for the > > number of clocks would deal with the problem (eg, using ARRAY_SIZE > > internally). > ARRAY_SIZE would work fine, but the code is: > > #include > ... > struct bcm2835_cprman { > struct device *dev; > void __iomem *regs; > spinlock_t regs_lock; > const char *osc_name; > > struct clk_onecell_data onecell; > struct clk *clks[BCM2835_CLOCK_COUNT]; > }; > ... > static int bcm2835_clk_probe(struct platform_device *pdev) > { > ... > clks[BCM2835_PLLA_CORE] = > bcm2835_register_pll_divider(cprman, &bcm2835_plla_core_data); > ... > clks[BCM2835_CLOCK_PCM] = > bcm2835_register_clock(cprman, &bcm2835_clock_pcm_data); > ... > } > > So the Array size is defined by the dt-bindings. > > What you propose is a major change to the clock framework, so I would > hope that Eric (the original author of this clock-driver) would address > it. > > Maybe someone has a better idea for a pattern to use to achieve > the required while maintaining “synchronization” between defines > inside the dt-binding and the driver. > Why not just get rid of BCM2835_CLOCK_COUNT and use an internal clock count ? Something like the patch attached at the end of the mail. This has the downside to be more careful when adding a new clock. If it is not ok, I could try to modify the clk driver to use Mark's solution if you want. Regards, diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 015e687..f558c5b 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -281,6 +281,8 @@ #define LOCK_TIMEOUT_NS 100000000 #define BCM2835_MAX_FB_RATE 1750000000u +#define BCM2835_CLOCK_MAX BCM2835_CLOCK_PCM + struct bcm2835_cprman { struct device *dev; void __iomem *regs; @@ -288,7 +290,7 @@ struct bcm2835_cprman { const char *osc_name; struct clk_onecell_data onecell; - struct clk *clks[BCM2835_CLOCK_COUNT]; + struct clk *clks[BCM2835_CLOCK_MAX + 1]; }; static inline void cprman_write(struct bcm2835_cprman *cprman, u32 reg, u32 val)