From de7345ca24094c5df0ee17c49998e3faf6cd6dda Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 21 Feb 2018 12:58:03 -0800 Subject: [PATCH] compat: Introduce DEVICE_ATTR_RO Signed-off-by: Guenter Roeck --- compat.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 */ -- 2.39.5