Blame view
include/linux/sysdev.h
4.78 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 |
/** * System devices follow a slightly different driver model. * They don't need to do dynammic driver binding, can't be probed, * and don't reside on any type of peripheral bus. * So, we represent and treat them a little differently. * * We still have a notion of a driver for a system device, because we still * want to perform basic operations on these devices. * |
25985edce Fix common misspe... |
10 |
* We also support auxiliary drivers binding to devices of a certain class. |
1da177e4c Linux-2.6.12-rc2 |
11 12 13 14 15 |
* * This allows configurable drivers to register themselves for devices of * a certain type. And, it allows class definitions to reside in generic * code while arch-specific code can register specific drivers. * |
25985edce Fix common misspe... |
16 |
* Auxiliary drivers registered with a NULL cls are registered as drivers |
1da177e4c Linux-2.6.12-rc2 |
17 18 19 20 21 22 23 24 |
* for all system devices, and get notification calls for each device. */ #ifndef _SYSDEV_H_ #define _SYSDEV_H_ #include <linux/kobject.h> |
438510f6f [PATCH] pm_messag... |
25 |
#include <linux/pm.h> |
1da177e4c Linux-2.6.12-rc2 |
26 27 28 |
struct sys_device; |
38457ab3a sysfs: Add attrib... |
29 |
struct sysdev_class_attribute; |
1da177e4c Linux-2.6.12-rc2 |
30 31 |
struct sysdev_class { |
af5ca3f4e Driver core: chan... |
32 |
const char *name; |
1da177e4c Linux-2.6.12-rc2 |
33 |
struct list_head drivers; |
38457ab3a sysfs: Add attrib... |
34 |
struct sysdev_class_attribute **attrs; |
d47d81c0e Introduce ARCH_NO... |
35 |
struct kset kset; |
1da177e4c Linux-2.6.12-rc2 |
36 |
}; |
670dd90d8 [PATCH] Driver Co... |
37 38 |
struct sysdev_class_attribute { struct attribute attr; |
c9be0a36f sysdev: Pass attr... |
39 40 41 42 |
ssize_t (*show)(struct sysdev_class *, struct sysdev_class_attribute *, char *); ssize_t (*store)(struct sysdev_class *, struct sysdev_class_attribute *, const char *, size_t); |
670dd90d8 [PATCH] Driver Co... |
43 |
}; |
9d1fe3236 cpumask: add show... |
44 45 |
#define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \ { \ |
670dd90d8 [PATCH] Driver Co... |
46 47 48 |
.attr = {.name = __stringify(_name), .mode = _mode }, \ .show = _show, \ .store = _store, \ |
9d1fe3236 cpumask: add show... |
49 50 51 52 53 |
} #define SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \ struct sysdev_class_attribute attr_##_name = \ _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) |
670dd90d8 [PATCH] Driver Co... |
54 |
|
1da177e4c Linux-2.6.12-rc2 |
55 56 57 |
extern int sysdev_class_register(struct sysdev_class *); extern void sysdev_class_unregister(struct sysdev_class *); |
670dd90d8 [PATCH] Driver Co... |
58 59 60 61 |
extern int sysdev_class_create_file(struct sysdev_class *, struct sysdev_class_attribute *); extern void sysdev_class_remove_file(struct sysdev_class *, struct sysdev_class_attribute *); |
1da177e4c Linux-2.6.12-rc2 |
62 |
/** |
25985edce Fix common misspe... |
63 |
* Auxiliary system device drivers. |
1da177e4c Linux-2.6.12-rc2 |
64 65 66 67 68 69 |
*/ struct sysdev_driver { struct list_head entry; int (*add)(struct sys_device *); int (*remove)(struct sys_device *); |
1da177e4c Linux-2.6.12-rc2 |
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
}; extern int sysdev_driver_register(struct sysdev_class *, struct sysdev_driver *); extern void sysdev_driver_unregister(struct sysdev_class *, struct sysdev_driver *); /** * sys_devices can be simplified a lot from regular devices, because they're * simply not as versatile. */ struct sys_device { u32 id; struct sysdev_class * cls; struct kobject kobj; }; extern int sysdev_register(struct sys_device *); extern void sysdev_unregister(struct sys_device *); struct sysdev_attribute { struct attribute attr; |
4a0b2b4db sysdev: Pass the ... |
94 95 96 |
ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *); ssize_t (*store)(struct sys_device *, struct sysdev_attribute *, const char *, size_t); |
1da177e4c Linux-2.6.12-rc2 |
97 |
}; |
9d1fe3236 cpumask: add show... |
98 |
#define _SYSDEV_ATTR(_name, _mode, _show, _store) \ |
7583b6e42 [POWERPC] Introdu... |
99 |
{ \ |
7b595756e sysfs: kill unnec... |
100 |
.attr = { .name = __stringify(_name), .mode = _mode }, \ |
1da177e4c Linux-2.6.12-rc2 |
101 102 |
.show = _show, \ .store = _store, \ |
7583b6e42 [POWERPC] Introdu... |
103 |
} |
9d1fe3236 cpumask: add show... |
104 105 106 |
#define SYSDEV_ATTR(_name, _mode, _show, _store) \ struct sysdev_attribute attr_##_name = \ _SYSDEV_ATTR(_name, _mode, _show, _store); |
1da177e4c Linux-2.6.12-rc2 |
107 108 109 |
extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); |
1e395ab3d sysdev: Add sysde... |
110 111 112 113 114 115 116 117 118 119 120 121 |
/* Create/remove NULL terminated attribute list */ static inline int sysdev_create_files(struct sys_device *d, struct sysdev_attribute **a) { return sysfs_create_files(&d->kobj, (const struct attribute **)a); } static inline void sysdev_remove_files(struct sys_device *d, struct sysdev_attribute **a) { return sysfs_remove_files(&d->kobj, (const struct attribute **)a); } |
9800794ac sysdev: Add utili... |
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
struct sysdev_ext_attribute { struct sysdev_attribute attr; void *var; }; /* * Support for simple variable sysdev attributes. * The pointer to the variable is stored in a sysdev_ext_attribute */ /* Add more types as needed */ extern ssize_t sysdev_show_ulong(struct sys_device *, struct sysdev_attribute *, char *); extern ssize_t sysdev_store_ulong(struct sys_device *, struct sysdev_attribute *, const char *, size_t); extern ssize_t sysdev_show_int(struct sys_device *, struct sysdev_attribute *, char *); extern ssize_t sysdev_store_int(struct sys_device *, struct sysdev_attribute *, const char *, size_t); #define _SYSDEV_ULONG_ATTR(_name, _mode, _var) \ { _SYSDEV_ATTR(_name, _mode, sysdev_show_ulong, sysdev_store_ulong), \ &(_var) } #define SYSDEV_ULONG_ATTR(_name, _mode, _var) \ struct sysdev_ext_attribute attr_##_name = \ _SYSDEV_ULONG_ATTR(_name, _mode, _var); #define _SYSDEV_INT_ATTR(_name, _mode, _var) \ { _SYSDEV_ATTR(_name, _mode, sysdev_show_int, sysdev_store_int), \ &(_var) } #define SYSDEV_INT_ATTR(_name, _mode, _var) \ struct sysdev_ext_attribute attr_##_name = \ _SYSDEV_INT_ATTR(_name, _mode, _var); |
1da177e4c Linux-2.6.12-rc2 |
155 |
#endif /* _SYSDEV_H_ */ |