From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Simek Subject: Re: [PATCH 1/2] GPIO: Add driver for Zynq GPIO controller Date: Wed, 02 Apr 2014 07:56:11 +0200 Message-ID: <533BA67B.6070905@monstr.eu> References: <1395933906-2268-1-git-send-email-harinik@xilinx.com> Reply-To: monstr@monstr.eu Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="r2KnN0hcoO0hcQAeq1QDjdmSoPJFmgSJH" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Linus Walleij Cc: Harini Katakam , Alexandre Courbot , Michal Simek , Grant Likely , Rob Herring , Pawel Moll , Mark Rutland , "ijc+devicetree@hellion.org.uk" , Kumar Gala , Rob Landley , "linux-gpio@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-doc@vger.kernel.org" , michals@xilinx.com, Ulf Hansson List-Id: linux-gpio@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --r2KnN0hcoO0hcQAeq1QDjdmSoPJFmgSJH Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Linus, On 03/31/2014 10:22 AM, Linus Walleij wrote: > On Sat, Mar 29, 2014 at 5:44 AM, Harini Katakam > wrote: >> On Sat, Mar 29, 2014 at 3:20 AM, Linus Walleij wrote: >>> On Thu, Mar 27, 2014 at 4:25 PM, Harini Katakam = wrote: >=20 >>>> +/* Read/Write access to the GPIO PS registers */ >>>> +static inline u32 zynq_gpio_readreg(void __iomem *offset) >>>> +{ >>>> + return readl_relaxed(offset); >>>> +} >>>> + >>>> +static inline void zynq_gpio_writereg(void __iomem *offset, u32 val= ) >>>> +{ >>>> + writel_relaxed(val, offset); >>>> +} >>> >>> I think this is unnecessary and confusing indirection. >>> Just use the readl_relaxed/writel_relaxed functions directly in >>> the code. >>> >> >> This is just to be flexible. >=20 > Define exactly what you mean with "flexible" in this context. I > only see unnecessary overhead and hard-to-read code. We have just passed this discussion for watchdog driver here: https://lkml.org/lkml/2014/4/1/843 Are you ok with doing it in this way? static inline u32 zynq_gpio_readreg(struct zynq_gpio *gpio, u32 offset) { return readl_relaxed(gpio->base_addr + offset); } static inline void zynq_gpio_writereg(struct zynq_gpio *gpio, u32 offset,= u32 val) { writel_relaxed(val, gpio->base_addr + offset); } Or even like this to be able to handle error cases. static inline int zynq_gpio_readreg(struct zynq_gpio *gpio, u32 offset, u= 32 *val) { *val =3D readl_relaxed(gpio->base_addr + offset); return 0; } static inline int zynq_gpio_writereg(struct zynq_gpio *gpio, u32 offset, = u32 val) { writel_relaxed(val, gpio->base_addr + offset); return 0; } Thanks, Michal --=20 Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform --r2KnN0hcoO0hcQAeq1QDjdmSoPJFmgSJH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlM7pnsACgkQykllyylKDCEp3gCfQ7mVJJXVhKELQsvo1vn7O1Hc u0MAoIXoytmGzpDKyLSLfMrxWooULvxR =ixQs -----END PGP SIGNATURE----- --r2KnN0hcoO0hcQAeq1QDjdmSoPJFmgSJH--