linux-next: manual merge of the gpio-brgl tree with the gpio-brgl-fixes tree

From: Stephen Rothwell
Date: Mon Mar 03 2025 - 00:57:44 EST


Hi all,

Today's linux-next merge of the gpio-brgl tree got a conflict in:

drivers/gpio/gpiolib.c

between commit:

64407f4b5807 ("gpiolib: Fix Oops in gpiod_direction_input_nonotify()")

from the gpio-brgl-fixes tree and commit:

e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")

from the gpio-brgl tree.

I fixed it up (I think - see below) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging. You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

--
Cheers,
Stephen Rothwell

diff --cc drivers/gpio/gpiolib.c
index 8741600af7ef,d0108cf2ee0b..000000000000
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@@ -2737,15 -2804,14 +2804,14 @@@ int gpiod_direction_input_nonotify(stru
* assume we are in input mode after this.
*/
if (guard.gc->direction_input) {
- ret = guard.gc->direction_input(guard.gc,
- gpio_chip_hwgpio(desc));
+ ret = gpiochip_direction_input(guard.gc,
+ gpio_chip_hwgpio(desc));
} else if (guard.gc->get_direction) {
- dir = guard.gc->get_direction(guard.gc,
- gpio_chip_hwgpio(desc));
- ret = gpiochip_get_direction(guard.gc, gpio_chip_hwgpio(desc));
- if (ret < 0)
- return ret;
++ dir = gpiochip_get_direction(guard.gc, gpio_chip_hwgpio(desc));
+ if (dir < 0)
+ return dir;

- if (ret != GPIO_LINE_DIRECTION_IN) {
+ if (dir != GPIO_LINE_DIRECTION_IN) {
gpiod_warn(desc,
"%s: missing direction_input() operation and line is output\n",
__func__);
@@@ -2762,9 -2828,30 +2828,30 @@@
return ret;
}

+ static int gpiochip_set(struct gpio_chip *gc, unsigned int offset, int value)
+ {
+ int ret;
+
+ lockdep_assert_held(&gc->gpiodev->srcu);
+
+ if (WARN_ON(unlikely(!gc->set && !gc->set_rv)))
+ return -EOPNOTSUPP;
+
+ if (gc->set_rv) {
+ ret = gc->set_rv(gc, offset, value);
+ if (ret > 0)
+ ret = -EBADE;
+
+ return ret;
+ }
+
+ gc->set(gc, offset, value);
+ return 0;
+ }
+
static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
{
- int val = !!value, ret = 0;
+ int val = !!value, ret = 0, dir;

CLASS(gpio_chip_guard, guard)(desc);
if (!guard.gc)
@@@ -2788,12 -2875,12 +2875,12 @@@
} else {
/* Check that we are in output mode if we can */
if (guard.gc->get_direction) {
- dir = guard.gc->get_direction(guard.gc,
- gpio_chip_hwgpio(desc));
- ret = gpiochip_get_direction(guard.gc,
++ dir = gpiochip_get_direction(guard.gc,
+ gpio_chip_hwgpio(desc));
- if (ret < 0)
- return ret;
+ if (dir < 0)
+ return dir;

- if (ret != GPIO_LINE_DIRECTION_OUT) {
+ if (dir != GPIO_LINE_DIRECTION_OUT) {
gpiod_warn(desc,
"%s: missing direction_output() operation\n",
__func__);

Attachment: pgpTkIMBZqR71.pgp
Description: OpenPGP digital signature