From mboxrd@z Thu Jan 1 00:00:00 1970 From: Quentin Schulz Subject: Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features Date: Tue, 26 Sep 2017 15:37:37 +0200 Message-ID: <0bc7efe6-8d0e-ddae-617b-36e4357f76ce@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> Reply-To: quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="EOb1IFLpWDGHuD8HcIq4bWc07ciEaEgGC" Return-path: Sender: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org In-Reply-To: <20170926132709.od3myumh5xtungvs@flea> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Maxime Ripard Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, mark.rutland-5wv7dgnIgG8@public.gmane.org, wens-jdAy2FN1RRM@public.gmane.org, linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org, lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org List-Id: devicetree@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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, mark.rutland-5wv7dgnIgG8@public.gmane.org, wens-jdAy2FN1RRM@public.gmane.org, linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org, lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org Message-ID: <0bc7efe6-8d0e-ddae-617b-36e4357f76ce-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> Subject: Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features References: <6b89df1bf07dac2ab295fca5fdf0e55179c47ed6.1506428208.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> <20170926130009.r5isgrjvkwmm44nn@flea> <5596280a-51bb-7491-31f4-5800219888ad-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> <20170926132709.od3myumh5xtungvs@flea> In-Reply-To: <20170926132709.od3myumh5xtungvs@flea> --P5BQno4whI5rSVkdPLIEHJAWaqwxeVg4D Content-Type: text/plain; charset="UTF-8" Content-Language: en-US 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[] = { >>>> + 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? > > What I mean is: > > static int axp20x_get_func(char *func) > { > if (!strcmp(func, "gpio_out")) > return 0; > > if (!strcmp(func, "gpio_in")) > return 2; > > if (!strcmp(func, "ldo")) > return 3; > > if (!strcmp(func, "adc")) > return 4; > > return -EINVAL; > } > 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 PMICs. Quentin -- Quentin Schulz, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. --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--