public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org,
	"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
	"José Guilherme de Castro Rodrigues"
	<joseguilhermebh@hotmail.com>
Subject: Re: [PATCH] gpio: improve the API contract for setting direction
Date: Wed, 24 Jan 2024 18:51:15 +0800	[thread overview]
Message-ID: <20240124105115.GB63670@rigel> (raw)
In-Reply-To: <20240124101803.23580-1-brgl@bgdev.pl>

On Wed, Jan 24, 2024 at 11:18:03AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> If a GPIO driver returns a positive integer from one of the direction
> setter callbacks, we'll end up propagating it to user-space. Whether we
> should sanitize the values returned by callbacks is a different question
> but let's first improve the documentation and fortify the contract with
> GPIO providers.
>
> Reported-by: José Guilherme de Castro Rodrigues <joseguilhermebh@hotmail.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  include/linux/gpio/driver.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
> index 9a5c6c76e653..c1c516b8a880 100644
> --- a/include/linux/gpio/driver.h
> +++ b/include/linux/gpio/driver.h
> @@ -335,10 +335,12 @@ struct gpio_irq_chip {
>   *	(same as GPIO_LINE_DIRECTION_OUT / GPIO_LINE_DIRECTION_IN),
>   *	or negative error. It is recommended to always implement this
>   *	function, even on input-only or output-only gpio chips.
> - * @direction_input: configures signal "offset" as input, or returns error
> - *	This can be omitted on input-only or output-only gpio chips.
> - * @direction_output: configures signal "offset" as output, or returns error
> - *	This can be omitted on input-only or output-only gpio chips.
> + * @direction_input: configures signal "offset" as input, or returns a negative
> + *	error number. This can be omitted on input-only or output-only gpio
> + *	chips.
> + * @direction_output: configures signal "offset" as output, or returns
> + *	a negative error number. This can be omitted on input-only or
> + *	output-only gpio chips.
>   * @get: returns value for signal "offset", 0=low, 1=high, or negative error
>   * @get_multiple: reads values for multiple signals defined by "mask" and
>   *	stores them in "bits", returns 0 on success or negative error

Also specify 0 on success, as per @get_multiple?

It would be good to revise the documentation for all the ops, but this
is a start.

Cheers,
Kent.

      reply	other threads:[~2024-01-24 10:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 10:18 [PATCH] gpio: improve the API contract for setting direction Bartosz Golaszewski
2024-01-24 10:51 ` Kent Gibson [this message]

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=20240124105115.GB63670@rigel \
    --to=warthog618@gmail.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=joseguilhermebh@hotmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.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