From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030786AbdIZN1X (ORCPT ); Tue, 26 Sep 2017 09:27:23 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:55306 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030289AbdIZN1V (ORCPT ); Tue, 26 Sep 2017 09:27:21 -0400 Date: Tue, 26 Sep 2017 15:27:09 +0200 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, linux-sunxi@googlegroups.com, thomas.petazzoni@free-electrons.com Subject: Re: [PATCH v2 02/10] pinctrl: axp209: add pinctrl features Message-ID: <20170926132709.od3myumh5xtungvs@flea> References: <6b89df1bf07dac2ab295fca5fdf0e55179c47ed6.1506428208.git-series.quentin.schulz@free-electrons.com> <20170926130009.r5isgrjvkwmm44nn@flea> <5596280a-51bb-7491-31f4-5800219888ad@free-electrons.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oyfuwka7pc3evugi" Content-Disposition: inline In-Reply-To: <5596280a-51bb-7491-31f4-5800219888ad@free-electrons.com> User-Agent: NeoMutt/20170914 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --oyfuwka7pc3evugi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 26, 2017 at 01:08:21PM +0000, Quentin Schulz wrote: > Hi Maxime, >=20 > 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")), > >> +}; > >=20 > > 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? > >=20 >=20 > AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0"), > AXP20X_GPIO_OUT, > AXP20X_GPIO_IN, > AXP20X_LDO, > AXP20X_ADC)) >=20 > 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; =20 if (!strcmp(func, "ldo")) return 3; =20 if (!strcmp(func, "adc")) return 4; return -EINVAL; } > >> + pctrl_desc =3D devm_kzalloc(&pdev->dev, sizeof(*pctrl_desc), GFP_KER= NEL); > >> + if (!pctrl_desc) > >> + return -ENOMEM; > >> + > >> + pctrl_desc->name =3D dev_name(&pdev->dev); > >> + pctrl_desc->owner =3D THIS_MODULE; > >> + pctrl_desc->pins =3D pins; > >> + pctrl_desc->npins =3D gpio->desc->npins; > >> + pctrl_desc->pctlops =3D &axp20x_pctrl_ops; > >> + pctrl_desc->pmxops =3D &axp20x_pmx_ops; > >=20 > > The strict flag needs to be set too in order to avoid concurrent uses > > of GPIO and other functions. > >=20 >=20 > Strict is a property of pinmux_ops struct (pmxops) and it is set. Ah, right, my bad. Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --oyfuwka7pc3evugi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJZylWtAAoJEBx+YmzsjxAgEuAP/1omAYbgUcAQ58XYl5mlnYoN C00FxuGxBoabjyoIla2906+b7DX0mfw+t0/VIvR3XzURsmtMh6T8epId8nsZu4It RDNJSBe4gM5aJX+q6K3eCDiUuPrlCp9nnbtREu83xDcETQNr7prZGkfgbaht1HRv ML7bLXql+WrGZg5LMIH3snPOIpF5p+K2QPzwML7Z+Z/p873V3m55qx+INqbS74iL 4jjZFYhDgHcKL57yX38b7A6Lnuhgv64G6umR70BU/POJdBt3Rm/0mJ0FWUbFOJBk cBAvPmqEpBq2Ik+BAEe3OHmpnmPXHCdDVZHGfuAUISsBpoaOc/zNFLKC6avemNmb MwDWS5Ge6TijDuPAFwjATVT4HlqyQqRxsrhS2LICutjpdPxdmxBhIQ8cOigxQI4t x6qT3BPuHNZvVVTQiFx+LtuDMiA3RgaEzda94Ag4wEDV3qGf4ISUzWzbNZpRo1VM NWi7cqnDtE8ymHsfYmJkbU7/UDycE+uKclHATe8EaDR4CtKpkU4EANkswqv83lGX w50GXBQIUGfS2D0UOAzIlAzyGKjj0eAv5TTi7nbVhCqrUcQpiv9llJ9MlcKEfQlT tDrFGBzLCWOQeMUz6/40ioBu1+WCTj6kIJOytM0CRzgyqcJ+/S+ic+YvRUvvXtB5 8XWbRGi03Bxaqp/yotBd =jRj3 -----END PGP SIGNATURE----- --oyfuwka7pc3evugi--