Skip to content

Commit ae587a5

Browse files
t-8chgregkh
authored andcommitted
sysfs: implement all BIN_ATTR_* macros in terms of __BIN_ATTR()
The preparations for the upcoming constification of struct bin_attribute requires some logic in the structure definition macros. To avoid duplication of that logic in multiple macros, reimplement all other macros in terms of __BIN_ATTR(). Signed-off-by: Thomas Weißschuh <[email protected]> Acked-by: Krzysztof Wilczyński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 699e7b8 commit ae587a5

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

include/linux/sysfs.h

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,11 @@ struct bin_attribute {
333333
.size = _size, \
334334
}
335335

336-
#define __BIN_ATTR_RO(_name, _size) { \
337-
.attr = { .name = __stringify(_name), .mode = 0444 }, \
338-
.read = _name##_read, \
339-
.size = _size, \
340-
}
336+
#define __BIN_ATTR_RO(_name, _size) \
337+
__BIN_ATTR(_name, 0444, _name##_read, NULL, _size)
341338

342-
#define __BIN_ATTR_WO(_name, _size) { \
343-
.attr = { .name = __stringify(_name), .mode = 0200 }, \
344-
.write = _name##_write, \
345-
.size = _size, \
346-
}
339+
#define __BIN_ATTR_WO(_name, _size) \
340+
__BIN_ATTR(_name, 0200, NULL, _name##_write, _size)
347341

348342
#define __BIN_ATTR_RW(_name, _size) \
349343
__BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size)
@@ -364,11 +358,8 @@ struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size)
364358
struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
365359

366360

367-
#define __BIN_ATTR_ADMIN_RO(_name, _size) { \
368-
.attr = { .name = __stringify(_name), .mode = 0400 }, \
369-
.read = _name##_read, \
370-
.size = _size, \
371-
}
361+
#define __BIN_ATTR_ADMIN_RO(_name, _size) \
362+
__BIN_ATTR(_name, 0400, _name##_read, NULL, _size)
372363

373364
#define __BIN_ATTR_ADMIN_RW(_name, _size) \
374365
__BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size)
@@ -379,10 +370,8 @@ struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size)
379370
#define BIN_ATTR_ADMIN_RW(_name, _size) \
380371
struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size)
381372

382-
#define __BIN_ATTR_SIMPLE_RO(_name, _mode) { \
383-
.attr = { .name = __stringify(_name), .mode = _mode }, \
384-
.read = sysfs_bin_attr_simple_read, \
385-
}
373+
#define __BIN_ATTR_SIMPLE_RO(_name, _mode) \
374+
__BIN_ATTR(_name, _mode, sysfs_bin_attr_simple_read, NULL, 0)
386375

387376
#define BIN_ATTR_SIMPLE_RO(_name) \
388377
struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0444)

0 commit comments

Comments
 (0)