Commit 427fdeef authored by Johan Hovold's avatar Johan Hovold Committed by Linus Walleij

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: 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 2f323b85
...@@ -16,6 +16,8 @@ struct gpiod_data { ...@@ -16,6 +16,8 @@ struct gpiod_data {
struct mutex mutex; struct mutex mutex;
struct kernfs_node *value_kn; struct kernfs_node *value_kn;
int irq; int irq;
bool direction_can_change;
}; };
/* /*
...@@ -354,7 +356,7 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, ...@@ -354,7 +356,7 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr,
struct gpiod_data *data = dev_get_drvdata(dev); struct gpiod_data *data = dev_get_drvdata(dev);
struct gpio_desc *desc = data->desc; struct gpio_desc *desc = data->desc;
umode_t mode = attr->mode; umode_t mode = attr->mode;
bool show_direction = test_bit(FLAG_SYSFS_DIR, &desc->flags); bool show_direction = data->direction_can_change;
if (attr == &dev_attr_direction.attr) { if (attr == &dev_attr_direction.attr) {
if (!show_direction) if (!show_direction)
...@@ -583,12 +585,6 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) ...@@ -583,12 +585,6 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
status = -EPERM; status = -EPERM;
goto err_unlock; goto err_unlock;
} }
if (chip->direction_input && chip->direction_output &&
direction_may_change) {
set_bit(FLAG_SYSFS_DIR, &desc->flags);
}
spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags);
data = kzalloc(sizeof(*data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
...@@ -599,6 +595,10 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) ...@@ -599,6 +595,10 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
data->desc = desc; data->desc = desc;
mutex_init(&data->mutex); mutex_init(&data->mutex);
if (chip->direction_input && chip->direction_output)
data->direction_can_change = direction_may_change;
else
data->direction_can_change = false;
offset = gpio_chip_hwgpio(desc); offset = gpio_chip_hwgpio(desc);
if (chip->names && chip->names[offset]) if (chip->names && chip->names[offset])
...@@ -693,7 +693,6 @@ void gpiod_unexport(struct gpio_desc *desc) ...@@ -693,7 +693,6 @@ void gpiod_unexport(struct gpio_desc *desc)
data = dev_get_drvdata(dev); data = dev_get_drvdata(dev);
clear_bit(FLAG_SYSFS_DIR, &desc->flags);
clear_bit(FLAG_EXPORT, &desc->flags); clear_bit(FLAG_EXPORT, &desc->flags);
device_unregister(dev); device_unregister(dev);
......
...@@ -89,7 +89,6 @@ struct gpio_desc { ...@@ -89,7 +89,6 @@ struct gpio_desc {
#define FLAG_OPEN_DRAIN 7 /* Gpio is open drain type */ #define FLAG_OPEN_DRAIN 7 /* Gpio is open drain type */
#define FLAG_OPEN_SOURCE 8 /* Gpio is open source type */ #define FLAG_OPEN_SOURCE 8 /* Gpio is open source type */
#define FLAG_USED_AS_IRQ 9 /* GPIO is connected to an IRQ */ #define FLAG_USED_AS_IRQ 9 /* GPIO is connected to an IRQ */
#define FLAG_SYSFS_DIR 10 /* show sysfs direction attribute */
#define FLAG_IS_HOGGED 11 /* GPIO is hogged */ #define FLAG_IS_HOGGED 11 /* GPIO is hogged */
#define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE)) #define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE))
......
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