From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754523AbbKYOS1 (ORCPT ); Wed, 25 Nov 2015 09:18:27 -0500 Received: from down.free-electrons.com ([37.187.137.238]:47057 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752696AbbKYOSZ (ORCPT ); Wed, 25 Nov 2015 09:18:25 -0500 Date: Wed, 25 Nov 2015 15:18:22 +0100 From: Maxime Ripard To: Chen-Yu Tsai Cc: Michael Turquette , Stephen Boyd , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver Message-ID: <20151125141822.GM32142@lukather> References: <1448357536-26613-1-git-send-email-wens@csie.org> <1448357536-26613-2-git-send-email-wens@csie.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="anmYPbAsEPjx7802" Content-Disposition: inline In-Reply-To: <1448357536-26613-2-git-send-email-wens@csie.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --anmYPbAsEPjx7802 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 24, 2015 at 05:32:12PM +0800, Chen-Yu Tsai wrote: > The APBS clock on sun9i is the same as the APB0 clock on sun8i. With > sun9i we are supporting the PRCM clocks by using CLK_OF_DECLARE, > instead of through a PRCM mfd device and subdevices for each clock > and reset control. As such we need a CLK_OF_DECLARE version of > the sun8i-a23-apb0-clk driver. >=20 > Also, build it for all Allwinner/sunxi platforms, and not just for > configurations with MFD_SUN6I_PRCM enabled. >=20 > Signed-off-by: Chen-Yu Tsai > --- > drivers/clk/sunxi/Makefile | 4 ++-- > drivers/clk/sunxi/clk-sun8i-apb0.c | 43 ++++++++++++++++++++++++++++++++= ++++++ > 2 files changed, 45 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile > index cb4c299214ce..121333ce34ea 100644 > --- a/drivers/clk/sunxi/Makefile > +++ b/drivers/clk/sunxi/Makefile > @@ -10,11 +10,11 @@ obj-y +=3D clk-a10-pll2.o > obj-y +=3D clk-a20-gmac.o > obj-y +=3D clk-mod0.o > obj-y +=3D clk-simple-gates.o > +obj-y +=3D clk-sun8i-apb0.o > obj-y +=3D clk-sun8i-mbus.o > obj-y +=3D clk-sun9i-core.o > obj-y +=3D clk-sun9i-mmc.o > obj-y +=3D clk-usb.o > =20 > obj-$(CONFIG_MFD_SUN6I_PRCM) +=3D \ > - clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \ > - clk-sun8i-apb0.o > + clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o I'd really prefer not to build a driver that is used only on a few SoCs if the support for these SoCs are not even enabled. > diff --git a/drivers/clk/sunxi/clk-sun8i-apb0.c b/drivers/clk/sunxi/clk-s= un8i-apb0.c > index 7ae5d2c2cde1..11b2f2fde245 100644 > --- a/drivers/clk/sunxi/clk-sun8i-apb0.c > +++ b/drivers/clk/sunxi/clk-sun8i-apb0.c > @@ -17,8 +17,51 @@ > #include > #include > #include > +#include > #include > =20 > +static void sun8i_a23_apb0_setup(struct device_node *node) > +{ > + const char *clk_name =3D node->name; > + const char *clk_parent; > + void __iomem *reg; > + struct resource res; > + struct clk *clk; > + int ret; > + > + reg =3D of_io_request_and_map(node, 0, of_node_full_name(node)); > + if (IS_ERR(reg)) > + return; > + > + clk_parent =3D of_clk_get_parent_name(node, 0); > + if (!clk_parent) > + goto err_unmap; > + > + of_property_read_string(node, "clock-output-names", &clk_name); > + > + /* The A23 APB0 clock is a standard 2 bit wide divider clock */ > + clk =3D clk_register_divider(NULL, clk_name, clk_parent, 0, reg, > + 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL); > + if (IS_ERR(clk)) > + goto err_unmap; > + > + ret =3D of_clk_add_provider(node, of_clk_src_simple_get, clk); > + if (ret) > + goto err_unregister; > + > + return; > + > +err_unregister: > + clk_unregister_divider(clk); > + > +err_unmap: > + iounmap(reg); > + of_address_to_resource(node, 0, &res); > + release_mem_region(res.start, resource_size(&res)); > +} > +CLK_OF_DECLARE(sun8i_a23_apb0, "allwinner,sun8i-a23-apb0-clk", > + sun8i_a23_apb0_setup); So, beside the memory request / mapping, everything else is duplicated? Can't you just create a common function and call it from both? Thanks, Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com --anmYPbAsEPjx7802 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWVcMuAAoJEBx+YmzsjxAgKaYP/iihm9DHT50xf2FmvS7iKDtw YFxU9k+4c6egiNrrhyyyzG6gX2zmPtA+Dayd+VBovKjL65HgmwJH1pVRdaskh5VN A/EF19js+Bt7g6gETiEwgUr6mkZY8M63EBZEGieVXexwZvv/B+l+KKtLBm18Xdt/ 67NVObxo9oxA4sJfZPwc5zGi3ETbx6sJKyPFBpfL5G3ri/sOvye21Fx7+4y9TRQL Uww98Vfjtv2r2SBUafDLkJv40iKfdj2OMAGDBwiuoEeyjp2L2vNr2qdfPBsXxDZt tXk0kH7hZ4AlrNxLvJu8zNUpzDA5jaKYAgt/6enEERofScKSX8Mdv10o5i2jo9bG oiZ2IeBr/c8hKTYWloCdzNGepVGL+vKfLLZi/MSlY7JU4kbfQLQnlTK2HcMM6Dkx DSukeegHYKDv/yjoQJClrTMGpMeBi5V/mskWR5Y66Kfm7p52iTfQcoeM/RufpnDg nY2t97+71KA3lFgLM21JkfQ3zRqPv5CwfT6Gb4vSW6Uous/I4hPmcCmkVOqtY2FB 3eSovqx9d2k1QCM/r/ra8jWU5vvJsCpW4fMV21QXkoJ3kXq1XH2UtuAzgh2iS7iF TDLX8YsCP8vxbMmj1P7XDaObw6lXNziLJSwVvky+IA+PtjDn7LHr6H51w+8tACfo wya3izr48J4A/TqcJYll =fBzF -----END PGP SIGNATURE----- --anmYPbAsEPjx7802--