Skip to content

Commit

Permalink
gpio: sysfs: use DEVICE_ATTR macros
Browse files Browse the repository at this point in the history
Use DEVICE_ATTR_RO and DEVICE_ATTR_RW rather than specifying masks and
callbacks directly.

Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Alexandre Courbot <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
jhovold authored and linusw committed May 12, 2015
1 parent 166a85e commit 6beac9d
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions drivers/gpio/gpiolib-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static DEFINE_MUTEX(sysfs_lock);
* /edge configuration
*/

static ssize_t gpio_direction_show(struct device *dev,
static ssize_t direction_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -59,7 +59,7 @@ static ssize_t gpio_direction_show(struct device *dev,
return status;
}

static ssize_t gpio_direction_store(struct device *dev,
static ssize_t direction_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -81,11 +81,9 @@ static ssize_t gpio_direction_store(struct device *dev,
mutex_unlock(&sysfs_lock);
return status ? : size;
}
static DEVICE_ATTR_RW(direction);

static /* const */ DEVICE_ATTR(direction, 0644,
gpio_direction_show, gpio_direction_store);

static ssize_t gpio_value_show(struct device *dev,
static ssize_t value_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -102,7 +100,7 @@ static ssize_t gpio_value_show(struct device *dev,
return status;
}

static ssize_t gpio_value_store(struct device *dev,
static ssize_t value_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -127,9 +125,7 @@ static ssize_t gpio_value_store(struct device *dev,
mutex_unlock(&sysfs_lock);
return status;
}

static DEVICE_ATTR(value, 0644,
gpio_value_show, gpio_value_store);
static DEVICE_ATTR_RW(value);

static irqreturn_t gpio_sysfs_irq(int irq, void *priv)
{
Expand Down Expand Up @@ -237,7 +233,7 @@ static const struct {
{ "both", BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE) },
};

static ssize_t gpio_edge_show(struct device *dev,
static ssize_t edge_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -264,7 +260,7 @@ static ssize_t gpio_edge_show(struct device *dev,
return status;
}

static ssize_t gpio_edge_store(struct device *dev,
static ssize_t edge_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -291,8 +287,7 @@ static ssize_t gpio_edge_store(struct device *dev,

return status;
}

static DEVICE_ATTR(edge, 0644, gpio_edge_show, gpio_edge_store);
static DEVICE_ATTR_RW(edge);

static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev,
int value)
Expand All @@ -319,7 +314,7 @@ static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev,
return status;
}

static ssize_t gpio_active_low_show(struct device *dev,
static ssize_t active_low_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -338,7 +333,7 @@ static ssize_t gpio_active_low_show(struct device *dev,
return status;
}

static ssize_t gpio_active_low_store(struct device *dev,
static ssize_t active_low_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct gpio_desc *desc = dev_get_drvdata(dev);
Expand All @@ -360,9 +355,7 @@ static ssize_t gpio_active_low_store(struct device *dev,

return status ? : size;
}

static DEVICE_ATTR(active_low, 0644,
gpio_active_low_show, gpio_active_low_store);
static DEVICE_ATTR_RW(active_low);

static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr,
int n)
Expand Down Expand Up @@ -410,32 +403,32 @@ static const struct attribute_group *gpio_groups[] = {
* /ngpio ... matching gpio_chip.ngpio
*/

static ssize_t chip_base_show(struct device *dev,
static ssize_t base_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct gpio_chip *chip = dev_get_drvdata(dev);

return sprintf(buf, "%d\n", chip->base);
}
static DEVICE_ATTR(base, 0444, chip_base_show, NULL);
static DEVICE_ATTR_RO(base);

static ssize_t chip_label_show(struct device *dev,
static ssize_t label_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct gpio_chip *chip = dev_get_drvdata(dev);

return sprintf(buf, "%s\n", chip->label ? : "");
}
static DEVICE_ATTR(label, 0444, chip_label_show, NULL);
static DEVICE_ATTR_RO(label);

static ssize_t chip_ngpio_show(struct device *dev,
static ssize_t ngpio_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct gpio_chip *chip = dev_get_drvdata(dev);

return sprintf(buf, "%u\n", chip->ngpio);
}
static DEVICE_ATTR(ngpio, 0444, chip_ngpio_show, NULL);
static DEVICE_ATTR_RO(ngpio);

static struct attribute *gpiochip_attrs[] = {
&dev_attr_base.attr,
Expand Down

0 comments on commit 6beac9d

Please sign in to comment.