aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilo Kim <milo.kim@ti.com>2013-08-07 23:46:43 -0400
committerBryan Wu <cooloney@gmail.com>2013-08-26 20:22:12 -0400
commit36030978f51b596c30188187ffcc8a436cce16f0 (patch)
tree595dee4978abbd561405d48a16abcc77e3355460
parent6841a91dc5cfcb02b99413fa4199d9a8ce5ae770 (diff)
leds: lp55xx: add common macros for device attributes
This patch provides common macros for LP5521 and LP5523 device attributes and functions. (Device attributes) LP5521: 'mode', 'load' and 'selftest' LP5523: 'mode', 'load', 'leds' and 'selftest' (Permissions) mode: R/W load: Write-only leds: R/W selftest: Read-only Couple of lines are duplicate, so use these macros for adding device attributes in LP5521 and LP5523 drivers. Signed-off-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r--drivers/leds/leds-lp55xx-common.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h
index 04c1d4fc18c0..cceab483edd0 100644
--- a/drivers/leds/leds-lp55xx-common.h
+++ b/drivers/leds/leds-lp55xx-common.h
@@ -29,6 +29,53 @@ enum lp55xx_engine_mode {
29 LP55XX_ENGINE_RUN, 29 LP55XX_ENGINE_RUN,
30}; 30};
31 31
32#define LP55XX_DEV_ATTR_RW(name, show, store) \
33 DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show, store)
34#define LP55XX_DEV_ATTR_RO(name, show) \
35 DEVICE_ATTR(name, S_IRUGO, show, NULL)
36#define LP55XX_DEV_ATTR_WO(name, store) \
37 DEVICE_ATTR(name, S_IWUSR, NULL, store)
38
39#define show_mode(nr) \
40static ssize_t show_engine##nr##_mode(struct device *dev, \
41 struct device_attribute *attr, \
42 char *buf) \
43{ \
44 return show_engine_mode(dev, attr, buf, nr); \
45}
46
47#define store_mode(nr) \
48static ssize_t store_engine##nr##_mode(struct device *dev, \
49 struct device_attribute *attr, \
50 const char *buf, size_t len) \
51{ \
52 return store_engine_mode(dev, attr, buf, len, nr); \
53}
54
55#define show_leds(nr) \
56static ssize_t show_engine##nr##_leds(struct device *dev, \
57 struct device_attribute *attr, \
58 char *buf) \
59{ \
60 return show_engine_leds(dev, attr, buf, nr); \
61}
62
63#define store_leds(nr) \
64static ssize_t store_engine##nr##_leds(struct device *dev, \
65 struct device_attribute *attr, \
66 const char *buf, size_t len) \
67{ \
68 return store_engine_leds(dev, attr, buf, len, nr); \
69}
70
71#define store_load(nr) \
72static ssize_t store_engine##nr##_load(struct device *dev, \
73 struct device_attribute *attr, \
74 const char *buf, size_t len) \
75{ \
76 return store_engine_load(dev, attr, buf, len, nr); \
77}
78
32struct lp55xx_led; 79struct lp55xx_led;
33struct lp55xx_chip; 80struct lp55xx_chip;
34 81