From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 1/2] gpio: provide gpiod_is_equal()
Date: Wed, 9 Apr 2025 17:32:37 +0300 [thread overview]
Message-ID: <Z_aFBfjb17JxOwyk@black.fi.intel.com> (raw)
In-Reply-To: <20250407-gpiod-is-equal-v1-1-7d85f568ae6e@linaro.org>
On Mon, Apr 07, 2025 at 09:08:14AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> There are users in the kernel that directly compare raw GPIO descriptor
> pointers in order to determine whether they refer to the same physical
> GPIO pin. This accidentally works like this but is not guaranteed by any
> API contract. Let's provide a comparator function that hides the actual
> logic.
...
> +bool gpiod_is_equal(struct gpio_desc *desc, struct gpio_desc *other)
> +{
> + return desc == other;
I think it's better to have the one checked against NULL. That's how
comparators make more sense, see, for example, 1b1bb7b29b10 ("drivers:
base: Don't match devices with NULL of_node/fwnode/etc").
Ideally it should be IS_ERR_OR_NULL(), but we have here a principal disagreement,
so this might be yet another (buggy) function in GPIOLIB.
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-04-09 14:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 7:08 [PATCH 0/2] gpio: don't compare raw GPIO descriptor pointers directly Bartosz Golaszewski
2025-04-07 7:08 ` [PATCH 1/2] gpio: provide gpiod_is_equal() Bartosz Golaszewski
2025-04-07 17:11 ` Mark Brown
2025-04-09 14:32 ` Andy Shevchenko [this message]
2025-04-09 17:03 ` Bartosz Golaszewski
2025-04-07 7:08 ` [PATCH 2/2] regulator: don't compare raw GPIO descriptor pointers Bartosz Golaszewski
2025-04-07 14:04 ` [PATCH 0/2] gpio: don't compare raw GPIO descriptor pointers directly Mark Brown
2025-04-09 8:01 ` (subset) " Bartosz Golaszewski
2025-04-09 20:18 ` Mark Brown
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=Z_aFBfjb17JxOwyk@black.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®