Blame view
include/linux/sysfs.h
5.67 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 |
/* * sysfs.h - definitions for the device driver filesystem * * Copyright (c) 2001,2002 Patrick Mochel * Copyright (c) 2004 Silicon Graphics, Inc. |
6d66f5cd2 sysfs: add copyri... |
6 7 |
* Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo <teheo@suse.de> |
1da177e4c Linux-2.6.12-rc2 |
8 9 10 11 12 13 |
* * Please see Documentation/filesystems/sysfs.txt for more information. */ #ifndef _SYSFS_H_ #define _SYSFS_H_ |
4a7fb6363 add __must_check ... |
14 |
#include <linux/compiler.h> |
5851fadce [PATCH] Fix build... |
15 |
#include <linux/errno.h> |
bf0acc330 SYSFS: Fix missin... |
16 |
#include <linux/list.h> |
1da177e4c Linux-2.6.12-rc2 |
17 18 19 20 |
#include <asm/atomic.h> struct kobject; struct module; |
7b595756e sysfs: kill unnec... |
21 22 23 24 |
/* FIXME * The *owner field is no longer used, but leave around * until the tree gets cleaned up fully. */ |
1da177e4c Linux-2.6.12-rc2 |
25 |
struct attribute { |
59f690156 sysfs: clean up h... |
26 27 |
const char *name; struct module *owner; |
1da177e4c Linux-2.6.12-rc2 |
28 29 30 31 |
mode_t mode; }; struct attribute_group { |
59f690156 sysfs: clean up h... |
32 |
const char *name; |
0f4238958 [SCSI] sysfs: mak... |
33 |
mode_t (*is_visible)(struct kobject *, |
d4acd722b [SCSI] sysfs: add... |
34 |
struct attribute *, int); |
59f690156 sysfs: clean up h... |
35 |
struct attribute **attrs; |
1da177e4c Linux-2.6.12-rc2 |
36 37 38 39 40 41 42 43 44 45 |
}; /** * Use these macros to make defining attributes easier. See include/linux/device.h * for examples.. */ #define __ATTR(_name,_mode,_show,_store) { \ |
7b595756e sysfs: kill unnec... |
46 |
.attr = {.name = __stringify(_name), .mode = _mode }, \ |
1da177e4c Linux-2.6.12-rc2 |
47 48 49 50 51 |
.show = _show, \ .store = _store, \ } #define __ATTR_RO(_name) { \ |
7b595756e sysfs: kill unnec... |
52 53 |
.attr = { .name = __stringify(_name), .mode = 0444 }, \ .show = _name##_show, \ |
1da177e4c Linux-2.6.12-rc2 |
54 55 56 57 58 59 60 61 62 63 64 65 |
} #define __ATTR_NULL { .attr = { .name = NULL } } #define attr_name(_attr) (_attr).attr.name struct vm_area_struct; struct bin_attribute { struct attribute attr; size_t size; void *private; |
91a690295 sysfs: add parame... |
66 67 68 69 |
ssize_t (*read)(struct kobject *, struct bin_attribute *, char *, loff_t, size_t); ssize_t (*write)(struct kobject *, struct bin_attribute *, char *, loff_t, size_t); |
1da177e4c Linux-2.6.12-rc2 |
70 71 72 73 74 75 76 77 |
int (*mmap)(struct kobject *, struct bin_attribute *attr, struct vm_area_struct *vma); }; struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *,char *); ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); }; |
1da177e4c Linux-2.6.12-rc2 |
78 |
#ifdef CONFIG_SYSFS |
59f690156 sysfs: clean up h... |
79 80 |
int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), void *data, struct module *owner); |
1da177e4c Linux-2.6.12-rc2 |
81 |
|
59f690156 sysfs: clean up h... |
82 83 84 85 86 |
int __must_check sysfs_create_dir(struct kobject *kobj); void sysfs_remove_dir(struct kobject *kobj); int __must_check sysfs_rename_dir(struct kobject *kobj, const char *new_name); int __must_check sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj); |
31e5abe9a [PATCH] sysfs: ad... |
87 |
|
59f690156 sysfs: clean up h... |
88 89 |
int __must_check sysfs_create_file(struct kobject *kobj, const struct attribute *attr); |
59f690156 sysfs: clean up h... |
90 91 92 |
int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode); void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); |
1da177e4c Linux-2.6.12-rc2 |
93 |
|
4a7fb6363 add __must_check ... |
94 |
int __must_check sysfs_create_bin_file(struct kobject *kobj, |
59f690156 sysfs: clean up h... |
95 |
struct bin_attribute *attr); |
995982ca7 sysfs_remove_bin_... |
96 |
void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr); |
1da177e4c Linux-2.6.12-rc2 |
97 |
|
59f690156 sysfs: clean up h... |
98 99 |
int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, const char *name); |
36ce6dad6 driver core: Supp... |
100 101 102 |
int __must_check sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target, const char *name); |
59f690156 sysfs: clean up h... |
103 104 105 106 |
void sysfs_remove_link(struct kobject *kobj, const char *name); int __must_check sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp); |
0f4238958 [SCSI] sysfs: mak... |
107 108 |
int sysfs_update_group(struct kobject *kobj, const struct attribute_group *grp); |
59f690156 sysfs: clean up h... |
109 110 |
void sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp); |
dfa87c824 sysfs: allow attr... |
111 |
int sysfs_add_file_to_group(struct kobject *kobj, |
59f690156 sysfs: clean up h... |
112 |
const struct attribute *attr, const char *group); |
dfa87c824 sysfs: allow attr... |
113 |
void sysfs_remove_file_from_group(struct kobject *kobj, |
59f690156 sysfs: clean up h... |
114 |
const struct attribute *attr, const char *group); |
dfa87c824 sysfs: allow attr... |
115 |
|
59f690156 sysfs: clean up h... |
116 |
void sysfs_notify(struct kobject *kobj, char *dir, char *attr); |
1da177e4c Linux-2.6.12-rc2 |
117 |
|
f20a9ead0 sysfs: add proper... |
118 |
extern int __must_check sysfs_init(void); |
1da177e4c Linux-2.6.12-rc2 |
119 |
#else /* CONFIG_SYSFS */ |
d9a9cdfb0 [PATCH] sysfs and... |
120 |
static inline int sysfs_schedule_callback(struct kobject *kobj, |
523ded71d device_schedule_c... |
121 |
void (*func)(void *), void *data, struct module *owner) |
d9a9cdfb0 [PATCH] sysfs and... |
122 123 124 |
{ return -ENOSYS; } |
59f690156 sysfs: clean up h... |
125 |
static inline int sysfs_create_dir(struct kobject *kobj) |
1da177e4c Linux-2.6.12-rc2 |
126 127 128 |
{ return 0; } |
59f690156 sysfs: clean up h... |
129 |
static inline void sysfs_remove_dir(struct kobject *kobj) |
1da177e4c Linux-2.6.12-rc2 |
130 |
{ |
1da177e4c Linux-2.6.12-rc2 |
131 |
} |
59f690156 sysfs: clean up h... |
132 |
static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name) |
1da177e4c Linux-2.6.12-rc2 |
133 134 135 |
{ return 0; } |
59f690156 sysfs: clean up h... |
136 137 |
static inline int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) |
8a82472f8 driver core: Intr... |
138 139 140 |
{ return 0; } |
59f690156 sysfs: clean up h... |
141 142 |
static inline int sysfs_create_file(struct kobject *kobj, const struct attribute *attr) |
1da177e4c Linux-2.6.12-rc2 |
143 144 145 |
{ return 0; } |
59f690156 sysfs: clean up h... |
146 147 |
static inline int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) |
31e5abe9a [PATCH] sysfs: ad... |
148 149 150 |
{ return 0; } |
1da177e4c Linux-2.6.12-rc2 |
151 |
|
59f690156 sysfs: clean up h... |
152 153 |
static inline void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr) |
1da177e4c Linux-2.6.12-rc2 |
154 |
{ |
1da177e4c Linux-2.6.12-rc2 |
155 |
} |
59f690156 sysfs: clean up h... |
156 157 |
static inline int sysfs_create_bin_file(struct kobject *kobj, struct bin_attribute *attr) |
1da177e4c Linux-2.6.12-rc2 |
158 159 160 |
{ return 0; } |
3612e06b2 sysfs: small head... |
161 162 |
static inline void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr) |
1da177e4c Linux-2.6.12-rc2 |
163 |
{ |
1da177e4c Linux-2.6.12-rc2 |
164 |
} |
59f690156 sysfs: clean up h... |
165 166 |
static inline int sysfs_create_link(struct kobject *kobj, struct kobject *target, const char *name) |
1da177e4c Linux-2.6.12-rc2 |
167 168 169 |
{ return 0; } |
36ce6dad6 driver core: Supp... |
170 171 172 173 174 175 |
static inline int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target, const char *name) { return 0; } |
59f690156 sysfs: clean up h... |
176 |
static inline void sysfs_remove_link(struct kobject *kobj, const char *name) |
1da177e4c Linux-2.6.12-rc2 |
177 |
{ |
1da177e4c Linux-2.6.12-rc2 |
178 |
} |
59f690156 sysfs: clean up h... |
179 180 |
static inline int sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp) |
1da177e4c Linux-2.6.12-rc2 |
181 182 183 |
{ return 0; } |
1cbfb7a5a sysfs: sysfs_upda... |
184 185 186 187 188 |
static inline int sysfs_update_group(struct kobject *kobj, const struct attribute_group *grp) { return 0; } |
59f690156 sysfs: clean up h... |
189 190 |
static inline void sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp) |
1da177e4c Linux-2.6.12-rc2 |
191 |
{ |
1da177e4c Linux-2.6.12-rc2 |
192 |
} |
dfa87c824 sysfs: allow attr... |
193 194 195 196 197 198 199 |
static inline int sysfs_add_file_to_group(struct kobject *kobj, const struct attribute *attr, const char *group) { return 0; } static inline void sysfs_remove_file_from_group(struct kobject *kobj, |
d701d8a3b [PATCH] Fix sysfs... |
200 |
const struct attribute *attr, const char *group) |
dfa87c824 sysfs: allow attr... |
201 |
{ |
dfa87c824 sysfs: allow attr... |
202 |
} |
59f690156 sysfs: clean up h... |
203 |
static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) |
4508a7a73 [PATCH] sysfs: Al... |
204 205 |
{ } |
f20a9ead0 sysfs: add proper... |
206 207 208 209 |
static inline int __must_check sysfs_init(void) { return 0; } |
1da177e4c Linux-2.6.12-rc2 |
210 211 212 |
#endif /* CONFIG_SYSFS */ #endif /* _SYSFS_H_ */ |