]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: sysfs: rename the data variable in gpiod_(un)export()
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 4 Jul 2025 12:58:52 +0000 (14:58 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 16 Jul 2025 08:27:07 +0000 (10:27 +0200)
In preparation for future commits which will make use of descriptor AND
GPIO-device data in the same functions rename the former from data to
desc_data separately which will make future changes smaller and easier
to read.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250704-gpio-sysfs-chip-export-v4-5-9289d8758243@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib-sysfs.c

index 0cfa73e92b47fd089b973e96b5062694b7f8abd3..fc9c19fde3f12c16a26aa09dcb6f17960942c4bd 100644 (file)
@@ -663,8 +663,8 @@ gdev_get_data(struct gpio_device *gdev) __must_hold(&sysfs_lock)
  */
 int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
 {
+       struct gpiod_data *desc_data;
        struct gpio_device *gdev;
-       struct gpiod_data *data;
        struct device *dev;
        int status;
 
@@ -696,29 +696,29 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
                goto err_clear_bit;
        }
 
-       data = kzalloc(sizeof(*data), GFP_KERNEL);
-       if (!data) {
+       desc_data = kzalloc(sizeof(*desc_data), GFP_KERNEL);
+       if (!desc_data) {
                status = -ENOMEM;
                goto err_clear_bit;
        }
 
-       data->desc = desc;
-       mutex_init(&data->mutex);
+       desc_data->desc = desc;
+       mutex_init(&desc_data->mutex);
        if (guard.gc->direction_input && guard.gc->direction_output)
-               data->direction_can_change = direction_may_change;
+               desc_data->direction_can_change = direction_may_change;
        else
-               data->direction_can_change = false;
+               desc_data->direction_can_change = false;
 
        dev = device_create_with_groups(&gpio_class, &gdev->dev,
-                                       MKDEV(0, 0), data, gpio_groups,
+                                       MKDEV(0, 0), desc_data, gpio_groups,
                                        "gpio%u", desc_to_gpio(desc));
        if (IS_ERR(dev)) {
                status = PTR_ERR(dev);
                goto err_free_data;
        }
 
-       data->value_kn = sysfs_get_dirent(dev->kobj.sd, "value");
-       if (!data->value_kn) {
+       desc_data->value_kn = sysfs_get_dirent(dev->kobj.sd, "value");
+       if (!desc_data->value_kn) {
                status = -ENODEV;
                goto err_unregister_device;
        }
@@ -728,7 +728,7 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
 err_unregister_device:
        device_unregister(dev);
 err_free_data:
-       kfree(data);
+       kfree(desc_data);
 err_clear_bit:
        clear_bit(FLAG_EXPORT, &desc->flags);
        gpiod_dbg(desc, "%s: status %d\n", __func__, status);
@@ -785,7 +785,7 @@ EXPORT_SYMBOL_GPL(gpiod_export_link);
  */
 void gpiod_unexport(struct gpio_desc *desc)
 {
-       struct gpiod_data *data;
+       struct gpiod_data *desc_data;
        struct device *dev;
 
        if (!desc) {
@@ -801,22 +801,22 @@ void gpiod_unexport(struct gpio_desc *desc)
                if (!dev)
                        return;
 
-               data = dev_get_drvdata(dev);
+               desc_data = dev_get_drvdata(dev);
                clear_bit(FLAG_EXPORT, &desc->flags);
-               sysfs_put(data->value_kn);
+               sysfs_put(desc_data->value_kn);
                device_unregister(dev);
 
                /*
                 * Release irq after deregistration to prevent race with
                 * edge_store.
                 */
-               if (data->irq_flags)
-                       gpio_sysfs_free_irq(data);
+               if (desc_data->irq_flags)
+                       gpio_sysfs_free_irq(desc_data);
        }
 
        put_device(dev);
-       mutex_destroy(&data->mutex);
-       kfree(data);
+       mutex_destroy(&desc_data->mutex);
+       kfree(desc_data);
 }
 EXPORT_SYMBOL_GPL(gpiod_unexport);