public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 2/3] gpiolib: use a more explicit retval logic in gpiochip_get_direction()
Date: Tue, 25 Feb 2025 15:19:22 +0200	[thread overview]
Message-ID: <Z73DWoscARsC06gS@smile.fi.intel.com> (raw)
In-Reply-To: <20250225-retval-fixes-v1-2-078c4c98517a@linaro.org>

On Tue, Feb 25, 2025 at 12:56:24PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> We have existing macros for direction settings so we don't need to rely
> on the magic value of 1 in the retval check. Use readable logic that
> explicitly says we expect INPUT, OUTPUT or a negative errno and nothing
> else in gpiochip_get_direction().

...

>  	ret = gc->get_direction(gc, offset);
> -	if (ret > 1)
> +	if (!(ret == GPIO_LINE_DIRECTION_OUT ||
> +	      ret == GPIO_LINE_DIRECTION_IN || ret < 0))
>  		ret = -EBADE;

Wouldn't be better to write it as

	if (ret < 0)
		return ret;

	if (ret != GPIO_LINE_DIRECTION_OUT && ret != GPIO_LINE_DIRECTION_IN)
		ret = -EBADE;

	return ret;


Otherwise LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
after addressing the above.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-02-25 13:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 11:56 [PATCH 0/3] gpiolib: fix bugs in retval sanitization Bartosz Golaszewski
2025-02-25 11:56 ` [PATCH 1/3] gpiolib: don't use gpiochip_get_direction() when registering a chip Bartosz Golaszewski
2025-02-25 13:22   ` Marek Szyprowski
2025-02-25 13:22   ` Andy Shevchenko
2025-02-25 14:43     ` Bartosz Golaszewski
2025-02-25 14:46       ` Andy Shevchenko
2025-02-25 11:56 ` [PATCH 2/3] gpiolib: use a more explicit retval logic in gpiochip_get_direction() Bartosz Golaszewski
2025-02-25 13:19   ` Andy Shevchenko [this message]
2025-02-25 11:56 ` [PATCH 3/3] gpiolib: don't double-check the gc->get callback's existence Bartosz Golaszewski
2025-02-25 13:20   ` Andy Shevchenko

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=Z73DWoscARsC06gS@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox