Commit 3ff74be5 authored by Johan Hovold's avatar Johan Hovold Committed by Linus Walleij

gpio: sysfs: reduce gpiochip-export locking scope

Reduce scope of sysfs_lock protection during chip export and unexport,
which is only needed to prevent gpiod (re-)exports during chip removal.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent cecf58ab
...@@ -779,7 +779,6 @@ int gpiochip_export(struct gpio_chip *chip) ...@@ -779,7 +779,6 @@ int gpiochip_export(struct gpio_chip *chip)
return 0; return 0;
/* use chip->base for the ID; it's already known to be unique */ /* use chip->base for the ID; it's already known to be unique */
mutex_lock(&sysfs_lock);
dev = device_create_with_groups(&gpio_class, chip->dev, MKDEV(0, 0), dev = device_create_with_groups(&gpio_class, chip->dev, MKDEV(0, 0),
chip, gpiochip_groups, chip, gpiochip_groups,
"gpiochip%d", chip->base); "gpiochip%d", chip->base);
...@@ -787,6 +786,8 @@ int gpiochip_export(struct gpio_chip *chip) ...@@ -787,6 +786,8 @@ int gpiochip_export(struct gpio_chip *chip)
status = PTR_ERR(dev); status = PTR_ERR(dev);
else else
status = 0; status = 0;
mutex_lock(&sysfs_lock);
chip->exported = (status == 0); chip->exported = (status == 0);
mutex_unlock(&sysfs_lock); mutex_unlock(&sysfs_lock);
...@@ -803,17 +804,17 @@ void gpiochip_unexport(struct gpio_chip *chip) ...@@ -803,17 +804,17 @@ void gpiochip_unexport(struct gpio_chip *chip)
struct gpio_desc *desc; struct gpio_desc *desc;
unsigned int i; unsigned int i;
mutex_lock(&sysfs_lock);
dev = class_find_device(&gpio_class, NULL, chip, match_export); dev = class_find_device(&gpio_class, NULL, chip, match_export);
if (dev) { if (dev) {
put_device(dev); put_device(dev);
device_unregister(dev); device_unregister(dev);
/* prevent further gpiod exports */ /* prevent further gpiod exports */
mutex_lock(&sysfs_lock);
chip->exported = false; chip->exported = false;
mutex_unlock(&sysfs_lock);
status = 0; status = 0;
} else } else
status = -ENODEV; status = -ENODEV;
mutex_unlock(&sysfs_lock);
if (status) if (status)
chip_dbg(chip, "%s: status %d\n", __func__, status); chip_dbg(chip, "%s: status %d\n", __func__, status);
......
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