]> git.sur5r.net Git - groeck-nct6775/blobdiff - compat.h
compat: Introduce DEVICE_ATTR_RO
[groeck-nct6775] / 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 */