Root/
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/bug.h> |
14 | #include <linux/attribute_container.h> |
15 | |
16 | struct transport_container; |
17 | |
18 | struct transport_class { |
19 | struct class class; |
20 | int (*setup)(struct transport_container *, struct device *, |
21 | struct device *); |
22 | int (*configure)(struct transport_container *, struct device *, |
23 | struct device *); |
24 | int (*remove)(struct transport_container *, struct device *, |
25 | struct device *); |
26 | }; |
27 | |
28 | #define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \ |
29 | struct transport_class cls = { \ |
30 | .class = { \ |
31 | .name = nm, \ |
32 | }, \ |
33 | .setup = su, \ |
34 | .remove = rm, \ |
35 | .configure = cfg, \ |
36 | } |
37 | |
38 | |
39 | struct anon_transport_class { |
40 | struct transport_class tclass; |
41 | struct attribute_container container; |
42 | }; |
43 | |
44 | #define DECLARE_ANON_TRANSPORT_CLASS(cls, mtch, cfg) \ |
45 | struct anon_transport_class cls = { \ |
46 | .tclass = { \ |
47 | .configure = cfg, \ |
48 | }, \ |
49 | . container = { \ |
50 | .match = mtch, \ |
51 | }, \ |
52 | } |
53 | |
54 | #define class_to_transport_class(x) \ |
55 | container_of(x, struct transport_class, class) |
56 | |
57 | struct transport_container { |
58 | struct attribute_container ac; |
59 | const struct attribute_group *statistics; |
60 | }; |
61 | |
62 | #define attribute_container_to_transport_container(x) \ |
63 | container_of(x, struct transport_container, ac) |
64 | |
65 | void transport_remove_device(struct device *); |
66 | void transport_add_device(struct device *); |
67 | void transport_setup_device(struct device *); |
68 | void transport_configure_device(struct device *); |
69 | void transport_destroy_device(struct device *); |
70 | |
71 | static inline void |
72 | transport_register_device(struct device *dev) |
73 | { |
74 | transport_setup_device(dev); |
75 | transport_add_device(dev); |
76 | } |
77 | |
78 | static inline void |
79 | transport_unregister_device(struct device *dev) |
80 | { |
81 | transport_remove_device(dev); |
82 | transport_destroy_device(dev); |
83 | } |
84 | |
85 | static inline int transport_container_register(struct transport_container *tc) |
86 | { |
87 | return attribute_container_register(&tc->ac); |
88 | } |
89 | |
90 | static inline void transport_container_unregister(struct transport_container *tc) |
91 | { |
92 | if (unlikely(attribute_container_unregister(&tc->ac))) |
93 | BUG(); |
94 | } |
95 | |
96 | int transport_class_register(struct transport_class *); |
97 | int anon_transport_class_register(struct anon_transport_class *); |
98 | void transport_class_unregister(struct transport_class *); |
99 | void anon_transport_class_unregister(struct anon_transport_class *); |
100 | |
101 | |
102 | #endif |
103 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9