diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/transport_class.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/linux/transport_class.h')
-rw-r--r-- | include/linux/transport_class.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h new file mode 100644 index 000000000000..87d98d1faefb --- /dev/null +++ b/include/linux/transport_class.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * transport_class.h - a generic container for all transport classes | ||
3 | * | ||
4 | * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> | ||
5 | * | ||
6 | * This file is licensed under GPLv2 | ||
7 | */ | ||
8 | |||
9 | #ifndef _TRANSPORT_CLASS_H_ | ||
10 | #define _TRANSPORT_CLASS_H_ | ||
11 | |||
12 | #include <linux/device.h> | ||
13 | #include <linux/attribute_container.h> | ||
14 | |||
15 | struct transport_class { | ||
16 | struct class class; | ||
17 | int (*setup)(struct device *); | ||
18 | int (*configure)(struct device *); | ||
19 | int (*remove)(struct device *); | ||
20 | }; | ||
21 | |||
22 | #define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \ | ||
23 | struct transport_class cls = { \ | ||
24 | .class = { \ | ||
25 | .name = nm, \ | ||
26 | }, \ | ||
27 | .setup = su, \ | ||
28 | .remove = rm, \ | ||
29 | .configure = cfg, \ | ||
30 | } | ||
31 | |||
32 | |||
33 | struct anon_transport_class { | ||
34 | struct transport_class tclass; | ||
35 | struct attribute_container container; | ||
36 | }; | ||
37 | |||
38 | #define DECLARE_ANON_TRANSPORT_CLASS(cls, mtch, cfg) \ | ||
39 | struct anon_transport_class cls = { \ | ||
40 | .tclass = { \ | ||
41 | .configure = cfg, \ | ||
42 | }, \ | ||
43 | . container = { \ | ||
44 | .match = mtch, \ | ||
45 | }, \ | ||
46 | } | ||
47 | |||
48 | #define class_to_transport_class(x) \ | ||
49 | container_of(x, struct transport_class, class) | ||
50 | |||
51 | struct transport_container { | ||
52 | struct attribute_container ac; | ||
53 | struct attribute_group *statistics; | ||
54 | }; | ||
55 | |||
56 | #define attribute_container_to_transport_container(x) \ | ||
57 | container_of(x, struct transport_container, ac) | ||
58 | |||
59 | void transport_remove_device(struct device *); | ||
60 | void transport_add_device(struct device *); | ||
61 | void transport_setup_device(struct device *); | ||
62 | void transport_configure_device(struct device *); | ||
63 | void transport_destroy_device(struct device *); | ||
64 | |||
65 | static inline void | ||
66 | transport_register_device(struct device *dev) | ||
67 | { | ||
68 | transport_setup_device(dev); | ||
69 | transport_add_device(dev); | ||
70 | } | ||
71 | |||
72 | static inline void | ||
73 | transport_unregister_device(struct device *dev) | ||
74 | { | ||
75 | transport_remove_device(dev); | ||
76 | transport_destroy_device(dev); | ||
77 | } | ||
78 | |||
79 | static inline int transport_container_register(struct transport_container *tc) | ||
80 | { | ||
81 | return attribute_container_register(&tc->ac); | ||
82 | } | ||
83 | |||
84 | static inline int transport_container_unregister(struct transport_container *tc) | ||
85 | { | ||
86 | return attribute_container_unregister(&tc->ac); | ||
87 | } | ||
88 | |||
89 | int transport_class_register(struct transport_class *); | ||
90 | int anon_transport_class_register(struct anon_transport_class *); | ||
91 | void transport_class_unregister(struct transport_class *); | ||
92 | void anon_transport_class_unregister(struct anon_transport_class *); | ||
93 | |||
94 | |||
95 | #endif | ||