This source file includes following definitions.
- transport_class_register
- transport_class_unregister
- anon_transport_dummy_function
- anon_transport_class_register
- anon_transport_class_unregister
- transport_setup_classdev
- transport_setup_device
- transport_add_class_device
- transport_add_device
- transport_configure
- transport_configure_device
- transport_remove_classdev
- transport_remove_device
- transport_destroy_classdev
- transport_destroy_device
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #include <linux/export.h>
30 #include <linux/attribute_container.h>
31 #include <linux/transport_class.h>
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 int transport_class_register(struct transport_class *tclass)
48 {
49 return class_register(&tclass->class);
50 }
51 EXPORT_SYMBOL_GPL(transport_class_register);
52
53
54
55
56
57
58
59
60
61 void transport_class_unregister(struct transport_class *tclass)
62 {
63 class_unregister(&tclass->class);
64 }
65 EXPORT_SYMBOL_GPL(transport_class_unregister);
66
67 static int anon_transport_dummy_function(struct transport_container *tc,
68 struct device *dev,
69 struct device *cdev)
70 {
71
72 return 0;
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87 int anon_transport_class_register(struct anon_transport_class *atc)
88 {
89 int error;
90 atc->container.class = &atc->tclass.class;
91 attribute_container_set_no_classdevs(&atc->container);
92 error = attribute_container_register(&atc->container);
93 if (error)
94 return error;
95 atc->tclass.setup = anon_transport_dummy_function;
96 atc->tclass.remove = anon_transport_dummy_function;
97 return 0;
98 }
99 EXPORT_SYMBOL_GPL(anon_transport_class_register);
100
101
102
103
104
105
106
107
108
109 void anon_transport_class_unregister(struct anon_transport_class *atc)
110 {
111 if (unlikely(attribute_container_unregister(&atc->container)))
112 BUG();
113 }
114 EXPORT_SYMBOL_GPL(anon_transport_class_unregister);
115
116 static int transport_setup_classdev(struct attribute_container *cont,
117 struct device *dev,
118 struct device *classdev)
119 {
120 struct transport_class *tclass = class_to_transport_class(cont->class);
121 struct transport_container *tcont = attribute_container_to_transport_container(cont);
122
123 if (tclass->setup)
124 tclass->setup(tcont, dev, classdev);
125
126 return 0;
127 }
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144 void transport_setup_device(struct device *dev)
145 {
146 attribute_container_add_device(dev, transport_setup_classdev);
147 }
148 EXPORT_SYMBOL_GPL(transport_setup_device);
149
150 static int transport_add_class_device(struct attribute_container *cont,
151 struct device *dev,
152 struct device *classdev)
153 {
154 int error = attribute_container_add_class_device(classdev);
155 struct transport_container *tcont =
156 attribute_container_to_transport_container(cont);
157
158 if (!error && tcont->statistics)
159 error = sysfs_create_group(&classdev->kobj, tcont->statistics);
160
161 return error;
162 }
163
164
165
166
167
168
169
170
171
172
173
174
175
176 void transport_add_device(struct device *dev)
177 {
178 attribute_container_device_trigger(dev, transport_add_class_device);
179 }
180 EXPORT_SYMBOL_GPL(transport_add_device);
181
182 static int transport_configure(struct attribute_container *cont,
183 struct device *dev,
184 struct device *cdev)
185 {
186 struct transport_class *tclass = class_to_transport_class(cont->class);
187 struct transport_container *tcont = attribute_container_to_transport_container(cont);
188
189 if (tclass->configure)
190 tclass->configure(tcont, dev, cdev);
191
192 return 0;
193 }
194
195
196
197
198
199
200
201
202
203
204
205
206
207 void transport_configure_device(struct device *dev)
208 {
209 attribute_container_device_trigger(dev, transport_configure);
210 }
211 EXPORT_SYMBOL_GPL(transport_configure_device);
212
213 static int transport_remove_classdev(struct attribute_container *cont,
214 struct device *dev,
215 struct device *classdev)
216 {
217 struct transport_container *tcont =
218 attribute_container_to_transport_container(cont);
219 struct transport_class *tclass = class_to_transport_class(cont->class);
220
221 if (tclass->remove)
222 tclass->remove(tcont, dev, classdev);
223
224 if (tclass->remove != anon_transport_dummy_function) {
225 if (tcont->statistics)
226 sysfs_remove_group(&classdev->kobj, tcont->statistics);
227 attribute_container_class_device_del(classdev);
228 }
229
230 return 0;
231 }
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246 void transport_remove_device(struct device *dev)
247 {
248 attribute_container_device_trigger(dev, transport_remove_classdev);
249 }
250 EXPORT_SYMBOL_GPL(transport_remove_device);
251
252 static void transport_destroy_classdev(struct attribute_container *cont,
253 struct device *dev,
254 struct device *classdev)
255 {
256 struct transport_class *tclass = class_to_transport_class(cont->class);
257
258 if (tclass->remove != anon_transport_dummy_function)
259 put_device(classdev);
260 }
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 void transport_destroy_device(struct device *dev)
276 {
277 attribute_container_remove_device(dev, transport_destroy_classdev);
278 }
279 EXPORT_SYMBOL_GPL(transport_destroy_device);