]> git.sur5r.net Git - groeck-nct6775/commitdiff
compat: Introduce DEVICE_ATTR_RO
authorGuenter Roeck <linux@roeck-us.net>
Wed, 21 Feb 2018 20:58:03 +0000 (12:58 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 21 Feb 2018 20:58:03 +0000 (12:58 -0800)
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
compat.h

index 4ea3a997928f9fb3c34b3a341a07e242ffff07dd..de03ccbc560c4a434d5927c174f1d80e1b302207 100644 (file)
--- a/compat.h
+++ b/compat.h
@@ -234,4 +234,16 @@ module_exit(__driver##_exit);
 #define sysfs_attr_init(attr) do {} while (0)
 #endif
 
+#ifndef __ATTR_RO
+#define __ATTR_RO(_name) {                                             \
+       .attr   = { .name = __stringify(_name), .mode = 0444 },         \
+       .show   = _name##_show,                                         \
+}
+#endif
+
+#ifndef DEVICE_ATTR_RO
+#define DEVICE_ATTR_RO(_name) \
+       struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
+#endif
+
 #endif /* __COMPAT_H */