From: Guenter Roeck Date: Wed, 21 Feb 2018 20:58:03 +0000 (-0800) Subject: compat: Introduce DEVICE_ATTR_RO X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=de7345ca24094c5df0ee17c49998e3faf6cd6dda;p=groeck-nct6775 compat: Introduce DEVICE_ATTR_RO Signed-off-by: Guenter Roeck --- diff --git a/compat.h b/compat.h index 4ea3a99..de03ccb 100644 --- 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 */