Skip to content

Commit 3af9a52

Browse files
committed
Merge tag 'gpio-v5.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "As you can see [in the git history] I was away on leave and Bartosz kindly stepped in and collected a slew of fixes, I pulled them into my tree in two sets and merged some two more fixes (fixing my own caused bugs) on top. Summary: - Revert the extended use of gpio_set_config() and think about how we can do this properly. - Fix up the SPI CS GPIO handling so it now works properly on the SPI bus children, as intended. - Error paths and driver fixes" * tag 'gpio-v5.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: mockup: use simple_read_from_buffer() in debugfs read callback gpio: of: Fix of_gpiochip_add() error path gpio: of: Check for "spi-cs-high" in child instead of parent node gpio: of: Check propname before applying "cs-gpios" quirks gpio: mockup: fix debugfs read Revert "gpio: use new gpio_set_config() helper in more places" gpio: aspeed: fix a potential NULL pointer dereference gpio: amd-fch: Fix bogus SPDX identifier gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input gpio: exar: add a check for the return value of ida_simple_get fails
2 parents 32faca6 + 86d0756 commit 3af9a52

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

drivers/gpio/gpio-adnp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
132132
if (err < 0)
133133
goto out;
134134

135-
if (err & BIT(pos))
136-
err = -EACCES;
135+
if (value & BIT(pos)) {
136+
err = -EPERM;
137+
goto out;
138+
}
137139

138140
err = 0;
139141

drivers/gpio/gpio-aspeed.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
12241224

12251225
gpio->offset_timer =
12261226
devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL);
1227+
if (!gpio->offset_timer)
1228+
return -ENOMEM;
12271229

12281230
return aspeed_gpio_setup_irqs(gpio, pdev);
12291231
}

drivers/gpio/gpio-exar.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev)
148148
mutex_init(&exar_gpio->lock);
149149

150150
index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
151+
if (index < 0)
152+
goto err_destroy;
151153

152154
sprintf(exar_gpio->name, "exar_gpio%d", index);
153155
exar_gpio->gpio_chip.label = exar_gpio->name;

drivers/gpio/gpio-mockup.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
204204
struct gpio_mockup_chip *chip;
205205
struct seq_file *sfile;
206206
struct gpio_chip *gc;
207+
int val, cnt;
207208
char buf[3];
208-
int val, rv;
209209

210210
if (*ppos != 0)
211211
return 0;
@@ -216,13 +216,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
216216
gc = &chip->gc;
217217

218218
val = gpio_mockup_get(gc, priv->offset);
219-
snprintf(buf, sizeof(buf), "%d\n", val);
219+
cnt = snprintf(buf, sizeof(buf), "%d\n", val);
220220

221-
rv = copy_to_user(usr_buf, buf, sizeof(buf));
222-
if (rv)
223-
return rv;
224-
225-
return sizeof(buf) - 1;
221+
return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt);
226222
}
227223

228224
static ssize_t gpio_mockup_debugfs_write(struct file *file,

drivers/gpio/gpiolib-of.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
120120
* to determine if the flags should have inverted semantics.
121121
*/
122122
if (IS_ENABLED(CONFIG_SPI_MASTER) &&
123-
of_property_read_bool(np, "cs-gpios")) {
123+
of_property_read_bool(np, "cs-gpios") &&
124+
!strcmp(propname, "cs-gpios")) {
124125
struct device_node *child;
125126
u32 cs;
126127
int ret;
@@ -142,16 +143,16 @@ static void of_gpio_flags_quirks(struct device_node *np,
142143
* conflict and the "spi-cs-high" flag will
143144
* take precedence.
144145
*/
145-
if (of_property_read_bool(np, "spi-cs-high")) {
146+
if (of_property_read_bool(child, "spi-cs-high")) {
146147
if (*flags & OF_GPIO_ACTIVE_LOW) {
147148
pr_warn("%s GPIO handle specifies active low - ignored\n",
148-
of_node_full_name(np));
149+
of_node_full_name(child));
149150
*flags &= ~OF_GPIO_ACTIVE_LOW;
150151
}
151152
} else {
152153
if (!(*flags & OF_GPIO_ACTIVE_LOW))
153154
pr_info("%s enforce active low on chipselect handle\n",
154-
of_node_full_name(np));
155+
of_node_full_name(child));
155156
*flags |= OF_GPIO_ACTIVE_LOW;
156157
}
157158
break;
@@ -717,7 +718,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
717718

718719
of_node_get(chip->of_node);
719720

720-
return of_gpiochip_scan_gpios(chip);
721+
status = of_gpiochip_scan_gpios(chip);
722+
if (status) {
723+
of_node_put(chip->of_node);
724+
gpiochip_remove_pin_ranges(chip);
725+
}
726+
727+
return status;
721728
}
722729

723730
void of_gpiochip_remove(struct gpio_chip *chip)

drivers/gpio/gpiolib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,7 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
27762776
}
27772777

27782778
config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce);
2779-
return gpio_set_config(chip, gpio_chip_hwgpio(desc), config);
2779+
return chip->set_config(chip, gpio_chip_hwgpio(desc), config);
27802780
}
27812781
EXPORT_SYMBOL_GPL(gpiod_set_debounce);
27822782

@@ -2813,7 +2813,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
28132813
packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE,
28142814
!transitory);
28152815
gpio = gpio_chip_hwgpio(desc);
2816-
rc = gpio_set_config(chip, gpio, packed);
2816+
rc = chip->set_config(chip, gpio, packed);
28172817
if (rc == -ENOTSUPP) {
28182818
dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n",
28192819
gpio);

include/linux/platform_data/gpio/gpio-amd-fch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: GPL+ */
1+
/* SPDX-License-Identifier: GPL-2.0+ */
22

33
/*
44
* AMD FCH gpio driver platform-data

0 commit comments

Comments
 (0)