1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef _SYSDEV_H_
22#define _SYSDEV_H_
23
24#include <linux/kobject.h>
25
26
27struct sys_device;
28
29struct sysdev_class {
30 struct list_head drivers;
31
32
33 int (*shutdown)(struct sys_device *);
34 int (*suspend)(struct sys_device *, u32 state);
35 int (*resume)(struct sys_device *);
36 struct kset kset;
37};
38
39
40extern int sysdev_class_register(struct sysdev_class *);
41extern void sysdev_class_unregister(struct sysdev_class *);
42
43
44
45
46
47
48struct sysdev_driver {
49 struct list_head entry;
50 int (*add)(struct sys_device *);
51 int (*remove)(struct sys_device *);
52 int (*shutdown)(struct sys_device *);
53 int (*suspend)(struct sys_device *, u32 state);
54 int (*resume)(struct sys_device *);
55};
56
57
58extern int sysdev_driver_register(struct sysdev_class *, struct sysdev_driver *);
59extern void sysdev_driver_unregister(struct sysdev_class *, struct sysdev_driver *);
60
61
62
63
64
65
66
67struct sys_device {
68 u32 id;
69 struct sysdev_class * cls;
70 struct kobject kobj;
71};
72
73extern int sysdev_register(struct sys_device *);
74extern void sysdev_unregister(struct sys_device *);
75
76
77struct sysdev_attribute {
78 struct attribute attr;
79 ssize_t (*show)(struct sys_device *, char *);
80 ssize_t (*store)(struct sys_device *, const char *, size_t);
81};
82
83
84#define SYSDEV_ATTR(_name,_mode,_show,_store) \
85struct sysdev_attribute attr_##_name = { \
86 .attr = {.name = __stringify(_name), .mode = _mode }, \
87 .show = _show, \
88 .store = _store, \
89};
90
91extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
92extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
93
94#endif
95