Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/kobject.h
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
struct kobj_attribute { | struct kobj_attribute { | ||||
struct attribute attr; | struct attribute attr; | ||||
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, | ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, | ||||
char *buf); | char *buf); | ||||
ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr, | ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr, | ||||
const char *buf, size_t count); | const char *buf, size_t count); | ||||
}; | }; | ||||
int lkpi_kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list); | |||||
int lkpi_kobject_add(struct kobject *kobj, struct kobject *parent, | |||||
const char *fmt, ...); | |||||
int lkpi_kobject_set_name(struct kobject *kobj, const char *fmt, ...); | |||||
int lkpi_kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype, | |||||
struct kobject *parent, const char *fmt, ...); | |||||
void lkpi_kobject_kfree_name(struct kobject *kobj); | |||||
int lkpi_kobject_add_complete(struct kobject *kobj, struct kobject *parent); | |||||
void lkpi_kobject_release(struct kref *kref); | |||||
#define kobject_set_name_vargs(kobj, fmt, va) \ | |||||
lkpi_kobject_set_name_vargs(kobj, fmt, va) | |||||
#define kobject_add(kobj, parent, fmt, ...) \ | |||||
lkpi_kobject_add(kobj, parent, fmt, ##__VA_ARGS__) | |||||
#define kobject_set_name(kobj, fmt, ...) \ | |||||
lkpi_kobject_set_name(kobj, fmt, ##__VA_ARGS__) | |||||
#define kobject_init_and_add(kobj, ktype, parent, fmt, ...) \ | |||||
lkpi_kobject_init_and_add(kobj, ktype, parent, fmt, ##__VA_ARGS__) | |||||
#define kobject_kfree_name(kobj) \ | |||||
lkpi_kobject_kfree_name(kobj) | |||||
#define kobject_add_complete(kobj, parent) \ | |||||
lkpi_kobject_add_complete(kobj, parent) | |||||
#define kobject_release(kobj) \ | |||||
lkpi_kobject_release(kobj) | |||||
static inline void | static inline void | ||||
kobject_init(struct kobject *kobj, const struct kobj_type *ktype) | kobject_init(struct kobject *kobj, const struct kobj_type *ktype) | ||||
{ | { | ||||
kref_init(&kobj->kref); | kref_init(&kobj->kref); | ||||
INIT_LIST_HEAD(&kobj->entry); | INIT_LIST_HEAD(&kobj->entry); | ||||
kobj->ktype = ktype; | kobj->ktype = ktype; | ||||
kobj->oidp = NULL; | kobj->oidp = NULL; | ||||
} | } | ||||
void linux_kobject_release(struct kref *kref); | |||||
static inline void | static inline void | ||||
kobject_put(struct kobject *kobj) | kobject_put(struct kobject *kobj) | ||||
{ | { | ||||
if (kobj) | if (kobj) | ||||
kref_put(&kobj->kref, linux_kobject_release); | kref_put(&kobj->kref, lkpi_kobject_release); | ||||
} | } | ||||
static inline struct kobject * | static inline struct kobject * | ||||
kobject_get(struct kobject *kobj) | kobject_get(struct kobject *kobj) | ||||
{ | { | ||||
if (kobj) | if (kobj) | ||||
kref_get(&kobj->kref); | kref_get(&kobj->kref); | ||||
return kobj; | return kobj; | ||||
} | } | ||||
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list); | |||||
int kobject_add(struct kobject *kobj, struct kobject *parent, | |||||
const char *fmt, ...); | |||||
static inline struct kobject * | static inline struct kobject * | ||||
kobject_create(void) | kobject_create(void) | ||||
{ | { | ||||
struct kobject *kobj; | struct kobject *kobj; | ||||
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); | kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); | ||||
if (kobj == NULL) | if (kobj == NULL) | ||||
return (NULL); | return (NULL); | ||||
Show All 23 Lines | |||||
} | } | ||||
static inline char * | static inline char * | ||||
kobject_name(const struct kobject *kobj) | kobject_name(const struct kobject *kobj) | ||||
{ | { | ||||
return kobj->name; | return kobj->name; | ||||
} | } | ||||
int kobject_set_name(struct kobject *kobj, const char *fmt, ...); | |||||
int kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype, | |||||
struct kobject *parent, const char *fmt, ...); | |||||
#endif /* _LINUX_KOBJECT_H_ */ | #endif /* _LINUX_KOBJECT_H_ */ |