Commit 3af9a525 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 32faca66 86d07565
...@@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) ...@@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
if (err < 0) if (err < 0)
goto out; goto out;
if (err & BIT(pos)) if (value & BIT(pos)) {
err = -EACCES; err = -EPERM;
goto out;
}
err = 0; err = 0;
......
...@@ -1224,6 +1224,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) ...@@ -1224,6 +1224,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
gpio->offset_timer = gpio->offset_timer =
devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL); devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL);
if (!gpio->offset_timer)
return -ENOMEM;
return aspeed_gpio_setup_irqs(gpio, pdev); return aspeed_gpio_setup_irqs(gpio, pdev);
} }
......
...@@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev) ...@@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev)
mutex_init(&exar_gpio->lock); mutex_init(&exar_gpio->lock);
index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
if (index < 0)
goto err_destroy;
sprintf(exar_gpio->name, "exar_gpio%d", index); sprintf(exar_gpio->name, "exar_gpio%d", index);
exar_gpio->gpio_chip.label = exar_gpio->name; exar_gpio->gpio_chip.label = exar_gpio->name;
......
...@@ -204,8 +204,8 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file, ...@@ -204,8 +204,8 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
struct gpio_mockup_chip *chip; struct gpio_mockup_chip *chip;
struct seq_file *sfile; struct seq_file *sfile;
struct gpio_chip *gc; struct gpio_chip *gc;
int val, cnt;
char buf[3]; char buf[3];
int val, rv;
if (*ppos != 0) if (*ppos != 0)
return 0; return 0;
...@@ -216,13 +216,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file, ...@@ -216,13 +216,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
gc = &chip->gc; gc = &chip->gc;
val = gpio_mockup_get(gc, priv->offset); val = gpio_mockup_get(gc, priv->offset);
snprintf(buf, sizeof(buf), "%d\n", val); cnt = snprintf(buf, sizeof(buf), "%d\n", val);
rv = copy_to_user(usr_buf, buf, sizeof(buf)); return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt);
if (rv)
return rv;
return sizeof(buf) - 1;
} }
static ssize_t gpio_mockup_debugfs_write(struct file *file, static ssize_t gpio_mockup_debugfs_write(struct file *file,
......
...@@ -120,7 +120,8 @@ static void of_gpio_flags_quirks(struct device_node *np, ...@@ -120,7 +120,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
* to determine if the flags should have inverted semantics. * to determine if the flags should have inverted semantics.
*/ */
if (IS_ENABLED(CONFIG_SPI_MASTER) && if (IS_ENABLED(CONFIG_SPI_MASTER) &&
of_property_read_bool(np, "cs-gpios")) { of_property_read_bool(np, "cs-gpios") &&
!strcmp(propname, "cs-gpios")) {
struct device_node *child; struct device_node *child;
u32 cs; u32 cs;
int ret; int ret;
...@@ -142,16 +143,16 @@ static void of_gpio_flags_quirks(struct device_node *np, ...@@ -142,16 +143,16 @@ static void of_gpio_flags_quirks(struct device_node *np,
* conflict and the "spi-cs-high" flag will * conflict and the "spi-cs-high" flag will
* take precedence. * take precedence.
*/ */
if (of_property_read_bool(np, "spi-cs-high")) { if (of_property_read_bool(child, "spi-cs-high")) {
if (*flags & OF_GPIO_ACTIVE_LOW) { if (*flags & OF_GPIO_ACTIVE_LOW) {
pr_warn("%s GPIO handle specifies active low - ignored\n", pr_warn("%s GPIO handle specifies active low - ignored\n",
of_node_full_name(np)); of_node_full_name(child));
*flags &= ~OF_GPIO_ACTIVE_LOW; *flags &= ~OF_GPIO_ACTIVE_LOW;
} }
} else { } else {
if (!(*flags & OF_GPIO_ACTIVE_LOW)) if (!(*flags & OF_GPIO_ACTIVE_LOW))
pr_info("%s enforce active low on chipselect handle\n", pr_info("%s enforce active low on chipselect handle\n",
of_node_full_name(np)); of_node_full_name(child));
*flags |= OF_GPIO_ACTIVE_LOW; *flags |= OF_GPIO_ACTIVE_LOW;
} }
break; break;
...@@ -717,7 +718,13 @@ int of_gpiochip_add(struct gpio_chip *chip) ...@@ -717,7 +718,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
of_node_get(chip->of_node); of_node_get(chip->of_node);
return of_gpiochip_scan_gpios(chip); status = of_gpiochip_scan_gpios(chip);
if (status) {
of_node_put(chip->of_node);
gpiochip_remove_pin_ranges(chip);
}
return status;
} }
void of_gpiochip_remove(struct gpio_chip *chip) void of_gpiochip_remove(struct gpio_chip *chip)
......
...@@ -2776,7 +2776,7 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) ...@@ -2776,7 +2776,7 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
} }
config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce);
return gpio_set_config(chip, gpio_chip_hwgpio(desc), config); return chip->set_config(chip, gpio_chip_hwgpio(desc), config);
} }
EXPORT_SYMBOL_GPL(gpiod_set_debounce); EXPORT_SYMBOL_GPL(gpiod_set_debounce);
...@@ -2813,7 +2813,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) ...@@ -2813,7 +2813,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE,
!transitory); !transitory);
gpio = gpio_chip_hwgpio(desc); gpio = gpio_chip_hwgpio(desc);
rc = gpio_set_config(chip, gpio, packed); rc = chip->set_config(chip, gpio, packed);
if (rc == -ENOTSUPP) { if (rc == -ENOTSUPP) {
dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n",
gpio); gpio);
......
/* SPDX-License-Identifier: GPL+ */ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* AMD FCH gpio driver platform-data * AMD FCH gpio driver platform-data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment