Skip to contentSkip to conversation

FAILED: patch "[PATCH] gpiolib: Preserve desc->flags when setting state" failed to apply to 4.19-stable tree

PATCH [email protected] 1 participant 1 message Aug 5, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From d95da993383c78f7efd25957ba3af23af4b1c613 Mon Sep 17 00:00:00 2001
From: Chris Packham <[email protected]>
Date: Mon, 8 Jul 2019 08:35:58 +1200
Subject: [PATCH] gpiolib: Preserve desc->flags when setting state

desc->flags may already have values set by of_gpiochip_add() so make sure that this isn't undone when setting the initial direction.

Fixes 3edfb7bd76bd1cba ("gpiolib: Show correct direction from the beginning")
drivers/gpio/gpiolib.c +11 -6
index bf05c29b53be..f497003f119c 100644
@@ -1394,12 +1394,17 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
 	for (i = 0; i < chip->ngpio; i++) {
 		struct gpio_desc *desc = &gdev->descs[i];
 
-		if (chip->get_direction && gpiochip_line_is_valid(chip, i))
-			desc->flags = !chip->get_direction(chip, i) ?
-					(1 << FLAG_IS_OUT) : 0;
-		else
-			desc->flags = !chip->direction_input ?
-					(1 << FLAG_IS_OUT) : 0;
+		if (chip->get_direction && gpiochip_line_is_valid(chip, i)) {
+			if (!chip->get_direction(chip, i))
+				set_bit(FLAG_IS_OUT, &desc->flags);
+			else
+				clear_bit(FLAG_IS_OUT, &desc->flags);
+		} else {
+			if (!chip->direction_input)
+				set_bit(FLAG_IS_OUT, &desc->flags);
+			else
+				clear_bit(FLAG_IS_OUT, &desc->flags);
+		}
 	}
 
 	acpi_gpiochip_add(chip);