From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756335AbcBHRUg (ORCPT ); Mon, 8 Feb 2016 12:20:36 -0500 Received: from down.free-electrons.com ([37.187.137.238]:44506 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756057AbcBHRUe (ORCPT ); Mon, 8 Feb 2016 12:20:34 -0500 Date: Mon, 8 Feb 2016 18:20:31 +0100 From: Maxime Ripard To: Krzysztof Adamski Cc: Linus Walleij , Chen-Yu Tsai , Hans de Goede , Thomas Gleixner , Lee Jones , Jonas Gorski , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH] pinctrl: sunxi: set pin function as input on export Message-ID: <20160208172031.GJ31506@lukather> References: <1454942242-25690-1-git-send-email-krzysztof.adamski@tieto.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Do4IU1xF/9sod/r6" Content-Disposition: inline In-Reply-To: <1454942242-25690-1-git-send-email-krzysztof.adamski@tieto.com> 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 --Do4IU1xF/9sod/r6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Mon, Feb 08, 2016 at 03:37:22PM +0100, Krzysztof Adamski wrote: > Default function of a pin in sunxi SoCs is "disabled". By default gpios > exported by sysfs are set as input and indeed, when reading "direction" > file you will get "in". The "value" pin won't return proper value, > though, confusing user of this interface. >=20 > This patch sets direction of a GPIO as input when exporting it. >=20 > Signed-off-by: Krzysztof Adamski > --- > drivers/pinctrl/sunxi/pinctrl-sunxi.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunx= i/pinctrl-sunxi.c > index 7a2465f..905a9fb 100644 > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > @@ -452,6 +452,16 @@ static int sunxi_pinctrl_gpio_direction_input(struct= gpio_chip *chip, > return pinctrl_gpio_direction_input(chip->base + offset); > } > =20 > +int sunxi_pinctrl_gpio_request(struct gpio_chip *chip, unsigned offset) > +{ > + int ret =3D pinctrl_gpio_direction_input(chip->base + offset); > + > + if (ret) > + return ret; > + > + return pinctrl_request_gpio(chip->base + offset); > +} > + > static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offse= t) > { > struct sunxi_pinctrl *pctl =3D gpiochip_get_data(chip); > @@ -946,7 +956,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev, > =20 > last_pin =3D pctl->desc->pins[pctl->desc->npins - 1].pin.number; > pctl->chip->owner =3D THIS_MODULE; > - pctl->chip->request =3D gpiochip_generic_request, > + pctl->chip->request =3D sunxi_pinctrl_gpio_request, > pctl->chip->free =3D gpiochip_generic_free, > pctl->chip->direction_input =3D sunxi_pinctrl_gpio_direction_input, > pctl->chip->direction_output =3D sunxi_pinctrl_gpio_direction_output, > --=20 > 2.4.2 >=20 It seems to me that it's something that should be enforced in the core, there's nothing sunxi specific here. Thanks! Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com --Do4IU1xF/9sod/r6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWuM5fAAoJEBx+YmzsjxAgZV8P/3TQyIJm2kZ3P/w51YBfO06R OGdiLaw6aLgLFRLp829zZZ2xsz+aoCF+P0Dzew/bsNj9Ph+XrvfBjmHjgS7wcGxM Qqgp33EoDjDuIxRFmhabT9c1BzEaCrm0XrIw0W/YlC56O27zuNJGALE+BisPSdc3 4zvUtHC/I8HoTwEUsjSLxp4PQppjuvTqfP+z184WP8JmI01XHFB2Ug6GFHyEr3Y1 n6qeaPdHX23DCKPQUbbFqBnplLpsvYisKHI3MHCIrv1TSIcUwTFVUhvUt5M0WHc/ J2Jd4Z5fTXLkGoGXBxelOXaKgipBYRvhdDLrACInnEQkIhIyTzsmVQaCclW/TWZV m3eOwUKgX0wD0VkCP4uGTswXU9DI3FzGTUP1zJTUneHitnDSTBvO8SxRov8c5H+P lHqB4eHL4N+ucqBgKEPcuM5nEwiVeoHzmwtgRAIktOVy+oRRPQJFVc/3GcLtE8Nl FvTKS0p5MMuJMmNK0qeoI/5X5/6Ptmycq1Plx5TUPHP2iRG+ko52xSaEFNuoC5Bi 7SNISGWwMabQwGg1Q7WxdLel4tPD2SXz7EPskPCywJ/TzpIbFgEce3cgQFboo7pt wIEKfEqmx5pbhBRT0igwW1lY4pwHhy5u4Ed5EFdvrsz9zv2QU6VDucHKa2+jrzX3 gtlMxDoXQu+B8lDcpOro =lLNw -----END PGP SIGNATURE----- --Do4IU1xF/9sod/r6--