diff mbox series

[29/47] headers: Add DEVICE_ATTR_ADMIN_RW

Message ID 20211019214320.2035704-30-hauke@hauke-m.de (mailing list archive)
State New, archived
Headers show
Series backports: Update to kernel 5.15-rc6 | expand

Commit Message

Hauke Mehrtens Oct. 19, 2021, 9:43 p.m. UTC
The DEVICE_ATTR_ADMIN_RW define was added with kernel 5.9 and is now
used by ssb.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/device.h | 10 ++++++++++
 backport/backport-include/linux/sysfs.h  |  9 +++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 backport/backport-include/linux/device.h
diff mbox series

Patch

diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h
new file mode 100644
index 00000000..46f2190b
--- /dev/null
+++ b/backport/backport-include/linux/device.h
@@ -0,0 +1,10 @@ 
+#ifndef __BACKPORT_DEVICE_H_
+#define __BACKPORT_DEVICE_H_
+#include_next <linux/device.h>
+
+#ifndef DEVICE_ATTR_ADMIN_RW
+#define DEVICE_ATTR_ADMIN_RW(_name) \
+	struct device_attribute dev_attr_##_name = __ATTR_RW_MODE(_name, 0600)
+#endif
+
+#endif /* __BACKPORT_DEVICE_H_ */
diff --git a/backport/backport-include/linux/sysfs.h b/backport/backport-include/linux/sysfs.h
index ad8a8229..7126fb03 100644
--- a/backport/backport-include/linux/sysfs.h
+++ b/backport/backport-include/linux/sysfs.h
@@ -22,4 +22,13 @@  static inline int sysfs_emit(char *buf, const char *fmt, ...)
 #endif /* CONFIG_SYSFS */
 #endif /* < 5.10 */
 
+#ifndef __ATTR_RW_MODE
+#define __ATTR_RW_MODE(_name, _mode) {					\
+	.attr	= { .name = __stringify(_name),				\
+		    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
+	.show	= _name##_show,						\
+	.store	= _name##_store,					\
+}
+#endif
+
 #endif /* __BACKPORT_LINUX_SYSFS_H */