summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilo Kim2013-08-08 05:46:43 +0200
committerBryan Wu2013-08-27 02:22:12 +0200
commit36030978f51b596c30188187ffcc8a436cce16f0 (patch)
tree595dee4978abbd561405d48a16abcc77e3355460
parentleds: lp55xx: add common data structure for program (diff)
downloadkernel-qcow2-linux-36030978f51b596c30188187ffcc8a436cce16f0.tar.gz
kernel-qcow2-linux-36030978f51b596c30188187ffcc8a436cce16f0.tar.xz
kernel-qcow2-linux-36030978f51b596c30188187ffcc8a436cce16f0.zip
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 {
LP55XX_ENGINE_RUN,
};
+#define LP55XX_DEV_ATTR_RW(name, show, store) \
+ DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show, store)
+#define LP55XX_DEV_ATTR_RO(name, show) \
+ DEVICE_ATTR(name, S_IRUGO, show, NULL)
+#define LP55XX_DEV_ATTR_WO(name, store) \
+ DEVICE_ATTR(name, S_IWUSR, NULL, store)
+
+#define show_mode(nr) \
+static ssize_t show_engine##nr##_mode(struct device *dev, \
+ struct device_attribute *attr, \
+ char *buf) \
+{ \
+ return show_engine_mode(dev, attr, buf, nr); \
+}
+
+#define store_mode(nr) \
+static ssize_t store_engine##nr##_mode(struct device *dev, \
+ struct device_attribute *attr, \
+ const char *buf, size_t len) \
+{ \
+ return store_engine_mode(dev, attr, buf, len, nr); \
+}
+
+#define show_leds(nr) \
+static ssize_t show_engine##nr##_leds(struct device *dev, \
+ struct device_attribute *attr, \
+ char *buf) \
+{ \
+ return show_engine_leds(dev, attr, buf, nr); \
+}
+
+#define store_leds(nr) \
+static ssize_t store_engine##nr##_leds(struct device *dev, \
+ struct device_attribute *attr, \
+ const char *buf, size_t len) \
+{ \
+ return store_engine_leds(dev, attr, buf, len, nr); \
+}
+
+#define store_load(nr) \
+static ssize_t store_engine##nr##_load(struct device *dev, \
+ struct device_attribute *attr, \
+ const char *buf, size_t len) \
+{ \
+ return store_engine_load(dev, attr, buf, len, nr); \
+}
+
struct lp55xx_led;
struct lp55xx_chip;