diff options
author | Johan Hovold <johan@kernel.org> | 2015-05-04 11:10:47 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-05-12 04:47:52 -0400 |
commit | 427fdeef5014c77aea7ca10c104d534786c3c1e0 (patch) | |
tree | dc7ac195615a9c7bd5b469bdb2fe522384fc2646 /drivers/gpio/gpiolib-sysfs.c | |
parent | 2f323b85675d89c85e72bec191d42b72d905a652 (diff) |
gpio: sysfs: remove FLAG_SYSFS_DIR
Remove FLAG_SYSFS_DIR, which is sysfs-interface specific, and store it
in the class-device data instead.
Note that the flag is only used during export.
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib-sysfs.c')
-rw-r--r-- | drivers/gpio/gpiolib-sysfs.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 06372c7c822c..9047b2d556a0 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c | |||
@@ -16,6 +16,8 @@ struct gpiod_data { | |||
16 | struct mutex mutex; | 16 | struct mutex mutex; |
17 | struct kernfs_node *value_kn; | 17 | struct kernfs_node *value_kn; |
18 | int irq; | 18 | int irq; |
19 | |||
20 | bool direction_can_change; | ||
19 | }; | 21 | }; |
20 | 22 | ||
21 | /* | 23 | /* |
@@ -354,7 +356,7 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, | |||
354 | struct gpiod_data *data = dev_get_drvdata(dev); | 356 | struct gpiod_data *data = dev_get_drvdata(dev); |
355 | struct gpio_desc *desc = data->desc; | 357 | struct gpio_desc *desc = data->desc; |
356 | umode_t mode = attr->mode; | 358 | umode_t mode = attr->mode; |
357 | bool show_direction = test_bit(FLAG_SYSFS_DIR, &desc->flags); | 359 | bool show_direction = data->direction_can_change; |
358 | 360 | ||
359 | if (attr == &dev_attr_direction.attr) { | 361 | if (attr == &dev_attr_direction.attr) { |
360 | if (!show_direction) | 362 | if (!show_direction) |
@@ -583,12 +585,6 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) | |||
583 | status = -EPERM; | 585 | status = -EPERM; |
584 | goto err_unlock; | 586 | goto err_unlock; |
585 | } | 587 | } |
586 | |||
587 | if (chip->direction_input && chip->direction_output && | ||
588 | direction_may_change) { | ||
589 | set_bit(FLAG_SYSFS_DIR, &desc->flags); | ||
590 | } | ||
591 | |||
592 | spin_unlock_irqrestore(&gpio_lock, flags); | 588 | spin_unlock_irqrestore(&gpio_lock, flags); |
593 | 589 | ||
594 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 590 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
@@ -599,6 +595,10 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) | |||
599 | 595 | ||
600 | data->desc = desc; | 596 | data->desc = desc; |
601 | mutex_init(&data->mutex); | 597 | mutex_init(&data->mutex); |
598 | if (chip->direction_input && chip->direction_output) | ||
599 | data->direction_can_change = direction_may_change; | ||
600 | else | ||
601 | data->direction_can_change = false; | ||
602 | 602 | ||
603 | offset = gpio_chip_hwgpio(desc); | 603 | offset = gpio_chip_hwgpio(desc); |
604 | if (chip->names && chip->names[offset]) | 604 | if (chip->names && chip->names[offset]) |
@@ -693,7 +693,6 @@ void gpiod_unexport(struct gpio_desc *desc) | |||
693 | 693 | ||
694 | data = dev_get_drvdata(dev); | 694 | data = dev_get_drvdata(dev); |
695 | 695 | ||
696 | clear_bit(FLAG_SYSFS_DIR, &desc->flags); | ||
697 | clear_bit(FLAG_EXPORT, &desc->flags); | 696 | clear_bit(FLAG_EXPORT, &desc->flags); |
698 | 697 | ||
699 | device_unregister(dev); | 698 | device_unregister(dev); |