diff options
author | Johan Hovold <johan@kernel.org> | 2015-05-04 11:10:34 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-05-12 04:46:59 -0400 |
commit | 6beac9d1aa9bf104b01816852131fa175c0a178b (patch) | |
tree | a07f56687a9e64e6b8e715cffc29207fee5c3156 /drivers/gpio/gpiolib-sysfs.c | |
parent | 166a85e44245d771bd7042f3ad72aa0e12bb53bd (diff) |
gpio: sysfs: use DEVICE_ATTR macros
Use DEVICE_ATTR_RO and DEVICE_ATTR_RW rather than specifying masks and
callbacks directly.
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 | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 9dcd346a20fb..a78dabd4035b 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c | |||
@@ -38,7 +38,7 @@ static DEFINE_MUTEX(sysfs_lock); | |||
38 | * /edge configuration | 38 | * /edge configuration |
39 | */ | 39 | */ |
40 | 40 | ||
41 | static ssize_t gpio_direction_show(struct device *dev, | 41 | static ssize_t direction_show(struct device *dev, |
42 | struct device_attribute *attr, char *buf) | 42 | struct device_attribute *attr, char *buf) |
43 | { | 43 | { |
44 | struct gpio_desc *desc = dev_get_drvdata(dev); | 44 | struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -59,7 +59,7 @@ static ssize_t gpio_direction_show(struct device *dev, | |||
59 | return status; | 59 | return status; |
60 | } | 60 | } |
61 | 61 | ||
62 | static ssize_t gpio_direction_store(struct device *dev, | 62 | static ssize_t direction_store(struct device *dev, |
63 | struct device_attribute *attr, const char *buf, size_t size) | 63 | struct device_attribute *attr, const char *buf, size_t size) |
64 | { | 64 | { |
65 | struct gpio_desc *desc = dev_get_drvdata(dev); | 65 | struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -81,11 +81,9 @@ static ssize_t gpio_direction_store(struct device *dev, | |||
81 | mutex_unlock(&sysfs_lock); | 81 | mutex_unlock(&sysfs_lock); |
82 | return status ? : size; | 82 | return status ? : size; |
83 | } | 83 | } |
84 | static DEVICE_ATTR_RW(direction); | ||
84 | 85 | ||
85 | static /* const */ DEVICE_ATTR(direction, 0644, | 86 | static ssize_t value_show(struct device *dev, |
86 | gpio_direction_show, gpio_direction_store); | ||
87 | |||
88 | static ssize_t gpio_value_show(struct device *dev, | ||
89 | struct device_attribute *attr, char *buf) | 87 | struct device_attribute *attr, char *buf) |
90 | { | 88 | { |
91 | struct gpio_desc *desc = dev_get_drvdata(dev); | 89 | struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -102,7 +100,7 @@ static ssize_t gpio_value_show(struct device *dev, | |||
102 | return status; | 100 | return status; |
103 | } | 101 | } |
104 | 102 | ||
105 | static ssize_t gpio_value_store(struct device *dev, | 103 | static ssize_t value_store(struct device *dev, |
106 | struct device_attribute *attr, const char *buf, size_t size) | 104 | struct device_attribute *attr, const char *buf, size_t size) |
107 | { | 105 | { |
108 | struct gpio_desc *desc = dev_get_drvdata(dev); | 106 | struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -127,9 +125,7 @@ static ssize_t gpio_value_store(struct device *dev, | |||
127 | mutex_unlock(&sysfs_lock); | 125 | mutex_unlock(&sysfs_lock); |
128 | return status; | 126 | return status; |
129 | } | 127 | } |
130 | 128 | static DEVICE_ATTR_RW(value); | |
131 | static DEVICE_ATTR(value, 0644, | ||
132 | gpio_value_show, gpio_value_store); | ||
133 | 129 | ||
134 | static irqreturn_t gpio_sysfs_irq(int irq, void *priv) | 130 | static irqreturn_t gpio_sysfs_irq(int irq, void *priv) |
135 | { | 131 | { |
@@ -237,7 +233,7 @@ static const struct { | |||
237 | { "both", BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE) }, | 233 | { "both", BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE) }, |
238 | }; | 234 | }; |
239 | 235 | ||
240 | static ssize_t gpio_edge_show(struct device *dev, | 236 | static ssize_t edge_show(struct device *dev, |
241 | struct device_attribute *attr, char *buf) | 237 | struct device_attribute *attr, char *buf) |
242 | { | 238 | { |
243 | const struct gpio_desc *desc = dev_get_drvdata(dev); | 239 | const struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -264,7 +260,7 @@ static ssize_t gpio_edge_show(struct device *dev, | |||
264 | return status; | 260 | return status; |
265 | } | 261 | } |
266 | 262 | ||
267 | static ssize_t gpio_edge_store(struct device *dev, | 263 | static ssize_t edge_store(struct device *dev, |
268 | struct device_attribute *attr, const char *buf, size_t size) | 264 | struct device_attribute *attr, const char *buf, size_t size) |
269 | { | 265 | { |
270 | struct gpio_desc *desc = dev_get_drvdata(dev); | 266 | struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -291,8 +287,7 @@ found: | |||
291 | 287 | ||
292 | return status; | 288 | return status; |
293 | } | 289 | } |
294 | 290 | static DEVICE_ATTR_RW(edge); | |
295 | static DEVICE_ATTR(edge, 0644, gpio_edge_show, gpio_edge_store); | ||
296 | 291 | ||
297 | static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev, | 292 | static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev, |
298 | int value) | 293 | int value) |
@@ -319,7 +314,7 @@ static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev, | |||
319 | return status; | 314 | return status; |
320 | } | 315 | } |
321 | 316 | ||
322 | static ssize_t gpio_active_low_show(struct device *dev, | 317 | static ssize_t active_low_show(struct device *dev, |
323 | struct device_attribute *attr, char *buf) | 318 | struct device_attribute *attr, char *buf) |
324 | { | 319 | { |
325 | const struct gpio_desc *desc = dev_get_drvdata(dev); | 320 | const struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -338,7 +333,7 @@ static ssize_t gpio_active_low_show(struct device *dev, | |||
338 | return status; | 333 | return status; |
339 | } | 334 | } |
340 | 335 | ||
341 | static ssize_t gpio_active_low_store(struct device *dev, | 336 | static ssize_t active_low_store(struct device *dev, |
342 | struct device_attribute *attr, const char *buf, size_t size) | 337 | struct device_attribute *attr, const char *buf, size_t size) |
343 | { | 338 | { |
344 | struct gpio_desc *desc = dev_get_drvdata(dev); | 339 | struct gpio_desc *desc = dev_get_drvdata(dev); |
@@ -360,9 +355,7 @@ static ssize_t gpio_active_low_store(struct device *dev, | |||
360 | 355 | ||
361 | return status ? : size; | 356 | return status ? : size; |
362 | } | 357 | } |
363 | 358 | static DEVICE_ATTR_RW(active_low); | |
364 | static DEVICE_ATTR(active_low, 0644, | ||
365 | gpio_active_low_show, gpio_active_low_store); | ||
366 | 359 | ||
367 | static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, | 360 | static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, |
368 | int n) | 361 | int n) |
@@ -410,32 +403,32 @@ static const struct attribute_group *gpio_groups[] = { | |||
410 | * /ngpio ... matching gpio_chip.ngpio | 403 | * /ngpio ... matching gpio_chip.ngpio |
411 | */ | 404 | */ |
412 | 405 | ||
413 | static ssize_t chip_base_show(struct device *dev, | 406 | static ssize_t base_show(struct device *dev, |
414 | struct device_attribute *attr, char *buf) | 407 | struct device_attribute *attr, char *buf) |
415 | { | 408 | { |
416 | const struct gpio_chip *chip = dev_get_drvdata(dev); | 409 | const struct gpio_chip *chip = dev_get_drvdata(dev); |
417 | 410 | ||
418 | return sprintf(buf, "%d\n", chip->base); | 411 | return sprintf(buf, "%d\n", chip->base); |
419 | } | 412 | } |
420 | static DEVICE_ATTR(base, 0444, chip_base_show, NULL); | 413 | static DEVICE_ATTR_RO(base); |
421 | 414 | ||
422 | static ssize_t chip_label_show(struct device *dev, | 415 | static ssize_t label_show(struct device *dev, |
423 | struct device_attribute *attr, char *buf) | 416 | struct device_attribute *attr, char *buf) |
424 | { | 417 | { |
425 | const struct gpio_chip *chip = dev_get_drvdata(dev); | 418 | const struct gpio_chip *chip = dev_get_drvdata(dev); |
426 | 419 | ||
427 | return sprintf(buf, "%s\n", chip->label ? : ""); | 420 | return sprintf(buf, "%s\n", chip->label ? : ""); |
428 | } | 421 | } |
429 | static DEVICE_ATTR(label, 0444, chip_label_show, NULL); | 422 | static DEVICE_ATTR_RO(label); |
430 | 423 | ||
431 | static ssize_t chip_ngpio_show(struct device *dev, | 424 | static ssize_t ngpio_show(struct device *dev, |
432 | struct device_attribute *attr, char *buf) | 425 | struct device_attribute *attr, char *buf) |
433 | { | 426 | { |
434 | const struct gpio_chip *chip = dev_get_drvdata(dev); | 427 | const struct gpio_chip *chip = dev_get_drvdata(dev); |
435 | 428 | ||
436 | return sprintf(buf, "%u\n", chip->ngpio); | 429 | return sprintf(buf, "%u\n", chip->ngpio); |
437 | } | 430 | } |
438 | static DEVICE_ATTR(ngpio, 0444, chip_ngpio_show, NULL); | 431 | static DEVICE_ATTR_RO(ngpio); |
439 | 432 | ||
440 | static struct attribute *gpiochip_attrs[] = { | 433 | static struct attribute *gpiochip_attrs[] = { |
441 | &dev_attr_base.attr, | 434 | &dev_attr_base.attr, |