Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/sysfs.h
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | #define __ATTR(_name, _mode, _show, _store) { \ | ||||
.show = _show, .store = _store, \ | .show = _show, .store = _store, \ | ||||
} | } | ||||
#define __ATTR_RO(_name) __ATTR(_name, 0444, _name##_show, NULL) | #define __ATTR_RO(_name) __ATTR(_name, 0444, _name##_show, NULL) | ||||
#define __ATTR_WO(_name) __ATTR(_name, 0200, NULL, _name##_store) | #define __ATTR_WO(_name) __ATTR(_name, 0200, NULL, _name##_store) | ||||
#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store) | #define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store) | ||||
#define __ATTR_NULL { .attr = { .name = NULL } } | #define __ATTR_NULL { .attr = { .name = NULL } } | ||||
#define ATTRIBUTE_GROUPS(_name) \ | #define ATTRIBUTE_GROUPS(_name) \ | ||||
val_packett.cool: why remove the comment? :) | |||||
static struct attribute_group _name##_group = { \ | static struct attribute_group _name##_group = { \ | ||||
.name = __stringify(_name), \ | |||||
.attrs = _name##_attrs, \ | .attrs = _name##_attrs, \ | ||||
}; \ | }; \ | ||||
static struct attribute_group *_name##_groups[] = { \ | static const struct attribute_group *_name##_groups[] = { \ | ||||
&_name##_group, \ | &_name##_group, \ | ||||
NULL, \ | NULL, \ | ||||
}; | } | ||||
/* | /* | ||||
* Handle our generic '\0' terminated 'C' string. | * Handle our generic '\0' terminated 'C' string. | ||||
* Two cases: | * Two cases: | ||||
* a variable string: point arg1 at it, arg2 is max length. | * a variable string: point arg1 at it, arg2 is max length. | ||||
* a constant string: point arg1 at it, arg2 is zero. | * a constant string: point arg1 at it, arg2 is zero. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static inline int | static inline int | ||||
sysfs_create_groups(struct kobject *kobj, const struct attribute_group **grps) | sysfs_create_groups(struct kobject *kobj, const struct attribute_group **grps) | ||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
int i; | int i; | ||||
if (grps == NULL) | |||||
goto done; | |||||
for (i = 0; grps[i] && !error; i++) | for (i = 0; grps[i] && !error; i++) | ||||
error = sysfs_create_group(kobj, grps[i]); | error = sysfs_create_group(kobj, grps[i]); | ||||
while (error && --i >= 0) | while (error && --i >= 0) | ||||
sysfs_remove_group(kobj, grps[i]); | sysfs_remove_group(kobj, grps[i]); | ||||
done: | |||||
return (error); | return (error); | ||||
} | |||||
static inline void | |||||
sysfs_remove_groups(struct kobject *kobj, const struct attribute_group **grps) | |||||
{ | |||||
int i; | |||||
if (grps == NULL) | |||||
return; | |||||
for (i = 0; grps[i]; i++) | |||||
sysfs_remove_group(kobj, grps[i]); | |||||
} | } | ||||
static inline int | static inline int | ||||
sysfs_merge_group(struct kobject *kobj, const struct attribute_group *grp) | sysfs_merge_group(struct kobject *kobj, const struct attribute_group *grp) | ||||
{ | { | ||||
/* Really expected behavior is to return failure if group exists. */ | /* Really expected behavior is to return failure if group exists. */ | ||||
return (sysfs_create_group(kobj, grp)); | return (sysfs_create_group(kobj, grp)); | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
why remove the comment? :)