From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030915AbdIZNhz (ORCPT ); Tue, 26 Sep 2017 09:37:55 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:55581 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967806AbdIZNhx (ORCPT ); Tue, 26 Sep 2017 09:37:53 -0400 Subject: Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features To: Maxime Ripard Cc: linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, linux@armlinux.org.uk, lee.jones@linaro.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, thomas.petazzoni@free-electrons.com References: <6b89df1bf07dac2ab295fca5fdf0e55179c47ed6.1506428208.git-series.quentin.schulz@free-electrons.com> <20170926130009.r5isgrjvkwmm44nn@flea> <5596280a-51bb-7491-31f4-5800219888ad@free-electrons.com> <20170926132709.od3myumh5xtungvs@flea> From: Quentin Schulz Message-ID: <0bc7efe6-8d0e-ddae-617b-36e4357f76ce@free-electrons.com> Date: Tue, 26 Sep 2017 15:37:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170926132709.od3myumh5xtungvs@flea> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="EOb1IFLpWDGHuD8HcIq4bWc07ciEaEgGC" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --EOb1IFLpWDGHuD8HcIq4bWc07ciEaEgGC Content-Type: multipart/mixed; boundary="P5BQno4whI5rSVkdPLIEHJAWaqwxeVg4D"; protected-headers="v1" From: Quentin Schulz To: Maxime Ripard Cc: linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, linux@armlinux.org.uk, lee.jones@linaro.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, thomas.petazzoni@free-electrons.com Message-ID: <0bc7efe6-8d0e-ddae-617b-36e4357f76ce@free-electrons.com> Subject: Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features References: <6b89df1bf07dac2ab295fca5fdf0e55179c47ed6.1506428208.git-series.quentin.schulz@free-electrons.com> <20170926130009.r5isgrjvkwmm44nn@flea> <5596280a-51bb-7491-31f4-5800219888ad@free-electrons.com> <20170926132709.od3myumh5xtungvs@flea> In-Reply-To: <20170926132709.od3myumh5xtungvs@flea> --P5BQno4whI5rSVkdPLIEHJAWaqwxeVg4D Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 26/09/2017 15:27, Maxime Ripard wrote: > On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote: >> Hi Maxime, >> >> On 26/09/2017 15:00, Maxime Ripard wrote: >>> On Tue, Sep 26, 2017 at 12:17:12PM +0000, Quentin Schulz wrote: >>>> +static const struct axp20x_desc_pin axp209_pins[] =3D { >>>> + AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"), >>>> + AXP20X_FUNCTION(0x0, "gpio_out"), >>>> + AXP20X_FUNCTION(0x2, "gpio_in"), >>>> + AXP20X_FUNCTION(0x3, "ldo"), >>>> + AXP20X_FUNCTION(0x4, "adc")), >>>> + AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1"), >>>> + AXP20X_FUNCTION(0x0, "gpio_out"), >>>> + AXP20X_FUNCTION(0x2, "gpio_in"), >>>> + AXP20X_FUNCTION(0x3, "ldo"), >>>> + AXP20X_FUNCTION(0x4, "adc")), >>>> + AXP20X_PIN(AXP20X_PINCTRL_PIN(2, "GPIO2"), >>>> + AXP20X_FUNCTION(0x0, "gpio_out"), >>>> + AXP20X_FUNCTION(0x2, "gpio_in")), >>>> +}; >>> >>> If all the functions are the same, and at the same offset, can't we >>> just hardcode it, instead of having (and duplicate) all the logic >>> below? >>> >> >> AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"), >> AXP20X_GPIO_OUT, >> AXP20X_GPIO_IN, >> AXP20X_LDO, >> AXP20X_ADC)) >> >> That's what you mean? >=20 > What I mean is: >=20 > static int axp20x_get_func(char *func) > { > if (!strcmp(func, "gpio_out")) > return 0; >=20 > if (!strcmp(func, "gpio_in")) > return 2; > =20 > if (!strcmp(func, "ldo")) > return 3; > =20 > if (!strcmp(func, "adc")) > return 4; >=20 > return -EINVAL; > } >=20 GPIO2 on AXP209 does not support ldo nor adc. GPIO1 on AXP813 does not support adc. I find it more complex to handle those two cases in a function than by hardcoding it in structures like above. Moreover, nothing tells us that it would be the same offset for other PMI= Cs. Quentin --=20 Quentin Schulz, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --P5BQno4whI5rSVkdPLIEHJAWaqwxeVg4D-- --EOb1IFLpWDGHuD8HcIq4bWc07ciEaEgGC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJZylghAAoJEIS4mnU+4PGj8AAP/3bk0EhrI3tbZhaFFlhy7GQX V1wpbPbTR1Kv12AeGmver5B0dU9kjX0nGeKKbiCV66NpziLpJoprUN3dYLXgI0CT kqpog/mpVNip7oERljqGmj8zwNrxAzlQz9jiAIKryW09ZsxE+5e8fAGGO/jAqSgT Vt29uUPPvTlahJPhf5fpzxwPOrKsYi/v2+uEblnKP44Kc31nZCS6DIz6Qvjhqkt6 hF8sVahp4AONrMjZTJG3iAq+L/QPYGZNbVMByt6WkPn71eVed917PGODPFJjgEHJ H9+WO2c9niUm622DZ6e0n89usnfA3GtGPxx8eqSQUPxnVud9X0y1KUjC8PqpUJ78 NEHKI+njUhy+p9yRfPA0fnaI7sr8lxesRphBoen+uFhrqhUVOkKuByyxDF0I0PM8 0f0+JvpPsDu1UB7mVk8GZzQQjjDD2za3Fg82doRZxzqn0tvWmagCDtXWxTaezWVU nIyDl95Spb6OmC2FmHlA4eysU9r2RWOBEeL7eFeuOvP1hbWA94DLaraUoHCtrta8 YLHgCJ1WELiQ3RrlrBGjYgtq3yh0hvFbXu0B1fsIZSH3mTXhDI9sd02JzwlzCz23 4kqZgoZCmhQvGZaQu9ulEX+cETfS2k19aWjvPz44Dj2LudTfDme0zHWzbHmB9YlM GkZCW7K66IrfPn4EVWe6 =GuuE -----END PGP SIGNATURE----- --EOb1IFLpWDGHuD8HcIq4bWc07ciEaEgGC--