linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Timur Tabi <timur@kernel.org>
To: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	swboyd@chromium.org, linux-gpio@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] gpiolib: Show correct direction from the beginning
Date: Fri, 21 Sep 2018 07:25:14 -0500	[thread overview]
Message-ID: <7bda989e-3a7d-8a95-78b0-60b79e414245@kernel.org> (raw)
In-Reply-To: <20180921103604.13361-2-ricardo.ribalda@gmail.com>

Jeff, can you test these two patches on Amberwing to make sure that they 
don't cause an XPU violation on boot?

The call to gpiochip_line_is_valid() should return false on any GPIOs 
that aren't listed in the ACPI table.

My concern is that this patch might be calling gpiochip_line_is_valid() 
too early, before all the arrays have been set up.

Thanks.

On 9/21/18 5:36 AM, Ricardo Ribalda Delgado wrote:
> Current code assumes that the direction is input if direction_input
> function is set.
> This might not be the case on GPIOs with programmable direction.
> 
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>   drivers/gpio/gpiolib.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 4b45de883ada..00c17f64d9ff 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1352,7 +1352,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
>   		 * it does, and in case chip->get_direction is not set, we may
>   		 * expose the wrong direction in sysfs.
>   		 */
> -		desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0;
> +		if (chip->get_direction && gpiochip_line_is_valid(chip, i))
> +			desc->flags = !chip->get_direction(chip, i) ?
> +					(1 << FLAG_IS_OUT) : 0;
> +		else
> +			desc->flags = !chip->direction_input ?
> +					(1 << FLAG_IS_OUT) : 0;
>   	}
>   
>   #ifdef CONFIG_PINCTRL
> 


  reply	other threads:[~2018-09-21 12:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-21 10:36 [PATCH] gpiolib: Fix gpio_direction_* for single direction GPIOs Ricardo Ribalda Delgado
2018-09-21 10:36 ` [PATCH v2] gpiolib: Show correct direction from the beginning Ricardo Ribalda Delgado
2018-09-21 12:25   ` Timur Tabi [this message]
2018-09-27  6:51   ` Stephen Boyd
2018-09-27 12:19     ` Timur Tabi
2018-09-27 14:04       ` Jeffrey Hugo
2018-09-27 14:19         ` Timur Tabi
2018-09-27 14:34           ` Jeffrey Hugo
2018-09-28 19:14         ` Jeffrey Hugo
2018-09-28 19:22           ` Timur Tabi
2018-09-29  6:23             ` Ricardo Ribalda Delgado
2018-09-29 13:21               ` Timur Tabi
2018-09-29 13:25                 ` Timur Tabi
     [not found]             ` <D3E6F4C4-E1C4-4D88-B118-878576BF5281@gmail.com>
2018-10-01 11:54               ` Linus Walleij
2018-10-01 13:36                 ` Ricardo Ribalda Delgado
2018-10-01 14:27                   ` Jeffrey Hugo
2018-10-01 21:20                   ` Linus Walleij
2018-10-02  7:15                     ` Ricardo Ribalda Delgado
2018-10-02  7:38                       ` Linus Walleij
2018-10-02 12:26                         ` Timur Tabi
2018-10-02 12:51                           ` Linus Walleij
2018-09-25  7:36 ` [PATCH] gpiolib: Fix gpio_direction_* for single direction GPIOs Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bda989e-3a7d-8a95-78b0-60b79e414245@kernel.org \
    --to=timur@kernel.org \
    --cc=jhugo@codeaurora.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ricardo.ribalda@gmail.com \
    --cc=swboyd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).