From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753015AbdLEIxr (ORCPT ); Tue, 5 Dec 2017 03:53:47 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:45488 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752645AbdLEIxm (ORCPT ); Tue, 5 Dec 2017 03:53:42 -0500 Date: Tue, 5 Dec 2017 09:53:40 +0100 From: Maxime Ripard To: Quentin Schulz 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, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com Subject: Re: [PATCH v4 02/10] pinctrl: axp209: add pinctrl features Message-ID: <20171205085340.z2mb4uujencw7bct@flea.lan> References: <71c9da94df2a5938cb8c092e40f8e36eec0b01c3.1512135804.git-series.quentin.schulz@free-electrons.com> <20171201155702.irfox7vf3kfjvpjx@flea.lan> <2207ddcb-21fc-e3e1-1a1c-11e11690a02e@free-electrons.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="i4sblixkcnkossi4" Content-Disposition: inline In-Reply-To: <2207ddcb-21fc-e3e1-1a1c-11e11690a02e@free-electrons.com> User-Agent: NeoMutt/20171027 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --i4sblixkcnkossi4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Mon, Dec 04, 2017 at 09:07:52AM +0100, Quentin Schulz wrote: > >> +static int axp20x_pmx_set_mux(struct pinctrl_dev *pctldev, > >> + unsigned int function, unsigned int group) > >> +{ > >> + struct axp20x_gpio *gpio =3D pinctrl_dev_get_drvdata(pctldev); > >> + unsigned int mask; > >> + > >> + /* Every pin supports GPIO_OUT and GPIO_IN functions */ > >> + if (function <=3D AXP20X_FUNC_GPIO_IN) > >> + return axp20x_pmx_set(pctldev, group, > >> + gpio->funcs[function].muxval); > >> + > >> + if (function =3D=3D AXP20X_FUNC_LDO) > >> + mask =3D gpio->desc->ldo_mask; > >> + else > >> + mask =3D gpio->desc->adc_mask; > >=20 > > What is the point of this test... > >=20 > >> + if (!(BIT(group) & mask)) > >> + return -EINVAL; > >> + > >> + /* > >> + * We let the regulator framework handle the LDO muxing as muxing bi= ts > >> + * are basically also regulators on/off bits. It's better not to enf= orce > >> + * any state of the regulator when selecting LDO mux so that we don't > >> + * interfere with the regulator driver. > >> + */ > >> + if (function =3D=3D AXP20X_FUNC_LDO) > >> + return 0; > >=20 > > ... if you know that you're not going to do anything with one of the > > outcomes. It would be better to just move that part above, instead of > > doing the same test twice. > >=20 >=20 > Return value is different. In one case, it is an error to request "ldo" > for a pin that does not support it. In the other case, the ldo request > is valid but nothing's done on driver side. >=20 > Both cases are handled differently by the core: > http://elixir.free-electrons.com/linux/latest/source/drivers/pinctrl/pinm= ux.c#L439 >=20 > I think that's the behavior we're expecting from this driver. Ah, right. > Or maybe you're asking to do: >=20 > + if (function =3D=3D AXP20X_FUNC_LDO) { > + if (!(BIT(group) & gpio->desc->ldo_mask)) > + return -EINVAL; > + return 0; > + } else if (!(BIT(group) & gpio->desc->adc_mask)) { > + return -EINVAL; > + } >=20 > ? No, it's definitely better the way you did it. Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --i4sblixkcnkossi4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE0VqZU19dR2zEVaqr0rTAlCFNr3QFAlomXpAACgkQ0rTAlCFN r3R6Tg//RSRbAeAvgzNGpsXhvStwAKGntgwQmevTlFnRZGYZF2zQ70qiKC1PkM8L FVSearuv6+66dWmEuudwsEFtOuiTRr0iBYvQ19SlIvlzfT1Kty+sAJF11U8P3Au+ rnkpRaT3myXJ5ObBMzTmolHUR6Upx2fRhNRtkG2Mo51nvCKTsMiFkZZM+Cz1ZAoL RdsBZAu/3y9AEKO7VJ72OKgCDkd4IuC8hHsWqn0WBazr5iViHIJY7degsr2Mgfsb Ow6mk2+byiKlxwJcwln6JijTshvDg2oXriHVMoFqj/Nb6vYEBDa5GIDLL9HvvhOH zE/pGFC9+lW29NT3ZMu+Qh4+X0m4nD4tZn2cMwJB/myyfYs9+t+1xJBGfyTz/U6h o1MyN/EfiU1aPe8Hrj2/XCxWUfDfz/ZvuPrVI4qog0/V2aplXwP5mHLGgJEBzmc4 Vb2zUquUHKaGIUrOFPG5r+bevWCF75xrdBJ56xMukoHXPTSyOpvdboWx5TRjBpu1 ilKGcoWMM1+BcG1aPjxM4T/67E2W/oFfDHHh9Aymm5f0fL7a2KOl+MMKUvf/79F+ O95zDXCLYvdaRGRpu9Emg+YnoM5lqjSQaep01NR2u3c/jwtdj/jVbAS/hdp+TzdW jwcTaFh6rI3kUHyVt3HhHgtczECRl79y1QcTxLX8GzagES9fn+o= =V4FS -----END PGP SIGNATURE----- --i4sblixkcnkossi4--