source: svn/trunk/newcon3bcm2_21bu/toolchain/mipsel-linux-uclibc/include/linux/sysdev.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1/**
2 * System devices follow a slightly different driver model.
3 * They don't need to do dynammic driver binding, can't be probed,
4 * and don't reside on any type of peripheral bus.
5 * So, we represent and treat them a little differently.
6 *
7 * We still have a notion of a driver for a system device, because we still
8 * want to perform basic operations on these devices.
9 *
10 * We also support auxillary drivers binding to devices of a certain class.
11 *
12 * This allows configurable drivers to register themselves for devices of
13 * a certain type. And, it allows class definitions to reside in generic
14 * code while arch-specific code can register specific drivers.
15 *
16 * Auxillary drivers registered with a NULL cls are registered as drivers
17 * for all system devices, and get notification calls for each device.
18 */
19
20
21#ifndef _SYSDEV_H_
22#define _SYSDEV_H_
23
24#include <asm/types.h>
25
26#include <linux/kobject.h>
27
28
29struct sys_device;
30
31struct sysdev_class {
32        struct list_head        drivers;
33
34        /* Default operations for these types of devices */
35        int     (*shutdown)(struct sys_device *);
36        int     (*suspend)(struct sys_device *, pm_message_t state);
37        int     (*resume)(struct sys_device *);
38        struct kset             kset;
39};
40
41
42extern int sysdev_class_register(struct sysdev_class *);
43extern void sysdev_class_unregister(struct sysdev_class *);
44
45
46/**
47 * Auxillary system device drivers.
48 */
49
50struct sysdev_driver {
51        struct list_head        entry;
52        int     (*add)(struct sys_device *);
53        int     (*remove)(struct sys_device *);
54        int     (*shutdown)(struct sys_device *);
55        int     (*suspend)(struct sys_device *, pm_message_t state);
56        int     (*resume)(struct sys_device *);
57};
58
59
60extern int sysdev_driver_register(struct sysdev_class *, struct sysdev_driver *);
61extern void sysdev_driver_unregister(struct sysdev_class *, struct sysdev_driver *);
62
63
64/**
65 * sys_devices can be simplified a lot from regular devices, because they're
66 * simply not as versatile.
67 */
68
69struct sys_device {
70        __u32           id;
71        struct sysdev_class     * cls;
72        struct kobject          kobj;
73};
74
75extern int sysdev_register(struct sys_device *);
76extern void sysdev_unregister(struct sys_device *);
77
78
79struct sysdev_attribute { 
80        struct attribute        attr;
81        ssize_t (*show)(struct sys_device *, char *);
82        ssize_t (*store)(struct sys_device *, const char *, size_t);
83};
84
85
86#define SYSDEV_ATTR(_name,_mode,_show,_store)           \
87struct sysdev_attribute attr_##_name = {                        \
88        .attr = {.name = __stringify(_name), .mode = _mode },   \
89        .show   = _show,                                        \
90        .store  = _store,                                       \
91};
92
93extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
94extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
95
96#endif /* _SYSDEV_H_ */
Note: See TracBrowser for help on using the repository browser.