From: Wolfram Sang <wsa@the-dreams.de>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH] gpiolib: use better errno if get_direction is not available
Date: Thu, 12 Jul 2018 17:51:52 +0200 [thread overview]
Message-ID: <20180712155152.lbpsbd6b5ai73bd6@ninjato> (raw)
In-Reply-To: <20180711163319.28004-1-wsa+renesas@sang-engineering.com>
[-- Attachment #1: Type: text/plain, Size: 2014 bytes --]
On Wed, Jul 11, 2018 at 06:33:19PM +0200, Wolfram Sang wrote:
> EINVAL is very generic, use ENOTSUPP in case the gpiochip does not
> provide this function. While removing the assignment from the 'status'
> variable, use better indentation in the declaration block.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
So, Geert implemented get_direction for gpio-rcar, but this doesn't help
my case sadly. Because I2C is open drain, get_direction returns 'input'
:( As mentioned in a previous discussion, returning '0' and '1' from
get_direction() is confusing. But as it looks now, it also is not
enough. Or we'd need another function from which I could determine the
OUT_OPEN_DRAIN state.
For the short term, I will remove the sanity check from the I2C core and
hope the user properly set up the GPIO. It would be nice to check for it
somewhen in the future, though.
That all being said, I think this patch is still useful as is.
Thanks,
Wolfram
> ---
>
> I got puzzled by the EINVAL until I found out that gpio-rcar simply does not
> implement it.
>
> @Geert: any reason gpio-rcar is missing it? I would need it for the
> i2c-gpio-fault-injector.
>
> drivers/gpio/gpiolib.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index e11a3bb03820..18719f64e80b 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -210,15 +210,15 @@ static int gpiochip_find_base(int ngpio)
> */
> int gpiod_get_direction(struct gpio_desc *desc)
> {
> - struct gpio_chip *chip;
> - unsigned offset;
> - int status = -EINVAL;
> + struct gpio_chip *chip;
> + unsigned offset;
> + int status;
>
> chip = gpiod_to_chip(desc);
> offset = gpio_chip_hwgpio(desc);
>
> if (!chip->get_direction)
> - return status;
> + return -ENOTSUPP;
>
> status = chip->get_direction(chip, offset);
> if (status > 0) {
> --
> 2.11.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-07-12 16:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 16:33 [PATCH] gpiolib: use better errno if get_direction is not available Wolfram Sang
2018-07-11 17:24 ` Geert Uytterhoeven
2018-07-11 17:29 ` Wolfram Sang
2018-07-12 15:51 ` Wolfram Sang [this message]
2018-07-12 16:31 ` Wolfram Sang
2018-07-25 20:20 ` Wolfram Sang
2018-07-29 21:33 ` Linus Walleij
2018-09-11 12:03 ` Geert Uytterhoeven
2018-09-14 8:46 ` Linus Walleij
2018-09-14 8:52 ` Wolfram Sang
2018-07-13 8:01 ` Simon Horman
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=20180712155152.lbpsbd6b5ai73bd6@ninjato \
--to=wsa@the-dreams.de \
--cc=geert@linux-m68k.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.