mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
kobject: Provide macros to initialize 'struct kobj_attribute'
Currently the generic __ATTR*() macros are used to initialize kobject attributes. These are not able to handle the upcoming piece-by-piece constification of the attribute callback handlers. Add dedicated macros of kobject attributes. For now these are the same as the generic macros, but they will change soon. Users will be converted to these macros as part of the constification, but it is expected that they will be used generally in the future. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://patch.msgid.link/20260707-sysfs-const-attr-kobj-attr-prep-v2-1-35ae1bc0f9ef@weissschuh.net Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
8b29d0b452
commit
418a74d106
|
|
@ -144,6 +144,28 @@ struct kobj_attribute {
|
|||
const char *buf, size_t count);
|
||||
};
|
||||
|
||||
#define __KOBJ_ATTR(_name, _mode, _show, _store) { \
|
||||
.attr = { .name = __stringify(_name), \
|
||||
.mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
|
||||
.show = _show, \
|
||||
.store = _store, \
|
||||
}
|
||||
|
||||
#define __KOBJ_ATTR_RO_MODE(_name, _mode) \
|
||||
__KOBJ_ATTR(_name, _mode, _name##_show, NULL)
|
||||
|
||||
#define __KOBJ_ATTR_RO(_name) \
|
||||
__KOBJ_ATTR_RO_MODE(_name, 0444)
|
||||
|
||||
#define __KOBJ_ATTR_RW_MODE(_name, _mode) \
|
||||
__KOBJ_ATTR(_name, _mode, _name##_show, _name##_store)
|
||||
|
||||
#define __KOBJ_ATTR_WO(_name) \
|
||||
__KOBJ_ATTR(_name, 0200, NULL, _name##_store)
|
||||
|
||||
#define __KOBJ_ATTR_RW(_name) \
|
||||
__KOBJ_ATTR(_name, 0644, _name##_show, _name##_store)
|
||||
|
||||
extern const struct sysfs_ops kobj_sysfs_ops;
|
||||
|
||||
struct sock;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user