Patchwork [1/2] include: linux: sysfs: Add __ATTR_NAMED macro

login
register
mail settings
Submitter Himanshi Jain
Date Sept. 13, 2017, 7:56 a.m.
Message ID <2bc7a124ab925dd2c50aa8c778745d179777d50d.1505288677.git.himshijain.hj@gmail.com>
Download mbox | patch
Permalink /patch/9950639/
State New
Headers show

Comments

Himanshi Jain - Sept. 13, 2017, 7:56 a.m.
Add __ATTR_NAMED macro similar to __ATTR but taking name as a
string instead of implicit conversion of argument to string using
the macro _stringify(_name).

Signed-off-by: Himanshi Jain <himshijain.hj@gmail.com>
---
 include/linux/sysfs.h | 7 +++++++
 1 file changed, 7 insertions(+)

Patch

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index aa02c32..20321cf 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -104,6 +104,13 @@  struct attribute_group {
 	.store	= _store,						\
 }
 
+#define __ATTR_NAMED(_name, _mode, _show, _store) {			\
+	.attr = {.name = _name,						\
+		 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
+	.show = _show,							\
+	.store = _store,						\
+}
+
 #define __ATTR_PREALLOC(_name, _mode, _show, _store) {			\
 	.attr = {.name = __stringify(_name),				\
 		 .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\