diff options
author | Tony Jones <tonyj@suse.de> | 2008-02-21 18:13:36 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-19 22:10:33 -0400 |
commit | ee959b00c335d7780136c5abda37809191fe52c3 (patch) | |
tree | 7775f3b274fd8caf5e7e5154fea89e96f2babd94 /drivers/base | |
parent | 56d110e852b0b1c85ad6c9bfe1cb4473ceb16402 (diff) |
SCSI: convert struct class_device to struct device
It's big, but there doesn't seem to be a way to split it up smaller...
Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/attribute_container.c | 77 | ||||
-rw-r--r-- | drivers/base/transport_class.c | 14 |
2 files changed, 45 insertions, 46 deletions
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 3b43e8a9f87e..f57652db0a2a 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c | |||
@@ -27,21 +27,21 @@ | |||
27 | struct internal_container { | 27 | struct internal_container { |
28 | struct klist_node node; | 28 | struct klist_node node; |
29 | struct attribute_container *cont; | 29 | struct attribute_container *cont; |
30 | struct class_device classdev; | 30 | struct device classdev; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static void internal_container_klist_get(struct klist_node *n) | 33 | static void internal_container_klist_get(struct klist_node *n) |
34 | { | 34 | { |
35 | struct internal_container *ic = | 35 | struct internal_container *ic = |
36 | container_of(n, struct internal_container, node); | 36 | container_of(n, struct internal_container, node); |
37 | class_device_get(&ic->classdev); | 37 | get_device(&ic->classdev); |
38 | } | 38 | } |
39 | 39 | ||
40 | static void internal_container_klist_put(struct klist_node *n) | 40 | static void internal_container_klist_put(struct klist_node *n) |
41 | { | 41 | { |
42 | struct internal_container *ic = | 42 | struct internal_container *ic = |
43 | container_of(n, struct internal_container, node); | 43 | container_of(n, struct internal_container, node); |
44 | class_device_put(&ic->classdev); | 44 | put_device(&ic->classdev); |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
@@ -53,7 +53,7 @@ static void internal_container_klist_put(struct klist_node *n) | |||
53 | * Returns the container associated with this classdev. | 53 | * Returns the container associated with this classdev. |
54 | */ | 54 | */ |
55 | struct attribute_container * | 55 | struct attribute_container * |
56 | attribute_container_classdev_to_container(struct class_device *classdev) | 56 | attribute_container_classdev_to_container(struct device *classdev) |
57 | { | 57 | { |
58 | struct internal_container *ic = | 58 | struct internal_container *ic = |
59 | container_of(classdev, struct internal_container, classdev); | 59 | container_of(classdev, struct internal_container, classdev); |
@@ -110,11 +110,11 @@ attribute_container_unregister(struct attribute_container *cont) | |||
110 | EXPORT_SYMBOL_GPL(attribute_container_unregister); | 110 | EXPORT_SYMBOL_GPL(attribute_container_unregister); |
111 | 111 | ||
112 | /* private function used as class release */ | 112 | /* private function used as class release */ |
113 | static void attribute_container_release(struct class_device *classdev) | 113 | static void attribute_container_release(struct device *classdev) |
114 | { | 114 | { |
115 | struct internal_container *ic | 115 | struct internal_container *ic |
116 | = container_of(classdev, struct internal_container, classdev); | 116 | = container_of(classdev, struct internal_container, classdev); |
117 | struct device *dev = classdev->dev; | 117 | struct device *dev = classdev->parent; |
118 | 118 | ||
119 | kfree(ic); | 119 | kfree(ic); |
120 | put_device(dev); | 120 | put_device(dev); |
@@ -129,12 +129,12 @@ static void attribute_container_release(struct class_device *classdev) | |||
129 | * This function allocates storage for the class device(s) to be | 129 | * This function allocates storage for the class device(s) to be |
130 | * attached to dev (one for each matching attribute_container). If no | 130 | * attached to dev (one for each matching attribute_container). If no |
131 | * fn is provided, the code will simply register the class device via | 131 | * fn is provided, the code will simply register the class device via |
132 | * class_device_add. If a function is provided, it is expected to add | 132 | * device_add. If a function is provided, it is expected to add |
133 | * the class device at the appropriate time. One of the things that | 133 | * the class device at the appropriate time. One of the things that |
134 | * might be necessary is to allocate and initialise the classdev and | 134 | * might be necessary is to allocate and initialise the classdev and |
135 | * then add it a later time. To do this, call this routine for | 135 | * then add it a later time. To do this, call this routine for |
136 | * allocation and initialisation and then use | 136 | * allocation and initialisation and then use |
137 | * attribute_container_device_trigger() to call class_device_add() on | 137 | * attribute_container_device_trigger() to call device_add() on |
138 | * it. Note: after this, the class device contains a reference to dev | 138 | * it. Note: after this, the class device contains a reference to dev |
139 | * which is not relinquished until the release of the classdev. | 139 | * which is not relinquished until the release of the classdev. |
140 | */ | 140 | */ |
@@ -142,7 +142,7 @@ void | |||
142 | attribute_container_add_device(struct device *dev, | 142 | attribute_container_add_device(struct device *dev, |
143 | int (*fn)(struct attribute_container *, | 143 | int (*fn)(struct attribute_container *, |
144 | struct device *, | 144 | struct device *, |
145 | struct class_device *)) | 145 | struct device *)) |
146 | { | 146 | { |
147 | struct attribute_container *cont; | 147 | struct attribute_container *cont; |
148 | 148 | ||
@@ -163,11 +163,11 @@ attribute_container_add_device(struct device *dev, | |||
163 | } | 163 | } |
164 | 164 | ||
165 | ic->cont = cont; | 165 | ic->cont = cont; |
166 | class_device_initialize(&ic->classdev); | 166 | device_initialize(&ic->classdev); |
167 | ic->classdev.dev = get_device(dev); | 167 | ic->classdev.parent = get_device(dev); |
168 | ic->classdev.class = cont->class; | 168 | ic->classdev.class = cont->class; |
169 | cont->class->release = attribute_container_release; | 169 | cont->class->dev_release = attribute_container_release; |
170 | strcpy(ic->classdev.class_id, dev->bus_id); | 170 | strcpy(ic->classdev.bus_id, dev->bus_id); |
171 | if (fn) | 171 | if (fn) |
172 | fn(cont, dev, &ic->classdev); | 172 | fn(cont, dev, &ic->classdev); |
173 | else | 173 | else |
@@ -195,20 +195,19 @@ attribute_container_add_device(struct device *dev, | |||
195 | * @fn: A function to call to remove the device | 195 | * @fn: A function to call to remove the device |
196 | * | 196 | * |
197 | * This routine triggers device removal. If fn is NULL, then it is | 197 | * This routine triggers device removal. If fn is NULL, then it is |
198 | * simply done via class_device_unregister (note that if something | 198 | * simply done via device_unregister (note that if something |
199 | * still has a reference to the classdev, then the memory occupied | 199 | * still has a reference to the classdev, then the memory occupied |
200 | * will not be freed until the classdev is released). If you want a | 200 | * will not be freed until the classdev is released). If you want a |
201 | * two phase release: remove from visibility and then delete the | 201 | * two phase release: remove from visibility and then delete the |
202 | * device, then you should use this routine with a fn that calls | 202 | * device, then you should use this routine with a fn that calls |
203 | * class_device_del() and then use | 203 | * device_del() and then use attribute_container_device_trigger() |
204 | * attribute_container_device_trigger() to do the final put on the | 204 | * to do the final put on the classdev. |
205 | * classdev. | ||
206 | */ | 205 | */ |
207 | void | 206 | void |
208 | attribute_container_remove_device(struct device *dev, | 207 | attribute_container_remove_device(struct device *dev, |
209 | void (*fn)(struct attribute_container *, | 208 | void (*fn)(struct attribute_container *, |
210 | struct device *, | 209 | struct device *, |
211 | struct class_device *)) | 210 | struct device *)) |
212 | { | 211 | { |
213 | struct attribute_container *cont; | 212 | struct attribute_container *cont; |
214 | 213 | ||
@@ -224,14 +223,14 @@ attribute_container_remove_device(struct device *dev, | |||
224 | continue; | 223 | continue; |
225 | 224 | ||
226 | klist_for_each_entry(ic, &cont->containers, node, &iter) { | 225 | klist_for_each_entry(ic, &cont->containers, node, &iter) { |
227 | if (dev != ic->classdev.dev) | 226 | if (dev != ic->classdev.parent) |
228 | continue; | 227 | continue; |
229 | klist_del(&ic->node); | 228 | klist_del(&ic->node); |
230 | if (fn) | 229 | if (fn) |
231 | fn(cont, dev, &ic->classdev); | 230 | fn(cont, dev, &ic->classdev); |
232 | else { | 231 | else { |
233 | attribute_container_remove_attrs(&ic->classdev); | 232 | attribute_container_remove_attrs(&ic->classdev); |
234 | class_device_unregister(&ic->classdev); | 233 | device_unregister(&ic->classdev); |
235 | } | 234 | } |
236 | } | 235 | } |
237 | } | 236 | } |
@@ -252,7 +251,7 @@ void | |||
252 | attribute_container_device_trigger(struct device *dev, | 251 | attribute_container_device_trigger(struct device *dev, |
253 | int (*fn)(struct attribute_container *, | 252 | int (*fn)(struct attribute_container *, |
254 | struct device *, | 253 | struct device *, |
255 | struct class_device *)) | 254 | struct device *)) |
256 | { | 255 | { |
257 | struct attribute_container *cont; | 256 | struct attribute_container *cont; |
258 | 257 | ||
@@ -270,7 +269,7 @@ attribute_container_device_trigger(struct device *dev, | |||
270 | } | 269 | } |
271 | 270 | ||
272 | klist_for_each_entry(ic, &cont->containers, node, &iter) { | 271 | klist_for_each_entry(ic, &cont->containers, node, &iter) { |
273 | if (dev == ic->classdev.dev) | 272 | if (dev == ic->classdev.parent) |
274 | fn(cont, dev, &ic->classdev); | 273 | fn(cont, dev, &ic->classdev); |
275 | } | 274 | } |
276 | } | 275 | } |
@@ -313,11 +312,11 @@ attribute_container_trigger(struct device *dev, | |||
313 | * attributes listed in the container | 312 | * attributes listed in the container |
314 | */ | 313 | */ |
315 | int | 314 | int |
316 | attribute_container_add_attrs(struct class_device *classdev) | 315 | attribute_container_add_attrs(struct device *classdev) |
317 | { | 316 | { |
318 | struct attribute_container *cont = | 317 | struct attribute_container *cont = |
319 | attribute_container_classdev_to_container(classdev); | 318 | attribute_container_classdev_to_container(classdev); |
320 | struct class_device_attribute **attrs = cont->attrs; | 319 | struct device_attribute **attrs = cont->attrs; |
321 | int i, error; | 320 | int i, error; |
322 | 321 | ||
323 | BUG_ON(attrs && cont->grp); | 322 | BUG_ON(attrs && cont->grp); |
@@ -329,7 +328,7 @@ attribute_container_add_attrs(struct class_device *classdev) | |||
329 | return sysfs_create_group(&classdev->kobj, cont->grp); | 328 | return sysfs_create_group(&classdev->kobj, cont->grp); |
330 | 329 | ||
331 | for (i = 0; attrs[i]; i++) { | 330 | for (i = 0; attrs[i]; i++) { |
332 | error = class_device_create_file(classdev, attrs[i]); | 331 | error = device_create_file(classdev, attrs[i]); |
333 | if (error) | 332 | if (error) |
334 | return error; | 333 | return error; |
335 | } | 334 | } |
@@ -338,18 +337,18 @@ attribute_container_add_attrs(struct class_device *classdev) | |||
338 | } | 337 | } |
339 | 338 | ||
340 | /** | 339 | /** |
341 | * attribute_container_add_class_device - same function as class_device_add | 340 | * attribute_container_add_class_device - same function as device_add |
342 | * | 341 | * |
343 | * @classdev: the class device to add | 342 | * @classdev: the class device to add |
344 | * | 343 | * |
345 | * This performs essentially the same function as class_device_add except for | 344 | * This performs essentially the same function as device_add except for |
346 | * attribute containers, namely add the classdev to the system and then | 345 | * attribute containers, namely add the classdev to the system and then |
347 | * create the attribute files | 346 | * create the attribute files |
348 | */ | 347 | */ |
349 | int | 348 | int |
350 | attribute_container_add_class_device(struct class_device *classdev) | 349 | attribute_container_add_class_device(struct device *classdev) |
351 | { | 350 | { |
352 | int error = class_device_add(classdev); | 351 | int error = device_add(classdev); |
353 | if (error) | 352 | if (error) |
354 | return error; | 353 | return error; |
355 | return attribute_container_add_attrs(classdev); | 354 | return attribute_container_add_attrs(classdev); |
@@ -364,7 +363,7 @@ attribute_container_add_class_device(struct class_device *classdev) | |||
364 | int | 363 | int |
365 | attribute_container_add_class_device_adapter(struct attribute_container *cont, | 364 | attribute_container_add_class_device_adapter(struct attribute_container *cont, |
366 | struct device *dev, | 365 | struct device *dev, |
367 | struct class_device *classdev) | 366 | struct device *classdev) |
368 | { | 367 | { |
369 | return attribute_container_add_class_device(classdev); | 368 | return attribute_container_add_class_device(classdev); |
370 | } | 369 | } |
@@ -376,11 +375,11 @@ attribute_container_add_class_device_adapter(struct attribute_container *cont, | |||
376 | * | 375 | * |
377 | */ | 376 | */ |
378 | void | 377 | void |
379 | attribute_container_remove_attrs(struct class_device *classdev) | 378 | attribute_container_remove_attrs(struct device *classdev) |
380 | { | 379 | { |
381 | struct attribute_container *cont = | 380 | struct attribute_container *cont = |
382 | attribute_container_classdev_to_container(classdev); | 381 | attribute_container_classdev_to_container(classdev); |
383 | struct class_device_attribute **attrs = cont->attrs; | 382 | struct device_attribute **attrs = cont->attrs; |
384 | int i; | 383 | int i; |
385 | 384 | ||
386 | if (!attrs && !cont->grp) | 385 | if (!attrs && !cont->grp) |
@@ -392,7 +391,7 @@ attribute_container_remove_attrs(struct class_device *classdev) | |||
392 | } | 391 | } |
393 | 392 | ||
394 | for (i = 0; attrs[i]; i++) | 393 | for (i = 0; attrs[i]; i++) |
395 | class_device_remove_file(classdev, attrs[i]); | 394 | device_remove_file(classdev, attrs[i]); |
396 | } | 395 | } |
397 | 396 | ||
398 | /** | 397 | /** |
@@ -401,13 +400,13 @@ attribute_container_remove_attrs(struct class_device *classdev) | |||
401 | * @classdev: the class device | 400 | * @classdev: the class device |
402 | * | 401 | * |
403 | * This function simply removes all the attribute files and then calls | 402 | * This function simply removes all the attribute files and then calls |
404 | * class_device_del. | 403 | * device_del. |
405 | */ | 404 | */ |
406 | void | 405 | void |
407 | attribute_container_class_device_del(struct class_device *classdev) | 406 | attribute_container_class_device_del(struct device *classdev) |
408 | { | 407 | { |
409 | attribute_container_remove_attrs(classdev); | 408 | attribute_container_remove_attrs(classdev); |
410 | class_device_del(classdev); | 409 | device_del(classdev); |
411 | } | 410 | } |
412 | 411 | ||
413 | /** | 412 | /** |
@@ -419,16 +418,16 @@ attribute_container_class_device_del(struct class_device *classdev) | |||
419 | * Looks up the device in the container's list of class devices and returns | 418 | * Looks up the device in the container's list of class devices and returns |
420 | * the corresponding class_device. | 419 | * the corresponding class_device. |
421 | */ | 420 | */ |
422 | struct class_device * | 421 | struct device * |
423 | attribute_container_find_class_device(struct attribute_container *cont, | 422 | attribute_container_find_class_device(struct attribute_container *cont, |
424 | struct device *dev) | 423 | struct device *dev) |
425 | { | 424 | { |
426 | struct class_device *cdev = NULL; | 425 | struct device *cdev = NULL; |
427 | struct internal_container *ic; | 426 | struct internal_container *ic; |
428 | struct klist_iter iter; | 427 | struct klist_iter iter; |
429 | 428 | ||
430 | klist_for_each_entry(ic, &cont->containers, node, &iter) { | 429 | klist_for_each_entry(ic, &cont->containers, node, &iter) { |
431 | if (ic->classdev.dev == dev) { | 430 | if (ic->classdev.parent == dev) { |
432 | cdev = &ic->classdev; | 431 | cdev = &ic->classdev; |
433 | /* FIXME: must exit iterator then break */ | 432 | /* FIXME: must exit iterator then break */ |
434 | klist_iter_exit(&iter); | 433 | klist_iter_exit(&iter); |
diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c index cabd0edf2156..84997efdb23d 100644 --- a/drivers/base/transport_class.c +++ b/drivers/base/transport_class.c | |||
@@ -66,7 +66,7 @@ EXPORT_SYMBOL_GPL(transport_class_unregister); | |||
66 | 66 | ||
67 | static int anon_transport_dummy_function(struct transport_container *tc, | 67 | static int anon_transport_dummy_function(struct transport_container *tc, |
68 | struct device *dev, | 68 | struct device *dev, |
69 | struct class_device *cdev) | 69 | struct device *cdev) |
70 | { | 70 | { |
71 | /* do nothing */ | 71 | /* do nothing */ |
72 | return 0; | 72 | return 0; |
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(anon_transport_class_unregister); | |||
115 | 115 | ||
116 | static int transport_setup_classdev(struct attribute_container *cont, | 116 | static int transport_setup_classdev(struct attribute_container *cont, |
117 | struct device *dev, | 117 | struct device *dev, |
118 | struct class_device *classdev) | 118 | struct device *classdev) |
119 | { | 119 | { |
120 | struct transport_class *tclass = class_to_transport_class(cont->class); | 120 | struct transport_class *tclass = class_to_transport_class(cont->class); |
121 | struct transport_container *tcont = attribute_container_to_transport_container(cont); | 121 | struct transport_container *tcont = attribute_container_to_transport_container(cont); |
@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(transport_setup_device); | |||
149 | 149 | ||
150 | static int transport_add_class_device(struct attribute_container *cont, | 150 | static int transport_add_class_device(struct attribute_container *cont, |
151 | struct device *dev, | 151 | struct device *dev, |
152 | struct class_device *classdev) | 152 | struct device *classdev) |
153 | { | 153 | { |
154 | int error = attribute_container_add_class_device(classdev); | 154 | int error = attribute_container_add_class_device(classdev); |
155 | struct transport_container *tcont = | 155 | struct transport_container *tcont = |
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(transport_add_device); | |||
181 | 181 | ||
182 | static int transport_configure(struct attribute_container *cont, | 182 | static int transport_configure(struct attribute_container *cont, |
183 | struct device *dev, | 183 | struct device *dev, |
184 | struct class_device *cdev) | 184 | struct device *cdev) |
185 | { | 185 | { |
186 | struct transport_class *tclass = class_to_transport_class(cont->class); | 186 | struct transport_class *tclass = class_to_transport_class(cont->class); |
187 | struct transport_container *tcont = attribute_container_to_transport_container(cont); | 187 | struct transport_container *tcont = attribute_container_to_transport_container(cont); |
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(transport_configure_device); | |||
212 | 212 | ||
213 | static int transport_remove_classdev(struct attribute_container *cont, | 213 | static int transport_remove_classdev(struct attribute_container *cont, |
214 | struct device *dev, | 214 | struct device *dev, |
215 | struct class_device *classdev) | 215 | struct device *classdev) |
216 | { | 216 | { |
217 | struct transport_container *tcont = | 217 | struct transport_container *tcont = |
218 | attribute_container_to_transport_container(cont); | 218 | attribute_container_to_transport_container(cont); |
@@ -251,12 +251,12 @@ EXPORT_SYMBOL_GPL(transport_remove_device); | |||
251 | 251 | ||
252 | static void transport_destroy_classdev(struct attribute_container *cont, | 252 | static void transport_destroy_classdev(struct attribute_container *cont, |
253 | struct device *dev, | 253 | struct device *dev, |
254 | struct class_device *classdev) | 254 | struct device *classdev) |
255 | { | 255 | { |
256 | struct transport_class *tclass = class_to_transport_class(cont->class); | 256 | struct transport_class *tclass = class_to_transport_class(cont->class); |
257 | 257 | ||
258 | if (tclass->remove != anon_transport_dummy_function) | 258 | if (tclass->remove != anon_transport_dummy_function) |
259 | class_device_put(classdev); | 259 | put_device(classdev); |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||