[PATCH 29/47] headers: Add DEVICE_ATTR_ADMIN_RW

Hauke Mehrtens <[email protected]>
Newsgroups org.kernel.vger.backports
Message-ID <[email protected]>
The DEVICE_ATTR_ADMIN_RW define was added with kernel 5.9 and is now
used by ssb.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
 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 --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 */
-- 
2.30.2

--
To unsubscribe from this list: send the line "unsubscribe backports" in
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.