diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-21 18:49:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-21 18:49:58 -0400 |
commit | e80ab411e589e00550e2e6e5a6a02d59cc730357 (patch) | |
tree | 870225ff7b5b8d03e82a996963213a4bb9cce248 /drivers | |
parent | 529a41e36673b518c9e091f3a8d932b6b9e3c461 (diff) | |
parent | ee959b00c335d7780136c5abda37809191fe52c3 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (36 commits)
SCSI: convert struct class_device to struct device
DRM: remove unused dev_class
IB: rename "dev" to "srp_dev" in srp_host structure
IB: convert struct class_device to struct device
memstick: convert struct class_device to struct device
driver core: replace remaining __FUNCTION__ occurrences
sysfs: refill attribute buffer when reading from offset 0
PM: Remove destroy_suspended_device()
Firmware: add iSCSI iBFT Support
PM: Remove legacy PM (fix)
Kobject: Replace list_for_each() with list_for_each_entry().
SYSFS: Explicitly include required header file slab.h.
Driver core: make device_is_registered() work for class devices
PM: Convert wakeup flag accessors to inline functions
PM: Make wakeup flags available whenever CONFIG_PM is set
PM: Fix misuse of wakeup flag accessors in serial core
Driver core: Call device_pm_add() after bus_add_device() in device_add()
PM: Handle device registrations during suspend/resume
block: send disk "change" event for rescan_partitions()
sysdev: detect multiple driver registrations
...
Fixed trivial conflict in include/linux/memory.h due to semaphore header
file change (made irrelevant by the change to mutex).
Diffstat (limited to 'drivers')
86 files changed, 3497 insertions, 2071 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 739ba3f222e8..986e3324e302 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -273,8 +273,8 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | |||
273 | static int ahci_pci_device_resume(struct pci_dev *pdev); | 273 | static int ahci_pci_device_resume(struct pci_dev *pdev); |
274 | #endif | 274 | #endif |
275 | 275 | ||
276 | static struct class_device_attribute *ahci_shost_attrs[] = { | 276 | static struct device_attribute *ahci_shost_attrs[] = { |
277 | &class_device_attr_link_power_management_policy, | 277 | &dev_attr_link_power_management_policy, |
278 | NULL | 278 | NULL |
279 | }; | 279 | }; |
280 | 280 | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index f3c69a8c1103..a34f32442edf 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -131,10 +131,11 @@ static const char *ata_scsi_lpm_get(enum link_pm policy) | |||
131 | return NULL; | 131 | return NULL; |
132 | } | 132 | } |
133 | 133 | ||
134 | static ssize_t ata_scsi_lpm_put(struct class_device *class_dev, | 134 | static ssize_t ata_scsi_lpm_put(struct device *dev, |
135 | const char *buf, size_t count) | 135 | struct device_attribute *attr, |
136 | const char *buf, size_t count) | ||
136 | { | 137 | { |
137 | struct Scsi_Host *shost = class_to_shost(class_dev); | 138 | struct Scsi_Host *shost = class_to_shost(dev); |
138 | struct ata_port *ap = ata_shost_to_port(shost); | 139 | struct ata_port *ap = ata_shost_to_port(shost); |
139 | enum link_pm policy = 0; | 140 | enum link_pm policy = 0; |
140 | int i; | 141 | int i; |
@@ -162,9 +163,9 @@ static ssize_t ata_scsi_lpm_put(struct class_device *class_dev, | |||
162 | } | 163 | } |
163 | 164 | ||
164 | static ssize_t | 165 | static ssize_t |
165 | ata_scsi_lpm_show(struct class_device *class_dev, char *buf) | 166 | ata_scsi_lpm_show(struct device *dev, struct device_attribute *attr, char *buf) |
166 | { | 167 | { |
167 | struct Scsi_Host *shost = class_to_shost(class_dev); | 168 | struct Scsi_Host *shost = class_to_shost(dev); |
168 | struct ata_port *ap = ata_shost_to_port(shost); | 169 | struct ata_port *ap = ata_shost_to_port(shost); |
169 | const char *policy = | 170 | const char *policy = |
170 | ata_scsi_lpm_get(ap->pm_policy); | 171 | ata_scsi_lpm_get(ap->pm_policy); |
@@ -174,9 +175,9 @@ ata_scsi_lpm_show(struct class_device *class_dev, char *buf) | |||
174 | 175 | ||
175 | return snprintf(buf, 23, "%s\n", policy); | 176 | return snprintf(buf, 23, "%s\n", policy); |
176 | } | 177 | } |
177 | CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, | 178 | DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, |
178 | ata_scsi_lpm_show, ata_scsi_lpm_put); | 179 | ata_scsi_lpm_show, ata_scsi_lpm_put); |
179 | EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy); | 180 | EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); |
180 | 181 | ||
181 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, | 182 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, |
182 | void (*done)(struct scsi_cmnd *)) | 183 | void (*done)(struct scsi_cmnd *)) |
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/bus.c b/drivers/base/bus.c index 2d207ad30336..be1cc5143354 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -79,7 +79,7 @@ static void driver_release(struct kobject *kobj) | |||
79 | { | 79 | { |
80 | struct driver_private *drv_priv = to_driver(kobj); | 80 | struct driver_private *drv_priv = to_driver(kobj); |
81 | 81 | ||
82 | pr_debug("driver: '%s': %s\n", kobject_name(kobj), __FUNCTION__); | 82 | pr_debug("driver: '%s': %s\n", kobject_name(kobj), __func__); |
83 | kfree(drv_priv); | 83 | kfree(drv_priv); |
84 | } | 84 | } |
85 | 85 | ||
@@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev) | |||
505 | int ret = 0; | 505 | int ret = 0; |
506 | 506 | ||
507 | if (bus) { | 507 | if (bus) { |
508 | dev->is_registered = 1; | ||
509 | if (bus->p->drivers_autoprobe) | 508 | if (bus->p->drivers_autoprobe) |
510 | ret = device_attach(dev); | 509 | ret = device_attach(dev); |
511 | WARN_ON(ret < 0); | 510 | WARN_ON(ret < 0); |
512 | if (ret >= 0) | 511 | if (ret >= 0) |
513 | klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); | 512 | klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); |
514 | else | ||
515 | dev->is_registered = 0; | ||
516 | } | 513 | } |
517 | } | 514 | } |
518 | 515 | ||
@@ -533,10 +530,8 @@ void bus_remove_device(struct device *dev) | |||
533 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, | 530 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, |
534 | dev->bus_id); | 531 | dev->bus_id); |
535 | device_remove_attrs(dev->bus, dev); | 532 | device_remove_attrs(dev->bus, dev); |
536 | if (dev->is_registered) { | 533 | klist_del(&dev->knode_bus); |
537 | dev->is_registered = 0; | 534 | |
538 | klist_del(&dev->knode_bus); | ||
539 | } | ||
540 | pr_debug("bus: '%s': remove device %s\n", | 535 | pr_debug("bus: '%s': remove device %s\n", |
541 | dev->bus->name, dev->bus_id); | 536 | dev->bus->name, dev->bus_id); |
542 | device_release_driver(dev); | 537 | device_release_driver(dev); |
@@ -682,19 +677,19 @@ int bus_add_driver(struct device_driver *drv) | |||
682 | error = driver_create_file(drv, &driver_attr_uevent); | 677 | error = driver_create_file(drv, &driver_attr_uevent); |
683 | if (error) { | 678 | if (error) { |
684 | printk(KERN_ERR "%s: uevent attr (%s) failed\n", | 679 | printk(KERN_ERR "%s: uevent attr (%s) failed\n", |
685 | __FUNCTION__, drv->name); | 680 | __func__, drv->name); |
686 | } | 681 | } |
687 | error = driver_add_attrs(bus, drv); | 682 | error = driver_add_attrs(bus, drv); |
688 | if (error) { | 683 | if (error) { |
689 | /* How the hell do we get out of this pickle? Give up */ | 684 | /* How the hell do we get out of this pickle? Give up */ |
690 | printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", | 685 | printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", |
691 | __FUNCTION__, drv->name); | 686 | __func__, drv->name); |
692 | } | 687 | } |
693 | error = add_bind_files(drv); | 688 | error = add_bind_files(drv); |
694 | if (error) { | 689 | if (error) { |
695 | /* Ditto */ | 690 | /* Ditto */ |
696 | printk(KERN_ERR "%s: add_bind_files(%s) failed\n", | 691 | printk(KERN_ERR "%s: add_bind_files(%s) failed\n", |
697 | __FUNCTION__, drv->name); | 692 | __func__, drv->name); |
698 | } | 693 | } |
699 | 694 | ||
700 | kobject_uevent(&priv->kobj, KOBJ_ADD); | 695 | kobject_uevent(&priv->kobj, KOBJ_ADD); |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 9d915376c313..b4901799308b 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -175,13 +175,13 @@ void class_unregister(struct class *cls) | |||
175 | 175 | ||
176 | static void class_create_release(struct class *cls) | 176 | static void class_create_release(struct class *cls) |
177 | { | 177 | { |
178 | pr_debug("%s called for %s\n", __FUNCTION__, cls->name); | 178 | pr_debug("%s called for %s\n", __func__, cls->name); |
179 | kfree(cls); | 179 | kfree(cls); |
180 | } | 180 | } |
181 | 181 | ||
182 | static void class_device_create_release(struct class_device *class_dev) | 182 | static void class_device_create_release(struct class_device *class_dev) |
183 | { | 183 | { |
184 | pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); | 184 | pr_debug("%s called for %s\n", __func__, class_dev->class_id); |
185 | kfree(class_dev); | 185 | kfree(class_dev); |
186 | } | 186 | } |
187 | 187 | ||
@@ -189,7 +189,7 @@ static void class_device_create_release(struct class_device *class_dev) | |||
189 | static int class_device_create_uevent(struct class_device *class_dev, | 189 | static int class_device_create_uevent(struct class_device *class_dev, |
190 | struct kobj_uevent_env *env) | 190 | struct kobj_uevent_env *env) |
191 | { | 191 | { |
192 | pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); | 192 | pr_debug("%s called for %s\n", __func__, class_dev->class_id); |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
@@ -415,7 +415,7 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, | |||
415 | struct device *dev = class_dev->dev; | 415 | struct device *dev = class_dev->dev; |
416 | int retval = 0; | 416 | int retval = 0; |
417 | 417 | ||
418 | pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); | 418 | pr_debug("%s - name = %s\n", __func__, class_dev->class_id); |
419 | 419 | ||
420 | if (MAJOR(class_dev->devt)) { | 420 | if (MAJOR(class_dev->devt)) { |
421 | add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt)); | 421 | add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt)); |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 7c4b36ccb1a0..9248e0927d08 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -207,7 +207,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
207 | retval = dev->bus->uevent(dev, env); | 207 | retval = dev->bus->uevent(dev, env); |
208 | if (retval) | 208 | if (retval) |
209 | pr_debug("device: '%s': %s: bus uevent() returned %d\n", | 209 | pr_debug("device: '%s': %s: bus uevent() returned %d\n", |
210 | dev->bus_id, __FUNCTION__, retval); | 210 | dev->bus_id, __func__, retval); |
211 | } | 211 | } |
212 | 212 | ||
213 | /* have the class specific function add its stuff */ | 213 | /* have the class specific function add its stuff */ |
@@ -216,7 +216,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
216 | if (retval) | 216 | if (retval) |
217 | pr_debug("device: '%s': %s: class uevent() " | 217 | pr_debug("device: '%s': %s: class uevent() " |
218 | "returned %d\n", dev->bus_id, | 218 | "returned %d\n", dev->bus_id, |
219 | __FUNCTION__, retval); | 219 | __func__, retval); |
220 | } | 220 | } |
221 | 221 | ||
222 | /* have the device type specific fuction add its stuff */ | 222 | /* have the device type specific fuction add its stuff */ |
@@ -225,7 +225,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
225 | if (retval) | 225 | if (retval) |
226 | pr_debug("device: '%s': %s: dev_type uevent() " | 226 | pr_debug("device: '%s': %s: dev_type uevent() " |
227 | "returned %d\n", dev->bus_id, | 227 | "returned %d\n", dev->bus_id, |
228 | __FUNCTION__, retval); | 228 | __func__, retval); |
229 | } | 229 | } |
230 | 230 | ||
231 | return retval; | 231 | return retval; |
@@ -782,7 +782,7 @@ int device_add(struct device *dev) | |||
782 | goto Done; | 782 | goto Done; |
783 | } | 783 | } |
784 | 784 | ||
785 | pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); | 785 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); |
786 | 786 | ||
787 | parent = get_device(dev->parent); | 787 | parent = get_device(dev->parent); |
788 | setup_parent(dev, parent); | 788 | setup_parent(dev, parent); |
@@ -817,13 +817,12 @@ int device_add(struct device *dev) | |||
817 | error = device_add_attrs(dev); | 817 | error = device_add_attrs(dev); |
818 | if (error) | 818 | if (error) |
819 | goto AttrsError; | 819 | goto AttrsError; |
820 | error = dpm_sysfs_add(dev); | ||
821 | if (error) | ||
822 | goto PMError; | ||
823 | device_pm_add(dev); | ||
824 | error = bus_add_device(dev); | 820 | error = bus_add_device(dev); |
825 | if (error) | 821 | if (error) |
826 | goto BusError; | 822 | goto BusError; |
823 | error = device_pm_add(dev); | ||
824 | if (error) | ||
825 | goto PMError; | ||
827 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 826 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
828 | bus_attach_device(dev); | 827 | bus_attach_device(dev); |
829 | if (parent) | 828 | if (parent) |
@@ -843,9 +842,9 @@ int device_add(struct device *dev) | |||
843 | Done: | 842 | Done: |
844 | put_device(dev); | 843 | put_device(dev); |
845 | return error; | 844 | return error; |
846 | BusError: | ||
847 | device_pm_remove(dev); | ||
848 | PMError: | 845 | PMError: |
846 | bus_remove_device(dev); | ||
847 | BusError: | ||
849 | if (dev->bus) | 848 | if (dev->bus) |
850 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | 849 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, |
851 | BUS_NOTIFY_DEL_DEVICE, dev); | 850 | BUS_NOTIFY_DEL_DEVICE, dev); |
@@ -981,7 +980,7 @@ void device_del(struct device *dev) | |||
981 | */ | 980 | */ |
982 | void device_unregister(struct device *dev) | 981 | void device_unregister(struct device *dev) |
983 | { | 982 | { |
984 | pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); | 983 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); |
985 | device_del(dev); | 984 | device_del(dev); |
986 | put_device(dev); | 985 | put_device(dev); |
987 | } | 986 | } |
@@ -1076,7 +1075,7 @@ EXPORT_SYMBOL_GPL(device_remove_file); | |||
1076 | 1075 | ||
1077 | static void device_create_release(struct device *dev) | 1076 | static void device_create_release(struct device *dev) |
1078 | { | 1077 | { |
1079 | pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); | 1078 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); |
1080 | kfree(dev); | 1079 | kfree(dev); |
1081 | } | 1080 | } |
1082 | 1081 | ||
@@ -1164,35 +1163,6 @@ void device_destroy(struct class *class, dev_t devt) | |||
1164 | } | 1163 | } |
1165 | EXPORT_SYMBOL_GPL(device_destroy); | 1164 | EXPORT_SYMBOL_GPL(device_destroy); |
1166 | 1165 | ||
1167 | #ifdef CONFIG_PM_SLEEP | ||
1168 | /** | ||
1169 | * destroy_suspended_device - asks the PM core to remove a suspended device | ||
1170 | * @class: pointer to the struct class that this device was registered with | ||
1171 | * @devt: the dev_t of the device that was previously registered | ||
1172 | * | ||
1173 | * This call notifies the PM core of the necessity to unregister a suspended | ||
1174 | * device created with a call to device_create() (devices cannot be | ||
1175 | * unregistered directly while suspended, since the PM core holds their | ||
1176 | * semaphores at that time). | ||
1177 | * | ||
1178 | * It can only be called within the scope of a system sleep transition. In | ||
1179 | * practice this means it has to be directly or indirectly invoked either by | ||
1180 | * a suspend or resume method, or by the PM core (e.g. via | ||
1181 | * disable_nonboot_cpus() or enable_nonboot_cpus()). | ||
1182 | */ | ||
1183 | void destroy_suspended_device(struct class *class, dev_t devt) | ||
1184 | { | ||
1185 | struct device *dev; | ||
1186 | |||
1187 | dev = class_find_device(class, &devt, __match_devt); | ||
1188 | if (dev) { | ||
1189 | device_pm_schedule_removal(dev); | ||
1190 | put_device(dev); | ||
1191 | } | ||
1192 | } | ||
1193 | EXPORT_SYMBOL_GPL(destroy_suspended_device); | ||
1194 | #endif /* CONFIG_PM_SLEEP */ | ||
1195 | |||
1196 | /** | 1166 | /** |
1197 | * device_rename - renames a device | 1167 | * device_rename - renames a device |
1198 | * @dev: the pointer to the struct device to be renamed | 1168 | * @dev: the pointer to the struct device to be renamed |
@@ -1210,7 +1180,7 @@ int device_rename(struct device *dev, char *new_name) | |||
1210 | return -EINVAL; | 1180 | return -EINVAL; |
1211 | 1181 | ||
1212 | pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, | 1182 | pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, |
1213 | __FUNCTION__, new_name); | 1183 | __func__, new_name); |
1214 | 1184 | ||
1215 | #ifdef CONFIG_SYSFS_DEPRECATED | 1185 | #ifdef CONFIG_SYSFS_DEPRECATED |
1216 | if ((dev->class) && (dev->parent)) | 1186 | if ((dev->class) && (dev->parent)) |
@@ -1249,7 +1219,7 @@ int device_rename(struct device *dev, char *new_name) | |||
1249 | dev->bus_id); | 1219 | dev->bus_id); |
1250 | if (error) { | 1220 | if (error) { |
1251 | dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", | 1221 | dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", |
1252 | __FUNCTION__, error); | 1222 | __func__, error); |
1253 | } | 1223 | } |
1254 | } | 1224 | } |
1255 | #endif | 1225 | #endif |
@@ -1325,7 +1295,7 @@ int device_move(struct device *dev, struct device *new_parent) | |||
1325 | new_parent_kobj = get_device_parent(dev, new_parent); | 1295 | new_parent_kobj = get_device_parent(dev, new_parent); |
1326 | 1296 | ||
1327 | pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, | 1297 | pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, |
1328 | __FUNCTION__, new_parent ? new_parent->bus_id : "<NULL>"); | 1298 | __func__, new_parent ? new_parent->bus_id : "<NULL>"); |
1329 | error = kobject_move(&dev->kobj, new_parent_kobj); | 1299 | error = kobject_move(&dev->kobj, new_parent_kobj); |
1330 | if (error) { | 1300 | if (error) { |
1331 | cleanup_glue_dir(dev, new_parent_kobj); | 1301 | cleanup_glue_dir(dev, new_parent_kobj); |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 2c76afff3b15..6fe417429977 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -28,7 +28,7 @@ static ssize_t show_online(struct sys_device *dev, char *buf) | |||
28 | return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); | 28 | return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); |
29 | } | 29 | } |
30 | 30 | ||
31 | static ssize_t store_online(struct sys_device *dev, const char *buf, | 31 | static ssize_t __ref store_online(struct sys_device *dev, const char *buf, |
32 | size_t count) | 32 | size_t count) |
33 | { | 33 | { |
34 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); | 34 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); |
@@ -55,7 +55,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf, | |||
55 | } | 55 | } |
56 | static SYSDEV_ATTR(online, 0644, show_online, store_online); | 56 | static SYSDEV_ATTR(online, 0644, show_online, store_online); |
57 | 57 | ||
58 | static void __devinit register_cpu_control(struct cpu *cpu) | 58 | static void __cpuinit register_cpu_control(struct cpu *cpu) |
59 | { | 59 | { |
60 | sysdev_create_file(&cpu->sysdev, &attr_online); | 60 | sysdev_create_file(&cpu->sysdev, &attr_online); |
61 | } | 61 | } |
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index a5cde94bb982..3ac443b2ac08 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -30,12 +30,12 @@ static void driver_bound(struct device *dev) | |||
30 | { | 30 | { |
31 | if (klist_node_attached(&dev->knode_driver)) { | 31 | if (klist_node_attached(&dev->knode_driver)) { |
32 | printk(KERN_WARNING "%s: device %s already bound\n", | 32 | printk(KERN_WARNING "%s: device %s already bound\n", |
33 | __FUNCTION__, kobject_name(&dev->kobj)); | 33 | __func__, kobject_name(&dev->kobj)); |
34 | return; | 34 | return; |
35 | } | 35 | } |
36 | 36 | ||
37 | pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, | 37 | pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, |
38 | __FUNCTION__, dev->driver->name); | 38 | __func__, dev->driver->name); |
39 | 39 | ||
40 | if (dev->bus) | 40 | if (dev->bus) |
41 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | 41 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, |
@@ -104,13 +104,13 @@ static int really_probe(struct device *dev, struct device_driver *drv) | |||
104 | 104 | ||
105 | atomic_inc(&probe_count); | 105 | atomic_inc(&probe_count); |
106 | pr_debug("bus: '%s': %s: probing driver %s with device %s\n", | 106 | pr_debug("bus: '%s': %s: probing driver %s with device %s\n", |
107 | drv->bus->name, __FUNCTION__, drv->name, dev->bus_id); | 107 | drv->bus->name, __func__, drv->name, dev->bus_id); |
108 | WARN_ON(!list_empty(&dev->devres_head)); | 108 | WARN_ON(!list_empty(&dev->devres_head)); |
109 | 109 | ||
110 | dev->driver = drv; | 110 | dev->driver = drv; |
111 | if (driver_sysfs_add(dev)) { | 111 | if (driver_sysfs_add(dev)) { |
112 | printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", | 112 | printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", |
113 | __FUNCTION__, dev->bus_id); | 113 | __func__, dev->bus_id); |
114 | goto probe_failed; | 114 | goto probe_failed; |
115 | } | 115 | } |
116 | 116 | ||
@@ -127,7 +127,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) | |||
127 | driver_bound(dev); | 127 | driver_bound(dev); |
128 | ret = 1; | 128 | ret = 1; |
129 | pr_debug("bus: '%s': %s: bound device %s to driver %s\n", | 129 | pr_debug("bus: '%s': %s: bound device %s to driver %s\n", |
130 | drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); | 130 | drv->bus->name, __func__, dev->bus_id, drv->name); |
131 | goto done; | 131 | goto done; |
132 | 132 | ||
133 | probe_failed: | 133 | probe_failed: |
@@ -160,7 +160,7 @@ done: | |||
160 | */ | 160 | */ |
161 | int driver_probe_done(void) | 161 | int driver_probe_done(void) |
162 | { | 162 | { |
163 | pr_debug("%s: probe_count = %d\n", __FUNCTION__, | 163 | pr_debug("%s: probe_count = %d\n", __func__, |
164 | atomic_read(&probe_count)); | 164 | atomic_read(&probe_count)); |
165 | if (atomic_read(&probe_count)) | 165 | if (atomic_read(&probe_count)) |
166 | return -EBUSY; | 166 | return -EBUSY; |
@@ -194,7 +194,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev) | |||
194 | goto done; | 194 | goto done; |
195 | 195 | ||
196 | pr_debug("bus: '%s': %s: matched device %s with driver %s\n", | 196 | pr_debug("bus: '%s': %s: matched device %s with driver %s\n", |
197 | drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); | 197 | drv->bus->name, __func__, dev->bus_id, drv->name); |
198 | 198 | ||
199 | ret = really_probe(dev, drv); | 199 | ret = really_probe(dev, drv); |
200 | 200 | ||
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 4a1b9bfc5471..1fef7df8c9d6 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -156,7 +156,7 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
156 | } | 156 | } |
157 | /* fallthrough */ | 157 | /* fallthrough */ |
158 | default: | 158 | default: |
159 | printk(KERN_ERR "%s: unexpected value (%d)\n", __FUNCTION__, | 159 | printk(KERN_ERR "%s: unexpected value (%d)\n", __func__, |
160 | loading); | 160 | loading); |
161 | /* fallthrough */ | 161 | /* fallthrough */ |
162 | case -1: | 162 | case -1: |
@@ -209,7 +209,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | |||
209 | new_size = ALIGN(min_size, PAGE_SIZE); | 209 | new_size = ALIGN(min_size, PAGE_SIZE); |
210 | new_data = vmalloc(new_size); | 210 | new_data = vmalloc(new_size); |
211 | if (!new_data) { | 211 | if (!new_data) { |
212 | printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__); | 212 | printk(KERN_ERR "%s: unable to alloc buffer\n", __func__); |
213 | /* Make sure that we don't keep incomplete data */ | 213 | /* Make sure that we don't keep incomplete data */ |
214 | fw_load_abort(fw_priv); | 214 | fw_load_abort(fw_priv); |
215 | return -ENOMEM; | 215 | return -ENOMEM; |
@@ -307,7 +307,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
307 | *dev_p = NULL; | 307 | *dev_p = NULL; |
308 | 308 | ||
309 | if (!fw_priv || !f_dev) { | 309 | if (!fw_priv || !f_dev) { |
310 | printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__); | 310 | printk(KERN_ERR "%s: kmalloc failed\n", __func__); |
311 | retval = -ENOMEM; | 311 | retval = -ENOMEM; |
312 | goto error_kfree; | 312 | goto error_kfree; |
313 | } | 313 | } |
@@ -328,7 +328,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
328 | retval = device_register(f_dev); | 328 | retval = device_register(f_dev); |
329 | if (retval) { | 329 | if (retval) { |
330 | printk(KERN_ERR "%s: device_register failed\n", | 330 | printk(KERN_ERR "%s: device_register failed\n", |
331 | __FUNCTION__); | 331 | __func__); |
332 | goto error_kfree; | 332 | goto error_kfree; |
333 | } | 333 | } |
334 | *dev_p = f_dev; | 334 | *dev_p = f_dev; |
@@ -362,14 +362,14 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, | |||
362 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); | 362 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); |
363 | if (retval) { | 363 | if (retval) { |
364 | printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", | 364 | printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", |
365 | __FUNCTION__); | 365 | __func__); |
366 | goto error_unreg; | 366 | goto error_unreg; |
367 | } | 367 | } |
368 | 368 | ||
369 | retval = device_create_file(f_dev, &dev_attr_loading); | 369 | retval = device_create_file(f_dev, &dev_attr_loading); |
370 | if (retval) { | 370 | if (retval) { |
371 | printk(KERN_ERR "%s: device_create_file failed\n", | 371 | printk(KERN_ERR "%s: device_create_file failed\n", |
372 | __FUNCTION__); | 372 | __func__); |
373 | goto error_unreg; | 373 | goto error_unreg; |
374 | } | 374 | } |
375 | 375 | ||
@@ -399,7 +399,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
399 | *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); | 399 | *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); |
400 | if (!firmware) { | 400 | if (!firmware) { |
401 | printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", | 401 | printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", |
402 | __FUNCTION__); | 402 | __func__); |
403 | retval = -ENOMEM; | 403 | retval = -ENOMEM; |
404 | goto out; | 404 | goto out; |
405 | } | 405 | } |
@@ -570,13 +570,13 @@ firmware_class_init(void) | |||
570 | int error; | 570 | int error; |
571 | error = class_register(&firmware_class); | 571 | error = class_register(&firmware_class); |
572 | if (error) { | 572 | if (error) { |
573 | printk(KERN_ERR "%s: class_register failed\n", __FUNCTION__); | 573 | printk(KERN_ERR "%s: class_register failed\n", __func__); |
574 | return error; | 574 | return error; |
575 | } | 575 | } |
576 | error = class_create_file(&firmware_class, &class_attr_timeout); | 576 | error = class_create_file(&firmware_class, &class_attr_timeout); |
577 | if (error) { | 577 | if (error) { |
578 | printk(KERN_ERR "%s: class_create_file failed\n", | 578 | printk(KERN_ERR "%s: class_create_file failed\n", |
579 | __FUNCTION__); | 579 | __func__); |
580 | class_unregister(&firmware_class); | 580 | class_unregister(&firmware_class); |
581 | } | 581 | } |
582 | return error; | 582 | return error; |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 7ae413fdd5fc..8ce6de5a7e28 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/kobject.h> | 20 | #include <linux/kobject.h> |
21 | #include <linux/memory_hotplug.h> | 21 | #include <linux/memory_hotplug.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/mutex.h> | ||
23 | #include <asm/atomic.h> | 24 | #include <asm/atomic.h> |
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
25 | 26 | ||
@@ -61,8 +62,8 @@ void unregister_memory_notifier(struct notifier_block *nb) | |||
61 | /* | 62 | /* |
62 | * register_memory - Setup a sysfs device for a memory block | 63 | * register_memory - Setup a sysfs device for a memory block |
63 | */ | 64 | */ |
64 | int register_memory(struct memory_block *memory, struct mem_section *section, | 65 | static |
65 | struct node *root) | 66 | int register_memory(struct memory_block *memory, struct mem_section *section) |
66 | { | 67 | { |
67 | int error; | 68 | int error; |
68 | 69 | ||
@@ -70,26 +71,18 @@ int register_memory(struct memory_block *memory, struct mem_section *section, | |||
70 | memory->sysdev.id = __section_nr(section); | 71 | memory->sysdev.id = __section_nr(section); |
71 | 72 | ||
72 | error = sysdev_register(&memory->sysdev); | 73 | error = sysdev_register(&memory->sysdev); |
73 | |||
74 | if (root && !error) | ||
75 | error = sysfs_create_link(&root->sysdev.kobj, | ||
76 | &memory->sysdev.kobj, | ||
77 | kobject_name(&memory->sysdev.kobj)); | ||
78 | |||
79 | return error; | 74 | return error; |
80 | } | 75 | } |
81 | 76 | ||
82 | static void | 77 | static void |
83 | unregister_memory(struct memory_block *memory, struct mem_section *section, | 78 | unregister_memory(struct memory_block *memory, struct mem_section *section) |
84 | struct node *root) | ||
85 | { | 79 | { |
86 | BUG_ON(memory->sysdev.cls != &memory_sysdev_class); | 80 | BUG_ON(memory->sysdev.cls != &memory_sysdev_class); |
87 | BUG_ON(memory->sysdev.id != __section_nr(section)); | 81 | BUG_ON(memory->sysdev.id != __section_nr(section)); |
88 | 82 | ||
83 | /* drop the ref. we got in remove_memory_block() */ | ||
84 | kobject_put(&memory->sysdev.kobj); | ||
89 | sysdev_unregister(&memory->sysdev); | 85 | sysdev_unregister(&memory->sysdev); |
90 | if (root) | ||
91 | sysfs_remove_link(&root->sysdev.kobj, | ||
92 | kobject_name(&memory->sysdev.kobj)); | ||
93 | } | 86 | } |
94 | 87 | ||
95 | /* | 88 | /* |
@@ -193,7 +186,7 @@ memory_block_action(struct memory_block *mem, unsigned long action) | |||
193 | break; | 186 | break; |
194 | default: | 187 | default: |
195 | printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", | 188 | printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", |
196 | __FUNCTION__, mem, action, action); | 189 | __func__, mem, action, action); |
197 | WARN_ON(1); | 190 | WARN_ON(1); |
198 | ret = -EINVAL; | 191 | ret = -EINVAL; |
199 | } | 192 | } |
@@ -205,7 +198,7 @@ static int memory_block_change_state(struct memory_block *mem, | |||
205 | unsigned long to_state, unsigned long from_state_req) | 198 | unsigned long to_state, unsigned long from_state_req) |
206 | { | 199 | { |
207 | int ret = 0; | 200 | int ret = 0; |
208 | down(&mem->state_sem); | 201 | mutex_lock(&mem->state_mutex); |
209 | 202 | ||
210 | if (mem->state != from_state_req) { | 203 | if (mem->state != from_state_req) { |
211 | ret = -EINVAL; | 204 | ret = -EINVAL; |
@@ -217,7 +210,7 @@ static int memory_block_change_state(struct memory_block *mem, | |||
217 | mem->state = to_state; | 210 | mem->state = to_state; |
218 | 211 | ||
219 | out: | 212 | out: |
220 | up(&mem->state_sem); | 213 | mutex_unlock(&mem->state_mutex); |
221 | return ret; | 214 | return ret; |
222 | } | 215 | } |
223 | 216 | ||
@@ -341,10 +334,10 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section, | |||
341 | 334 | ||
342 | mem->phys_index = __section_nr(section); | 335 | mem->phys_index = __section_nr(section); |
343 | mem->state = state; | 336 | mem->state = state; |
344 | init_MUTEX(&mem->state_sem); | 337 | mutex_init(&mem->state_mutex); |
345 | mem->phys_device = phys_device; | 338 | mem->phys_device = phys_device; |
346 | 339 | ||
347 | ret = register_memory(mem, section, NULL); | 340 | ret = register_memory(mem, section); |
348 | if (!ret) | 341 | if (!ret) |
349 | ret = mem_create_simple_file(mem, phys_index); | 342 | ret = mem_create_simple_file(mem, phys_index); |
350 | if (!ret) | 343 | if (!ret) |
@@ -395,7 +388,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
395 | mem_remove_simple_file(mem, phys_index); | 388 | mem_remove_simple_file(mem, phys_index); |
396 | mem_remove_simple_file(mem, state); | 389 | mem_remove_simple_file(mem, state); |
397 | mem_remove_simple_file(mem, phys_device); | 390 | mem_remove_simple_file(mem, phys_device); |
398 | unregister_memory(mem, section, NULL); | 391 | unregister_memory(mem, section); |
399 | 392 | ||
400 | return 0; | 393 | return 0; |
401 | } | 394 | } |
@@ -451,6 +444,6 @@ int __init memory_dev_init(void) | |||
451 | ret = err; | 444 | ret = err; |
452 | out: | 445 | out: |
453 | if (ret) | 446 | if (ret) |
454 | printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret); | 447 | printk(KERN_ERR "%s() failed: %d\n", __func__, ret); |
455 | return ret; | 448 | return ret; |
456 | } | 449 | } |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index d887d5cb5bef..c4568b82875b 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -50,26 +50,40 @@ | |||
50 | LIST_HEAD(dpm_active); | 50 | LIST_HEAD(dpm_active); |
51 | static LIST_HEAD(dpm_off); | 51 | static LIST_HEAD(dpm_off); |
52 | static LIST_HEAD(dpm_off_irq); | 52 | static LIST_HEAD(dpm_off_irq); |
53 | static LIST_HEAD(dpm_destroy); | ||
54 | 53 | ||
55 | static DEFINE_MUTEX(dpm_list_mtx); | 54 | static DEFINE_MUTEX(dpm_list_mtx); |
56 | 55 | ||
57 | static DECLARE_RWSEM(pm_sleep_rwsem); | 56 | /* 'true' if all devices have been suspended, protected by dpm_list_mtx */ |
58 | 57 | static bool all_sleeping; | |
59 | int (*platform_enable_wakeup)(struct device *dev, int is_on); | ||
60 | 58 | ||
61 | /** | 59 | /** |
62 | * device_pm_add - add a device to the list of active devices | 60 | * device_pm_add - add a device to the list of active devices |
63 | * @dev: Device to be added to the list | 61 | * @dev: Device to be added to the list |
64 | */ | 62 | */ |
65 | void device_pm_add(struct device *dev) | 63 | int device_pm_add(struct device *dev) |
66 | { | 64 | { |
65 | int error = 0; | ||
66 | |||
67 | pr_debug("PM: Adding info for %s:%s\n", | 67 | pr_debug("PM: Adding info for %s:%s\n", |
68 | dev->bus ? dev->bus->name : "No Bus", | 68 | dev->bus ? dev->bus->name : "No Bus", |
69 | kobject_name(&dev->kobj)); | 69 | kobject_name(&dev->kobj)); |
70 | mutex_lock(&dpm_list_mtx); | 70 | mutex_lock(&dpm_list_mtx); |
71 | list_add_tail(&dev->power.entry, &dpm_active); | 71 | if ((dev->parent && dev->parent->power.sleeping) || all_sleeping) { |
72 | if (dev->parent->power.sleeping) | ||
73 | dev_warn(dev, | ||
74 | "parent %s is sleeping, will not add\n", | ||
75 | dev->parent->bus_id); | ||
76 | else | ||
77 | dev_warn(dev, "devices are sleeping, will not add\n"); | ||
78 | WARN_ON(true); | ||
79 | error = -EBUSY; | ||
80 | } else { | ||
81 | error = dpm_sysfs_add(dev); | ||
82 | if (!error) | ||
83 | list_add_tail(&dev->power.entry, &dpm_active); | ||
84 | } | ||
72 | mutex_unlock(&dpm_list_mtx); | 85 | mutex_unlock(&dpm_list_mtx); |
86 | return error; | ||
73 | } | 87 | } |
74 | 88 | ||
75 | /** | 89 | /** |
@@ -89,50 +103,6 @@ void device_pm_remove(struct device *dev) | |||
89 | mutex_unlock(&dpm_list_mtx); | 103 | mutex_unlock(&dpm_list_mtx); |
90 | } | 104 | } |
91 | 105 | ||
92 | /** | ||
93 | * device_pm_schedule_removal - schedule the removal of a suspended device | ||
94 | * @dev: Device to destroy | ||
95 | * | ||
96 | * Moves the device to the dpm_destroy list for further processing by | ||
97 | * unregister_dropped_devices(). | ||
98 | */ | ||
99 | void device_pm_schedule_removal(struct device *dev) | ||
100 | { | ||
101 | pr_debug("PM: Preparing for removal: %s:%s\n", | ||
102 | dev->bus ? dev->bus->name : "No Bus", | ||
103 | kobject_name(&dev->kobj)); | ||
104 | mutex_lock(&dpm_list_mtx); | ||
105 | list_move_tail(&dev->power.entry, &dpm_destroy); | ||
106 | mutex_unlock(&dpm_list_mtx); | ||
107 | } | ||
108 | EXPORT_SYMBOL_GPL(device_pm_schedule_removal); | ||
109 | |||
110 | /** | ||
111 | * pm_sleep_lock - mutual exclusion for registration and suspend | ||
112 | * | ||
113 | * Returns 0 if no suspend is underway and device registration | ||
114 | * may proceed, otherwise -EBUSY. | ||
115 | */ | ||
116 | int pm_sleep_lock(void) | ||
117 | { | ||
118 | if (down_read_trylock(&pm_sleep_rwsem)) | ||
119 | return 0; | ||
120 | |||
121 | return -EBUSY; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * pm_sleep_unlock - mutual exclusion for registration and suspend | ||
126 | * | ||
127 | * This routine undoes the effect of device_pm_add_lock | ||
128 | * when a device's registration is complete. | ||
129 | */ | ||
130 | void pm_sleep_unlock(void) | ||
131 | { | ||
132 | up_read(&pm_sleep_rwsem); | ||
133 | } | ||
134 | |||
135 | |||
136 | /*------------------------- Resume routines -------------------------*/ | 106 | /*------------------------- Resume routines -------------------------*/ |
137 | 107 | ||
138 | /** | 108 | /** |
@@ -242,11 +212,13 @@ static int resume_device(struct device *dev) | |||
242 | static void dpm_resume(void) | 212 | static void dpm_resume(void) |
243 | { | 213 | { |
244 | mutex_lock(&dpm_list_mtx); | 214 | mutex_lock(&dpm_list_mtx); |
215 | all_sleeping = false; | ||
245 | while(!list_empty(&dpm_off)) { | 216 | while(!list_empty(&dpm_off)) { |
246 | struct list_head *entry = dpm_off.next; | 217 | struct list_head *entry = dpm_off.next; |
247 | struct device *dev = to_device(entry); | 218 | struct device *dev = to_device(entry); |
248 | 219 | ||
249 | list_move_tail(entry, &dpm_active); | 220 | list_move_tail(entry, &dpm_active); |
221 | dev->power.sleeping = false; | ||
250 | mutex_unlock(&dpm_list_mtx); | 222 | mutex_unlock(&dpm_list_mtx); |
251 | resume_device(dev); | 223 | resume_device(dev); |
252 | mutex_lock(&dpm_list_mtx); | 224 | mutex_lock(&dpm_list_mtx); |
@@ -255,26 +227,6 @@ static void dpm_resume(void) | |||
255 | } | 227 | } |
256 | 228 | ||
257 | /** | 229 | /** |
258 | * unregister_dropped_devices - Unregister devices scheduled for removal | ||
259 | * | ||
260 | * Unregister all devices on the dpm_destroy list. | ||
261 | */ | ||
262 | static void unregister_dropped_devices(void) | ||
263 | { | ||
264 | mutex_lock(&dpm_list_mtx); | ||
265 | while (!list_empty(&dpm_destroy)) { | ||
266 | struct list_head *entry = dpm_destroy.next; | ||
267 | struct device *dev = to_device(entry); | ||
268 | |||
269 | mutex_unlock(&dpm_list_mtx); | ||
270 | /* This also removes the device from the list */ | ||
271 | device_unregister(dev); | ||
272 | mutex_lock(&dpm_list_mtx); | ||
273 | } | ||
274 | mutex_unlock(&dpm_list_mtx); | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * device_resume - Restore state of each device in system. | 230 | * device_resume - Restore state of each device in system. |
279 | * | 231 | * |
280 | * Resume all the devices, unlock them all, and allow new | 232 | * Resume all the devices, unlock them all, and allow new |
@@ -284,8 +236,6 @@ void device_resume(void) | |||
284 | { | 236 | { |
285 | might_sleep(); | 237 | might_sleep(); |
286 | dpm_resume(); | 238 | dpm_resume(); |
287 | unregister_dropped_devices(); | ||
288 | up_write(&pm_sleep_rwsem); | ||
289 | } | 239 | } |
290 | EXPORT_SYMBOL_GPL(device_resume); | 240 | EXPORT_SYMBOL_GPL(device_resume); |
291 | 241 | ||
@@ -377,11 +327,6 @@ static int suspend_device(struct device *dev, pm_message_t state) | |||
377 | 327 | ||
378 | down(&dev->sem); | 328 | down(&dev->sem); |
379 | 329 | ||
380 | if (dev->power.power_state.event) { | ||
381 | dev_dbg(dev, "PM: suspend %d-->%d\n", | ||
382 | dev->power.power_state.event, state.event); | ||
383 | } | ||
384 | |||
385 | if (dev->class && dev->class->suspend) { | 330 | if (dev->class && dev->class->suspend) { |
386 | suspend_device_dbg(dev, state, "class "); | 331 | suspend_device_dbg(dev, state, "class "); |
387 | error = dev->class->suspend(dev, state); | 332 | error = dev->class->suspend(dev, state); |
@@ -426,6 +371,9 @@ static int dpm_suspend(pm_message_t state) | |||
426 | struct list_head *entry = dpm_active.prev; | 371 | struct list_head *entry = dpm_active.prev; |
427 | struct device *dev = to_device(entry); | 372 | struct device *dev = to_device(entry); |
428 | 373 | ||
374 | WARN_ON(dev->parent && dev->parent->power.sleeping); | ||
375 | |||
376 | dev->power.sleeping = true; | ||
429 | mutex_unlock(&dpm_list_mtx); | 377 | mutex_unlock(&dpm_list_mtx); |
430 | error = suspend_device(dev, state); | 378 | error = suspend_device(dev, state); |
431 | mutex_lock(&dpm_list_mtx); | 379 | mutex_lock(&dpm_list_mtx); |
@@ -437,11 +385,14 @@ static int dpm_suspend(pm_message_t state) | |||
437 | (error == -EAGAIN ? | 385 | (error == -EAGAIN ? |
438 | " (please convert to suspend_late)" : | 386 | " (please convert to suspend_late)" : |
439 | "")); | 387 | "")); |
388 | dev->power.sleeping = false; | ||
440 | break; | 389 | break; |
441 | } | 390 | } |
442 | if (!list_empty(&dev->power.entry)) | 391 | if (!list_empty(&dev->power.entry)) |
443 | list_move(&dev->power.entry, &dpm_off); | 392 | list_move(&dev->power.entry, &dpm_off); |
444 | } | 393 | } |
394 | if (!error) | ||
395 | all_sleeping = true; | ||
445 | mutex_unlock(&dpm_list_mtx); | 396 | mutex_unlock(&dpm_list_mtx); |
446 | 397 | ||
447 | return error; | 398 | return error; |
@@ -459,7 +410,6 @@ int device_suspend(pm_message_t state) | |||
459 | int error; | 410 | int error; |
460 | 411 | ||
461 | might_sleep(); | 412 | might_sleep(); |
462 | down_write(&pm_sleep_rwsem); | ||
463 | error = dpm_suspend(state); | 413 | error = dpm_suspend(state); |
464 | if (error) | 414 | if (error) |
465 | device_resume(); | 415 | device_resume(); |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index e32d3bdb92c1..a6894f2a4b99 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -11,30 +11,13 @@ static inline struct device *to_device(struct list_head *entry) | |||
11 | return container_of(entry, struct device, power.entry); | 11 | return container_of(entry, struct device, power.entry); |
12 | } | 12 | } |
13 | 13 | ||
14 | extern void device_pm_add(struct device *); | 14 | extern int device_pm_add(struct device *); |
15 | extern void device_pm_remove(struct device *); | 15 | extern void device_pm_remove(struct device *); |
16 | extern int pm_sleep_lock(void); | ||
17 | extern void pm_sleep_unlock(void); | ||
18 | 16 | ||
19 | #else /* CONFIG_PM_SLEEP */ | 17 | #else /* CONFIG_PM_SLEEP */ |
20 | 18 | ||
21 | 19 | static inline int device_pm_add(struct device *dev) { return 0; } | |
22 | static inline void device_pm_add(struct device *dev) | 20 | static inline void device_pm_remove(struct device *dev) {} |
23 | { | ||
24 | } | ||
25 | |||
26 | static inline void device_pm_remove(struct device *dev) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | static inline int pm_sleep_lock(void) | ||
31 | { | ||
32 | return 0; | ||
33 | } | ||
34 | |||
35 | static inline void pm_sleep_unlock(void) | ||
36 | { | ||
37 | } | ||
38 | 21 | ||
39 | #endif | 22 | #endif |
40 | 23 | ||
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index f2ed179cd695..d11f74b038db 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c | |||
@@ -6,6 +6,8 @@ | |||
6 | #include <linux/string.h> | 6 | #include <linux/string.h> |
7 | #include "power.h" | 7 | #include "power.h" |
8 | 8 | ||
9 | int (*platform_enable_wakeup)(struct device *dev, int is_on); | ||
10 | |||
9 | 11 | ||
10 | /* | 12 | /* |
11 | * wakeup - Report/change current wakeup option for device | 13 | * wakeup - Report/change current wakeup option for device |
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 8e13fd942163..4fbb56bcb1ee 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -167,6 +167,22 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv) | |||
167 | { | 167 | { |
168 | int err = 0; | 168 | int err = 0; |
169 | 169 | ||
170 | if (!cls) { | ||
171 | printk(KERN_WARNING "sysdev: invalid class passed to " | ||
172 | "sysdev_driver_register!\n"); | ||
173 | WARN_ON(1); | ||
174 | return -EINVAL; | ||
175 | } | ||
176 | |||
177 | /* Check whether this driver has already been added to a class. */ | ||
178 | if ((drv->entry.next != drv->entry.prev) || | ||
179 | (drv->entry.next != NULL)) { | ||
180 | printk(KERN_WARNING "sysdev: class %s: driver (%p) has already" | ||
181 | " been registered to a class, something is wrong, but " | ||
182 | "will forge on!\n", cls->name, drv); | ||
183 | WARN_ON(1); | ||
184 | } | ||
185 | |||
170 | mutex_lock(&sysdev_drivers_lock); | 186 | mutex_lock(&sysdev_drivers_lock); |
171 | if (cls && kset_get(&cls->kset)) { | 187 | if (cls && kset_get(&cls->kset)) { |
172 | list_add_tail(&drv->entry, &cls->drivers); | 188 | list_add_tail(&drv->entry, &cls->drivers); |
@@ -179,7 +195,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv) | |||
179 | } | 195 | } |
180 | } else { | 196 | } else { |
181 | err = -EINVAL; | 197 | err = -EINVAL; |
182 | printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__); | 198 | printk(KERN_ERR "%s: invalid device class\n", __func__); |
183 | WARN_ON(1); | 199 | WARN_ON(1); |
184 | } | 200 | } |
185 | mutex_unlock(&sysdev_drivers_lock); | 201 | mutex_unlock(&sysdev_drivers_lock); |
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 | ||
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index 8ea9dd1717a9..6540948d5176 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -640,7 +640,6 @@ struct drm_head { | |||
640 | struct drm_device *dev; | 640 | struct drm_device *dev; |
641 | struct proc_dir_entry *dev_root; /**< proc directory entry */ | 641 | struct proc_dir_entry *dev_root; /**< proc directory entry */ |
642 | dev_t device; /**< Device number for mknod */ | 642 | dev_t device; /**< Device number for mknod */ |
643 | struct class_device *dev_class; | ||
644 | }; | 643 | }; |
645 | 644 | ||
646 | /** | 645 | /** |
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 349b6edc5794..662d60e44e9a 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c | |||
@@ -238,11 +238,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO, | |||
238 | NULL); | 238 | NULL); |
239 | 239 | ||
240 | 240 | ||
241 | static void unregister_miscdev(bool suspended) | 241 | static void unregister_miscdev(void) |
242 | { | 242 | { |
243 | device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); | 243 | device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); |
244 | device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); | 244 | device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); |
245 | __misc_deregister(&rng_miscdev, suspended); | 245 | misc_deregister(&rng_miscdev); |
246 | } | 246 | } |
247 | 247 | ||
248 | static int register_miscdev(void) | 248 | static int register_miscdev(void) |
@@ -317,7 +317,7 @@ out: | |||
317 | } | 317 | } |
318 | EXPORT_SYMBOL_GPL(hwrng_register); | 318 | EXPORT_SYMBOL_GPL(hwrng_register); |
319 | 319 | ||
320 | void __hwrng_unregister(struct hwrng *rng, bool suspended) | 320 | void hwrng_unregister(struct hwrng *rng) |
321 | { | 321 | { |
322 | int err; | 322 | int err; |
323 | 323 | ||
@@ -336,11 +336,11 @@ void __hwrng_unregister(struct hwrng *rng, bool suspended) | |||
336 | } | 336 | } |
337 | } | 337 | } |
338 | if (list_empty(&rng_list)) | 338 | if (list_empty(&rng_list)) |
339 | unregister_miscdev(suspended); | 339 | unregister_miscdev(); |
340 | 340 | ||
341 | mutex_unlock(&rng_mutex); | 341 | mutex_unlock(&rng_mutex); |
342 | } | 342 | } |
343 | EXPORT_SYMBOL_GPL(__hwrng_unregister); | 343 | EXPORT_SYMBOL_GPL(hwrng_unregister); |
344 | 344 | ||
345 | 345 | ||
346 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); | 346 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index a39101feb2ed..4d058dadbfcc 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -232,9 +232,8 @@ int misc_register(struct miscdevice * misc) | |||
232 | } | 232 | } |
233 | 233 | ||
234 | /** | 234 | /** |
235 | * __misc_deregister - unregister a miscellaneous device | 235 | * misc_deregister - unregister a miscellaneous device |
236 | * @misc: device to unregister | 236 | * @misc: device to unregister |
237 | * @suspended: to be set if the function is used during suspend/resume | ||
238 | * | 237 | * |
239 | * Unregister a miscellaneous device that was previously | 238 | * Unregister a miscellaneous device that was previously |
240 | * successfully registered with misc_register(). Success | 239 | * successfully registered with misc_register(). Success |
@@ -242,7 +241,7 @@ int misc_register(struct miscdevice * misc) | |||
242 | * indicates an error. | 241 | * indicates an error. |
243 | */ | 242 | */ |
244 | 243 | ||
245 | int __misc_deregister(struct miscdevice *misc, bool suspended) | 244 | int misc_deregister(struct miscdevice *misc) |
246 | { | 245 | { |
247 | int i = misc->minor; | 246 | int i = misc->minor; |
248 | 247 | ||
@@ -251,11 +250,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended) | |||
251 | 250 | ||
252 | mutex_lock(&misc_mtx); | 251 | mutex_lock(&misc_mtx); |
253 | list_del(&misc->list); | 252 | list_del(&misc->list); |
254 | if (suspended) | 253 | device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); |
255 | destroy_suspended_device(misc_class, | ||
256 | MKDEV(MISC_MAJOR, misc->minor)); | ||
257 | else | ||
258 | device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); | ||
259 | if (i < DYNAMIC_MINORS && i>0) { | 254 | if (i < DYNAMIC_MINORS && i>0) { |
260 | misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); | 255 | misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); |
261 | } | 256 | } |
@@ -264,7 +259,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended) | |||
264 | } | 259 | } |
265 | 260 | ||
266 | EXPORT_SYMBOL(misc_register); | 261 | EXPORT_SYMBOL(misc_register); |
267 | EXPORT_SYMBOL(__misc_deregister); | 262 | EXPORT_SYMBOL(misc_deregister); |
268 | 263 | ||
269 | static int __init misc_init(void) | 264 | static int __init misc_init(void) |
270 | { | 265 | { |
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 05f02a326f1c..40ffd767647d 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig | |||
@@ -93,4 +93,24 @@ config DMIID | |||
93 | information from userspace through /sys/class/dmi/id/ or if you want | 93 | information from userspace through /sys/class/dmi/id/ or if you want |
94 | DMI-based module auto-loading. | 94 | DMI-based module auto-loading. |
95 | 95 | ||
96 | config ISCSI_IBFT_FIND | ||
97 | bool "iSCSI Boot Firmware Table Attributes" | ||
98 | depends on X86 | ||
99 | default n | ||
100 | help | ||
101 | This option enables the kernel to find the region of memory | ||
102 | in which the ISCSI Boot Firmware Table (iBFT) resides. This | ||
103 | is necessary for iSCSI Boot Firmware Table Attributes module to work | ||
104 | properly. | ||
105 | |||
106 | config ISCSI_IBFT | ||
107 | tristate "iSCSI Boot Firmware Table Attributes module" | ||
108 | depends on ISCSI_IBFT_FIND | ||
109 | default n | ||
110 | help | ||
111 | This option enables support for detection and exposing of iSCSI | ||
112 | Boot Firmware Table (iBFT) via sysfs to userspace. If you wish to | ||
113 | detect iSCSI boot parameters dynamically during system boot, say Y. | ||
114 | Otherwise, say N. | ||
115 | |||
96 | endmenu | 116 | endmenu |
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 8d4ebc805a50..4c9147154df8 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile | |||
@@ -8,3 +8,5 @@ obj-$(CONFIG_EFI_PCDP) += pcdp.o | |||
8 | obj-$(CONFIG_DELL_RBU) += dell_rbu.o | 8 | obj-$(CONFIG_DELL_RBU) += dell_rbu.o |
9 | obj-$(CONFIG_DCDBAS) += dcdbas.o | 9 | obj-$(CONFIG_DCDBAS) += dcdbas.o |
10 | obj-$(CONFIG_DMIID) += dmi-id.o | 10 | obj-$(CONFIG_DMIID) += dmi-id.o |
11 | obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o | ||
12 | obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o | ||
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c new file mode 100644 index 000000000000..8024e3bfd877 --- /dev/null +++ b/drivers/firmware/iscsi_ibft.c | |||
@@ -0,0 +1,982 @@ | |||
1 | /* | ||
2 | * Copyright 2007 Red Hat, Inc. | ||
3 | * by Peter Jones <pjones@redhat.com> | ||
4 | * Copyright 2008 IBM, Inc. | ||
5 | * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
6 | * Copyright 2008 | ||
7 | * by Konrad Rzeszutek <ketuzsezr@darnok.org> | ||
8 | * | ||
9 | * This code exposes the iSCSI Boot Format Table to userland via sysfs. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License v2.0 as published by | ||
13 | * the Free Software Foundation | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * Changelog: | ||
21 | * | ||
22 | * 14 Mar 2008 - Konrad Rzeszutek <ketuzsezr@darnok.org> | ||
23 | * Updated comments and copyrights. (v0.4.9) | ||
24 | * | ||
25 | * 11 Feb 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
26 | * Converted to using ibft_addr. (v0.4.8) | ||
27 | * | ||
28 | * 8 Feb 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
29 | * Combined two functions in one: reserve_ibft_region. (v0.4.7) | ||
30 | * | ||
31 | * 30 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
32 | * Added logic to handle IPv6 addresses. (v0.4.6) | ||
33 | * | ||
34 | * 25 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
35 | * Added logic to handle badly not-to-spec iBFT. (v0.4.5) | ||
36 | * | ||
37 | * 4 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
38 | * Added __init to function declarations. (v0.4.4) | ||
39 | * | ||
40 | * 21 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
41 | * Updated kobject registration, combined unregister functions in one | ||
42 | * and code and style cleanup. (v0.4.3) | ||
43 | * | ||
44 | * 5 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
45 | * Added end-markers to enums and re-organized kobject registration. (v0.4.2) | ||
46 | * | ||
47 | * 4 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
48 | * Created 'device' sysfs link to the NIC and style cleanup. (v0.4.1) | ||
49 | * | ||
50 | * 28 Nov 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
51 | * Added sysfs-ibft documentation, moved 'find_ibft' function to | ||
52 | * in its own file and added text attributes for every struct field. (v0.4) | ||
53 | * | ||
54 | * 21 Nov 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
55 | * Added text attributes emulating OpenFirmware /proc/device-tree naming. | ||
56 | * Removed binary /sysfs interface (v0.3) | ||
57 | * | ||
58 | * 29 Aug 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
59 | * Added functionality in setup.c to reserve iBFT region. (v0.2) | ||
60 | * | ||
61 | * 27 Aug 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
62 | * First version exposing iBFT data via a binary /sysfs. (v0.1) | ||
63 | * | ||
64 | */ | ||
65 | |||
66 | |||
67 | #include <linux/blkdev.h> | ||
68 | #include <linux/capability.h> | ||
69 | #include <linux/ctype.h> | ||
70 | #include <linux/device.h> | ||
71 | #include <linux/err.h> | ||
72 | #include <linux/init.h> | ||
73 | #include <linux/iscsi_ibft.h> | ||
74 | #include <linux/limits.h> | ||
75 | #include <linux/module.h> | ||
76 | #include <linux/pci.h> | ||
77 | #include <linux/slab.h> | ||
78 | #include <linux/stat.h> | ||
79 | #include <linux/string.h> | ||
80 | #include <linux/types.h> | ||
81 | |||
82 | #define IBFT_ISCSI_VERSION "0.4.9" | ||
83 | #define IBFT_ISCSI_DATE "2008-Mar-14" | ||
84 | |||
85 | MODULE_AUTHOR("Peter Jones <pjones@redhat.com> and \ | ||
86 | Konrad Rzeszutek <ketuzsezr@darnok.org>"); | ||
87 | MODULE_DESCRIPTION("sysfs interface to BIOS iBFT information"); | ||
88 | MODULE_LICENSE("GPL"); | ||
89 | MODULE_VERSION(IBFT_ISCSI_VERSION); | ||
90 | |||
91 | struct ibft_hdr { | ||
92 | u8 id; | ||
93 | u8 version; | ||
94 | u16 length; | ||
95 | u8 index; | ||
96 | u8 flags; | ||
97 | } __attribute__((__packed__)); | ||
98 | |||
99 | struct ibft_control { | ||
100 | struct ibft_hdr hdr; | ||
101 | u16 extensions; | ||
102 | u16 initiator_off; | ||
103 | u16 nic0_off; | ||
104 | u16 tgt0_off; | ||
105 | u16 nic1_off; | ||
106 | u16 tgt1_off; | ||
107 | } __attribute__((__packed__)); | ||
108 | |||
109 | struct ibft_initiator { | ||
110 | struct ibft_hdr hdr; | ||
111 | char isns_server[16]; | ||
112 | char slp_server[16]; | ||
113 | char pri_radius_server[16]; | ||
114 | char sec_radius_server[16]; | ||
115 | u16 initiator_name_len; | ||
116 | u16 initiator_name_off; | ||
117 | } __attribute__((__packed__)); | ||
118 | |||
119 | struct ibft_nic { | ||
120 | struct ibft_hdr hdr; | ||
121 | char ip_addr[16]; | ||
122 | u8 subnet_mask_prefix; | ||
123 | u8 origin; | ||
124 | char gateway[16]; | ||
125 | char primary_dns[16]; | ||
126 | char secondary_dns[16]; | ||
127 | char dhcp[16]; | ||
128 | u16 vlan; | ||
129 | char mac[6]; | ||
130 | u16 pci_bdf; | ||
131 | u16 hostname_len; | ||
132 | u16 hostname_off; | ||
133 | } __attribute__((__packed__)); | ||
134 | |||
135 | struct ibft_tgt { | ||
136 | struct ibft_hdr hdr; | ||
137 | char ip_addr[16]; | ||
138 | u16 port; | ||
139 | char lun[8]; | ||
140 | u8 chap_type; | ||
141 | u8 nic_assoc; | ||
142 | u16 tgt_name_len; | ||
143 | u16 tgt_name_off; | ||
144 | u16 chap_name_len; | ||
145 | u16 chap_name_off; | ||
146 | u16 chap_secret_len; | ||
147 | u16 chap_secret_off; | ||
148 | u16 rev_chap_name_len; | ||
149 | u16 rev_chap_name_off; | ||
150 | u16 rev_chap_secret_len; | ||
151 | u16 rev_chap_secret_off; | ||
152 | } __attribute__((__packed__)); | ||
153 | |||
154 | /* | ||
155 | * The kobject different types and its names. | ||
156 | * | ||
157 | */ | ||
158 | enum ibft_id { | ||
159 | id_reserved = 0, /* We don't support. */ | ||
160 | id_control = 1, /* Should show up only once and is not exported. */ | ||
161 | id_initiator = 2, | ||
162 | id_nic = 3, | ||
163 | id_target = 4, | ||
164 | id_extensions = 5, /* We don't support. */ | ||
165 | id_end_marker, | ||
166 | }; | ||
167 | |||
168 | /* | ||
169 | * We do not support the other types, hence the usage of NULL. | ||
170 | * This maps to the enum ibft_id. | ||
171 | */ | ||
172 | static const char *ibft_id_names[] = | ||
173 | {NULL, NULL, "initiator", "ethernet%d", "target%d", NULL, NULL}; | ||
174 | |||
175 | /* | ||
176 | * The text attributes names for each of the kobjects. | ||
177 | */ | ||
178 | enum ibft_eth_properties_enum { | ||
179 | ibft_eth_index, | ||
180 | ibft_eth_flags, | ||
181 | ibft_eth_ip_addr, | ||
182 | ibft_eth_subnet_mask, | ||
183 | ibft_eth_origin, | ||
184 | ibft_eth_gateway, | ||
185 | ibft_eth_primary_dns, | ||
186 | ibft_eth_secondary_dns, | ||
187 | ibft_eth_dhcp, | ||
188 | ibft_eth_vlan, | ||
189 | ibft_eth_mac, | ||
190 | /* ibft_eth_pci_bdf - this is replaced by link to the device itself. */ | ||
191 | ibft_eth_hostname, | ||
192 | ibft_eth_end_marker, | ||
193 | }; | ||
194 | |||
195 | static const char *ibft_eth_properties[] = | ||
196 | {"index", "flags", "ip-addr", "subnet-mask", "origin", "gateway", | ||
197 | "primary-dns", "secondary-dns", "dhcp", "vlan", "mac", "hostname", | ||
198 | NULL}; | ||
199 | |||
200 | enum ibft_tgt_properties_enum { | ||
201 | ibft_tgt_index, | ||
202 | ibft_tgt_flags, | ||
203 | ibft_tgt_ip_addr, | ||
204 | ibft_tgt_port, | ||
205 | ibft_tgt_lun, | ||
206 | ibft_tgt_chap_type, | ||
207 | ibft_tgt_nic_assoc, | ||
208 | ibft_tgt_name, | ||
209 | ibft_tgt_chap_name, | ||
210 | ibft_tgt_chap_secret, | ||
211 | ibft_tgt_rev_chap_name, | ||
212 | ibft_tgt_rev_chap_secret, | ||
213 | ibft_tgt_end_marker, | ||
214 | }; | ||
215 | |||
216 | static const char *ibft_tgt_properties[] = | ||
217 | {"index", "flags", "ip-addr", "port", "lun", "chap-type", "nic-assoc", | ||
218 | "target-name", "chap-name", "chap-secret", "rev-chap-name", | ||
219 | "rev-chap-name-secret", NULL}; | ||
220 | |||
221 | enum ibft_initiator_properties_enum { | ||
222 | ibft_init_index, | ||
223 | ibft_init_flags, | ||
224 | ibft_init_isns_server, | ||
225 | ibft_init_slp_server, | ||
226 | ibft_init_pri_radius_server, | ||
227 | ibft_init_sec_radius_server, | ||
228 | ibft_init_initiator_name, | ||
229 | ibft_init_end_marker, | ||
230 | }; | ||
231 | |||
232 | static const char *ibft_initiator_properties[] = | ||
233 | {"index", "flags", "isns-server", "slp-server", "pri-radius-server", | ||
234 | "sec-radius-server", "initiator-name", NULL}; | ||
235 | |||
236 | /* | ||
237 | * The kobject and attribute structures. | ||
238 | */ | ||
239 | |||
240 | struct ibft_kobject { | ||
241 | struct ibft_table_header *header; | ||
242 | union { | ||
243 | struct ibft_initiator *initiator; | ||
244 | struct ibft_nic *nic; | ||
245 | struct ibft_tgt *tgt; | ||
246 | struct ibft_hdr *hdr; | ||
247 | }; | ||
248 | struct kobject kobj; | ||
249 | struct list_head node; | ||
250 | }; | ||
251 | |||
252 | struct ibft_attribute { | ||
253 | struct attribute attr; | ||
254 | ssize_t (*show) (struct ibft_kobject *entry, | ||
255 | struct ibft_attribute *attr, char *buf); | ||
256 | union { | ||
257 | struct ibft_initiator *initiator; | ||
258 | struct ibft_nic *nic; | ||
259 | struct ibft_tgt *tgt; | ||
260 | struct ibft_hdr *hdr; | ||
261 | }; | ||
262 | struct kobject *kobj; | ||
263 | int type; /* The enum of the type. This can be any value of: | ||
264 | ibft_eth_properties_enum, ibft_tgt_properties_enum, | ||
265 | or ibft_initiator_properties_enum. */ | ||
266 | struct list_head node; | ||
267 | }; | ||
268 | |||
269 | static LIST_HEAD(ibft_attr_list); | ||
270 | static LIST_HEAD(ibft_kobject_list); | ||
271 | |||
272 | static const char nulls[16]; | ||
273 | |||
274 | /* | ||
275 | * Helper functions to parse data properly. | ||
276 | */ | ||
277 | static ssize_t sprintf_ipaddr(char *buf, u8 *ip) | ||
278 | { | ||
279 | char *str = buf; | ||
280 | |||
281 | if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 && | ||
282 | ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && ip[7] == 0 && | ||
283 | ip[8] == 0 && ip[9] == 0 && ip[10] == 0xff && ip[11] == 0xff) { | ||
284 | /* | ||
285 | * IPV4 | ||
286 | */ | ||
287 | str += sprintf(buf, NIPQUAD_FMT, ip[12], | ||
288 | ip[13], ip[14], ip[15]); | ||
289 | } else { | ||
290 | /* | ||
291 | * IPv6 | ||
292 | */ | ||
293 | str += sprintf(str, NIP6_FMT, ntohs(ip[0]), ntohs(ip[1]), | ||
294 | ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]), | ||
295 | ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7])); | ||
296 | } | ||
297 | str += sprintf(str, "\n"); | ||
298 | return str - buf; | ||
299 | } | ||
300 | |||
301 | static ssize_t sprintf_string(char *str, int len, char *buf) | ||
302 | { | ||
303 | return sprintf(str, "%.*s\n", len, buf); | ||
304 | } | ||
305 | |||
306 | /* | ||
307 | * Helper function to verify the IBFT header. | ||
308 | */ | ||
309 | static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length) | ||
310 | { | ||
311 | if (hdr->id != id) { | ||
312 | printk(KERN_ERR "iBFT error: We expected the " \ | ||
313 | "field header.id to have %d but " \ | ||
314 | "found %d instead!\n", id, hdr->id); | ||
315 | return -ENODEV; | ||
316 | } | ||
317 | if (hdr->length != length) { | ||
318 | printk(KERN_ERR "iBFT error: We expected the " \ | ||
319 | "field header.length to have %d but " \ | ||
320 | "found %d instead!\n", length, hdr->length); | ||
321 | return -ENODEV; | ||
322 | } | ||
323 | |||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static void ibft_release(struct kobject *kobj) | ||
328 | { | ||
329 | struct ibft_kobject *ibft = | ||
330 | container_of(kobj, struct ibft_kobject, kobj); | ||
331 | kfree(ibft); | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * Routines for parsing the iBFT data to be human readable. | ||
336 | */ | ||
337 | ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, | ||
338 | struct ibft_attribute *attr, | ||
339 | char *buf) | ||
340 | { | ||
341 | struct ibft_initiator *initiator = entry->initiator; | ||
342 | void *ibft_loc = entry->header; | ||
343 | char *str = buf; | ||
344 | |||
345 | if (!initiator) | ||
346 | return 0; | ||
347 | |||
348 | switch (attr->type) { | ||
349 | case ibft_init_index: | ||
350 | str += sprintf(str, "%d\n", initiator->hdr.index); | ||
351 | break; | ||
352 | case ibft_init_flags: | ||
353 | str += sprintf(str, "%d\n", initiator->hdr.flags); | ||
354 | break; | ||
355 | case ibft_init_isns_server: | ||
356 | str += sprintf_ipaddr(str, initiator->isns_server); | ||
357 | break; | ||
358 | case ibft_init_slp_server: | ||
359 | str += sprintf_ipaddr(str, initiator->slp_server); | ||
360 | break; | ||
361 | case ibft_init_pri_radius_server: | ||
362 | str += sprintf_ipaddr(str, initiator->pri_radius_server); | ||
363 | break; | ||
364 | case ibft_init_sec_radius_server: | ||
365 | str += sprintf_ipaddr(str, initiator->sec_radius_server); | ||
366 | break; | ||
367 | case ibft_init_initiator_name: | ||
368 | str += sprintf_string(str, initiator->initiator_name_len, | ||
369 | (char *)ibft_loc + | ||
370 | initiator->initiator_name_off); | ||
371 | break; | ||
372 | default: | ||
373 | break; | ||
374 | } | ||
375 | |||
376 | return str - buf; | ||
377 | } | ||
378 | |||
379 | ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, | ||
380 | struct ibft_attribute *attr, | ||
381 | char *buf) | ||
382 | { | ||
383 | struct ibft_nic *nic = entry->nic; | ||
384 | void *ibft_loc = entry->header; | ||
385 | char *str = buf; | ||
386 | char *mac; | ||
387 | int val; | ||
388 | |||
389 | if (!nic) | ||
390 | return 0; | ||
391 | |||
392 | switch (attr->type) { | ||
393 | case ibft_eth_index: | ||
394 | str += sprintf(str, "%d\n", nic->hdr.index); | ||
395 | break; | ||
396 | case ibft_eth_flags: | ||
397 | str += sprintf(str, "%d\n", nic->hdr.flags); | ||
398 | break; | ||
399 | case ibft_eth_ip_addr: | ||
400 | str += sprintf_ipaddr(str, nic->ip_addr); | ||
401 | break; | ||
402 | case ibft_eth_subnet_mask: | ||
403 | val = ~((1 << (32-nic->subnet_mask_prefix))-1); | ||
404 | str += sprintf(str, NIPQUAD_FMT, | ||
405 | (u8)(val >> 24), (u8)(val >> 16), | ||
406 | (u8)(val >> 8), (u8)(val)); | ||
407 | break; | ||
408 | case ibft_eth_origin: | ||
409 | str += sprintf(str, "%d\n", nic->origin); | ||
410 | break; | ||
411 | case ibft_eth_gateway: | ||
412 | str += sprintf_ipaddr(str, nic->gateway); | ||
413 | break; | ||
414 | case ibft_eth_primary_dns: | ||
415 | str += sprintf_ipaddr(str, nic->primary_dns); | ||
416 | break; | ||
417 | case ibft_eth_secondary_dns: | ||
418 | str += sprintf_ipaddr(str, nic->secondary_dns); | ||
419 | break; | ||
420 | case ibft_eth_dhcp: | ||
421 | str += sprintf_ipaddr(str, nic->dhcp); | ||
422 | break; | ||
423 | case ibft_eth_vlan: | ||
424 | str += sprintf(str, "%d\n", nic->vlan); | ||
425 | break; | ||
426 | case ibft_eth_mac: | ||
427 | mac = nic->mac; | ||
428 | str += sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x\n", | ||
429 | (u8)mac[0], (u8)mac[1], (u8)mac[2], | ||
430 | (u8)mac[3], (u8)mac[4], (u8)mac[5]); | ||
431 | break; | ||
432 | case ibft_eth_hostname: | ||
433 | str += sprintf_string(str, nic->hostname_len, | ||
434 | (char *)ibft_loc + nic->hostname_off); | ||
435 | break; | ||
436 | default: | ||
437 | break; | ||
438 | } | ||
439 | |||
440 | return str - buf; | ||
441 | }; | ||
442 | |||
443 | ssize_t ibft_attr_show_target(struct ibft_kobject *entry, | ||
444 | struct ibft_attribute *attr, | ||
445 | char *buf) | ||
446 | { | ||
447 | struct ibft_tgt *tgt = entry->tgt; | ||
448 | void *ibft_loc = entry->header; | ||
449 | char *str = buf; | ||
450 | int i; | ||
451 | |||
452 | if (!tgt) | ||
453 | return 0; | ||
454 | |||
455 | switch (attr->type) { | ||
456 | case ibft_tgt_index: | ||
457 | str += sprintf(str, "%d\n", tgt->hdr.index); | ||
458 | break; | ||
459 | case ibft_tgt_flags: | ||
460 | str += sprintf(str, "%d\n", tgt->hdr.flags); | ||
461 | break; | ||
462 | case ibft_tgt_ip_addr: | ||
463 | str += sprintf_ipaddr(str, tgt->ip_addr); | ||
464 | break; | ||
465 | case ibft_tgt_port: | ||
466 | str += sprintf(str, "%d\n", tgt->port); | ||
467 | break; | ||
468 | case ibft_tgt_lun: | ||
469 | for (i = 0; i < 8; i++) | ||
470 | str += sprintf(str, "%x", (u8)tgt->lun[i]); | ||
471 | str += sprintf(str, "\n"); | ||
472 | break; | ||
473 | case ibft_tgt_nic_assoc: | ||
474 | str += sprintf(str, "%d\n", tgt->nic_assoc); | ||
475 | break; | ||
476 | case ibft_tgt_chap_type: | ||
477 | str += sprintf(str, "%d\n", tgt->chap_type); | ||
478 | break; | ||
479 | case ibft_tgt_name: | ||
480 | str += sprintf_string(str, tgt->tgt_name_len, | ||
481 | (char *)ibft_loc + tgt->tgt_name_off); | ||
482 | break; | ||
483 | case ibft_tgt_chap_name: | ||
484 | str += sprintf_string(str, tgt->chap_name_len, | ||
485 | (char *)ibft_loc + tgt->chap_name_off); | ||
486 | break; | ||
487 | case ibft_tgt_chap_secret: | ||
488 | str += sprintf_string(str, tgt->chap_secret_len, | ||
489 | (char *)ibft_loc + tgt->chap_secret_off); | ||
490 | break; | ||
491 | case ibft_tgt_rev_chap_name: | ||
492 | str += sprintf_string(str, tgt->rev_chap_name_len, | ||
493 | (char *)ibft_loc + | ||
494 | tgt->rev_chap_name_off); | ||
495 | break; | ||
496 | case ibft_tgt_rev_chap_secret: | ||
497 | str += sprintf_string(str, tgt->rev_chap_secret_len, | ||
498 | (char *)ibft_loc + | ||
499 | tgt->rev_chap_secret_off); | ||
500 | break; | ||
501 | default: | ||
502 | break; | ||
503 | } | ||
504 | |||
505 | return str - buf; | ||
506 | } | ||
507 | |||
508 | /* | ||
509 | * The routine called for all sysfs attributes. | ||
510 | */ | ||
511 | static ssize_t ibft_show_attribute(struct kobject *kobj, | ||
512 | struct attribute *attr, | ||
513 | char *buf) | ||
514 | { | ||
515 | struct ibft_kobject *dev = | ||
516 | container_of(kobj, struct ibft_kobject, kobj); | ||
517 | struct ibft_attribute *ibft_attr = | ||
518 | container_of(attr, struct ibft_attribute, attr); | ||
519 | ssize_t ret = -EIO; | ||
520 | char *str = buf; | ||
521 | |||
522 | if (!capable(CAP_SYS_ADMIN)) | ||
523 | return -EACCES; | ||
524 | |||
525 | if (ibft_attr->show) | ||
526 | ret = ibft_attr->show(dev, ibft_attr, str); | ||
527 | |||
528 | return ret; | ||
529 | } | ||
530 | |||
531 | static struct sysfs_ops ibft_attr_ops = { | ||
532 | .show = ibft_show_attribute, | ||
533 | }; | ||
534 | |||
535 | static struct kobj_type ibft_ktype = { | ||
536 | .release = ibft_release, | ||
537 | .sysfs_ops = &ibft_attr_ops, | ||
538 | }; | ||
539 | |||
540 | static struct kset *ibft_kset; | ||
541 | |||
542 | static int __init ibft_check_device(void) | ||
543 | { | ||
544 | int len; | ||
545 | u8 *pos; | ||
546 | u8 csum = 0; | ||
547 | |||
548 | len = ibft_addr->length; | ||
549 | |||
550 | /* Sanity checking of iBFT. */ | ||
551 | if (ibft_addr->revision != 1) { | ||
552 | printk(KERN_ERR "iBFT module supports only revision 1, " \ | ||
553 | "while this is %d.\n", ibft_addr->revision); | ||
554 | return -ENOENT; | ||
555 | } | ||
556 | for (pos = (u8 *)ibft_addr; pos < (u8 *)ibft_addr + len; pos++) | ||
557 | csum += *pos; | ||
558 | |||
559 | if (csum) { | ||
560 | printk(KERN_ERR "iBFT has incorrect checksum (0x%x)!\n", csum); | ||
561 | return -ENOENT; | ||
562 | } | ||
563 | |||
564 | return 0; | ||
565 | } | ||
566 | |||
567 | /* | ||
568 | * Helper function for ibft_register_kobjects. | ||
569 | */ | ||
570 | static int __init ibft_create_kobject(struct ibft_table_header *header, | ||
571 | struct ibft_hdr *hdr, | ||
572 | struct list_head *list) | ||
573 | { | ||
574 | struct ibft_kobject *ibft_kobj = NULL; | ||
575 | struct ibft_nic *nic = (struct ibft_nic *)hdr; | ||
576 | struct pci_dev *pci_dev; | ||
577 | int rc = 0; | ||
578 | |||
579 | ibft_kobj = kzalloc(sizeof(*ibft_kobj), GFP_KERNEL); | ||
580 | if (!ibft_kobj) | ||
581 | return -ENOMEM; | ||
582 | |||
583 | ibft_kobj->header = header; | ||
584 | ibft_kobj->hdr = hdr; | ||
585 | |||
586 | switch (hdr->id) { | ||
587 | case id_initiator: | ||
588 | rc = ibft_verify_hdr("initiator", hdr, id_initiator, | ||
589 | sizeof(*ibft_kobj->initiator)); | ||
590 | break; | ||
591 | case id_nic: | ||
592 | rc = ibft_verify_hdr("ethernet", hdr, id_nic, | ||
593 | sizeof(*ibft_kobj->nic)); | ||
594 | break; | ||
595 | case id_target: | ||
596 | rc = ibft_verify_hdr("target", hdr, id_target, | ||
597 | sizeof(*ibft_kobj->tgt)); | ||
598 | break; | ||
599 | case id_reserved: | ||
600 | case id_control: | ||
601 | case id_extensions: | ||
602 | /* Fields which we don't support. Ignore them */ | ||
603 | rc = 1; | ||
604 | break; | ||
605 | default: | ||
606 | printk(KERN_ERR "iBFT has unknown structure type (%d). " \ | ||
607 | "Report this bug to %.6s!\n", hdr->id, | ||
608 | header->oem_id); | ||
609 | rc = 1; | ||
610 | break; | ||
611 | } | ||
612 | |||
613 | if (rc) { | ||
614 | /* Skip adding this kobject, but exit with non-fatal error. */ | ||
615 | kfree(ibft_kobj); | ||
616 | goto out_invalid_struct; | ||
617 | } | ||
618 | |||
619 | ibft_kobj->kobj.kset = ibft_kset; | ||
620 | |||
621 | rc = kobject_init_and_add(&ibft_kobj->kobj, &ibft_ktype, | ||
622 | NULL, ibft_id_names[hdr->id], hdr->index); | ||
623 | |||
624 | if (rc) { | ||
625 | kfree(ibft_kobj); | ||
626 | goto out; | ||
627 | } | ||
628 | |||
629 | kobject_uevent(&ibft_kobj->kobj, KOBJ_ADD); | ||
630 | |||
631 | if (hdr->id == id_nic) { | ||
632 | /* | ||
633 | * We don't search for the device in other domains than | ||
634 | * zero. This is because on x86 platforms the BIOS | ||
635 | * executes only devices which are in domain 0. Furthermore, the | ||
636 | * iBFT spec doesn't have a domain id field :-( | ||
637 | */ | ||
638 | pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >> 8, | ||
639 | (nic->pci_bdf & 0xff)); | ||
640 | if (pci_dev) { | ||
641 | rc = sysfs_create_link(&ibft_kobj->kobj, | ||
642 | &pci_dev->dev.kobj, "device"); | ||
643 | pci_dev_put(pci_dev); | ||
644 | } | ||
645 | } | ||
646 | |||
647 | /* Nothing broke so lets add it to the list. */ | ||
648 | list_add_tail(&ibft_kobj->node, list); | ||
649 | out: | ||
650 | return rc; | ||
651 | out_invalid_struct: | ||
652 | /* Unsupported structs are skipped. */ | ||
653 | return 0; | ||
654 | } | ||
655 | |||
656 | /* | ||
657 | * Scan the IBFT table structure for the NIC and Target fields. When | ||
658 | * found add them on the passed-in list. We do not support the other | ||
659 | * fields at this point, so they are skipped. | ||
660 | */ | ||
661 | static int __init ibft_register_kobjects(struct ibft_table_header *header, | ||
662 | struct list_head *list) | ||
663 | { | ||
664 | struct ibft_control *control = NULL; | ||
665 | void *ptr, *end; | ||
666 | int rc = 0; | ||
667 | u16 offset; | ||
668 | u16 eot_offset; | ||
669 | |||
670 | control = (void *)header + sizeof(*header); | ||
671 | end = (void *)control + control->hdr.length; | ||
672 | eot_offset = (void *)header + header->length - | ||
673 | (void *)control - sizeof(*header); | ||
674 | rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control, | ||
675 | sizeof(*control)); | ||
676 | |||
677 | /* iBFT table safety checking */ | ||
678 | rc |= ((control->hdr.index) ? -ENODEV : 0); | ||
679 | if (rc) { | ||
680 | printk(KERN_ERR "iBFT error: Control header is invalid!\n"); | ||
681 | return rc; | ||
682 | } | ||
683 | for (ptr = &control->initiator_off; ptr < end; ptr += sizeof(u16)) { | ||
684 | offset = *(u16 *)ptr; | ||
685 | if (offset && offset < header->length && offset < eot_offset) { | ||
686 | rc = ibft_create_kobject(header, | ||
687 | (void *)header + offset, | ||
688 | list); | ||
689 | if (rc) | ||
690 | break; | ||
691 | } | ||
692 | } | ||
693 | |||
694 | return rc; | ||
695 | } | ||
696 | |||
697 | static void ibft_unregister(struct list_head *attr_list, | ||
698 | struct list_head *kobj_list) | ||
699 | { | ||
700 | struct ibft_kobject *data = NULL, *n; | ||
701 | struct ibft_attribute *attr = NULL, *m; | ||
702 | |||
703 | list_for_each_entry_safe(attr, m, attr_list, node) { | ||
704 | sysfs_remove_file(attr->kobj, &attr->attr); | ||
705 | list_del(&attr->node); | ||
706 | kfree(attr); | ||
707 | }; | ||
708 | list_del_init(attr_list); | ||
709 | |||
710 | list_for_each_entry_safe(data, n, kobj_list, node) { | ||
711 | list_del(&data->node); | ||
712 | if (data->hdr->id == id_nic) | ||
713 | sysfs_remove_link(&data->kobj, "device"); | ||
714 | kobject_put(&data->kobj); | ||
715 | }; | ||
716 | list_del_init(kobj_list); | ||
717 | } | ||
718 | |||
719 | static int __init ibft_create_attribute(struct ibft_kobject *kobj_data, | ||
720 | int type, | ||
721 | const char *name, | ||
722 | ssize_t (*show)(struct ibft_kobject *, | ||
723 | struct ibft_attribute*, | ||
724 | char *buf), | ||
725 | struct list_head *list) | ||
726 | { | ||
727 | struct ibft_attribute *attr = NULL; | ||
728 | struct ibft_hdr *hdr = kobj_data->hdr; | ||
729 | |||
730 | attr = kmalloc(sizeof(*attr), GFP_KERNEL); | ||
731 | if (!attr) | ||
732 | return -ENOMEM; | ||
733 | |||
734 | attr->attr.name = name; | ||
735 | attr->attr.mode = S_IRUSR; | ||
736 | attr->attr.owner = THIS_MODULE; | ||
737 | |||
738 | attr->hdr = hdr; | ||
739 | attr->show = show; | ||
740 | attr->kobj = &kobj_data->kobj; | ||
741 | attr->type = type; | ||
742 | |||
743 | list_add_tail(&attr->node, list); | ||
744 | |||
745 | return 0; | ||
746 | } | ||
747 | |||
748 | /* | ||
749 | * Helper routiners to check to determine if the entry is valid | ||
750 | * in the proper iBFT structure. | ||
751 | */ | ||
752 | static int __init ibft_check_nic_for(struct ibft_nic *nic, int entry) | ||
753 | { | ||
754 | int rc = 0; | ||
755 | |||
756 | switch (entry) { | ||
757 | case ibft_eth_index: | ||
758 | case ibft_eth_flags: | ||
759 | rc = 1; | ||
760 | break; | ||
761 | case ibft_eth_ip_addr: | ||
762 | if (!memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) | ||
763 | rc = 1; | ||
764 | break; | ||
765 | case ibft_eth_subnet_mask: | ||
766 | if (!memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) | ||
767 | rc = 1; | ||
768 | break; | ||
769 | case ibft_eth_origin: | ||
770 | rc = 1; | ||
771 | break; | ||
772 | case ibft_eth_gateway: | ||
773 | if (memcmp(nic->gateway, nulls, sizeof(nic->gateway))) | ||
774 | rc = 1; | ||
775 | break; | ||
776 | case ibft_eth_primary_dns: | ||
777 | if (memcmp(nic->primary_dns, nulls, | ||
778 | sizeof(nic->primary_dns))) | ||
779 | rc = 1; | ||
780 | break; | ||
781 | case ibft_eth_secondary_dns: | ||
782 | if (memcmp(nic->secondary_dns, nulls, | ||
783 | sizeof(nic->secondary_dns))) | ||
784 | rc = 1; | ||
785 | break; | ||
786 | case ibft_eth_dhcp: | ||
787 | if (memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) | ||
788 | rc = 1; | ||
789 | break; | ||
790 | case ibft_eth_vlan: | ||
791 | case ibft_eth_mac: | ||
792 | rc = 1; | ||
793 | break; | ||
794 | case ibft_eth_hostname: | ||
795 | if (nic->hostname_off) | ||
796 | rc = 1; | ||
797 | break; | ||
798 | default: | ||
799 | break; | ||
800 | } | ||
801 | |||
802 | return rc; | ||
803 | } | ||
804 | |||
805 | static int __init ibft_check_tgt_for(struct ibft_tgt *tgt, int entry) | ||
806 | { | ||
807 | int rc = 0; | ||
808 | |||
809 | switch (entry) { | ||
810 | case ibft_tgt_index: | ||
811 | case ibft_tgt_flags: | ||
812 | case ibft_tgt_ip_addr: | ||
813 | case ibft_tgt_port: | ||
814 | case ibft_tgt_lun: | ||
815 | case ibft_tgt_nic_assoc: | ||
816 | case ibft_tgt_chap_type: | ||
817 | rc = 1; | ||
818 | case ibft_tgt_name: | ||
819 | if (tgt->tgt_name_len) | ||
820 | rc = 1; | ||
821 | break; | ||
822 | case ibft_tgt_chap_name: | ||
823 | case ibft_tgt_chap_secret: | ||
824 | if (tgt->chap_name_len) | ||
825 | rc = 1; | ||
826 | break; | ||
827 | case ibft_tgt_rev_chap_name: | ||
828 | case ibft_tgt_rev_chap_secret: | ||
829 | if (tgt->rev_chap_name_len) | ||
830 | rc = 1; | ||
831 | break; | ||
832 | default: | ||
833 | break; | ||
834 | } | ||
835 | |||
836 | return rc; | ||
837 | } | ||
838 | |||
839 | static int __init ibft_check_initiator_for(struct ibft_initiator *init, | ||
840 | int entry) | ||
841 | { | ||
842 | int rc = 0; | ||
843 | |||
844 | switch (entry) { | ||
845 | case ibft_init_index: | ||
846 | case ibft_init_flags: | ||
847 | rc = 1; | ||
848 | break; | ||
849 | case ibft_init_isns_server: | ||
850 | if (memcmp(init->isns_server, nulls, | ||
851 | sizeof(init->isns_server))) | ||
852 | rc = 1; | ||
853 | break; | ||
854 | case ibft_init_slp_server: | ||
855 | if (memcmp(init->slp_server, nulls, | ||
856 | sizeof(init->slp_server))) | ||
857 | rc = 1; | ||
858 | break; | ||
859 | case ibft_init_pri_radius_server: | ||
860 | if (memcmp(init->pri_radius_server, nulls, | ||
861 | sizeof(init->pri_radius_server))) | ||
862 | rc = 1; | ||
863 | break; | ||
864 | case ibft_init_sec_radius_server: | ||
865 | if (memcmp(init->sec_radius_server, nulls, | ||
866 | sizeof(init->sec_radius_server))) | ||
867 | rc = 1; | ||
868 | break; | ||
869 | case ibft_init_initiator_name: | ||
870 | if (init->initiator_name_len) | ||
871 | rc = 1; | ||
872 | break; | ||
873 | default: | ||
874 | break; | ||
875 | } | ||
876 | |||
877 | return rc; | ||
878 | } | ||
879 | |||
880 | /* | ||
881 | * Register the attributes for all of the kobjects. | ||
882 | */ | ||
883 | static int __init ibft_register_attributes(struct list_head *kobject_list, | ||
884 | struct list_head *attr_list) | ||
885 | { | ||
886 | int rc = 0, i = 0; | ||
887 | struct ibft_kobject *data = NULL; | ||
888 | struct ibft_attribute *attr = NULL, *m; | ||
889 | |||
890 | list_for_each_entry(data, kobject_list, node) { | ||
891 | switch (data->hdr->id) { | ||
892 | case id_nic: | ||
893 | for (i = 0; i < ibft_eth_end_marker && !rc; i++) | ||
894 | if (ibft_check_nic_for(data->nic, i)) | ||
895 | rc = ibft_create_attribute(data, i, | ||
896 | ibft_eth_properties[i], | ||
897 | ibft_attr_show_nic, attr_list); | ||
898 | break; | ||
899 | case id_target: | ||
900 | for (i = 0; i < ibft_tgt_end_marker && !rc; i++) | ||
901 | if (ibft_check_tgt_for(data->tgt, i)) | ||
902 | rc = ibft_create_attribute(data, i, | ||
903 | ibft_tgt_properties[i], | ||
904 | ibft_attr_show_target, | ||
905 | attr_list); | ||
906 | break; | ||
907 | case id_initiator: | ||
908 | for (i = 0; i < ibft_init_end_marker && !rc; i++) | ||
909 | if (ibft_check_initiator_for( | ||
910 | data->initiator, i)) | ||
911 | rc = ibft_create_attribute(data, i, | ||
912 | ibft_initiator_properties[i], | ||
913 | ibft_attr_show_initiator, | ||
914 | attr_list); | ||
915 | break; | ||
916 | default: | ||
917 | break; | ||
918 | } | ||
919 | if (rc) | ||
920 | break; | ||
921 | } | ||
922 | list_for_each_entry_safe(attr, m, attr_list, node) { | ||
923 | rc = sysfs_create_file(attr->kobj, &attr->attr); | ||
924 | if (rc) { | ||
925 | list_del(&attr->node); | ||
926 | kfree(attr); | ||
927 | break; | ||
928 | } | ||
929 | } | ||
930 | |||
931 | return rc; | ||
932 | } | ||
933 | |||
934 | /* | ||
935 | * ibft_init() - creates sysfs tree entries for the iBFT data. | ||
936 | */ | ||
937 | static int __init ibft_init(void) | ||
938 | { | ||
939 | int rc = 0; | ||
940 | |||
941 | ibft_kset = kset_create_and_add("ibft", NULL, firmware_kobj); | ||
942 | if (!ibft_kset) | ||
943 | return -ENOMEM; | ||
944 | |||
945 | if (ibft_addr) { | ||
946 | printk(KERN_INFO "iBFT detected at 0x%lx.\n", | ||
947 | virt_to_phys((void *)ibft_addr)); | ||
948 | |||
949 | rc = ibft_check_device(); | ||
950 | if (rc) | ||
951 | goto out_firmware_unregister; | ||
952 | |||
953 | /* Scan the IBFT for data and register the kobjects. */ | ||
954 | rc = ibft_register_kobjects(ibft_addr, &ibft_kobject_list); | ||
955 | if (rc) | ||
956 | goto out_free; | ||
957 | |||
958 | /* Register the attributes */ | ||
959 | rc = ibft_register_attributes(&ibft_kobject_list, | ||
960 | &ibft_attr_list); | ||
961 | if (rc) | ||
962 | goto out_free; | ||
963 | } else | ||
964 | printk(KERN_INFO "No iBFT detected.\n"); | ||
965 | |||
966 | return 0; | ||
967 | |||
968 | out_free: | ||
969 | ibft_unregister(&ibft_attr_list, &ibft_kobject_list); | ||
970 | out_firmware_unregister: | ||
971 | kset_unregister(ibft_kset); | ||
972 | return rc; | ||
973 | } | ||
974 | |||
975 | static void __exit ibft_exit(void) | ||
976 | { | ||
977 | ibft_unregister(&ibft_attr_list, &ibft_kobject_list); | ||
978 | kset_unregister(ibft_kset); | ||
979 | } | ||
980 | |||
981 | module_init(ibft_init); | ||
982 | module_exit(ibft_exit); | ||
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c new file mode 100644 index 000000000000..d0e5fa4ea51b --- /dev/null +++ b/drivers/firmware/iscsi_ibft_find.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright 2007 Red Hat, Inc. | ||
3 | * by Peter Jones <pjones@redhat.com> | ||
4 | * Copyright 2007 IBM, Inc. | ||
5 | * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com> | ||
6 | * Copyright 2008 | ||
7 | * by Konrad Rzeszutek <ketuzsezr@darnok.org> | ||
8 | * | ||
9 | * This code finds the iSCSI Boot Format Table. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License v2.0 as published by | ||
13 | * the Free Software Foundation | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | */ | ||
20 | |||
21 | #include <linux/bootmem.h> | ||
22 | #include <linux/blkdev.h> | ||
23 | #include <linux/ctype.h> | ||
24 | #include <linux/device.h> | ||
25 | #include <linux/err.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/limits.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/pci.h> | ||
30 | #include <linux/slab.h> | ||
31 | #include <linux/stat.h> | ||
32 | #include <linux/string.h> | ||
33 | #include <linux/types.h> | ||
34 | |||
35 | #include <asm/mmzone.h> | ||
36 | |||
37 | /* | ||
38 | * Physical location of iSCSI Boot Format Table. | ||
39 | */ | ||
40 | struct ibft_table_header *ibft_addr; | ||
41 | EXPORT_SYMBOL_GPL(ibft_addr); | ||
42 | |||
43 | #define IBFT_SIGN "iBFT" | ||
44 | #define IBFT_SIGN_LEN 4 | ||
45 | #define IBFT_START 0x80000 /* 512kB */ | ||
46 | #define IBFT_END 0x100000 /* 1MB */ | ||
47 | #define VGA_MEM 0xA0000 /* VGA buffer */ | ||
48 | #define VGA_SIZE 0x20000 /* 128kB */ | ||
49 | |||
50 | |||
51 | /* | ||
52 | * Routine used to find the iSCSI Boot Format Table. The logical | ||
53 | * kernel address is set in the ibft_addr global variable. | ||
54 | */ | ||
55 | void __init reserve_ibft_region(void) | ||
56 | { | ||
57 | unsigned long pos; | ||
58 | unsigned int len = 0; | ||
59 | void *virt; | ||
60 | |||
61 | ibft_addr = 0; | ||
62 | |||
63 | for (pos = IBFT_START; pos < IBFT_END; pos += 16) { | ||
64 | /* The table can't be inside the VGA BIOS reserved space, | ||
65 | * so skip that area */ | ||
66 | if (pos == VGA_MEM) | ||
67 | pos += VGA_SIZE; | ||
68 | virt = phys_to_virt(pos); | ||
69 | if (memcmp(virt, IBFT_SIGN, IBFT_SIGN_LEN) == 0) { | ||
70 | unsigned long *addr = | ||
71 | (unsigned long *)phys_to_virt(pos + 4); | ||
72 | len = *addr; | ||
73 | /* if the length of the table extends past 1M, | ||
74 | * the table cannot be valid. */ | ||
75 | if (pos + len <= (IBFT_END-1)) { | ||
76 | ibft_addr = (struct ibft_table_header *)virt; | ||
77 | break; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | if (ibft_addr) | ||
82 | reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT); | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(reserve_ibft_region); | ||
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 5a4b2e65534b..95756551cf7c 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -427,17 +427,17 @@ static struct kobj_type port_type = { | |||
427 | .default_attrs = port_default_attrs | 427 | .default_attrs = port_default_attrs |
428 | }; | 428 | }; |
429 | 429 | ||
430 | static void ib_device_release(struct class_device *cdev) | 430 | static void ib_device_release(struct device *device) |
431 | { | 431 | { |
432 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 432 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
433 | 433 | ||
434 | kfree(dev); | 434 | kfree(dev); |
435 | } | 435 | } |
436 | 436 | ||
437 | static int ib_device_uevent(struct class_device *cdev, | 437 | static int ib_device_uevent(struct device *device, |
438 | struct kobj_uevent_env *env) | 438 | struct kobj_uevent_env *env) |
439 | { | 439 | { |
440 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 440 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
441 | 441 | ||
442 | if (add_uevent_var(env, "NAME=%s", dev->name)) | 442 | if (add_uevent_var(env, "NAME=%s", dev->name)) |
443 | return -ENOMEM; | 443 | return -ENOMEM; |
@@ -567,9 +567,10 @@ err_put: | |||
567 | return ret; | 567 | return ret; |
568 | } | 568 | } |
569 | 569 | ||
570 | static ssize_t show_node_type(struct class_device *cdev, char *buf) | 570 | static ssize_t show_node_type(struct device *device, |
571 | struct device_attribute *attr, char *buf) | ||
571 | { | 572 | { |
572 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 573 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
573 | 574 | ||
574 | if (!ibdev_is_alive(dev)) | 575 | if (!ibdev_is_alive(dev)) |
575 | return -ENODEV; | 576 | return -ENODEV; |
@@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf) | |||
583 | } | 584 | } |
584 | } | 585 | } |
585 | 586 | ||
586 | static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) | 587 | static ssize_t show_sys_image_guid(struct device *device, |
588 | struct device_attribute *dev_attr, char *buf) | ||
587 | { | 589 | { |
588 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 590 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
589 | struct ib_device_attr attr; | 591 | struct ib_device_attr attr; |
590 | ssize_t ret; | 592 | ssize_t ret; |
591 | 593 | ||
@@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) | |||
603 | be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); | 605 | be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); |
604 | } | 606 | } |
605 | 607 | ||
606 | static ssize_t show_node_guid(struct class_device *cdev, char *buf) | 608 | static ssize_t show_node_guid(struct device *device, |
609 | struct device_attribute *attr, char *buf) | ||
607 | { | 610 | { |
608 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 611 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
609 | 612 | ||
610 | if (!ibdev_is_alive(dev)) | 613 | if (!ibdev_is_alive(dev)) |
611 | return -ENODEV; | 614 | return -ENODEV; |
@@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf) | |||
617 | be16_to_cpu(((__be16 *) &dev->node_guid)[3])); | 620 | be16_to_cpu(((__be16 *) &dev->node_guid)[3])); |
618 | } | 621 | } |
619 | 622 | ||
620 | static ssize_t show_node_desc(struct class_device *cdev, char *buf) | 623 | static ssize_t show_node_desc(struct device *device, |
624 | struct device_attribute *attr, char *buf) | ||
621 | { | 625 | { |
622 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 626 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
623 | 627 | ||
624 | return sprintf(buf, "%.64s\n", dev->node_desc); | 628 | return sprintf(buf, "%.64s\n", dev->node_desc); |
625 | } | 629 | } |
626 | 630 | ||
627 | static ssize_t set_node_desc(struct class_device *cdev, const char *buf, | 631 | static ssize_t set_node_desc(struct device *device, |
628 | size_t count) | 632 | struct device_attribute *attr, |
633 | const char *buf, size_t count) | ||
629 | { | 634 | { |
630 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 635 | struct ib_device *dev = container_of(device, struct ib_device, dev); |
631 | struct ib_device_modify desc = {}; | 636 | struct ib_device_modify desc = {}; |
632 | int ret; | 637 | int ret; |
633 | 638 | ||
@@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf, | |||
642 | return count; | 647 | return count; |
643 | } | 648 | } |
644 | 649 | ||
645 | static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); | 650 | static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); |
646 | static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); | 651 | static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); |
647 | static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); | 652 | static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); |
648 | static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, | 653 | static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc); |
649 | set_node_desc); | 654 | |
650 | 655 | static struct device_attribute *ib_class_attributes[] = { | |
651 | static struct class_device_attribute *ib_class_attributes[] = { | 656 | &dev_attr_node_type, |
652 | &class_device_attr_node_type, | 657 | &dev_attr_sys_image_guid, |
653 | &class_device_attr_sys_image_guid, | 658 | &dev_attr_node_guid, |
654 | &class_device_attr_node_guid, | 659 | &dev_attr_node_desc |
655 | &class_device_attr_node_desc | ||
656 | }; | 660 | }; |
657 | 661 | ||
658 | static struct class ib_class = { | 662 | static struct class ib_class = { |
659 | .name = "infiniband", | 663 | .name = "infiniband", |
660 | .release = ib_device_release, | 664 | .dev_release = ib_device_release, |
661 | .uevent = ib_device_uevent, | 665 | .dev_uevent = ib_device_uevent, |
662 | }; | 666 | }; |
663 | 667 | ||
664 | int ib_device_register_sysfs(struct ib_device *device) | 668 | int ib_device_register_sysfs(struct ib_device *device) |
665 | { | 669 | { |
666 | struct class_device *class_dev = &device->class_dev; | 670 | struct device *class_dev = &device->dev; |
667 | int ret; | 671 | int ret; |
668 | int i; | 672 | int i; |
669 | 673 | ||
670 | class_dev->class = &ib_class; | 674 | class_dev->class = &ib_class; |
671 | class_dev->class_data = device; | 675 | class_dev->driver_data = device; |
672 | class_dev->dev = device->dma_device; | 676 | class_dev->parent = device->dma_device; |
673 | strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); | 677 | strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE); |
674 | 678 | ||
675 | INIT_LIST_HEAD(&device->port_list); | 679 | INIT_LIST_HEAD(&device->port_list); |
676 | 680 | ||
677 | ret = class_device_register(class_dev); | 681 | ret = device_register(class_dev); |
678 | if (ret) | 682 | if (ret) |
679 | goto err; | 683 | goto err; |
680 | 684 | ||
681 | for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { | 685 | for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { |
682 | ret = class_device_create_file(class_dev, ib_class_attributes[i]); | 686 | ret = device_create_file(class_dev, ib_class_attributes[i]); |
683 | if (ret) | 687 | if (ret) |
684 | goto err_unregister; | 688 | goto err_unregister; |
685 | } | 689 | } |
@@ -723,7 +727,7 @@ err_put: | |||
723 | kobject_put(&class_dev->kobj); | 727 | kobject_put(&class_dev->kobj); |
724 | 728 | ||
725 | err_unregister: | 729 | err_unregister: |
726 | class_device_unregister(class_dev); | 730 | device_unregister(class_dev); |
727 | 731 | ||
728 | err: | 732 | err: |
729 | return ret; | 733 | return ret; |
@@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device) | |||
744 | } | 748 | } |
745 | 749 | ||
746 | kobject_put(device->ports_parent); | 750 | kobject_put(device->ports_parent); |
747 | class_device_unregister(&device->class_dev); | 751 | device_unregister(&device->dev); |
748 | } | 752 | } |
749 | 753 | ||
750 | int ib_sysfs_setup(void) | 754 | int ib_sysfs_setup(void) |
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 4291ab42a5b9..d7a6881b571d 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -58,8 +58,8 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
58 | 58 | ||
59 | struct ib_ucm_device { | 59 | struct ib_ucm_device { |
60 | int devnum; | 60 | int devnum; |
61 | struct cdev dev; | 61 | struct cdev cdev; |
62 | struct class_device class_dev; | 62 | struct device dev; |
63 | struct ib_device *ib_dev; | 63 | struct ib_device *ib_dev; |
64 | }; | 64 | }; |
65 | 65 | ||
@@ -1171,7 +1171,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp) | |||
1171 | 1171 | ||
1172 | filp->private_data = file; | 1172 | filp->private_data = file; |
1173 | file->filp = filp; | 1173 | file->filp = filp; |
1174 | file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev); | 1174 | file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev); |
1175 | 1175 | ||
1176 | return 0; | 1176 | return 0; |
1177 | } | 1177 | } |
@@ -1202,14 +1202,14 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) | |||
1202 | return 0; | 1202 | return 0; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | static void ucm_release_class_dev(struct class_device *class_dev) | 1205 | static void ib_ucm_release_dev(struct device *dev) |
1206 | { | 1206 | { |
1207 | struct ib_ucm_device *dev; | 1207 | struct ib_ucm_device *ucm_dev; |
1208 | 1208 | ||
1209 | dev = container_of(class_dev, struct ib_ucm_device, class_dev); | 1209 | ucm_dev = container_of(dev, struct ib_ucm_device, dev); |
1210 | cdev_del(&dev->dev); | 1210 | cdev_del(&ucm_dev->cdev); |
1211 | clear_bit(dev->devnum, dev_map); | 1211 | clear_bit(ucm_dev->devnum, dev_map); |
1212 | kfree(dev); | 1212 | kfree(ucm_dev); |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | static const struct file_operations ucm_fops = { | 1215 | static const struct file_operations ucm_fops = { |
@@ -1220,14 +1220,15 @@ static const struct file_operations ucm_fops = { | |||
1220 | .poll = ib_ucm_poll, | 1220 | .poll = ib_ucm_poll, |
1221 | }; | 1221 | }; |
1222 | 1222 | ||
1223 | static ssize_t show_ibdev(struct class_device *class_dev, char *buf) | 1223 | static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, |
1224 | char *buf) | ||
1224 | { | 1225 | { |
1225 | struct ib_ucm_device *dev; | 1226 | struct ib_ucm_device *ucm_dev; |
1226 | 1227 | ||
1227 | dev = container_of(class_dev, struct ib_ucm_device, class_dev); | 1228 | ucm_dev = container_of(dev, struct ib_ucm_device, dev); |
1228 | return sprintf(buf, "%s\n", dev->ib_dev->name); | 1229 | return sprintf(buf, "%s\n", ucm_dev->ib_dev->name); |
1229 | } | 1230 | } |
1230 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | 1231 | static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); |
1231 | 1232 | ||
1232 | static void ib_ucm_add_one(struct ib_device *device) | 1233 | static void ib_ucm_add_one(struct ib_device *device) |
1233 | { | 1234 | { |
@@ -1249,32 +1250,31 @@ static void ib_ucm_add_one(struct ib_device *device) | |||
1249 | 1250 | ||
1250 | set_bit(ucm_dev->devnum, dev_map); | 1251 | set_bit(ucm_dev->devnum, dev_map); |
1251 | 1252 | ||
1252 | cdev_init(&ucm_dev->dev, &ucm_fops); | 1253 | cdev_init(&ucm_dev->cdev, &ucm_fops); |
1253 | ucm_dev->dev.owner = THIS_MODULE; | 1254 | ucm_dev->cdev.owner = THIS_MODULE; |
1254 | kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum); | 1255 | kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); |
1255 | if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) | 1256 | if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) |
1256 | goto err; | 1257 | goto err; |
1257 | 1258 | ||
1258 | ucm_dev->class_dev.class = &cm_class; | 1259 | ucm_dev->dev.class = &cm_class; |
1259 | ucm_dev->class_dev.dev = device->dma_device; | 1260 | ucm_dev->dev.parent = device->dma_device; |
1260 | ucm_dev->class_dev.devt = ucm_dev->dev.dev; | 1261 | ucm_dev->dev.devt = ucm_dev->cdev.dev; |
1261 | ucm_dev->class_dev.release = ucm_release_class_dev; | 1262 | ucm_dev->dev.release = ib_ucm_release_dev; |
1262 | snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d", | 1263 | snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d", |
1263 | ucm_dev->devnum); | 1264 | ucm_dev->devnum); |
1264 | if (class_device_register(&ucm_dev->class_dev)) | 1265 | if (device_register(&ucm_dev->dev)) |
1265 | goto err_cdev; | 1266 | goto err_cdev; |
1266 | 1267 | ||
1267 | if (class_device_create_file(&ucm_dev->class_dev, | 1268 | if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev)) |
1268 | &class_device_attr_ibdev)) | 1269 | goto err_dev; |
1269 | goto err_class; | ||
1270 | 1270 | ||
1271 | ib_set_client_data(device, &ucm_client, ucm_dev); | 1271 | ib_set_client_data(device, &ucm_client, ucm_dev); |
1272 | return; | 1272 | return; |
1273 | 1273 | ||
1274 | err_class: | 1274 | err_dev: |
1275 | class_device_unregister(&ucm_dev->class_dev); | 1275 | device_unregister(&ucm_dev->dev); |
1276 | err_cdev: | 1276 | err_cdev: |
1277 | cdev_del(&ucm_dev->dev); | 1277 | cdev_del(&ucm_dev->cdev); |
1278 | clear_bit(ucm_dev->devnum, dev_map); | 1278 | clear_bit(ucm_dev->devnum, dev_map); |
1279 | err: | 1279 | err: |
1280 | kfree(ucm_dev); | 1280 | kfree(ucm_dev); |
@@ -1288,7 +1288,7 @@ static void ib_ucm_remove_one(struct ib_device *device) | |||
1288 | if (!ucm_dev) | 1288 | if (!ucm_dev) |
1289 | return; | 1289 | return; |
1290 | 1290 | ||
1291 | class_device_unregister(&ucm_dev->class_dev); | 1291 | device_unregister(&ucm_dev->dev); |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | static ssize_t show_abi_version(struct class *class, char *buf) | 1294 | static ssize_t show_abi_version(struct class *class, char *buf) |
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index be953e87bf93..3aa2db54eae4 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c | |||
@@ -88,11 +88,11 @@ enum { | |||
88 | */ | 88 | */ |
89 | 89 | ||
90 | struct ib_umad_port { | 90 | struct ib_umad_port { |
91 | struct cdev *dev; | 91 | struct cdev *cdev; |
92 | struct class_device *class_dev; | 92 | struct device *dev; |
93 | 93 | ||
94 | struct cdev *sm_dev; | 94 | struct cdev *sm_cdev; |
95 | struct class_device *sm_class_dev; | 95 | struct device *sm_dev; |
96 | struct semaphore sm_sem; | 96 | struct semaphore sm_sem; |
97 | 97 | ||
98 | struct mutex file_mutex; | 98 | struct mutex file_mutex; |
@@ -948,27 +948,29 @@ static struct ib_client umad_client = { | |||
948 | .remove = ib_umad_remove_one | 948 | .remove = ib_umad_remove_one |
949 | }; | 949 | }; |
950 | 950 | ||
951 | static ssize_t show_ibdev(struct class_device *class_dev, char *buf) | 951 | static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, |
952 | char *buf) | ||
952 | { | 953 | { |
953 | struct ib_umad_port *port = class_get_devdata(class_dev); | 954 | struct ib_umad_port *port = dev_get_drvdata(dev); |
954 | 955 | ||
955 | if (!port) | 956 | if (!port) |
956 | return -ENODEV; | 957 | return -ENODEV; |
957 | 958 | ||
958 | return sprintf(buf, "%s\n", port->ib_dev->name); | 959 | return sprintf(buf, "%s\n", port->ib_dev->name); |
959 | } | 960 | } |
960 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | 961 | static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); |
961 | 962 | ||
962 | static ssize_t show_port(struct class_device *class_dev, char *buf) | 963 | static ssize_t show_port(struct device *dev, struct device_attribute *attr, |
964 | char *buf) | ||
963 | { | 965 | { |
964 | struct ib_umad_port *port = class_get_devdata(class_dev); | 966 | struct ib_umad_port *port = dev_get_drvdata(dev); |
965 | 967 | ||
966 | if (!port) | 968 | if (!port) |
967 | return -ENODEV; | 969 | return -ENODEV; |
968 | 970 | ||
969 | return sprintf(buf, "%d\n", port->port_num); | 971 | return sprintf(buf, "%d\n", port->port_num); |
970 | } | 972 | } |
971 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 973 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
972 | 974 | ||
973 | static ssize_t show_abi_version(struct class *class, char *buf) | 975 | static ssize_t show_abi_version(struct class *class, char *buf) |
974 | { | 976 | { |
@@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, | |||
994 | mutex_init(&port->file_mutex); | 996 | mutex_init(&port->file_mutex); |
995 | INIT_LIST_HEAD(&port->file_list); | 997 | INIT_LIST_HEAD(&port->file_list); |
996 | 998 | ||
997 | port->dev = cdev_alloc(); | 999 | port->cdev = cdev_alloc(); |
998 | if (!port->dev) | 1000 | if (!port->cdev) |
999 | return -1; | 1001 | return -1; |
1000 | port->dev->owner = THIS_MODULE; | 1002 | port->cdev->owner = THIS_MODULE; |
1001 | port->dev->ops = &umad_fops; | 1003 | port->cdev->ops = &umad_fops; |
1002 | kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); | 1004 | kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num); |
1003 | if (cdev_add(port->dev, base_dev + port->dev_num, 1)) | 1005 | if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) |
1004 | goto err_cdev; | 1006 | goto err_cdev; |
1005 | 1007 | ||
1006 | port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, | 1008 | port->dev = device_create(umad_class, device->dma_device, |
1007 | device->dma_device, | 1009 | port->cdev->dev, "umad%d", port->dev_num); |
1008 | "umad%d", port->dev_num); | 1010 | if (IS_ERR(port->dev)) |
1009 | if (IS_ERR(port->class_dev)) | ||
1010 | goto err_cdev; | 1011 | goto err_cdev; |
1011 | 1012 | ||
1012 | if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) | 1013 | if (device_create_file(port->dev, &dev_attr_ibdev)) |
1013 | goto err_class; | 1014 | goto err_dev; |
1014 | if (class_device_create_file(port->class_dev, &class_device_attr_port)) | 1015 | if (device_create_file(port->dev, &dev_attr_port)) |
1015 | goto err_class; | 1016 | goto err_dev; |
1016 | 1017 | ||
1017 | port->sm_dev = cdev_alloc(); | 1018 | port->sm_cdev = cdev_alloc(); |
1018 | if (!port->sm_dev) | 1019 | if (!port->sm_cdev) |
1019 | goto err_class; | 1020 | goto err_dev; |
1020 | port->sm_dev->owner = THIS_MODULE; | 1021 | port->sm_cdev->owner = THIS_MODULE; |
1021 | port->sm_dev->ops = &umad_sm_fops; | 1022 | port->sm_cdev->ops = &umad_sm_fops; |
1022 | kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); | 1023 | kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num); |
1023 | if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) | 1024 | if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) |
1024 | goto err_sm_cdev; | 1025 | goto err_sm_cdev; |
1025 | 1026 | ||
1026 | port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, | 1027 | port->sm_dev = device_create(umad_class, device->dma_device, |
1027 | device->dma_device, | 1028 | port->sm_cdev->dev, |
1028 | "issm%d", port->dev_num); | 1029 | "issm%d", port->dev_num); |
1029 | if (IS_ERR(port->sm_class_dev)) | 1030 | if (IS_ERR(port->sm_dev)) |
1030 | goto err_sm_cdev; | 1031 | goto err_sm_cdev; |
1031 | 1032 | ||
1032 | class_set_devdata(port->class_dev, port); | 1033 | dev_set_drvdata(port->dev, port); |
1033 | class_set_devdata(port->sm_class_dev, port); | 1034 | dev_set_drvdata(port->sm_dev, port); |
1034 | 1035 | ||
1035 | if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) | 1036 | if (device_create_file(port->sm_dev, &dev_attr_ibdev)) |
1036 | goto err_sm_class; | 1037 | goto err_sm_dev; |
1037 | if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) | 1038 | if (device_create_file(port->sm_dev, &dev_attr_port)) |
1038 | goto err_sm_class; | 1039 | goto err_sm_dev; |
1039 | 1040 | ||
1040 | spin_lock(&port_lock); | 1041 | spin_lock(&port_lock); |
1041 | umad_port[port->dev_num] = port; | 1042 | umad_port[port->dev_num] = port; |
@@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, | |||
1043 | 1044 | ||
1044 | return 0; | 1045 | return 0; |
1045 | 1046 | ||
1046 | err_sm_class: | 1047 | err_sm_dev: |
1047 | class_device_destroy(umad_class, port->sm_dev->dev); | 1048 | device_destroy(umad_class, port->sm_cdev->dev); |
1048 | 1049 | ||
1049 | err_sm_cdev: | 1050 | err_sm_cdev: |
1050 | cdev_del(port->sm_dev); | 1051 | cdev_del(port->sm_cdev); |
1051 | 1052 | ||
1052 | err_class: | 1053 | err_dev: |
1053 | class_device_destroy(umad_class, port->dev->dev); | 1054 | device_destroy(umad_class, port->cdev->dev); |
1054 | 1055 | ||
1055 | err_cdev: | 1056 | err_cdev: |
1056 | cdev_del(port->dev); | 1057 | cdev_del(port->cdev); |
1057 | clear_bit(port->dev_num, dev_map); | 1058 | clear_bit(port->dev_num, dev_map); |
1058 | 1059 | ||
1059 | return -1; | 1060 | return -1; |
@@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port) | |||
1065 | int already_dead; | 1066 | int already_dead; |
1066 | int id; | 1067 | int id; |
1067 | 1068 | ||
1068 | class_set_devdata(port->class_dev, NULL); | 1069 | dev_set_drvdata(port->dev, NULL); |
1069 | class_set_devdata(port->sm_class_dev, NULL); | 1070 | dev_set_drvdata(port->sm_dev, NULL); |
1070 | 1071 | ||
1071 | class_device_destroy(umad_class, port->dev->dev); | 1072 | device_destroy(umad_class, port->cdev->dev); |
1072 | class_device_destroy(umad_class, port->sm_dev->dev); | 1073 | device_destroy(umad_class, port->sm_cdev->dev); |
1073 | 1074 | ||
1074 | cdev_del(port->dev); | 1075 | cdev_del(port->cdev); |
1075 | cdev_del(port->sm_dev); | 1076 | cdev_del(port->sm_cdev); |
1076 | 1077 | ||
1077 | spin_lock(&port_lock); | 1078 | spin_lock(&port_lock); |
1078 | umad_port[port->dev_num] = NULL; | 1079 | umad_port[port->dev_num] = NULL; |
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 2cad8b4b5292..376a57ce1b40 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -73,8 +73,8 @@ struct ib_uverbs_device { | |||
73 | struct kref ref; | 73 | struct kref ref; |
74 | struct completion comp; | 74 | struct completion comp; |
75 | int devnum; | 75 | int devnum; |
76 | struct cdev *dev; | 76 | struct cdev *cdev; |
77 | struct class_device *class_dev; | 77 | struct device *dev; |
78 | struct ib_device *ib_dev; | 78 | struct ib_device *ib_dev; |
79 | int num_comp_vectors; | 79 | int num_comp_vectors; |
80 | }; | 80 | }; |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index f49f94653a96..cc1afa28c181 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -690,27 +690,29 @@ static struct ib_client uverbs_client = { | |||
690 | .remove = ib_uverbs_remove_one | 690 | .remove = ib_uverbs_remove_one |
691 | }; | 691 | }; |
692 | 692 | ||
693 | static ssize_t show_ibdev(struct class_device *class_dev, char *buf) | 693 | static ssize_t show_ibdev(struct device *device, struct device_attribute *attr, |
694 | char *buf) | ||
694 | { | 695 | { |
695 | struct ib_uverbs_device *dev = class_get_devdata(class_dev); | 696 | struct ib_uverbs_device *dev = dev_get_drvdata(device); |
696 | 697 | ||
697 | if (!dev) | 698 | if (!dev) |
698 | return -ENODEV; | 699 | return -ENODEV; |
699 | 700 | ||
700 | return sprintf(buf, "%s\n", dev->ib_dev->name); | 701 | return sprintf(buf, "%s\n", dev->ib_dev->name); |
701 | } | 702 | } |
702 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | 703 | static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); |
703 | 704 | ||
704 | static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf) | 705 | static ssize_t show_dev_abi_version(struct device *device, |
706 | struct device_attribute *attr, char *buf) | ||
705 | { | 707 | { |
706 | struct ib_uverbs_device *dev = class_get_devdata(class_dev); | 708 | struct ib_uverbs_device *dev = dev_get_drvdata(device); |
707 | 709 | ||
708 | if (!dev) | 710 | if (!dev) |
709 | return -ENODEV; | 711 | return -ENODEV; |
710 | 712 | ||
711 | return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); | 713 | return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); |
712 | } | 714 | } |
713 | static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); | 715 | static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); |
714 | 716 | ||
715 | static ssize_t show_abi_version(struct class *class, char *buf) | 717 | static ssize_t show_abi_version(struct class *class, char *buf) |
716 | { | 718 | { |
@@ -744,27 +746,26 @@ static void ib_uverbs_add_one(struct ib_device *device) | |||
744 | uverbs_dev->ib_dev = device; | 746 | uverbs_dev->ib_dev = device; |
745 | uverbs_dev->num_comp_vectors = device->num_comp_vectors; | 747 | uverbs_dev->num_comp_vectors = device->num_comp_vectors; |
746 | 748 | ||
747 | uverbs_dev->dev = cdev_alloc(); | 749 | uverbs_dev->cdev = cdev_alloc(); |
748 | if (!uverbs_dev->dev) | 750 | if (!uverbs_dev->cdev) |
749 | goto err; | 751 | goto err; |
750 | uverbs_dev->dev->owner = THIS_MODULE; | 752 | uverbs_dev->cdev->owner = THIS_MODULE; |
751 | uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; | 753 | uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; |
752 | kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum); | 754 | kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum); |
753 | if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) | 755 | if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) |
754 | goto err_cdev; | 756 | goto err_cdev; |
755 | 757 | ||
756 | uverbs_dev->class_dev = class_device_create(uverbs_class, NULL, | 758 | uverbs_dev->dev = device_create(uverbs_class, device->dma_device, |
757 | uverbs_dev->dev->dev, | 759 | uverbs_dev->cdev->dev, |
758 | device->dma_device, | 760 | "uverbs%d", uverbs_dev->devnum); |
759 | "uverbs%d", uverbs_dev->devnum); | 761 | if (IS_ERR(uverbs_dev->dev)) |
760 | if (IS_ERR(uverbs_dev->class_dev)) | ||
761 | goto err_cdev; | 762 | goto err_cdev; |
762 | 763 | ||
763 | class_set_devdata(uverbs_dev->class_dev, uverbs_dev); | 764 | dev_set_drvdata(uverbs_dev->dev, uverbs_dev); |
764 | 765 | ||
765 | if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev)) | 766 | if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev)) |
766 | goto err_class; | 767 | goto err_class; |
767 | if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version)) | 768 | if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version)) |
768 | goto err_class; | 769 | goto err_class; |
769 | 770 | ||
770 | spin_lock(&map_lock); | 771 | spin_lock(&map_lock); |
@@ -776,10 +777,10 @@ static void ib_uverbs_add_one(struct ib_device *device) | |||
776 | return; | 777 | return; |
777 | 778 | ||
778 | err_class: | 779 | err_class: |
779 | class_device_destroy(uverbs_class, uverbs_dev->dev->dev); | 780 | device_destroy(uverbs_class, uverbs_dev->cdev->dev); |
780 | 781 | ||
781 | err_cdev: | 782 | err_cdev: |
782 | cdev_del(uverbs_dev->dev); | 783 | cdev_del(uverbs_dev->cdev); |
783 | clear_bit(uverbs_dev->devnum, dev_map); | 784 | clear_bit(uverbs_dev->devnum, dev_map); |
784 | 785 | ||
785 | err: | 786 | err: |
@@ -796,9 +797,9 @@ static void ib_uverbs_remove_one(struct ib_device *device) | |||
796 | if (!uverbs_dev) | 797 | if (!uverbs_dev) |
797 | return; | 798 | return; |
798 | 799 | ||
799 | class_set_devdata(uverbs_dev->class_dev, NULL); | 800 | dev_set_drvdata(uverbs_dev->dev, NULL); |
800 | class_device_destroy(uverbs_class, uverbs_dev->dev->dev); | 801 | device_destroy(uverbs_class, uverbs_dev->cdev->dev); |
801 | cdev_del(uverbs_dev->dev); | 802 | cdev_del(uverbs_dev->cdev); |
802 | 803 | ||
803 | spin_lock(&map_lock); | 804 | spin_lock(&map_lock); |
804 | dev_table[uverbs_dev->devnum] = NULL; | 805 | dev_table[uverbs_dev->devnum] = NULL; |
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c index e10d27a6e145..6af2c0f79a67 100644 --- a/drivers/infiniband/hw/amso1100/c2_provider.c +++ b/drivers/infiniband/hw/amso1100/c2_provider.c | |||
@@ -523,45 +523,49 @@ static int c2_dereg_mr(struct ib_mr *ib_mr) | |||
523 | return err; | 523 | return err; |
524 | } | 524 | } |
525 | 525 | ||
526 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 526 | static ssize_t show_rev(struct device *dev, struct device_attribute *attr, |
527 | char *buf) | ||
527 | { | 528 | { |
528 | struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); | 529 | struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev); |
529 | pr_debug("%s:%u\n", __func__, __LINE__); | 530 | pr_debug("%s:%u\n", __func__, __LINE__); |
530 | return sprintf(buf, "%x\n", dev->props.hw_ver); | 531 | return sprintf(buf, "%x\n", c2dev->props.hw_ver); |
531 | } | 532 | } |
532 | 533 | ||
533 | static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | 534 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, |
535 | char *buf) | ||
534 | { | 536 | { |
535 | struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); | 537 | struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev); |
536 | pr_debug("%s:%u\n", __func__, __LINE__); | 538 | pr_debug("%s:%u\n", __func__, __LINE__); |
537 | return sprintf(buf, "%x.%x.%x\n", | 539 | return sprintf(buf, "%x.%x.%x\n", |
538 | (int) (dev->props.fw_ver >> 32), | 540 | (int) (c2dev->props.fw_ver >> 32), |
539 | (int) (dev->props.fw_ver >> 16) & 0xffff, | 541 | (int) (c2dev->props.fw_ver >> 16) & 0xffff, |
540 | (int) (dev->props.fw_ver & 0xffff)); | 542 | (int) (c2dev->props.fw_ver & 0xffff)); |
541 | } | 543 | } |
542 | 544 | ||
543 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 545 | static ssize_t show_hca(struct device *dev, struct device_attribute *attr, |
546 | char *buf) | ||
544 | { | 547 | { |
545 | pr_debug("%s:%u\n", __func__, __LINE__); | 548 | pr_debug("%s:%u\n", __func__, __LINE__); |
546 | return sprintf(buf, "AMSO1100\n"); | 549 | return sprintf(buf, "AMSO1100\n"); |
547 | } | 550 | } |
548 | 551 | ||
549 | static ssize_t show_board(struct class_device *cdev, char *buf) | 552 | static ssize_t show_board(struct device *dev, struct device_attribute *attr, |
553 | char *buf) | ||
550 | { | 554 | { |
551 | pr_debug("%s:%u\n", __func__, __LINE__); | 555 | pr_debug("%s:%u\n", __func__, __LINE__); |
552 | return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID"); | 556 | return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID"); |
553 | } | 557 | } |
554 | 558 | ||
555 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 559 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
556 | static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | 560 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); |
557 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 561 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
558 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); | 562 | static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); |
559 | 563 | ||
560 | static struct class_device_attribute *c2_class_attributes[] = { | 564 | static struct device_attribute *c2_dev_attributes[] = { |
561 | &class_device_attr_hw_rev, | 565 | &dev_attr_hw_rev, |
562 | &class_device_attr_fw_ver, | 566 | &dev_attr_fw_ver, |
563 | &class_device_attr_hca_type, | 567 | &dev_attr_hca_type, |
564 | &class_device_attr_board_id | 568 | &dev_attr_board_id |
565 | }; | 569 | }; |
566 | 570 | ||
567 | static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | 571 | static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, |
@@ -861,9 +865,9 @@ int c2_register_device(struct c2_dev *dev) | |||
861 | if (ret) | 865 | if (ret) |
862 | goto out1; | 866 | goto out1; |
863 | 867 | ||
864 | for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { | 868 | for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) { |
865 | ret = class_device_create_file(&dev->ibdev.class_dev, | 869 | ret = device_create_file(&dev->ibdev.dev, |
866 | c2_class_attributes[i]); | 870 | c2_dev_attributes[i]); |
867 | if (ret) | 871 | if (ret) |
868 | goto out0; | 872 | goto out0; |
869 | } | 873 | } |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index ca7265443c05..ab4695c1dd56 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -1041,61 +1041,60 @@ static int iwch_query_port(struct ib_device *ibdev, | |||
1041 | return 0; | 1041 | return 0; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 1044 | static ssize_t show_rev(struct device *dev, struct device_attribute *attr, |
1045 | char *buf) | ||
1045 | { | 1046 | { |
1046 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | 1047 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, |
1047 | ibdev.class_dev); | 1048 | ibdev.dev); |
1048 | PDBG("%s class dev 0x%p\n", __func__, cdev); | 1049 | PDBG("%s dev 0x%p\n", __func__, dev); |
1049 | return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type); | 1050 | return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); |
1050 | } | 1051 | } |
1051 | 1052 | ||
1052 | static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | 1053 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) |
1053 | { | 1054 | { |
1054 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | 1055 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, |
1055 | ibdev.class_dev); | 1056 | ibdev.dev); |
1056 | struct ethtool_drvinfo info; | 1057 | struct ethtool_drvinfo info; |
1057 | struct net_device *lldev = dev->rdev.t3cdev_p->lldev; | 1058 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; |
1058 | 1059 | ||
1059 | PDBG("%s class dev 0x%p\n", __func__, cdev); | 1060 | PDBG("%s dev 0x%p\n", __func__, dev); |
1060 | rtnl_lock(); | ||
1061 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1061 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1062 | rtnl_unlock(); | ||
1063 | return sprintf(buf, "%s\n", info.fw_version); | 1062 | return sprintf(buf, "%s\n", info.fw_version); |
1064 | } | 1063 | } |
1065 | 1064 | ||
1066 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 1065 | static ssize_t show_hca(struct device *dev, struct device_attribute *attr, |
1066 | char *buf) | ||
1067 | { | 1067 | { |
1068 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | 1068 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, |
1069 | ibdev.class_dev); | 1069 | ibdev.dev); |
1070 | struct ethtool_drvinfo info; | 1070 | struct ethtool_drvinfo info; |
1071 | struct net_device *lldev = dev->rdev.t3cdev_p->lldev; | 1071 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; |
1072 | 1072 | ||
1073 | PDBG("%s class dev 0x%p\n", __func__, cdev); | 1073 | PDBG("%s dev 0x%p\n", __func__, dev); |
1074 | rtnl_lock(); | ||
1075 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1074 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1076 | rtnl_unlock(); | ||
1077 | return sprintf(buf, "%s\n", info.driver); | 1075 | return sprintf(buf, "%s\n", info.driver); |
1078 | } | 1076 | } |
1079 | 1077 | ||
1080 | static ssize_t show_board(struct class_device *cdev, char *buf) | 1078 | static ssize_t show_board(struct device *dev, struct device_attribute *attr, |
1079 | char *buf) | ||
1081 | { | 1080 | { |
1082 | struct iwch_dev *dev = container_of(cdev, struct iwch_dev, | 1081 | struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, |
1083 | ibdev.class_dev); | 1082 | ibdev.dev); |
1084 | PDBG("%s class dev 0x%p\n", __func__, dev); | 1083 | PDBG("%s dev 0x%p\n", __func__, dev); |
1085 | return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor, | 1084 | return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor, |
1086 | dev->rdev.rnic_info.pdev->device); | 1085 | iwch_dev->rdev.rnic_info.pdev->device); |
1087 | } | 1086 | } |
1088 | 1087 | ||
1089 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 1088 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
1090 | static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | 1089 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); |
1091 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 1090 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
1092 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); | 1091 | static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); |
1093 | 1092 | ||
1094 | static struct class_device_attribute *iwch_class_attributes[] = { | 1093 | static struct device_attribute *iwch_class_attributes[] = { |
1095 | &class_device_attr_hw_rev, | 1094 | &dev_attr_hw_rev, |
1096 | &class_device_attr_fw_ver, | 1095 | &dev_attr_fw_ver, |
1097 | &class_device_attr_hca_type, | 1096 | &dev_attr_hca_type, |
1098 | &class_device_attr_board_id | 1097 | &dev_attr_board_id |
1099 | }; | 1098 | }; |
1100 | 1099 | ||
1101 | int iwch_register_device(struct iwch_dev *dev) | 1100 | int iwch_register_device(struct iwch_dev *dev) |
@@ -1189,8 +1188,8 @@ int iwch_register_device(struct iwch_dev *dev) | |||
1189 | goto bail1; | 1188 | goto bail1; |
1190 | 1189 | ||
1191 | for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { | 1190 | for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { |
1192 | ret = class_device_create_file(&dev->ibdev.class_dev, | 1191 | ret = device_create_file(&dev->ibdev.dev, |
1193 | iwch_class_attributes[i]); | 1192 | iwch_class_attributes[i]); |
1194 | if (ret) { | 1193 | if (ret) { |
1195 | goto bail2; | 1194 | goto bail2; |
1196 | } | 1195 | } |
@@ -1208,8 +1207,8 @@ void iwch_unregister_device(struct iwch_dev *dev) | |||
1208 | 1207 | ||
1209 | PDBG("%s iwch_dev %p\n", __func__, dev); | 1208 | PDBG("%s iwch_dev %p\n", __func__, dev); |
1210 | for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) | 1209 | for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) |
1211 | class_device_remove_file(&dev->ibdev.class_dev, | 1210 | device_remove_file(&dev->ibdev.dev, |
1212 | iwch_class_attributes[i]); | 1211 | iwch_class_attributes[i]); |
1213 | ib_unregister_device(&dev->ibdev); | 1212 | ib_unregister_device(&dev->ibdev); |
1214 | return; | 1213 | return; |
1215 | } | 1214 | } |
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c index 6d49d2f18a88..d4ce8b63e19e 100644 --- a/drivers/infiniband/hw/ipath/ipath_diag.c +++ b/drivers/infiniband/hw/ipath/ipath_diag.c | |||
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = { | |||
79 | 79 | ||
80 | static atomic_t diagpkt_count = ATOMIC_INIT(0); | 80 | static atomic_t diagpkt_count = ATOMIC_INIT(0); |
81 | static struct cdev *diagpkt_cdev; | 81 | static struct cdev *diagpkt_cdev; |
82 | static struct class_device *diagpkt_class_dev; | 82 | static struct device *diagpkt_dev; |
83 | 83 | ||
84 | int ipath_diag_add(struct ipath_devdata *dd) | 84 | int ipath_diag_add(struct ipath_devdata *dd) |
85 | { | 85 | { |
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd) | |||
89 | if (atomic_inc_return(&diagpkt_count) == 1) { | 89 | if (atomic_inc_return(&diagpkt_count) == 1) { |
90 | ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, | 90 | ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, |
91 | "ipath_diagpkt", &diagpkt_file_ops, | 91 | "ipath_diagpkt", &diagpkt_file_ops, |
92 | &diagpkt_cdev, &diagpkt_class_dev); | 92 | &diagpkt_cdev, &diagpkt_dev); |
93 | 93 | ||
94 | if (ret) { | 94 | if (ret) { |
95 | ipath_dev_err(dd, "Couldn't create ipath_diagpkt " | 95 | ipath_dev_err(dd, "Couldn't create ipath_diagpkt " |
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd) | |||
102 | 102 | ||
103 | ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, | 103 | ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, |
104 | &diag_file_ops, &dd->diag_cdev, | 104 | &diag_file_ops, &dd->diag_cdev, |
105 | &dd->diag_class_dev); | 105 | &dd->diag_dev); |
106 | if (ret) | 106 | if (ret) |
107 | ipath_dev_err(dd, "Couldn't create %s device: %d", | 107 | ipath_dev_err(dd, "Couldn't create %s device: %d", |
108 | name, ret); | 108 | name, ret); |
@@ -114,9 +114,9 @@ done: | |||
114 | void ipath_diag_remove(struct ipath_devdata *dd) | 114 | void ipath_diag_remove(struct ipath_devdata *dd) |
115 | { | 115 | { |
116 | if (atomic_dec_and_test(&diagpkt_count)) | 116 | if (atomic_dec_and_test(&diagpkt_count)) |
117 | ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev); | 117 | ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev); |
118 | 118 | ||
119 | ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); | 119 | ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev); |
120 | } | 120 | } |
121 | 121 | ||
122 | /** | 122 | /** |
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 1e627aab18bf..8b1752202e78 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -2434,11 +2434,11 @@ static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2434 | static struct class *ipath_class; | 2434 | static struct class *ipath_class; |
2435 | 2435 | ||
2436 | static int init_cdev(int minor, char *name, const struct file_operations *fops, | 2436 | static int init_cdev(int minor, char *name, const struct file_operations *fops, |
2437 | struct cdev **cdevp, struct class_device **class_devp) | 2437 | struct cdev **cdevp, struct device **devp) |
2438 | { | 2438 | { |
2439 | const dev_t dev = MKDEV(IPATH_MAJOR, minor); | 2439 | const dev_t dev = MKDEV(IPATH_MAJOR, minor); |
2440 | struct cdev *cdev = NULL; | 2440 | struct cdev *cdev = NULL; |
2441 | struct class_device *class_dev = NULL; | 2441 | struct device *device = NULL; |
2442 | int ret; | 2442 | int ret; |
2443 | 2443 | ||
2444 | cdev = cdev_alloc(); | 2444 | cdev = cdev_alloc(); |
@@ -2462,12 +2462,12 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops, | |||
2462 | goto err_cdev; | 2462 | goto err_cdev; |
2463 | } | 2463 | } |
2464 | 2464 | ||
2465 | class_dev = class_device_create(ipath_class, NULL, dev, NULL, name); | 2465 | device = device_create(ipath_class, NULL, dev, name); |
2466 | 2466 | ||
2467 | if (IS_ERR(class_dev)) { | 2467 | if (IS_ERR(device)) { |
2468 | ret = PTR_ERR(class_dev); | 2468 | ret = PTR_ERR(device); |
2469 | printk(KERN_ERR IPATH_DRV_NAME ": Could not create " | 2469 | printk(KERN_ERR IPATH_DRV_NAME ": Could not create " |
2470 | "class_dev for minor %d, %s (err %d)\n", | 2470 | "device for minor %d, %s (err %d)\n", |
2471 | minor, name, -ret); | 2471 | minor, name, -ret); |
2472 | goto err_cdev; | 2472 | goto err_cdev; |
2473 | } | 2473 | } |
@@ -2481,29 +2481,29 @@ err_cdev: | |||
2481 | done: | 2481 | done: |
2482 | if (ret >= 0) { | 2482 | if (ret >= 0) { |
2483 | *cdevp = cdev; | 2483 | *cdevp = cdev; |
2484 | *class_devp = class_dev; | 2484 | *devp = device; |
2485 | } else { | 2485 | } else { |
2486 | *cdevp = NULL; | 2486 | *cdevp = NULL; |
2487 | *class_devp = NULL; | 2487 | *devp = NULL; |
2488 | } | 2488 | } |
2489 | 2489 | ||
2490 | return ret; | 2490 | return ret; |
2491 | } | 2491 | } |
2492 | 2492 | ||
2493 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, | 2493 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, |
2494 | struct cdev **cdevp, struct class_device **class_devp) | 2494 | struct cdev **cdevp, struct device **devp) |
2495 | { | 2495 | { |
2496 | return init_cdev(minor, name, fops, cdevp, class_devp); | 2496 | return init_cdev(minor, name, fops, cdevp, devp); |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | static void cleanup_cdev(struct cdev **cdevp, | 2499 | static void cleanup_cdev(struct cdev **cdevp, |
2500 | struct class_device **class_devp) | 2500 | struct device **devp) |
2501 | { | 2501 | { |
2502 | struct class_device *class_dev = *class_devp; | 2502 | struct device *dev = *devp; |
2503 | 2503 | ||
2504 | if (class_dev) { | 2504 | if (dev) { |
2505 | class_device_unregister(class_dev); | 2505 | device_unregister(dev); |
2506 | *class_devp = NULL; | 2506 | *devp = NULL; |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | if (*cdevp) { | 2509 | if (*cdevp) { |
@@ -2513,13 +2513,13 @@ static void cleanup_cdev(struct cdev **cdevp, | |||
2513 | } | 2513 | } |
2514 | 2514 | ||
2515 | void ipath_cdev_cleanup(struct cdev **cdevp, | 2515 | void ipath_cdev_cleanup(struct cdev **cdevp, |
2516 | struct class_device **class_devp) | 2516 | struct device **devp) |
2517 | { | 2517 | { |
2518 | cleanup_cdev(cdevp, class_devp); | 2518 | cleanup_cdev(cdevp, devp); |
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | static struct cdev *wildcard_cdev; | 2521 | static struct cdev *wildcard_cdev; |
2522 | static struct class_device *wildcard_class_dev; | 2522 | static struct device *wildcard_dev; |
2523 | 2523 | ||
2524 | static const dev_t dev = MKDEV(IPATH_MAJOR, 0); | 2524 | static const dev_t dev = MKDEV(IPATH_MAJOR, 0); |
2525 | 2525 | ||
@@ -2576,7 +2576,7 @@ int ipath_user_add(struct ipath_devdata *dd) | |||
2576 | goto bail; | 2576 | goto bail; |
2577 | } | 2577 | } |
2578 | ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, | 2578 | ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, |
2579 | &wildcard_class_dev); | 2579 | &wildcard_dev); |
2580 | if (ret < 0) { | 2580 | if (ret < 0) { |
2581 | ipath_dev_err(dd, "Could not create wildcard " | 2581 | ipath_dev_err(dd, "Could not create wildcard " |
2582 | "minor: error %d\n", -ret); | 2582 | "minor: error %d\n", -ret); |
@@ -2589,7 +2589,7 @@ int ipath_user_add(struct ipath_devdata *dd) | |||
2589 | snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); | 2589 | snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); |
2590 | 2590 | ||
2591 | ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, | 2591 | ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, |
2592 | &dd->user_cdev, &dd->user_class_dev); | 2592 | &dd->user_cdev, &dd->user_dev); |
2593 | if (ret < 0) | 2593 | if (ret < 0) |
2594 | ipath_dev_err(dd, "Could not create user minor %d, %s\n", | 2594 | ipath_dev_err(dd, "Could not create user minor %d, %s\n", |
2595 | dd->ipath_unit + 1, name); | 2595 | dd->ipath_unit + 1, name); |
@@ -2604,13 +2604,13 @@ bail: | |||
2604 | 2604 | ||
2605 | void ipath_user_remove(struct ipath_devdata *dd) | 2605 | void ipath_user_remove(struct ipath_devdata *dd) |
2606 | { | 2606 | { |
2607 | cleanup_cdev(&dd->user_cdev, &dd->user_class_dev); | 2607 | cleanup_cdev(&dd->user_cdev, &dd->user_dev); |
2608 | 2608 | ||
2609 | if (atomic_dec_return(&user_count) == 0) { | 2609 | if (atomic_dec_return(&user_count) == 0) { |
2610 | if (atomic_read(&user_setup) == 0) | 2610 | if (atomic_read(&user_setup) == 0) |
2611 | goto bail; | 2611 | goto bail; |
2612 | 2612 | ||
2613 | cleanup_cdev(&wildcard_cdev, &wildcard_class_dev); | 2613 | cleanup_cdev(&wildcard_cdev, &wildcard_dev); |
2614 | user_cleanup(); | 2614 | user_cleanup(); |
2615 | 2615 | ||
2616 | atomic_set(&user_setup, 0); | 2616 | atomic_set(&user_setup, 0); |
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h index 5863cbe99303..202337ae90dc 100644 --- a/drivers/infiniband/hw/ipath/ipath_kernel.h +++ b/drivers/infiniband/hw/ipath/ipath_kernel.h | |||
@@ -466,8 +466,8 @@ struct ipath_devdata { | |||
466 | struct pci_dev *pcidev; | 466 | struct pci_dev *pcidev; |
467 | struct cdev *user_cdev; | 467 | struct cdev *user_cdev; |
468 | struct cdev *diag_cdev; | 468 | struct cdev *diag_cdev; |
469 | struct class_device *user_class_dev; | 469 | struct device *user_dev; |
470 | struct class_device *diag_class_dev; | 470 | struct device *diag_dev; |
471 | /* timer used to prevent stats overflow, error throttling, etc. */ | 471 | /* timer used to prevent stats overflow, error throttling, etc. */ |
472 | struct timer_list ipath_stats_timer; | 472 | struct timer_list ipath_stats_timer; |
473 | /* timer to verify interrupts work, and fallback if possible */ | 473 | /* timer to verify interrupts work, and fallback if possible */ |
@@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *); | |||
854 | 854 | ||
855 | struct file_operations; | 855 | struct file_operations; |
856 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, | 856 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, |
857 | struct cdev **cdevp, struct class_device **class_devp); | 857 | struct cdev **cdevp, struct device **devp); |
858 | void ipath_cdev_cleanup(struct cdev **cdevp, | 858 | void ipath_cdev_cleanup(struct cdev **cdevp, |
859 | struct class_device **class_devp); | 859 | struct device **devp); |
860 | 860 | ||
861 | int ipath_diag_add(struct ipath_devdata *); | 861 | int ipath_diag_add(struct ipath_devdata *); |
862 | void ipath_diag_remove(struct ipath_devdata *); | 862 | void ipath_diag_remove(struct ipath_devdata *); |
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index 320a6d018de7..c38f9aa8be8d 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c | |||
@@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev) | |||
2172 | ib_dealloc_device(ibdev); | 2172 | ib_dealloc_device(ibdev); |
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 2175 | static ssize_t show_rev(struct device *device, struct device_attribute *attr, |
2176 | char *buf) | ||
2176 | { | 2177 | { |
2177 | struct ipath_ibdev *dev = | 2178 | struct ipath_ibdev *dev = |
2178 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 2179 | container_of(device, struct ipath_ibdev, ibdev.dev); |
2179 | 2180 | ||
2180 | return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); | 2181 | return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); |
2181 | } | 2182 | } |
2182 | 2183 | ||
2183 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 2184 | static ssize_t show_hca(struct device *device, struct device_attribute *attr, |
2185 | char *buf) | ||
2184 | { | 2186 | { |
2185 | struct ipath_ibdev *dev = | 2187 | struct ipath_ibdev *dev = |
2186 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 2188 | container_of(device, struct ipath_ibdev, ibdev.dev); |
2187 | int ret; | 2189 | int ret; |
2188 | 2190 | ||
2189 | ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); | 2191 | ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); |
@@ -2196,10 +2198,11 @@ bail: | |||
2196 | return ret; | 2198 | return ret; |
2197 | } | 2199 | } |
2198 | 2200 | ||
2199 | static ssize_t show_stats(struct class_device *cdev, char *buf) | 2201 | static ssize_t show_stats(struct device *device, struct device_attribute *attr, |
2202 | char *buf) | ||
2200 | { | 2203 | { |
2201 | struct ipath_ibdev *dev = | 2204 | struct ipath_ibdev *dev = |
2202 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 2205 | container_of(device, struct ipath_ibdev, ibdev.dev); |
2203 | int i; | 2206 | int i; |
2204 | int len; | 2207 | int len; |
2205 | 2208 | ||
@@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf) | |||
2237 | return len; | 2240 | return len; |
2238 | } | 2241 | } |
2239 | 2242 | ||
2240 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 2243 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
2241 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 2244 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
2242 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); | 2245 | static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); |
2243 | static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); | 2246 | static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); |
2244 | 2247 | ||
2245 | static struct class_device_attribute *ipath_class_attributes[] = { | 2248 | static struct device_attribute *ipath_class_attributes[] = { |
2246 | &class_device_attr_hw_rev, | 2249 | &dev_attr_hw_rev, |
2247 | &class_device_attr_hca_type, | 2250 | &dev_attr_hca_type, |
2248 | &class_device_attr_board_id, | 2251 | &dev_attr_board_id, |
2249 | &class_device_attr_stats | 2252 | &dev_attr_stats |
2250 | }; | 2253 | }; |
2251 | 2254 | ||
2252 | static int ipath_verbs_register_sysfs(struct ib_device *dev) | 2255 | static int ipath_verbs_register_sysfs(struct ib_device *dev) |
@@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev) | |||
2255 | int ret; | 2258 | int ret; |
2256 | 2259 | ||
2257 | for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) | 2260 | for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) |
2258 | if (class_device_create_file(&dev->class_dev, | 2261 | if (device_create_file(&dev->dev, |
2259 | ipath_class_attributes[i])) { | 2262 | ipath_class_attributes[i])) { |
2260 | ret = 1; | 2263 | ret = 1; |
2261 | goto bail; | 2264 | goto bail; |
2262 | } | 2265 | } |
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 136c76c7b4e7..4d9b5ac42202 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
@@ -481,42 +481,51 @@ out: | |||
481 | return err; | 481 | return err; |
482 | } | 482 | } |
483 | 483 | ||
484 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 484 | static ssize_t show_hca(struct device *device, struct device_attribute *attr, |
485 | char *buf) | ||
485 | { | 486 | { |
486 | struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); | 487 | struct mlx4_ib_dev *dev = |
488 | container_of(device, struct mlx4_ib_dev, ib_dev.dev); | ||
487 | return sprintf(buf, "MT%d\n", dev->dev->pdev->device); | 489 | return sprintf(buf, "MT%d\n", dev->dev->pdev->device); |
488 | } | 490 | } |
489 | 491 | ||
490 | static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | 492 | static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, |
493 | char *buf) | ||
491 | { | 494 | { |
492 | struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); | 495 | struct mlx4_ib_dev *dev = |
496 | container_of(device, struct mlx4_ib_dev, ib_dev.dev); | ||
493 | return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32), | 497 | return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32), |
494 | (int) (dev->dev->caps.fw_ver >> 16) & 0xffff, | 498 | (int) (dev->dev->caps.fw_ver >> 16) & 0xffff, |
495 | (int) dev->dev->caps.fw_ver & 0xffff); | 499 | (int) dev->dev->caps.fw_ver & 0xffff); |
496 | } | 500 | } |
497 | 501 | ||
498 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 502 | static ssize_t show_rev(struct device *device, struct device_attribute *attr, |
503 | char *buf) | ||
499 | { | 504 | { |
500 | struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); | 505 | struct mlx4_ib_dev *dev = |
506 | container_of(device, struct mlx4_ib_dev, ib_dev.dev); | ||
501 | return sprintf(buf, "%x\n", dev->dev->rev_id); | 507 | return sprintf(buf, "%x\n", dev->dev->rev_id); |
502 | } | 508 | } |
503 | 509 | ||
504 | static ssize_t show_board(struct class_device *cdev, char *buf) | 510 | static ssize_t show_board(struct device *device, struct device_attribute *attr, |
511 | char *buf) | ||
505 | { | 512 | { |
506 | struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); | 513 | struct mlx4_ib_dev *dev = |
507 | return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id); | 514 | container_of(device, struct mlx4_ib_dev, ib_dev.dev); |
515 | return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, | ||
516 | dev->dev->board_id); | ||
508 | } | 517 | } |
509 | 518 | ||
510 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 519 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
511 | static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | 520 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); |
512 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 521 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
513 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); | 522 | static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); |
514 | 523 | ||
515 | static struct class_device_attribute *mlx4_class_attributes[] = { | 524 | static struct device_attribute *mlx4_class_attributes[] = { |
516 | &class_device_attr_hw_rev, | 525 | &dev_attr_hw_rev, |
517 | &class_device_attr_fw_ver, | 526 | &dev_attr_fw_ver, |
518 | &class_device_attr_hca_type, | 527 | &dev_attr_hca_type, |
519 | &class_device_attr_board_id | 528 | &dev_attr_board_id |
520 | }; | 529 | }; |
521 | 530 | ||
522 | static void *mlx4_ib_add(struct mlx4_dev *dev) | 531 | static void *mlx4_ib_add(struct mlx4_dev *dev) |
@@ -640,8 +649,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) | |||
640 | goto err_reg; | 649 | goto err_reg; |
641 | 650 | ||
642 | for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) { | 651 | for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) { |
643 | if (class_device_create_file(&ibdev->ib_dev.class_dev, | 652 | if (device_create_file(&ibdev->ib_dev.dev, |
644 | mlx4_class_attributes[i])) | 653 | mlx4_class_attributes[i])) |
645 | goto err_reg; | 654 | goto err_reg; |
646 | } | 655 | } |
647 | 656 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 81b257e18bb6..696e1f302332 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -1170,23 +1170,29 @@ static int mthca_unmap_fmr(struct list_head *fmr_list) | |||
1170 | return 0; | 1170 | return 0; |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 1173 | static ssize_t show_rev(struct device *device, struct device_attribute *attr, |
1174 | char *buf) | ||
1174 | { | 1175 | { |
1175 | struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); | 1176 | struct mthca_dev *dev = |
1177 | container_of(device, struct mthca_dev, ib_dev.dev); | ||
1176 | return sprintf(buf, "%x\n", dev->rev_id); | 1178 | return sprintf(buf, "%x\n", dev->rev_id); |
1177 | } | 1179 | } |
1178 | 1180 | ||
1179 | static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | 1181 | static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, |
1182 | char *buf) | ||
1180 | { | 1183 | { |
1181 | struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); | 1184 | struct mthca_dev *dev = |
1185 | container_of(device, struct mthca_dev, ib_dev.dev); | ||
1182 | return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32), | 1186 | return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32), |
1183 | (int) (dev->fw_ver >> 16) & 0xffff, | 1187 | (int) (dev->fw_ver >> 16) & 0xffff, |
1184 | (int) dev->fw_ver & 0xffff); | 1188 | (int) dev->fw_ver & 0xffff); |
1185 | } | 1189 | } |
1186 | 1190 | ||
1187 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 1191 | static ssize_t show_hca(struct device *device, struct device_attribute *attr, |
1192 | char *buf) | ||
1188 | { | 1193 | { |
1189 | struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); | 1194 | struct mthca_dev *dev = |
1195 | container_of(device, struct mthca_dev, ib_dev.dev); | ||
1190 | switch (dev->pdev->device) { | 1196 | switch (dev->pdev->device) { |
1191 | case PCI_DEVICE_ID_MELLANOX_TAVOR: | 1197 | case PCI_DEVICE_ID_MELLANOX_TAVOR: |
1192 | return sprintf(buf, "MT23108\n"); | 1198 | return sprintf(buf, "MT23108\n"); |
@@ -1202,22 +1208,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf) | |||
1202 | } | 1208 | } |
1203 | } | 1209 | } |
1204 | 1210 | ||
1205 | static ssize_t show_board(struct class_device *cdev, char *buf) | 1211 | static ssize_t show_board(struct device *device, struct device_attribute *attr, |
1212 | char *buf) | ||
1206 | { | 1213 | { |
1207 | struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); | 1214 | struct mthca_dev *dev = |
1215 | container_of(device, struct mthca_dev, ib_dev.dev); | ||
1208 | return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id); | 1216 | return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id); |
1209 | } | 1217 | } |
1210 | 1218 | ||
1211 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 1219 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
1212 | static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | 1220 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); |
1213 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 1221 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
1214 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); | 1222 | static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); |
1215 | 1223 | ||
1216 | static struct class_device_attribute *mthca_class_attributes[] = { | 1224 | static struct device_attribute *mthca_dev_attributes[] = { |
1217 | &class_device_attr_hw_rev, | 1225 | &dev_attr_hw_rev, |
1218 | &class_device_attr_fw_ver, | 1226 | &dev_attr_fw_ver, |
1219 | &class_device_attr_hca_type, | 1227 | &dev_attr_hca_type, |
1220 | &class_device_attr_board_id | 1228 | &dev_attr_board_id |
1221 | }; | 1229 | }; |
1222 | 1230 | ||
1223 | static int mthca_init_node_data(struct mthca_dev *dev) | 1231 | static int mthca_init_node_data(struct mthca_dev *dev) |
@@ -1379,9 +1387,9 @@ int mthca_register_device(struct mthca_dev *dev) | |||
1379 | if (ret) | 1387 | if (ret) |
1380 | return ret; | 1388 | return ret; |
1381 | 1389 | ||
1382 | for (i = 0; i < ARRAY_SIZE(mthca_class_attributes); ++i) { | 1390 | for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) { |
1383 | ret = class_device_create_file(&dev->ib_dev.class_dev, | 1391 | ret = device_create_file(&dev->ib_dev.dev, |
1384 | mthca_class_attributes[i]); | 1392 | mthca_dev_attributes[i]); |
1385 | if (ret) { | 1393 | if (ret) { |
1386 | ib_unregister_device(&dev->ib_dev); | 1394 | ib_unregister_device(&dev->ib_dev); |
1387 | return ret; | 1395 | return ret; |
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 7c27420c2240..f9a5d4390892 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
@@ -2800,10 +2800,11 @@ static int nes_dereg_mr(struct ib_mr *ib_mr) | |||
2800 | /** | 2800 | /** |
2801 | * show_rev | 2801 | * show_rev |
2802 | */ | 2802 | */ |
2803 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 2803 | static ssize_t show_rev(struct device *dev, struct device_attribute *attr, |
2804 | char *buf) | ||
2804 | { | 2805 | { |
2805 | struct nes_ib_device *nesibdev = | 2806 | struct nes_ib_device *nesibdev = |
2806 | container_of(cdev, struct nes_ib_device, ibdev.class_dev); | 2807 | container_of(dev, struct nes_ib_device, ibdev.dev); |
2807 | struct nes_vnic *nesvnic = nesibdev->nesvnic; | 2808 | struct nes_vnic *nesvnic = nesibdev->nesvnic; |
2808 | 2809 | ||
2809 | nes_debug(NES_DBG_INIT, "\n"); | 2810 | nes_debug(NES_DBG_INIT, "\n"); |
@@ -2814,10 +2815,11 @@ static ssize_t show_rev(struct class_device *cdev, char *buf) | |||
2814 | /** | 2815 | /** |
2815 | * show_fw_ver | 2816 | * show_fw_ver |
2816 | */ | 2817 | */ |
2817 | static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | 2818 | static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, |
2819 | char *buf) | ||
2818 | { | 2820 | { |
2819 | struct nes_ib_device *nesibdev = | 2821 | struct nes_ib_device *nesibdev = |
2820 | container_of(cdev, struct nes_ib_device, ibdev.class_dev); | 2822 | container_of(dev, struct nes_ib_device, ibdev.dev); |
2821 | struct nes_vnic *nesvnic = nesibdev->nesvnic; | 2823 | struct nes_vnic *nesvnic = nesibdev->nesvnic; |
2822 | 2824 | ||
2823 | nes_debug(NES_DBG_INIT, "\n"); | 2825 | nes_debug(NES_DBG_INIT, "\n"); |
@@ -2831,7 +2833,8 @@ static ssize_t show_fw_ver(struct class_device *cdev, char *buf) | |||
2831 | /** | 2833 | /** |
2832 | * show_hca | 2834 | * show_hca |
2833 | */ | 2835 | */ |
2834 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 2836 | static ssize_t show_hca(struct device *dev, struct device_attribute *attr, |
2837 | char *buf) | ||
2835 | { | 2838 | { |
2836 | nes_debug(NES_DBG_INIT, "\n"); | 2839 | nes_debug(NES_DBG_INIT, "\n"); |
2837 | return sprintf(buf, "NES020\n"); | 2840 | return sprintf(buf, "NES020\n"); |
@@ -2841,23 +2844,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf) | |||
2841 | /** | 2844 | /** |
2842 | * show_board | 2845 | * show_board |
2843 | */ | 2846 | */ |
2844 | static ssize_t show_board(struct class_device *cdev, char *buf) | 2847 | static ssize_t show_board(struct device *dev, struct device_attribute *attr, |
2848 | char *buf) | ||
2845 | { | 2849 | { |
2846 | nes_debug(NES_DBG_INIT, "\n"); | 2850 | nes_debug(NES_DBG_INIT, "\n"); |
2847 | return sprintf(buf, "%.*s\n", 32, "NES020 Board ID"); | 2851 | return sprintf(buf, "%.*s\n", 32, "NES020 Board ID"); |
2848 | } | 2852 | } |
2849 | 2853 | ||
2850 | 2854 | ||
2851 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 2855 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
2852 | static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); | 2856 | static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); |
2853 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 2857 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
2854 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); | 2858 | static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); |
2855 | 2859 | ||
2856 | static struct class_device_attribute *nes_class_attributes[] = { | 2860 | static struct device_attribute *nes_dev_attributes[] = { |
2857 | &class_device_attr_hw_rev, | 2861 | &dev_attr_hw_rev, |
2858 | &class_device_attr_fw_ver, | 2862 | &dev_attr_fw_ver, |
2859 | &class_device_attr_hca_type, | 2863 | &dev_attr_hca_type, |
2860 | &class_device_attr_board_id | 2864 | &dev_attr_board_id |
2861 | }; | 2865 | }; |
2862 | 2866 | ||
2863 | 2867 | ||
@@ -3782,7 +3786,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev) | |||
3782 | nesibdev->ibdev.phys_port_cnt = 1; | 3786 | nesibdev->ibdev.phys_port_cnt = 1; |
3783 | nesibdev->ibdev.num_comp_vectors = 1; | 3787 | nesibdev->ibdev.num_comp_vectors = 1; |
3784 | nesibdev->ibdev.dma_device = &nesdev->pcidev->dev; | 3788 | nesibdev->ibdev.dma_device = &nesdev->pcidev->dev; |
3785 | nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev; | 3789 | nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev; |
3786 | nesibdev->ibdev.query_device = nes_query_device; | 3790 | nesibdev->ibdev.query_device = nes_query_device; |
3787 | nesibdev->ibdev.query_port = nes_query_port; | 3791 | nesibdev->ibdev.query_port = nes_query_port; |
3788 | nesibdev->ibdev.modify_port = nes_modify_port; | 3792 | nesibdev->ibdev.modify_port = nes_modify_port; |
@@ -3877,13 +3881,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev) | |||
3877 | nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count; | 3881 | nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count; |
3878 | nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count; | 3882 | nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count; |
3879 | 3883 | ||
3880 | for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { | 3884 | for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) { |
3881 | ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); | 3885 | ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]); |
3882 | if (ret) { | 3886 | if (ret) { |
3883 | while (i > 0) { | 3887 | while (i > 0) { |
3884 | i--; | 3888 | i--; |
3885 | class_device_remove_file(&nesibdev->ibdev.class_dev, | 3889 | device_remove_file(&nesibdev->ibdev.dev, |
3886 | nes_class_attributes[i]); | 3890 | nes_dev_attributes[i]); |
3887 | } | 3891 | } |
3888 | ib_unregister_device(&nesibdev->ibdev); | 3892 | ib_unregister_device(&nesibdev->ibdev); |
3889 | return ret; | 3893 | return ret; |
@@ -3904,8 +3908,8 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev) | |||
3904 | struct nes_vnic *nesvnic = nesibdev->nesvnic; | 3908 | struct nes_vnic *nesvnic = nesibdev->nesvnic; |
3905 | int i; | 3909 | int i; |
3906 | 3910 | ||
3907 | for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { | 3911 | for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) { |
3908 | class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); | 3912 | device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]); |
3909 | } | 3913 | } |
3910 | 3914 | ||
3911 | if (nesvnic->of_device_registered) { | 3915 | if (nesvnic->of_device_registered) { |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 125765aa9d59..435145709dd6 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -139,8 +139,9 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size, | |||
139 | if (!iu->buf) | 139 | if (!iu->buf) |
140 | goto out_free_iu; | 140 | goto out_free_iu; |
141 | 141 | ||
142 | iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction); | 142 | iu->dma = ib_dma_map_single(host->srp_dev->dev, iu->buf, size, |
143 | if (ib_dma_mapping_error(host->dev->dev, iu->dma)) | 143 | direction); |
144 | if (ib_dma_mapping_error(host->srp_dev->dev, iu->dma)) | ||
144 | goto out_free_buf; | 145 | goto out_free_buf; |
145 | 146 | ||
146 | iu->size = size; | 147 | iu->size = size; |
@@ -161,7 +162,8 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu) | |||
161 | if (!iu) | 162 | if (!iu) |
162 | return; | 163 | return; |
163 | 164 | ||
164 | ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction); | 165 | ib_dma_unmap_single(host->srp_dev->dev, iu->dma, iu->size, |
166 | iu->direction); | ||
165 | kfree(iu->buf); | 167 | kfree(iu->buf); |
166 | kfree(iu); | 168 | kfree(iu); |
167 | } | 169 | } |
@@ -181,7 +183,7 @@ static int srp_init_qp(struct srp_target_port *target, | |||
181 | if (!attr) | 183 | if (!attr) |
182 | return -ENOMEM; | 184 | return -ENOMEM; |
183 | 185 | ||
184 | ret = ib_find_cached_pkey(target->srp_host->dev->dev, | 186 | ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev, |
185 | target->srp_host->port, | 187 | target->srp_host->port, |
186 | be16_to_cpu(target->path.pkey), | 188 | be16_to_cpu(target->path.pkey), |
187 | &attr->pkey_index); | 189 | &attr->pkey_index); |
@@ -208,7 +210,7 @@ static int srp_new_cm_id(struct srp_target_port *target) | |||
208 | { | 210 | { |
209 | struct ib_cm_id *new_cm_id; | 211 | struct ib_cm_id *new_cm_id; |
210 | 212 | ||
211 | new_cm_id = ib_create_cm_id(target->srp_host->dev->dev, | 213 | new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev, |
212 | srp_cm_handler, target); | 214 | srp_cm_handler, target); |
213 | if (IS_ERR(new_cm_id)) | 215 | if (IS_ERR(new_cm_id)) |
214 | return PTR_ERR(new_cm_id); | 216 | return PTR_ERR(new_cm_id); |
@@ -229,8 +231,8 @@ static int srp_create_target_ib(struct srp_target_port *target) | |||
229 | if (!init_attr) | 231 | if (!init_attr) |
230 | return -ENOMEM; | 232 | return -ENOMEM; |
231 | 233 | ||
232 | target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion, | 234 | target->cq = ib_create_cq(target->srp_host->srp_dev->dev, |
233 | NULL, target, SRP_CQ_SIZE, 0); | 235 | srp_completion, NULL, target, SRP_CQ_SIZE, 0); |
234 | if (IS_ERR(target->cq)) { | 236 | if (IS_ERR(target->cq)) { |
235 | ret = PTR_ERR(target->cq); | 237 | ret = PTR_ERR(target->cq); |
236 | goto out; | 238 | goto out; |
@@ -248,7 +250,7 @@ static int srp_create_target_ib(struct srp_target_port *target) | |||
248 | init_attr->send_cq = target->cq; | 250 | init_attr->send_cq = target->cq; |
249 | init_attr->recv_cq = target->cq; | 251 | init_attr->recv_cq = target->cq; |
250 | 252 | ||
251 | target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr); | 253 | target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr); |
252 | if (IS_ERR(target->qp)) { | 254 | if (IS_ERR(target->qp)) { |
253 | ret = PTR_ERR(target->qp); | 255 | ret = PTR_ERR(target->qp); |
254 | ib_destroy_cq(target->cq); | 256 | ib_destroy_cq(target->cq); |
@@ -302,7 +304,7 @@ static int srp_lookup_path(struct srp_target_port *target) | |||
302 | init_completion(&target->done); | 304 | init_completion(&target->done); |
303 | 305 | ||
304 | target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, | 306 | target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, |
305 | target->srp_host->dev->dev, | 307 | target->srp_host->srp_dev->dev, |
306 | target->srp_host->port, | 308 | target->srp_host->port, |
307 | &target->path, | 309 | &target->path, |
308 | IB_SA_PATH_REC_SERVICE_ID | | 310 | IB_SA_PATH_REC_SERVICE_ID | |
@@ -403,7 +405,7 @@ static int srp_send_req(struct srp_target_port *target) | |||
403 | (unsigned long long) be64_to_cpu(target->ioc_guid)); | 405 | (unsigned long long) be64_to_cpu(target->ioc_guid)); |
404 | memset(req->priv.initiator_port_id, 0, 8); | 406 | memset(req->priv.initiator_port_id, 0, 8); |
405 | memcpy(req->priv.initiator_port_id + 8, | 407 | memcpy(req->priv.initiator_port_id + 8, |
406 | &target->srp_host->dev->dev->node_guid, 8); | 408 | &target->srp_host->srp_dev->dev->node_guid, 8); |
407 | } | 409 | } |
408 | 410 | ||
409 | status = ib_send_cm_req(target->cm_id, &req->param); | 411 | status = ib_send_cm_req(target->cm_id, &req->param); |
@@ -520,7 +522,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd, | |||
520 | req->fmr = NULL; | 522 | req->fmr = NULL; |
521 | } | 523 | } |
522 | 524 | ||
523 | ib_dma_unmap_sg(target->srp_host->dev->dev, scsi_sglist(scmnd), | 525 | ib_dma_unmap_sg(target->srp_host->srp_dev->dev, scsi_sglist(scmnd), |
524 | scsi_sg_count(scmnd), scmnd->sc_data_direction); | 526 | scsi_sg_count(scmnd), scmnd->sc_data_direction); |
525 | } | 527 | } |
526 | 528 | ||
@@ -628,7 +630,7 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat, | |||
628 | int page_cnt; | 630 | int page_cnt; |
629 | int i, j; | 631 | int i, j; |
630 | int ret; | 632 | int ret; |
631 | struct srp_device *dev = target->srp_host->dev; | 633 | struct srp_device *dev = target->srp_host->srp_dev; |
632 | struct ib_device *ibdev = dev->dev; | 634 | struct ib_device *ibdev = dev->dev; |
633 | struct scatterlist *sg; | 635 | struct scatterlist *sg; |
634 | 636 | ||
@@ -723,7 +725,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, | |||
723 | nents = scsi_sg_count(scmnd); | 725 | nents = scsi_sg_count(scmnd); |
724 | scat = scsi_sglist(scmnd); | 726 | scat = scsi_sglist(scmnd); |
725 | 727 | ||
726 | dev = target->srp_host->dev; | 728 | dev = target->srp_host->srp_dev; |
727 | ibdev = dev->dev; | 729 | ibdev = dev->dev; |
728 | 730 | ||
729 | count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); | 731 | count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); |
@@ -779,7 +781,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, | |||
779 | buf->table_desc.va = | 781 | buf->table_desc.va = |
780 | cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); | 782 | cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); |
781 | buf->table_desc.key = | 783 | buf->table_desc.key = |
782 | cpu_to_be32(target->srp_host->dev->mr->rkey); | 784 | cpu_to_be32(target->srp_host->srp_dev->mr->rkey); |
783 | buf->table_desc.len = | 785 | buf->table_desc.len = |
784 | cpu_to_be32(count * sizeof (struct srp_direct_buf)); | 786 | cpu_to_be32(count * sizeof (struct srp_direct_buf)); |
785 | 787 | ||
@@ -855,7 +857,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) | |||
855 | 857 | ||
856 | iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; | 858 | iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; |
857 | 859 | ||
858 | dev = target->srp_host->dev->dev; | 860 | dev = target->srp_host->srp_dev->dev; |
859 | ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, | 861 | ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, |
860 | DMA_FROM_DEVICE); | 862 | DMA_FROM_DEVICE); |
861 | 863 | ||
@@ -937,7 +939,7 @@ static int __srp_post_recv(struct srp_target_port *target) | |||
937 | 939 | ||
938 | list.addr = iu->dma; | 940 | list.addr = iu->dma; |
939 | list.length = iu->size; | 941 | list.length = iu->size; |
940 | list.lkey = target->srp_host->dev->mr->lkey; | 942 | list.lkey = target->srp_host->srp_dev->mr->lkey; |
941 | 943 | ||
942 | wr.next = NULL; | 944 | wr.next = NULL; |
943 | wr.sg_list = &list; | 945 | wr.sg_list = &list; |
@@ -996,7 +998,7 @@ static int __srp_post_send(struct srp_target_port *target, | |||
996 | 998 | ||
997 | list.addr = iu->dma; | 999 | list.addr = iu->dma; |
998 | list.length = len; | 1000 | list.length = len; |
999 | list.lkey = target->srp_host->dev->mr->lkey; | 1001 | list.lkey = target->srp_host->srp_dev->mr->lkey; |
1000 | 1002 | ||
1001 | wr.next = NULL; | 1003 | wr.next = NULL; |
1002 | wr.wr_id = target->tx_head & SRP_SQ_SIZE; | 1004 | wr.wr_id = target->tx_head & SRP_SQ_SIZE; |
@@ -1039,7 +1041,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd, | |||
1039 | if (!iu) | 1041 | if (!iu) |
1040 | goto err; | 1042 | goto err; |
1041 | 1043 | ||
1042 | dev = target->srp_host->dev->dev; | 1044 | dev = target->srp_host->srp_dev->dev; |
1043 | ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, | 1045 | ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, |
1044 | DMA_TO_DEVICE); | 1046 | DMA_TO_DEVICE); |
1045 | 1047 | ||
@@ -1456,9 +1458,10 @@ static int srp_reset_host(struct scsi_cmnd *scmnd) | |||
1456 | return ret; | 1458 | return ret; |
1457 | } | 1459 | } |
1458 | 1460 | ||
1459 | static ssize_t show_id_ext(struct class_device *cdev, char *buf) | 1461 | static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr, |
1462 | char *buf) | ||
1460 | { | 1463 | { |
1461 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1464 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1462 | 1465 | ||
1463 | if (target->state == SRP_TARGET_DEAD || | 1466 | if (target->state == SRP_TARGET_DEAD || |
1464 | target->state == SRP_TARGET_REMOVED) | 1467 | target->state == SRP_TARGET_REMOVED) |
@@ -1468,9 +1471,10 @@ static ssize_t show_id_ext(struct class_device *cdev, char *buf) | |||
1468 | (unsigned long long) be64_to_cpu(target->id_ext)); | 1471 | (unsigned long long) be64_to_cpu(target->id_ext)); |
1469 | } | 1472 | } |
1470 | 1473 | ||
1471 | static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) | 1474 | static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr, |
1475 | char *buf) | ||
1472 | { | 1476 | { |
1473 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1477 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1474 | 1478 | ||
1475 | if (target->state == SRP_TARGET_DEAD || | 1479 | if (target->state == SRP_TARGET_DEAD || |
1476 | target->state == SRP_TARGET_REMOVED) | 1480 | target->state == SRP_TARGET_REMOVED) |
@@ -1480,9 +1484,10 @@ static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) | |||
1480 | (unsigned long long) be64_to_cpu(target->ioc_guid)); | 1484 | (unsigned long long) be64_to_cpu(target->ioc_guid)); |
1481 | } | 1485 | } |
1482 | 1486 | ||
1483 | static ssize_t show_service_id(struct class_device *cdev, char *buf) | 1487 | static ssize_t show_service_id(struct device *dev, |
1488 | struct device_attribute *attr, char *buf) | ||
1484 | { | 1489 | { |
1485 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1490 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1486 | 1491 | ||
1487 | if (target->state == SRP_TARGET_DEAD || | 1492 | if (target->state == SRP_TARGET_DEAD || |
1488 | target->state == SRP_TARGET_REMOVED) | 1493 | target->state == SRP_TARGET_REMOVED) |
@@ -1492,9 +1497,10 @@ static ssize_t show_service_id(struct class_device *cdev, char *buf) | |||
1492 | (unsigned long long) be64_to_cpu(target->service_id)); | 1497 | (unsigned long long) be64_to_cpu(target->service_id)); |
1493 | } | 1498 | } |
1494 | 1499 | ||
1495 | static ssize_t show_pkey(struct class_device *cdev, char *buf) | 1500 | static ssize_t show_pkey(struct device *dev, struct device_attribute *attr, |
1501 | char *buf) | ||
1496 | { | 1502 | { |
1497 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1503 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1498 | 1504 | ||
1499 | if (target->state == SRP_TARGET_DEAD || | 1505 | if (target->state == SRP_TARGET_DEAD || |
1500 | target->state == SRP_TARGET_REMOVED) | 1506 | target->state == SRP_TARGET_REMOVED) |
@@ -1503,9 +1509,10 @@ static ssize_t show_pkey(struct class_device *cdev, char *buf) | |||
1503 | return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); | 1509 | return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); |
1504 | } | 1510 | } |
1505 | 1511 | ||
1506 | static ssize_t show_dgid(struct class_device *cdev, char *buf) | 1512 | static ssize_t show_dgid(struct device *dev, struct device_attribute *attr, |
1513 | char *buf) | ||
1507 | { | 1514 | { |
1508 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1515 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1509 | 1516 | ||
1510 | if (target->state == SRP_TARGET_DEAD || | 1517 | if (target->state == SRP_TARGET_DEAD || |
1511 | target->state == SRP_TARGET_REMOVED) | 1518 | target->state == SRP_TARGET_REMOVED) |
@@ -1522,9 +1529,10 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf) | |||
1522 | be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); | 1529 | be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); |
1523 | } | 1530 | } |
1524 | 1531 | ||
1525 | static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) | 1532 | static ssize_t show_orig_dgid(struct device *dev, |
1533 | struct device_attribute *attr, char *buf) | ||
1526 | { | 1534 | { |
1527 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1535 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1528 | 1536 | ||
1529 | if (target->state == SRP_TARGET_DEAD || | 1537 | if (target->state == SRP_TARGET_DEAD || |
1530 | target->state == SRP_TARGET_REMOVED) | 1538 | target->state == SRP_TARGET_REMOVED) |
@@ -1541,9 +1549,10 @@ static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) | |||
1541 | be16_to_cpu(target->orig_dgid[7])); | 1549 | be16_to_cpu(target->orig_dgid[7])); |
1542 | } | 1550 | } |
1543 | 1551 | ||
1544 | static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) | 1552 | static ssize_t show_zero_req_lim(struct device *dev, |
1553 | struct device_attribute *attr, char *buf) | ||
1545 | { | 1554 | { |
1546 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1555 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1547 | 1556 | ||
1548 | if (target->state == SRP_TARGET_DEAD || | 1557 | if (target->state == SRP_TARGET_DEAD || |
1549 | target->state == SRP_TARGET_REMOVED) | 1558 | target->state == SRP_TARGET_REMOVED) |
@@ -1552,40 +1561,42 @@ static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) | |||
1552 | return sprintf(buf, "%d\n", target->zero_req_lim); | 1561 | return sprintf(buf, "%d\n", target->zero_req_lim); |
1553 | } | 1562 | } |
1554 | 1563 | ||
1555 | static ssize_t show_local_ib_port(struct class_device *cdev, char *buf) | 1564 | static ssize_t show_local_ib_port(struct device *dev, |
1565 | struct device_attribute *attr, char *buf) | ||
1556 | { | 1566 | { |
1557 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1567 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1558 | 1568 | ||
1559 | return sprintf(buf, "%d\n", target->srp_host->port); | 1569 | return sprintf(buf, "%d\n", target->srp_host->port); |
1560 | } | 1570 | } |
1561 | 1571 | ||
1562 | static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) | 1572 | static ssize_t show_local_ib_device(struct device *dev, |
1573 | struct device_attribute *attr, char *buf) | ||
1563 | { | 1574 | { |
1564 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1575 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1565 | 1576 | ||
1566 | return sprintf(buf, "%s\n", target->srp_host->dev->dev->name); | 1577 | return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name); |
1567 | } | 1578 | } |
1568 | 1579 | ||
1569 | static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); | 1580 | static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); |
1570 | static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); | 1581 | static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); |
1571 | static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); | 1582 | static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); |
1572 | static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); | 1583 | static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); |
1573 | static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); | 1584 | static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); |
1574 | static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); | 1585 | static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); |
1575 | static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); | 1586 | static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); |
1576 | static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); | 1587 | static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); |
1577 | static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); | 1588 | static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); |
1578 | 1589 | ||
1579 | static struct class_device_attribute *srp_host_attrs[] = { | 1590 | static struct device_attribute *srp_host_attrs[] = { |
1580 | &class_device_attr_id_ext, | 1591 | &dev_attr_id_ext, |
1581 | &class_device_attr_ioc_guid, | 1592 | &dev_attr_ioc_guid, |
1582 | &class_device_attr_service_id, | 1593 | &dev_attr_service_id, |
1583 | &class_device_attr_pkey, | 1594 | &dev_attr_pkey, |
1584 | &class_device_attr_dgid, | 1595 | &dev_attr_dgid, |
1585 | &class_device_attr_orig_dgid, | 1596 | &dev_attr_orig_dgid, |
1586 | &class_device_attr_zero_req_lim, | 1597 | &dev_attr_zero_req_lim, |
1587 | &class_device_attr_local_ib_port, | 1598 | &dev_attr_local_ib_port, |
1588 | &class_device_attr_local_ib_device, | 1599 | &dev_attr_local_ib_device, |
1589 | NULL | 1600 | NULL |
1590 | }; | 1601 | }; |
1591 | 1602 | ||
@@ -1613,7 +1624,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | |||
1613 | sprintf(target->target_name, "SRP.T10:%016llX", | 1624 | sprintf(target->target_name, "SRP.T10:%016llX", |
1614 | (unsigned long long) be64_to_cpu(target->id_ext)); | 1625 | (unsigned long long) be64_to_cpu(target->id_ext)); |
1615 | 1626 | ||
1616 | if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) | 1627 | if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device)) |
1617 | return -ENODEV; | 1628 | return -ENODEV; |
1618 | 1629 | ||
1619 | memcpy(ids.port_id, &target->id_ext, 8); | 1630 | memcpy(ids.port_id, &target->id_ext, 8); |
@@ -1637,17 +1648,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | |||
1637 | return 0; | 1648 | return 0; |
1638 | } | 1649 | } |
1639 | 1650 | ||
1640 | static void srp_release_class_dev(struct class_device *class_dev) | 1651 | static void srp_release_dev(struct device *dev) |
1641 | { | 1652 | { |
1642 | struct srp_host *host = | 1653 | struct srp_host *host = |
1643 | container_of(class_dev, struct srp_host, class_dev); | 1654 | container_of(dev, struct srp_host, dev); |
1644 | 1655 | ||
1645 | complete(&host->released); | 1656 | complete(&host->released); |
1646 | } | 1657 | } |
1647 | 1658 | ||
1648 | static struct class srp_class = { | 1659 | static struct class srp_class = { |
1649 | .name = "infiniband_srp", | 1660 | .name = "infiniband_srp", |
1650 | .release = srp_release_class_dev | 1661 | .dev_release = srp_release_dev |
1651 | }; | 1662 | }; |
1652 | 1663 | ||
1653 | /* | 1664 | /* |
@@ -1835,11 +1846,12 @@ out: | |||
1835 | return ret; | 1846 | return ret; |
1836 | } | 1847 | } |
1837 | 1848 | ||
1838 | static ssize_t srp_create_target(struct class_device *class_dev, | 1849 | static ssize_t srp_create_target(struct device *dev, |
1850 | struct device_attribute *attr, | ||
1839 | const char *buf, size_t count) | 1851 | const char *buf, size_t count) |
1840 | { | 1852 | { |
1841 | struct srp_host *host = | 1853 | struct srp_host *host = |
1842 | container_of(class_dev, struct srp_host, class_dev); | 1854 | container_of(dev, struct srp_host, dev); |
1843 | struct Scsi_Host *target_host; | 1855 | struct Scsi_Host *target_host; |
1844 | struct srp_target_port *target; | 1856 | struct srp_target_port *target; |
1845 | int ret; | 1857 | int ret; |
@@ -1871,7 +1883,8 @@ static ssize_t srp_create_target(struct class_device *class_dev, | |||
1871 | if (ret) | 1883 | if (ret) |
1872 | goto err; | 1884 | goto err; |
1873 | 1885 | ||
1874 | ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid); | 1886 | ib_get_cached_gid(host->srp_dev->dev, host->port, 0, |
1887 | &target->path.sgid); | ||
1875 | 1888 | ||
1876 | shost_printk(KERN_DEBUG, target->scsi_host, PFX | 1889 | shost_printk(KERN_DEBUG, target->scsi_host, PFX |
1877 | "new target: id_ext %016llx ioc_guid %016llx pkey %04x " | 1890 | "new target: id_ext %016llx ioc_guid %016llx pkey %04x " |
@@ -1926,27 +1939,27 @@ err: | |||
1926 | return ret; | 1939 | return ret; |
1927 | } | 1940 | } |
1928 | 1941 | ||
1929 | static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); | 1942 | static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); |
1930 | 1943 | ||
1931 | static ssize_t show_ibdev(struct class_device *class_dev, char *buf) | 1944 | static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, |
1945 | char *buf) | ||
1932 | { | 1946 | { |
1933 | struct srp_host *host = | 1947 | struct srp_host *host = container_of(dev, struct srp_host, dev); |
1934 | container_of(class_dev, struct srp_host, class_dev); | ||
1935 | 1948 | ||
1936 | return sprintf(buf, "%s\n", host->dev->dev->name); | 1949 | return sprintf(buf, "%s\n", host->srp_dev->dev->name); |
1937 | } | 1950 | } |
1938 | 1951 | ||
1939 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | 1952 | static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); |
1940 | 1953 | ||
1941 | static ssize_t show_port(struct class_device *class_dev, char *buf) | 1954 | static ssize_t show_port(struct device *dev, struct device_attribute *attr, |
1955 | char *buf) | ||
1942 | { | 1956 | { |
1943 | struct srp_host *host = | 1957 | struct srp_host *host = container_of(dev, struct srp_host, dev); |
1944 | container_of(class_dev, struct srp_host, class_dev); | ||
1945 | 1958 | ||
1946 | return sprintf(buf, "%d\n", host->port); | 1959 | return sprintf(buf, "%d\n", host->port); |
1947 | } | 1960 | } |
1948 | 1961 | ||
1949 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 1962 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
1950 | 1963 | ||
1951 | static struct srp_host *srp_add_port(struct srp_device *device, u8 port) | 1964 | static struct srp_host *srp_add_port(struct srp_device *device, u8 port) |
1952 | { | 1965 | { |
@@ -1959,27 +1972,27 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) | |||
1959 | INIT_LIST_HEAD(&host->target_list); | 1972 | INIT_LIST_HEAD(&host->target_list); |
1960 | spin_lock_init(&host->target_lock); | 1973 | spin_lock_init(&host->target_lock); |
1961 | init_completion(&host->released); | 1974 | init_completion(&host->released); |
1962 | host->dev = device; | 1975 | host->srp_dev = device; |
1963 | host->port = port; | 1976 | host->port = port; |
1964 | 1977 | ||
1965 | host->class_dev.class = &srp_class; | 1978 | host->dev.class = &srp_class; |
1966 | host->class_dev.dev = device->dev->dma_device; | 1979 | host->dev.parent = device->dev->dma_device; |
1967 | snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", | 1980 | snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d", |
1968 | device->dev->name, port); | 1981 | device->dev->name, port); |
1969 | 1982 | ||
1970 | if (class_device_register(&host->class_dev)) | 1983 | if (device_register(&host->dev)) |
1971 | goto free_host; | 1984 | goto free_host; |
1972 | if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) | 1985 | if (device_create_file(&host->dev, &dev_attr_add_target)) |
1973 | goto err_class; | 1986 | goto err_class; |
1974 | if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) | 1987 | if (device_create_file(&host->dev, &dev_attr_ibdev)) |
1975 | goto err_class; | 1988 | goto err_class; |
1976 | if (class_device_create_file(&host->class_dev, &class_device_attr_port)) | 1989 | if (device_create_file(&host->dev, &dev_attr_port)) |
1977 | goto err_class; | 1990 | goto err_class; |
1978 | 1991 | ||
1979 | return host; | 1992 | return host; |
1980 | 1993 | ||
1981 | err_class: | 1994 | err_class: |
1982 | class_device_unregister(&host->class_dev); | 1995 | device_unregister(&host->dev); |
1983 | 1996 | ||
1984 | free_host: | 1997 | free_host: |
1985 | kfree(host); | 1998 | kfree(host); |
@@ -2084,7 +2097,7 @@ static void srp_remove_one(struct ib_device *device) | |||
2084 | srp_dev = ib_get_client_data(device, &srp_client); | 2097 | srp_dev = ib_get_client_data(device, &srp_client); |
2085 | 2098 | ||
2086 | list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { | 2099 | list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { |
2087 | class_device_unregister(&host->class_dev); | 2100 | device_unregister(&host->dev); |
2088 | /* | 2101 | /* |
2089 | * Wait for the sysfs entry to go away, so that no new | 2102 | * Wait for the sysfs entry to go away, so that no new |
2090 | * target ports can be created. | 2103 | * target ports can be created. |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index cb6eb816024a..63d2ae724061 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h | |||
@@ -97,9 +97,9 @@ struct srp_device { | |||
97 | }; | 97 | }; |
98 | 98 | ||
99 | struct srp_host { | 99 | struct srp_host { |
100 | struct srp_device *dev; | 100 | struct srp_device *srp_dev; |
101 | u8 port; | 101 | u8 port; |
102 | struct class_device class_dev; | 102 | struct device dev; |
103 | struct list_head target_list; | 103 | struct list_head target_list; |
104 | spinlock_t target_lock; | 104 | spinlock_t target_lock; |
105 | struct completion released; | 105 | struct completion released; |
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 4a938780dfc3..63aad90247c4 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -139,12 +139,10 @@ EXPORT_SYMBOL_GPL(led_classdev_register); | |||
139 | /** | 139 | /** |
140 | * __led_classdev_unregister - unregisters a object of led_properties class. | 140 | * __led_classdev_unregister - unregisters a object of led_properties class. |
141 | * @led_cdev: the led device to unregister | 141 | * @led_cdev: the led device to unregister |
142 | * @suspended: indicates whether system-wide suspend or resume is in progress | ||
143 | * | 142 | * |
144 | * Unregisters a previously registered via led_classdev_register object. | 143 | * Unregisters a previously registered via led_classdev_register object. |
145 | */ | 144 | */ |
146 | void __led_classdev_unregister(struct led_classdev *led_cdev, | 145 | void led_classdev_unregister(struct led_classdev *led_cdev) |
147 | bool suspended) | ||
148 | { | 146 | { |
149 | device_remove_file(led_cdev->dev, &dev_attr_brightness); | 147 | device_remove_file(led_cdev->dev, &dev_attr_brightness); |
150 | #ifdef CONFIG_LEDS_TRIGGERS | 148 | #ifdef CONFIG_LEDS_TRIGGERS |
@@ -155,16 +153,13 @@ void __led_classdev_unregister(struct led_classdev *led_cdev, | |||
155 | up_write(&led_cdev->trigger_lock); | 153 | up_write(&led_cdev->trigger_lock); |
156 | #endif | 154 | #endif |
157 | 155 | ||
158 | if (suspended) | 156 | device_unregister(led_cdev->dev); |
159 | device_pm_schedule_removal(led_cdev->dev); | ||
160 | else | ||
161 | device_unregister(led_cdev->dev); | ||
162 | 157 | ||
163 | down_write(&leds_list_lock); | 158 | down_write(&leds_list_lock); |
164 | list_del(&led_cdev->node); | 159 | list_del(&led_cdev->node); |
165 | up_write(&leds_list_lock); | 160 | up_write(&leds_list_lock); |
166 | } | 161 | } |
167 | EXPORT_SYMBOL_GPL(__led_classdev_unregister); | 162 | EXPORT_SYMBOL_GPL(led_classdev_unregister); |
168 | 163 | ||
169 | static int __init leds_init(void) | 164 | static int __init leds_init(void) |
170 | { | 165 | { |
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index 946e3d3506ac..61b98c333cb0 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c | |||
@@ -177,16 +177,16 @@ static struct bus_type memstick_bus_type = { | |||
177 | .resume = memstick_device_resume | 177 | .resume = memstick_device_resume |
178 | }; | 178 | }; |
179 | 179 | ||
180 | static void memstick_free(struct class_device *cdev) | 180 | static void memstick_free(struct device *dev) |
181 | { | 181 | { |
182 | struct memstick_host *host = container_of(cdev, struct memstick_host, | 182 | struct memstick_host *host = container_of(dev, struct memstick_host, |
183 | cdev); | 183 | dev); |
184 | kfree(host); | 184 | kfree(host); |
185 | } | 185 | } |
186 | 186 | ||
187 | static struct class memstick_host_class = { | 187 | static struct class memstick_host_class = { |
188 | .name = "memstick_host", | 188 | .name = "memstick_host", |
189 | .release = memstick_free | 189 | .dev_release = memstick_free |
190 | }; | 190 | }; |
191 | 191 | ||
192 | static void memstick_free_card(struct device *dev) | 192 | static void memstick_free_card(struct device *dev) |
@@ -383,8 +383,8 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host) | |||
383 | if (card) { | 383 | if (card) { |
384 | card->host = host; | 384 | card->host = host; |
385 | snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), | 385 | snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), |
386 | "%s", host->cdev.class_id); | 386 | "%s", host->dev.bus_id); |
387 | card->dev.parent = host->cdev.dev; | 387 | card->dev.parent = &host->dev; |
388 | card->dev.bus = &memstick_bus_type; | 388 | card->dev.bus = &memstick_bus_type; |
389 | card->dev.release = memstick_free_card; | 389 | card->dev.release = memstick_free_card; |
390 | card->check = memstick_dummy_check; | 390 | card->check = memstick_dummy_check; |
@@ -427,7 +427,7 @@ static void memstick_check(struct work_struct *work) | |||
427 | media_checker); | 427 | media_checker); |
428 | struct memstick_dev *card; | 428 | struct memstick_dev *card; |
429 | 429 | ||
430 | dev_dbg(host->cdev.dev, "memstick_check started\n"); | 430 | dev_dbg(&host->dev, "memstick_check started\n"); |
431 | mutex_lock(&host->lock); | 431 | mutex_lock(&host->lock); |
432 | if (!host->card) | 432 | if (!host->card) |
433 | memstick_power_on(host); | 433 | memstick_power_on(host); |
@@ -440,7 +440,7 @@ static void memstick_check(struct work_struct *work) | |||
440 | host->card = NULL; | 440 | host->card = NULL; |
441 | } | 441 | } |
442 | } else { | 442 | } else { |
443 | dev_dbg(host->cdev.dev, "new card %02x, %02x, %02x\n", | 443 | dev_dbg(&host->dev, "new card %02x, %02x, %02x\n", |
444 | card->id.type, card->id.category, card->id.class); | 444 | card->id.type, card->id.category, card->id.class); |
445 | if (host->card) { | 445 | if (host->card) { |
446 | if (memstick_set_rw_addr(host->card) | 446 | if (memstick_set_rw_addr(host->card) |
@@ -465,7 +465,7 @@ static void memstick_check(struct work_struct *work) | |||
465 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); | 465 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); |
466 | 466 | ||
467 | mutex_unlock(&host->lock); | 467 | mutex_unlock(&host->lock); |
468 | dev_dbg(host->cdev.dev, "memstick_check finished\n"); | 468 | dev_dbg(&host->dev, "memstick_check finished\n"); |
469 | } | 469 | } |
470 | 470 | ||
471 | /** | 471 | /** |
@@ -482,9 +482,9 @@ struct memstick_host *memstick_alloc_host(unsigned int extra, | |||
482 | if (host) { | 482 | if (host) { |
483 | mutex_init(&host->lock); | 483 | mutex_init(&host->lock); |
484 | INIT_WORK(&host->media_checker, memstick_check); | 484 | INIT_WORK(&host->media_checker, memstick_check); |
485 | host->cdev.class = &memstick_host_class; | 485 | host->dev.class = &memstick_host_class; |
486 | host->cdev.dev = dev; | 486 | host->dev.parent = dev; |
487 | class_device_initialize(&host->cdev); | 487 | device_initialize(&host->dev); |
488 | } | 488 | } |
489 | return host; | 489 | return host; |
490 | } | 490 | } |
@@ -507,10 +507,9 @@ int memstick_add_host(struct memstick_host *host) | |||
507 | if (rc) | 507 | if (rc) |
508 | return rc; | 508 | return rc; |
509 | 509 | ||
510 | snprintf(host->cdev.class_id, BUS_ID_SIZE, | 510 | snprintf(host->dev.bus_id, BUS_ID_SIZE, "memstick%u", host->id); |
511 | "memstick%u", host->id); | ||
512 | 511 | ||
513 | rc = class_device_add(&host->cdev); | 512 | rc = device_add(&host->dev); |
514 | if (rc) { | 513 | if (rc) { |
515 | spin_lock(&memstick_host_lock); | 514 | spin_lock(&memstick_host_lock); |
516 | idr_remove(&memstick_host_idr, host->id); | 515 | idr_remove(&memstick_host_idr, host->id); |
@@ -541,7 +540,7 @@ void memstick_remove_host(struct memstick_host *host) | |||
541 | spin_lock(&memstick_host_lock); | 540 | spin_lock(&memstick_host_lock); |
542 | idr_remove(&memstick_host_idr, host->id); | 541 | idr_remove(&memstick_host_idr, host->id); |
543 | spin_unlock(&memstick_host_lock); | 542 | spin_unlock(&memstick_host_lock); |
544 | class_device_del(&host->cdev); | 543 | device_del(&host->dev); |
545 | } | 544 | } |
546 | EXPORT_SYMBOL(memstick_remove_host); | 545 | EXPORT_SYMBOL(memstick_remove_host); |
547 | 546 | ||
@@ -552,7 +551,7 @@ EXPORT_SYMBOL(memstick_remove_host); | |||
552 | void memstick_free_host(struct memstick_host *host) | 551 | void memstick_free_host(struct memstick_host *host) |
553 | { | 552 | { |
554 | mutex_destroy(&host->lock); | 553 | mutex_destroy(&host->lock); |
555 | class_device_put(&host->cdev); | 554 | put_device(&host->dev); |
556 | } | 555 | } |
557 | EXPORT_SYMBOL(memstick_free_host); | 556 | EXPORT_SYMBOL(memstick_free_host); |
558 | 557 | ||
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index 557dbbba5cb2..477d0fb6e588 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c | |||
@@ -1127,8 +1127,8 @@ static int mspro_block_init_disk(struct memstick_dev *card) | |||
1127 | u64 limit = BLK_BOUNCE_HIGH; | 1127 | u64 limit = BLK_BOUNCE_HIGH; |
1128 | unsigned long capacity; | 1128 | unsigned long capacity; |
1129 | 1129 | ||
1130 | if (host->cdev.dev->dma_mask && *(host->cdev.dev->dma_mask)) | 1130 | if (host->dev.dma_mask && *(host->dev.dma_mask)) |
1131 | limit = *(host->cdev.dev->dma_mask); | 1131 | limit = *(host->dev.dma_mask); |
1132 | 1132 | ||
1133 | for (rc = 0; msb->attr_group.attrs[rc]; ++rc) { | 1133 | for (rc = 0; msb->attr_group.attrs[rc]; ++rc) { |
1134 | s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]); | 1134 | s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]); |
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c index 8770a5fac3b6..a054668eda16 100644 --- a/drivers/memstick/host/jmb38x_ms.c +++ b/drivers/memstick/host/jmb38x_ms.c | |||
@@ -361,15 +361,15 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh) | |||
361 | unsigned int data_len, cmd, t_val; | 361 | unsigned int data_len, cmd, t_val; |
362 | 362 | ||
363 | if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { | 363 | if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { |
364 | dev_dbg(msh->cdev.dev, "no media status\n"); | 364 | dev_dbg(&msh->dev, "no media status\n"); |
365 | host->req->error = -ETIME; | 365 | host->req->error = -ETIME; |
366 | return host->req->error; | 366 | return host->req->error; |
367 | } | 367 | } |
368 | 368 | ||
369 | dev_dbg(msh->cdev.dev, "control %08x\n", | 369 | dev_dbg(&msh->dev, "control %08x\n", |
370 | readl(host->addr + HOST_CONTROL)); | 370 | readl(host->addr + HOST_CONTROL)); |
371 | dev_dbg(msh->cdev.dev, "status %08x\n", readl(host->addr + INT_STATUS)); | 371 | dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS)); |
372 | dev_dbg(msh->cdev.dev, "hstatus %08x\n", readl(host->addr + STATUS)); | 372 | dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS)); |
373 | 373 | ||
374 | host->cmd_flags = 0; | 374 | host->cmd_flags = 0; |
375 | host->block_pos = 0; | 375 | host->block_pos = 0; |
@@ -448,7 +448,7 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh) | |||
448 | host->req->error = 0; | 448 | host->req->error = 0; |
449 | 449 | ||
450 | writel(cmd, host->addr + TPC); | 450 | writel(cmd, host->addr + TPC); |
451 | dev_dbg(msh->cdev.dev, "executing TPC %08x, len %x\n", cmd, data_len); | 451 | dev_dbg(&msh->dev, "executing TPC %08x, len %x\n", cmd, data_len); |
452 | 452 | ||
453 | return 0; | 453 | return 0; |
454 | } | 454 | } |
@@ -461,11 +461,11 @@ static void jmb38x_ms_complete_cmd(struct memstick_host *msh, int last) | |||
461 | 461 | ||
462 | del_timer(&host->timer); | 462 | del_timer(&host->timer); |
463 | 463 | ||
464 | dev_dbg(msh->cdev.dev, "c control %08x\n", | 464 | dev_dbg(&msh->dev, "c control %08x\n", |
465 | readl(host->addr + HOST_CONTROL)); | 465 | readl(host->addr + HOST_CONTROL)); |
466 | dev_dbg(msh->cdev.dev, "c status %08x\n", | 466 | dev_dbg(&msh->dev, "c status %08x\n", |
467 | readl(host->addr + INT_STATUS)); | 467 | readl(host->addr + INT_STATUS)); |
468 | dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS)); | 468 | dev_dbg(&msh->dev, "c hstatus %08x\n", readl(host->addr + STATUS)); |
469 | 469 | ||
470 | host->req->int_reg = readl(host->addr + STATUS) & 0xff; | 470 | host->req->int_reg = readl(host->addr + STATUS) & 0xff; |
471 | 471 | ||
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 89c63147a15d..b109bd8a4d19 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -3300,9 +3300,10 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice) | |||
3300 | } | 3300 | } |
3301 | 3301 | ||
3302 | static ssize_t | 3302 | static ssize_t |
3303 | mptscsih_version_fw_show(struct class_device *cdev, char *buf) | 3303 | mptscsih_version_fw_show(struct device *dev, struct device_attribute *attr, |
3304 | char *buf) | ||
3304 | { | 3305 | { |
3305 | struct Scsi_Host *host = class_to_shost(cdev); | 3306 | struct Scsi_Host *host = class_to_shost(dev); |
3306 | MPT_SCSI_HOST *hd = shost_priv(host); | 3307 | MPT_SCSI_HOST *hd = shost_priv(host); |
3307 | MPT_ADAPTER *ioc = hd->ioc; | 3308 | MPT_ADAPTER *ioc = hd->ioc; |
3308 | 3309 | ||
@@ -3312,12 +3313,13 @@ mptscsih_version_fw_show(struct class_device *cdev, char *buf) | |||
3312 | (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, | 3313 | (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, |
3313 | ioc->facts.FWVersion.Word & 0x000000FF); | 3314 | ioc->facts.FWVersion.Word & 0x000000FF); |
3314 | } | 3315 | } |
3315 | static CLASS_DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL); | 3316 | static DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL); |
3316 | 3317 | ||
3317 | static ssize_t | 3318 | static ssize_t |
3318 | mptscsih_version_bios_show(struct class_device *cdev, char *buf) | 3319 | mptscsih_version_bios_show(struct device *dev, struct device_attribute *attr, |
3320 | char *buf) | ||
3319 | { | 3321 | { |
3320 | struct Scsi_Host *host = class_to_shost(cdev); | 3322 | struct Scsi_Host *host = class_to_shost(dev); |
3321 | MPT_SCSI_HOST *hd = shost_priv(host); | 3323 | MPT_SCSI_HOST *hd = shost_priv(host); |
3322 | MPT_ADAPTER *ioc = hd->ioc; | 3324 | MPT_ADAPTER *ioc = hd->ioc; |
3323 | 3325 | ||
@@ -3327,129 +3329,141 @@ mptscsih_version_bios_show(struct class_device *cdev, char *buf) | |||
3327 | (ioc->biosVersion & 0x0000FF00) >> 8, | 3329 | (ioc->biosVersion & 0x0000FF00) >> 8, |
3328 | ioc->biosVersion & 0x000000FF); | 3330 | ioc->biosVersion & 0x000000FF); |
3329 | } | 3331 | } |
3330 | static CLASS_DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL); | 3332 | static DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL); |
3331 | 3333 | ||
3332 | static ssize_t | 3334 | static ssize_t |
3333 | mptscsih_version_mpi_show(struct class_device *cdev, char *buf) | 3335 | mptscsih_version_mpi_show(struct device *dev, struct device_attribute *attr, |
3336 | char *buf) | ||
3334 | { | 3337 | { |
3335 | struct Scsi_Host *host = class_to_shost(cdev); | 3338 | struct Scsi_Host *host = class_to_shost(dev); |
3336 | MPT_SCSI_HOST *hd = shost_priv(host); | 3339 | MPT_SCSI_HOST *hd = shost_priv(host); |
3337 | MPT_ADAPTER *ioc = hd->ioc; | 3340 | MPT_ADAPTER *ioc = hd->ioc; |
3338 | 3341 | ||
3339 | return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); | 3342 | return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); |
3340 | } | 3343 | } |
3341 | static CLASS_DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL); | 3344 | static DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL); |
3342 | 3345 | ||
3343 | static ssize_t | 3346 | static ssize_t |
3344 | mptscsih_version_product_show(struct class_device *cdev, char *buf) | 3347 | mptscsih_version_product_show(struct device *dev, |
3348 | struct device_attribute *attr, | ||
3349 | char *buf) | ||
3345 | { | 3350 | { |
3346 | struct Scsi_Host *host = class_to_shost(cdev); | 3351 | struct Scsi_Host *host = class_to_shost(dev); |
3347 | MPT_SCSI_HOST *hd = shost_priv(host); | 3352 | MPT_SCSI_HOST *hd = shost_priv(host); |
3348 | MPT_ADAPTER *ioc = hd->ioc; | 3353 | MPT_ADAPTER *ioc = hd->ioc; |
3349 | 3354 | ||
3350 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); | 3355 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); |
3351 | } | 3356 | } |
3352 | static CLASS_DEVICE_ATTR(version_product, S_IRUGO, | 3357 | static DEVICE_ATTR(version_product, S_IRUGO, |
3353 | mptscsih_version_product_show, NULL); | 3358 | mptscsih_version_product_show, NULL); |
3354 | 3359 | ||
3355 | static ssize_t | 3360 | static ssize_t |
3356 | mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) | 3361 | mptscsih_version_nvdata_persistent_show(struct device *dev, |
3362 | struct device_attribute *attr, | ||
3363 | char *buf) | ||
3357 | { | 3364 | { |
3358 | struct Scsi_Host *host = class_to_shost(cdev); | 3365 | struct Scsi_Host *host = class_to_shost(dev); |
3359 | MPT_SCSI_HOST *hd = shost_priv(host); | 3366 | MPT_SCSI_HOST *hd = shost_priv(host); |
3360 | MPT_ADAPTER *ioc = hd->ioc; | 3367 | MPT_ADAPTER *ioc = hd->ioc; |
3361 | 3368 | ||
3362 | return snprintf(buf, PAGE_SIZE, "%02xh\n", | 3369 | return snprintf(buf, PAGE_SIZE, "%02xh\n", |
3363 | ioc->nvdata_version_persistent); | 3370 | ioc->nvdata_version_persistent); |
3364 | } | 3371 | } |
3365 | static CLASS_DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, | 3372 | static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, |
3366 | mptscsih_version_nvdata_persistent_show, NULL); | 3373 | mptscsih_version_nvdata_persistent_show, NULL); |
3367 | 3374 | ||
3368 | static ssize_t | 3375 | static ssize_t |
3369 | mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) | 3376 | mptscsih_version_nvdata_default_show(struct device *dev, |
3377 | struct device_attribute *attr, char *buf) | ||
3370 | { | 3378 | { |
3371 | struct Scsi_Host *host = class_to_shost(cdev); | 3379 | struct Scsi_Host *host = class_to_shost(dev); |
3372 | MPT_SCSI_HOST *hd = shost_priv(host); | 3380 | MPT_SCSI_HOST *hd = shost_priv(host); |
3373 | MPT_ADAPTER *ioc = hd->ioc; | 3381 | MPT_ADAPTER *ioc = hd->ioc; |
3374 | 3382 | ||
3375 | return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); | 3383 | return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); |
3376 | } | 3384 | } |
3377 | static CLASS_DEVICE_ATTR(version_nvdata_default, S_IRUGO, | 3385 | static DEVICE_ATTR(version_nvdata_default, S_IRUGO, |
3378 | mptscsih_version_nvdata_default_show, NULL); | 3386 | mptscsih_version_nvdata_default_show, NULL); |
3379 | 3387 | ||
3380 | static ssize_t | 3388 | static ssize_t |
3381 | mptscsih_board_name_show(struct class_device *cdev, char *buf) | 3389 | mptscsih_board_name_show(struct device *dev, struct device_attribute *attr, |
3390 | char *buf) | ||
3382 | { | 3391 | { |
3383 | struct Scsi_Host *host = class_to_shost(cdev); | 3392 | struct Scsi_Host *host = class_to_shost(dev); |
3384 | MPT_SCSI_HOST *hd = shost_priv(host); | 3393 | MPT_SCSI_HOST *hd = shost_priv(host); |
3385 | MPT_ADAPTER *ioc = hd->ioc; | 3394 | MPT_ADAPTER *ioc = hd->ioc; |
3386 | 3395 | ||
3387 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); | 3396 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); |
3388 | } | 3397 | } |
3389 | static CLASS_DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL); | 3398 | static DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL); |
3390 | 3399 | ||
3391 | static ssize_t | 3400 | static ssize_t |
3392 | mptscsih_board_assembly_show(struct class_device *cdev, char *buf) | 3401 | mptscsih_board_assembly_show(struct device *dev, |
3402 | struct device_attribute *attr, char *buf) | ||
3393 | { | 3403 | { |
3394 | struct Scsi_Host *host = class_to_shost(cdev); | 3404 | struct Scsi_Host *host = class_to_shost(dev); |
3395 | MPT_SCSI_HOST *hd = shost_priv(host); | 3405 | MPT_SCSI_HOST *hd = shost_priv(host); |
3396 | MPT_ADAPTER *ioc = hd->ioc; | 3406 | MPT_ADAPTER *ioc = hd->ioc; |
3397 | 3407 | ||
3398 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); | 3408 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); |
3399 | } | 3409 | } |
3400 | static CLASS_DEVICE_ATTR(board_assembly, S_IRUGO, | 3410 | static DEVICE_ATTR(board_assembly, S_IRUGO, |
3401 | mptscsih_board_assembly_show, NULL); | 3411 | mptscsih_board_assembly_show, NULL); |
3402 | 3412 | ||
3403 | static ssize_t | 3413 | static ssize_t |
3404 | mptscsih_board_tracer_show(struct class_device *cdev, char *buf) | 3414 | mptscsih_board_tracer_show(struct device *dev, struct device_attribute *attr, |
3415 | char *buf) | ||
3405 | { | 3416 | { |
3406 | struct Scsi_Host *host = class_to_shost(cdev); | 3417 | struct Scsi_Host *host = class_to_shost(dev); |
3407 | MPT_SCSI_HOST *hd = shost_priv(host); | 3418 | MPT_SCSI_HOST *hd = shost_priv(host); |
3408 | MPT_ADAPTER *ioc = hd->ioc; | 3419 | MPT_ADAPTER *ioc = hd->ioc; |
3409 | 3420 | ||
3410 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); | 3421 | return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); |
3411 | } | 3422 | } |
3412 | static CLASS_DEVICE_ATTR(board_tracer, S_IRUGO, | 3423 | static DEVICE_ATTR(board_tracer, S_IRUGO, |
3413 | mptscsih_board_tracer_show, NULL); | 3424 | mptscsih_board_tracer_show, NULL); |
3414 | 3425 | ||
3415 | static ssize_t | 3426 | static ssize_t |
3416 | mptscsih_io_delay_show(struct class_device *cdev, char *buf) | 3427 | mptscsih_io_delay_show(struct device *dev, struct device_attribute *attr, |
3428 | char *buf) | ||
3417 | { | 3429 | { |
3418 | struct Scsi_Host *host = class_to_shost(cdev); | 3430 | struct Scsi_Host *host = class_to_shost(dev); |
3419 | MPT_SCSI_HOST *hd = shost_priv(host); | 3431 | MPT_SCSI_HOST *hd = shost_priv(host); |
3420 | MPT_ADAPTER *ioc = hd->ioc; | 3432 | MPT_ADAPTER *ioc = hd->ioc; |
3421 | 3433 | ||
3422 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); | 3434 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); |
3423 | } | 3435 | } |
3424 | static CLASS_DEVICE_ATTR(io_delay, S_IRUGO, | 3436 | static DEVICE_ATTR(io_delay, S_IRUGO, |
3425 | mptscsih_io_delay_show, NULL); | 3437 | mptscsih_io_delay_show, NULL); |
3426 | 3438 | ||
3427 | static ssize_t | 3439 | static ssize_t |
3428 | mptscsih_device_delay_show(struct class_device *cdev, char *buf) | 3440 | mptscsih_device_delay_show(struct device *dev, struct device_attribute *attr, |
3441 | char *buf) | ||
3429 | { | 3442 | { |
3430 | struct Scsi_Host *host = class_to_shost(cdev); | 3443 | struct Scsi_Host *host = class_to_shost(dev); |
3431 | MPT_SCSI_HOST *hd = shost_priv(host); | 3444 | MPT_SCSI_HOST *hd = shost_priv(host); |
3432 | MPT_ADAPTER *ioc = hd->ioc; | 3445 | MPT_ADAPTER *ioc = hd->ioc; |
3433 | 3446 | ||
3434 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); | 3447 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); |
3435 | } | 3448 | } |
3436 | static CLASS_DEVICE_ATTR(device_delay, S_IRUGO, | 3449 | static DEVICE_ATTR(device_delay, S_IRUGO, |
3437 | mptscsih_device_delay_show, NULL); | 3450 | mptscsih_device_delay_show, NULL); |
3438 | 3451 | ||
3439 | static ssize_t | 3452 | static ssize_t |
3440 | mptscsih_debug_level_show(struct class_device *cdev, char *buf) | 3453 | mptscsih_debug_level_show(struct device *dev, struct device_attribute *attr, |
3454 | char *buf) | ||
3441 | { | 3455 | { |
3442 | struct Scsi_Host *host = class_to_shost(cdev); | 3456 | struct Scsi_Host *host = class_to_shost(dev); |
3443 | MPT_SCSI_HOST *hd = shost_priv(host); | 3457 | MPT_SCSI_HOST *hd = shost_priv(host); |
3444 | MPT_ADAPTER *ioc = hd->ioc; | 3458 | MPT_ADAPTER *ioc = hd->ioc; |
3445 | 3459 | ||
3446 | return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); | 3460 | return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); |
3447 | } | 3461 | } |
3448 | static ssize_t | 3462 | static ssize_t |
3449 | mptscsih_debug_level_store(struct class_device *cdev, const char *buf, | 3463 | mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr, |
3450 | size_t count) | 3464 | const char *buf, size_t count) |
3451 | { | 3465 | { |
3452 | struct Scsi_Host *host = class_to_shost(cdev); | 3466 | struct Scsi_Host *host = class_to_shost(dev); |
3453 | MPT_SCSI_HOST *hd = shost_priv(host); | 3467 | MPT_SCSI_HOST *hd = shost_priv(host); |
3454 | MPT_ADAPTER *ioc = hd->ioc; | 3468 | MPT_ADAPTER *ioc = hd->ioc; |
3455 | int val = 0; | 3469 | int val = 0; |
@@ -3462,22 +3476,22 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf, | |||
3462 | ioc->name, ioc->debug_level); | 3476 | ioc->name, ioc->debug_level); |
3463 | return strlen(buf); | 3477 | return strlen(buf); |
3464 | } | 3478 | } |
3465 | static CLASS_DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR, | 3479 | static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR, |
3466 | mptscsih_debug_level_show, mptscsih_debug_level_store); | 3480 | mptscsih_debug_level_show, mptscsih_debug_level_store); |
3467 | 3481 | ||
3468 | struct class_device_attribute *mptscsih_host_attrs[] = { | 3482 | struct device_attribute *mptscsih_host_attrs[] = { |
3469 | &class_device_attr_version_fw, | 3483 | &dev_attr_version_fw, |
3470 | &class_device_attr_version_bios, | 3484 | &dev_attr_version_bios, |
3471 | &class_device_attr_version_mpi, | 3485 | &dev_attr_version_mpi, |
3472 | &class_device_attr_version_product, | 3486 | &dev_attr_version_product, |
3473 | &class_device_attr_version_nvdata_persistent, | 3487 | &dev_attr_version_nvdata_persistent, |
3474 | &class_device_attr_version_nvdata_default, | 3488 | &dev_attr_version_nvdata_default, |
3475 | &class_device_attr_board_name, | 3489 | &dev_attr_board_name, |
3476 | &class_device_attr_board_assembly, | 3490 | &dev_attr_board_assembly, |
3477 | &class_device_attr_board_tracer, | 3491 | &dev_attr_board_tracer, |
3478 | &class_device_attr_io_delay, | 3492 | &dev_attr_io_delay, |
3479 | &class_device_attr_device_delay, | 3493 | &dev_attr_device_delay, |
3480 | &class_device_attr_debug_level, | 3494 | &dev_attr_debug_level, |
3481 | NULL, | 3495 | NULL, |
3482 | }; | 3496 | }; |
3483 | EXPORT_SYMBOL(mptscsih_host_attrs); | 3497 | EXPORT_SYMBOL(mptscsih_host_attrs); |
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index d289e97cfe8b..7ea7da0e090c 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h | |||
@@ -129,4 +129,4 @@ extern void mptscsih_timer_expired(unsigned long data); | |||
129 | extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); | 129 | extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); |
130 | extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id); | 130 | extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id); |
131 | extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id); | 131 | extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id); |
132 | extern struct class_device_attribute *mptscsih_host_attrs[]; | 132 | extern struct device_attribute *mptscsih_host_attrs[]; |
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 6fcb0e96adf4..fafb57fed761 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c | |||
@@ -40,16 +40,16 @@ static struct class enclosure_component_class; | |||
40 | * Looks through the list of registered enclosures to see | 40 | * Looks through the list of registered enclosures to see |
41 | * if it can find a match for a device. Returns NULL if no | 41 | * if it can find a match for a device. Returns NULL if no |
42 | * enclosure is found. Obtains a reference to the enclosure class | 42 | * enclosure is found. Obtains a reference to the enclosure class |
43 | * device which must be released with class_device_put(). | 43 | * device which must be released with device_put(). |
44 | */ | 44 | */ |
45 | struct enclosure_device *enclosure_find(struct device *dev) | 45 | struct enclosure_device *enclosure_find(struct device *dev) |
46 | { | 46 | { |
47 | struct enclosure_device *edev = NULL; | 47 | struct enclosure_device *edev; |
48 | 48 | ||
49 | mutex_lock(&container_list_lock); | 49 | mutex_lock(&container_list_lock); |
50 | list_for_each_entry(edev, &container_list, node) { | 50 | list_for_each_entry(edev, &container_list, node) { |
51 | if (edev->cdev.dev == dev) { | 51 | if (edev->edev.parent == dev) { |
52 | class_device_get(&edev->cdev); | 52 | get_device(&edev->edev); |
53 | mutex_unlock(&container_list_lock); | 53 | mutex_unlock(&container_list_lock); |
54 | return edev; | 54 | return edev; |
55 | } | 55 | } |
@@ -117,11 +117,11 @@ enclosure_register(struct device *dev, const char *name, int components, | |||
117 | 117 | ||
118 | edev->components = components; | 118 | edev->components = components; |
119 | 119 | ||
120 | edev->cdev.class = &enclosure_class; | 120 | edev->edev.class = &enclosure_class; |
121 | edev->cdev.dev = get_device(dev); | 121 | edev->edev.parent = get_device(dev); |
122 | edev->cb = cb; | 122 | edev->cb = cb; |
123 | snprintf(edev->cdev.class_id, BUS_ID_SIZE, "%s", name); | 123 | snprintf(edev->edev.bus_id, BUS_ID_SIZE, "%s", name); |
124 | err = class_device_register(&edev->cdev); | 124 | err = device_register(&edev->edev); |
125 | if (err) | 125 | if (err) |
126 | goto err; | 126 | goto err; |
127 | 127 | ||
@@ -135,7 +135,7 @@ enclosure_register(struct device *dev, const char *name, int components, | |||
135 | return edev; | 135 | return edev; |
136 | 136 | ||
137 | err: | 137 | err: |
138 | put_device(edev->cdev.dev); | 138 | put_device(edev->edev.parent); |
139 | kfree(edev); | 139 | kfree(edev); |
140 | return ERR_PTR(err); | 140 | return ERR_PTR(err); |
141 | } | 141 | } |
@@ -158,27 +158,28 @@ void enclosure_unregister(struct enclosure_device *edev) | |||
158 | 158 | ||
159 | for (i = 0; i < edev->components; i++) | 159 | for (i = 0; i < edev->components; i++) |
160 | if (edev->component[i].number != -1) | 160 | if (edev->component[i].number != -1) |
161 | class_device_unregister(&edev->component[i].cdev); | 161 | device_unregister(&edev->component[i].cdev); |
162 | 162 | ||
163 | /* prevent any callbacks into service user */ | 163 | /* prevent any callbacks into service user */ |
164 | edev->cb = &enclosure_null_callbacks; | 164 | edev->cb = &enclosure_null_callbacks; |
165 | class_device_unregister(&edev->cdev); | 165 | device_unregister(&edev->edev); |
166 | } | 166 | } |
167 | EXPORT_SYMBOL_GPL(enclosure_unregister); | 167 | EXPORT_SYMBOL_GPL(enclosure_unregister); |
168 | 168 | ||
169 | static void enclosure_release(struct class_device *cdev) | 169 | static void enclosure_release(struct device *cdev) |
170 | { | 170 | { |
171 | struct enclosure_device *edev = to_enclosure_device(cdev); | 171 | struct enclosure_device *edev = to_enclosure_device(cdev); |
172 | 172 | ||
173 | put_device(cdev->dev); | 173 | put_device(cdev->parent); |
174 | kfree(edev); | 174 | kfree(edev); |
175 | } | 175 | } |
176 | 176 | ||
177 | static void enclosure_component_release(struct class_device *cdev) | 177 | static void enclosure_component_release(struct device *dev) |
178 | { | 178 | { |
179 | if (cdev->dev) | 179 | struct enclosure_component *cdev = to_enclosure_component(dev); |
180 | put_device(cdev->dev); | 180 | |
181 | class_device_put(cdev->parent); | 181 | put_device(cdev->dev); |
182 | put_device(dev->parent); | ||
182 | } | 183 | } |
183 | 184 | ||
184 | /** | 185 | /** |
@@ -201,7 +202,7 @@ enclosure_component_register(struct enclosure_device *edev, | |||
201 | const char *name) | 202 | const char *name) |
202 | { | 203 | { |
203 | struct enclosure_component *ecomp; | 204 | struct enclosure_component *ecomp; |
204 | struct class_device *cdev; | 205 | struct device *cdev; |
205 | int err; | 206 | int err; |
206 | 207 | ||
207 | if (number >= edev->components) | 208 | if (number >= edev->components) |
@@ -215,14 +216,14 @@ enclosure_component_register(struct enclosure_device *edev, | |||
215 | ecomp->type = type; | 216 | ecomp->type = type; |
216 | ecomp->number = number; | 217 | ecomp->number = number; |
217 | cdev = &ecomp->cdev; | 218 | cdev = &ecomp->cdev; |
218 | cdev->parent = class_device_get(&edev->cdev); | 219 | cdev->parent = get_device(&edev->edev); |
219 | cdev->class = &enclosure_component_class; | 220 | cdev->class = &enclosure_component_class; |
220 | if (name) | 221 | if (name) |
221 | snprintf(cdev->class_id, BUS_ID_SIZE, "%s", name); | 222 | snprintf(cdev->bus_id, BUS_ID_SIZE, "%s", name); |
222 | else | 223 | else |
223 | snprintf(cdev->class_id, BUS_ID_SIZE, "%u", number); | 224 | snprintf(cdev->bus_id, BUS_ID_SIZE, "%u", number); |
224 | 225 | ||
225 | err = class_device_register(cdev); | 226 | err = device_register(cdev); |
226 | if (err) | 227 | if (err) |
227 | ERR_PTR(err); | 228 | ERR_PTR(err); |
228 | 229 | ||
@@ -247,18 +248,17 @@ EXPORT_SYMBOL_GPL(enclosure_component_register); | |||
247 | int enclosure_add_device(struct enclosure_device *edev, int component, | 248 | int enclosure_add_device(struct enclosure_device *edev, int component, |
248 | struct device *dev) | 249 | struct device *dev) |
249 | { | 250 | { |
250 | struct class_device *cdev; | 251 | struct enclosure_component *cdev; |
251 | 252 | ||
252 | if (!edev || component >= edev->components) | 253 | if (!edev || component >= edev->components) |
253 | return -EINVAL; | 254 | return -EINVAL; |
254 | 255 | ||
255 | cdev = &edev->component[component].cdev; | 256 | cdev = &edev->component[component]; |
256 | 257 | ||
257 | class_device_del(cdev); | 258 | device_del(&cdev->cdev); |
258 | if (cdev->dev) | 259 | put_device(cdev->dev); |
259 | put_device(cdev->dev); | ||
260 | cdev->dev = get_device(dev); | 260 | cdev->dev = get_device(dev); |
261 | return class_device_add(cdev); | 261 | return device_add(&cdev->cdev); |
262 | } | 262 | } |
263 | EXPORT_SYMBOL_GPL(enclosure_add_device); | 263 | EXPORT_SYMBOL_GPL(enclosure_add_device); |
264 | 264 | ||
@@ -272,18 +272,17 @@ EXPORT_SYMBOL_GPL(enclosure_add_device); | |||
272 | */ | 272 | */ |
273 | int enclosure_remove_device(struct enclosure_device *edev, int component) | 273 | int enclosure_remove_device(struct enclosure_device *edev, int component) |
274 | { | 274 | { |
275 | struct class_device *cdev; | 275 | struct enclosure_component *cdev; |
276 | 276 | ||
277 | if (!edev || component >= edev->components) | 277 | if (!edev || component >= edev->components) |
278 | return -EINVAL; | 278 | return -EINVAL; |
279 | 279 | ||
280 | cdev = &edev->component[component].cdev; | 280 | cdev = &edev->component[component]; |
281 | 281 | ||
282 | class_device_del(cdev); | 282 | device_del(&cdev->cdev); |
283 | if (cdev->dev) | 283 | put_device(cdev->dev); |
284 | put_device(cdev->dev); | ||
285 | cdev->dev = NULL; | 284 | cdev->dev = NULL; |
286 | return class_device_add(cdev); | 285 | return device_add(&cdev->cdev); |
287 | } | 286 | } |
288 | EXPORT_SYMBOL_GPL(enclosure_remove_device); | 287 | EXPORT_SYMBOL_GPL(enclosure_remove_device); |
289 | 288 | ||
@@ -291,14 +290,16 @@ EXPORT_SYMBOL_GPL(enclosure_remove_device); | |||
291 | * sysfs pieces below | 290 | * sysfs pieces below |
292 | */ | 291 | */ |
293 | 292 | ||
294 | static ssize_t enclosure_show_components(struct class_device *cdev, char *buf) | 293 | static ssize_t enclosure_show_components(struct device *cdev, |
294 | struct device_attribute *attr, | ||
295 | char *buf) | ||
295 | { | 296 | { |
296 | struct enclosure_device *edev = to_enclosure_device(cdev); | 297 | struct enclosure_device *edev = to_enclosure_device(cdev); |
297 | 298 | ||
298 | return snprintf(buf, 40, "%d\n", edev->components); | 299 | return snprintf(buf, 40, "%d\n", edev->components); |
299 | } | 300 | } |
300 | 301 | ||
301 | static struct class_device_attribute enclosure_attrs[] = { | 302 | static struct device_attribute enclosure_attrs[] = { |
302 | __ATTR(components, S_IRUGO, enclosure_show_components, NULL), | 303 | __ATTR(components, S_IRUGO, enclosure_show_components, NULL), |
303 | __ATTR_NULL | 304 | __ATTR_NULL |
304 | }; | 305 | }; |
@@ -306,8 +307,8 @@ static struct class_device_attribute enclosure_attrs[] = { | |||
306 | static struct class enclosure_class = { | 307 | static struct class enclosure_class = { |
307 | .name = "enclosure", | 308 | .name = "enclosure", |
308 | .owner = THIS_MODULE, | 309 | .owner = THIS_MODULE, |
309 | .release = enclosure_release, | 310 | .dev_release = enclosure_release, |
310 | .class_dev_attrs = enclosure_attrs, | 311 | .dev_attrs = enclosure_attrs, |
311 | }; | 312 | }; |
312 | 313 | ||
313 | static const char *const enclosure_status [] = { | 314 | static const char *const enclosure_status [] = { |
@@ -326,7 +327,8 @@ static const char *const enclosure_type [] = { | |||
326 | [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device", | 327 | [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device", |
327 | }; | 328 | }; |
328 | 329 | ||
329 | static ssize_t get_component_fault(struct class_device *cdev, char *buf) | 330 | static ssize_t get_component_fault(struct device *cdev, |
331 | struct device_attribute *attr, char *buf) | ||
330 | { | 332 | { |
331 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 333 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
332 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 334 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -336,8 +338,9 @@ static ssize_t get_component_fault(struct class_device *cdev, char *buf) | |||
336 | return snprintf(buf, 40, "%d\n", ecomp->fault); | 338 | return snprintf(buf, 40, "%d\n", ecomp->fault); |
337 | } | 339 | } |
338 | 340 | ||
339 | static ssize_t set_component_fault(struct class_device *cdev, const char *buf, | 341 | static ssize_t set_component_fault(struct device *cdev, |
340 | size_t count) | 342 | struct device_attribute *attr, |
343 | const char *buf, size_t count) | ||
341 | { | 344 | { |
342 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 345 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
343 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 346 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -348,7 +351,8 @@ static ssize_t set_component_fault(struct class_device *cdev, const char *buf, | |||
348 | return count; | 351 | return count; |
349 | } | 352 | } |
350 | 353 | ||
351 | static ssize_t get_component_status(struct class_device *cdev, char *buf) | 354 | static ssize_t get_component_status(struct device *cdev, |
355 | struct device_attribute *attr,char *buf) | ||
352 | { | 356 | { |
353 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 357 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
354 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 358 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -358,8 +362,9 @@ static ssize_t get_component_status(struct class_device *cdev, char *buf) | |||
358 | return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]); | 362 | return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]); |
359 | } | 363 | } |
360 | 364 | ||
361 | static ssize_t set_component_status(struct class_device *cdev, const char *buf, | 365 | static ssize_t set_component_status(struct device *cdev, |
362 | size_t count) | 366 | struct device_attribute *attr, |
367 | const char *buf, size_t count) | ||
363 | { | 368 | { |
364 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 369 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
365 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 370 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -380,7 +385,8 @@ static ssize_t set_component_status(struct class_device *cdev, const char *buf, | |||
380 | return -EINVAL; | 385 | return -EINVAL; |
381 | } | 386 | } |
382 | 387 | ||
383 | static ssize_t get_component_active(struct class_device *cdev, char *buf) | 388 | static ssize_t get_component_active(struct device *cdev, |
389 | struct device_attribute *attr, char *buf) | ||
384 | { | 390 | { |
385 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 391 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
386 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 392 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -390,8 +396,9 @@ static ssize_t get_component_active(struct class_device *cdev, char *buf) | |||
390 | return snprintf(buf, 40, "%d\n", ecomp->active); | 396 | return snprintf(buf, 40, "%d\n", ecomp->active); |
391 | } | 397 | } |
392 | 398 | ||
393 | static ssize_t set_component_active(struct class_device *cdev, const char *buf, | 399 | static ssize_t set_component_active(struct device *cdev, |
394 | size_t count) | 400 | struct device_attribute *attr, |
401 | const char *buf, size_t count) | ||
395 | { | 402 | { |
396 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 403 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
397 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 404 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -402,7 +409,8 @@ static ssize_t set_component_active(struct class_device *cdev, const char *buf, | |||
402 | return count; | 409 | return count; |
403 | } | 410 | } |
404 | 411 | ||
405 | static ssize_t get_component_locate(struct class_device *cdev, char *buf) | 412 | static ssize_t get_component_locate(struct device *cdev, |
413 | struct device_attribute *attr, char *buf) | ||
406 | { | 414 | { |
407 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 415 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
408 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 416 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -412,8 +420,9 @@ static ssize_t get_component_locate(struct class_device *cdev, char *buf) | |||
412 | return snprintf(buf, 40, "%d\n", ecomp->locate); | 420 | return snprintf(buf, 40, "%d\n", ecomp->locate); |
413 | } | 421 | } |
414 | 422 | ||
415 | static ssize_t set_component_locate(struct class_device *cdev, const char *buf, | 423 | static ssize_t set_component_locate(struct device *cdev, |
416 | size_t count) | 424 | struct device_attribute *attr, |
425 | const char *buf, size_t count) | ||
417 | { | 426 | { |
418 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); | 427 | struct enclosure_device *edev = to_enclosure_device(cdev->parent); |
419 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 428 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
@@ -424,7 +433,8 @@ static ssize_t set_component_locate(struct class_device *cdev, const char *buf, | |||
424 | return count; | 433 | return count; |
425 | } | 434 | } |
426 | 435 | ||
427 | static ssize_t get_component_type(struct class_device *cdev, char *buf) | 436 | static ssize_t get_component_type(struct device *cdev, |
437 | struct device_attribute *attr, char *buf) | ||
428 | { | 438 | { |
429 | struct enclosure_component *ecomp = to_enclosure_component(cdev); | 439 | struct enclosure_component *ecomp = to_enclosure_component(cdev); |
430 | 440 | ||
@@ -432,7 +442,7 @@ static ssize_t get_component_type(struct class_device *cdev, char *buf) | |||
432 | } | 442 | } |
433 | 443 | ||
434 | 444 | ||
435 | static struct class_device_attribute enclosure_component_attrs[] = { | 445 | static struct device_attribute enclosure_component_attrs[] = { |
436 | __ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault, | 446 | __ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault, |
437 | set_component_fault), | 447 | set_component_fault), |
438 | __ATTR(status, S_IRUGO | S_IWUSR, get_component_status, | 448 | __ATTR(status, S_IRUGO | S_IWUSR, get_component_status, |
@@ -448,8 +458,8 @@ static struct class_device_attribute enclosure_component_attrs[] = { | |||
448 | static struct class enclosure_component_class = { | 458 | static struct class enclosure_component_class = { |
449 | .name = "enclosure_component", | 459 | .name = "enclosure_component", |
450 | .owner = THIS_MODULE, | 460 | .owner = THIS_MODULE, |
451 | .class_dev_attrs = enclosure_component_attrs, | 461 | .dev_attrs = enclosure_component_attrs, |
452 | .release = enclosure_component_release, | 462 | .dev_release = enclosure_component_release, |
453 | }; | 463 | }; |
454 | 464 | ||
455 | static int __init enclosure_init(void) | 465 | static int __init enclosure_init(void) |
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c index 0aac1ff511df..36a9c42df835 100644 --- a/drivers/net/wireless/b43/leds.c +++ b/drivers/net/wireless/b43/leds.c | |||
@@ -116,10 +116,7 @@ static void b43_unregister_led(struct b43_led *led) | |||
116 | { | 116 | { |
117 | if (!led->dev) | 117 | if (!led->dev) |
118 | return; | 118 | return; |
119 | if (led->dev->suspend_in_progress) | 119 | led_classdev_unregister(&led->led_dev); |
120 | led_classdev_unregister_suspended(&led->led_dev); | ||
121 | else | ||
122 | led_classdev_unregister(&led->led_dev); | ||
123 | b43_led_turn_off(led->dev, led->index, led->activelow); | 120 | b43_led_turn_off(led->dev, led->index, led->activelow); |
124 | led->dev = NULL; | 121 | led->dev = NULL; |
125 | } | 122 | } |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index cf5c046c9fa8..943cc851c504 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -2804,10 +2804,10 @@ static int b43_rng_read(struct hwrng *rng, u32 * data) | |||
2804 | return (sizeof(u16)); | 2804 | return (sizeof(u16)); |
2805 | } | 2805 | } |
2806 | 2806 | ||
2807 | static void b43_rng_exit(struct b43_wl *wl, bool suspended) | 2807 | static void b43_rng_exit(struct b43_wl *wl) |
2808 | { | 2808 | { |
2809 | if (wl->rng_initialized) | 2809 | if (wl->rng_initialized) |
2810 | __hwrng_unregister(&wl->rng, suspended); | 2810 | hwrng_unregister(&wl->rng); |
2811 | } | 2811 | } |
2812 | 2812 | ||
2813 | static int b43_rng_init(struct b43_wl *wl) | 2813 | static int b43_rng_init(struct b43_wl *wl) |
@@ -3824,7 +3824,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) | |||
3824 | 3824 | ||
3825 | if (!dev->suspend_in_progress) { | 3825 | if (!dev->suspend_in_progress) { |
3826 | b43_leds_exit(dev); | 3826 | b43_leds_exit(dev); |
3827 | b43_rng_exit(dev->wl, false); | 3827 | b43_rng_exit(dev->wl); |
3828 | } | 3828 | } |
3829 | b43_dma_free(dev); | 3829 | b43_dma_free(dev); |
3830 | b43_pio_free(dev); | 3830 | b43_pio_free(dev); |
@@ -4589,7 +4589,7 @@ static int b43_resume(struct ssb_device *dev) | |||
4589 | err = b43_wireless_core_start(wldev); | 4589 | err = b43_wireless_core_start(wldev); |
4590 | if (err) { | 4590 | if (err) { |
4591 | b43_leds_exit(wldev); | 4591 | b43_leds_exit(wldev); |
4592 | b43_rng_exit(wldev->wl, true); | 4592 | b43_rng_exit(wldev->wl); |
4593 | b43_wireless_core_exit(wldev); | 4593 | b43_wireless_core_exit(wldev); |
4594 | b43err(wl, "Resume failed at core start\n"); | 4594 | b43err(wl, "Resume failed at core start\n"); |
4595 | goto out; | 4595 | goto out; |
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 51c3ebf1c7d1..b31faeccb9cd 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -140,9 +140,10 @@ static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id); | |||
140 | /* Functions */ | 140 | /* Functions */ |
141 | 141 | ||
142 | /* Show some statistics about the card */ | 142 | /* Show some statistics about the card */ |
143 | static ssize_t twa_show_stats(struct class_device *class_dev, char *buf) | 143 | static ssize_t twa_show_stats(struct device *dev, |
144 | struct device_attribute *attr, char *buf) | ||
144 | { | 145 | { |
145 | struct Scsi_Host *host = class_to_shost(class_dev); | 146 | struct Scsi_Host *host = class_to_shost(dev); |
146 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; | 147 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; |
147 | unsigned long flags = 0; | 148 | unsigned long flags = 0; |
148 | ssize_t len; | 149 | ssize_t len; |
@@ -184,7 +185,7 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth) | |||
184 | } /* End twa_change_queue_depth() */ | 185 | } /* End twa_change_queue_depth() */ |
185 | 186 | ||
186 | /* Create sysfs 'stats' entry */ | 187 | /* Create sysfs 'stats' entry */ |
187 | static struct class_device_attribute twa_host_stats_attr = { | 188 | static struct device_attribute twa_host_stats_attr = { |
188 | .attr = { | 189 | .attr = { |
189 | .name = "stats", | 190 | .name = "stats", |
190 | .mode = S_IRUGO, | 191 | .mode = S_IRUGO, |
@@ -193,7 +194,7 @@ static struct class_device_attribute twa_host_stats_attr = { | |||
193 | }; | 194 | }; |
194 | 195 | ||
195 | /* Host attributes initializer */ | 196 | /* Host attributes initializer */ |
196 | static struct class_device_attribute *twa_host_attrs[] = { | 197 | static struct device_attribute *twa_host_attrs[] = { |
197 | &twa_host_stats_attr, | 198 | &twa_host_stats_attr, |
198 | NULL, | 199 | NULL, |
199 | }; | 200 | }; |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index adb98a297210..8c22329aa85e 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -484,9 +484,10 @@ static void tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id) | |||
484 | } /* End tw_state_request_start() */ | 484 | } /* End tw_state_request_start() */ |
485 | 485 | ||
486 | /* Show some statistics about the card */ | 486 | /* Show some statistics about the card */ |
487 | static ssize_t tw_show_stats(struct class_device *class_dev, char *buf) | 487 | static ssize_t tw_show_stats(struct device *dev, struct device_attribute *attr, |
488 | char *buf) | ||
488 | { | 489 | { |
489 | struct Scsi_Host *host = class_to_shost(class_dev); | 490 | struct Scsi_Host *host = class_to_shost(dev); |
490 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; | 491 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; |
491 | unsigned long flags = 0; | 492 | unsigned long flags = 0; |
492 | ssize_t len; | 493 | ssize_t len; |
@@ -528,7 +529,7 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth) | |||
528 | } /* End tw_change_queue_depth() */ | 529 | } /* End tw_change_queue_depth() */ |
529 | 530 | ||
530 | /* Create sysfs 'stats' entry */ | 531 | /* Create sysfs 'stats' entry */ |
531 | static struct class_device_attribute tw_host_stats_attr = { | 532 | static struct device_attribute tw_host_stats_attr = { |
532 | .attr = { | 533 | .attr = { |
533 | .name = "stats", | 534 | .name = "stats", |
534 | .mode = S_IRUGO, | 535 | .mode = S_IRUGO, |
@@ -537,7 +538,7 @@ static struct class_device_attribute tw_host_stats_attr = { | |||
537 | }; | 538 | }; |
538 | 539 | ||
539 | /* Host attributes initializer */ | 540 | /* Host attributes initializer */ |
540 | static struct class_device_attribute *tw_host_attrs[] = { | 541 | static struct device_attribute *tw_host_attrs[] = { |
541 | &tw_host_stats_attr, | 542 | &tw_host_stats_attr, |
542 | NULL, | 543 | NULL, |
543 | }; | 544 | }; |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index f1504beb2788..460d4024c46c 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -1315,7 +1315,7 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
1315 | tmp>>24,(tmp>>16)&0xff,tmp&0xff, | 1315 | tmp>>24,(tmp>>16)&0xff,tmp&0xff, |
1316 | le32_to_cpu(dev->adapter_info.biosbuild)); | 1316 | le32_to_cpu(dev->adapter_info.biosbuild)); |
1317 | buffer[0] = '\0'; | 1317 | buffer[0] = '\0'; |
1318 | if (aac_show_serial_number( | 1318 | if (aac_get_serial_number( |
1319 | shost_to_class(dev->scsi_host_ptr), buffer)) | 1319 | shost_to_class(dev->scsi_host_ptr), buffer)) |
1320 | printk(KERN_INFO "%s%d: serial %s", | 1320 | printk(KERN_INFO "%s%d: serial %s", |
1321 | dev->name, dev->id, buffer); | 1321 | dev->name, dev->id, buffer); |
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index ace0b751c131..113ca9c8934c 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
@@ -1850,9 +1850,9 @@ int aac_get_containers(struct aac_dev *dev); | |||
1850 | int aac_scsi_cmd(struct scsi_cmnd *cmd); | 1850 | int aac_scsi_cmd(struct scsi_cmnd *cmd); |
1851 | int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg); | 1851 | int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg); |
1852 | #ifndef shost_to_class | 1852 | #ifndef shost_to_class |
1853 | #define shost_to_class(shost) &shost->shost_classdev | 1853 | #define shost_to_class(shost) &shost->shost_dev |
1854 | #endif | 1854 | #endif |
1855 | ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf); | 1855 | ssize_t aac_get_serial_number(struct device *dev, char *buf); |
1856 | int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg); | 1856 | int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg); |
1857 | int aac_rx_init(struct aac_dev *dev); | 1857 | int aac_rx_init(struct aac_dev *dev); |
1858 | int aac_rkt_init(struct aac_dev *dev); | 1858 | int aac_rkt_init(struct aac_dev *dev); |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 8372bf6ed482..c109f63f8279 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -754,10 +754,10 @@ static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long | |||
754 | } | 754 | } |
755 | #endif | 755 | #endif |
756 | 756 | ||
757 | static ssize_t aac_show_model(struct class_device *class_dev, | 757 | static ssize_t aac_show_model(struct device *device, |
758 | char *buf) | 758 | struct device_attribute *attr, char *buf) |
759 | { | 759 | { |
760 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 760 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
761 | int len; | 761 | int len; |
762 | 762 | ||
763 | if (dev->supplement_adapter_info.AdapterTypeText[0]) { | 763 | if (dev->supplement_adapter_info.AdapterTypeText[0]) { |
@@ -773,10 +773,10 @@ static ssize_t aac_show_model(struct class_device *class_dev, | |||
773 | return len; | 773 | return len; |
774 | } | 774 | } |
775 | 775 | ||
776 | static ssize_t aac_show_vendor(struct class_device *class_dev, | 776 | static ssize_t aac_show_vendor(struct device *device, |
777 | char *buf) | 777 | struct device_attribute *attr, char *buf) |
778 | { | 778 | { |
779 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 779 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
780 | int len; | 780 | int len; |
781 | 781 | ||
782 | if (dev->supplement_adapter_info.AdapterTypeText[0]) { | 782 | if (dev->supplement_adapter_info.AdapterTypeText[0]) { |
@@ -792,10 +792,11 @@ static ssize_t aac_show_vendor(struct class_device *class_dev, | |||
792 | return len; | 792 | return len; |
793 | } | 793 | } |
794 | 794 | ||
795 | static ssize_t aac_show_flags(struct class_device *class_dev, char *buf) | 795 | static ssize_t aac_show_flags(struct device *cdev, |
796 | struct device_attribute *attr, char *buf) | ||
796 | { | 797 | { |
797 | int len = 0; | 798 | int len = 0; |
798 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 799 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata; |
799 | 800 | ||
800 | if (nblank(dprintk(x))) | 801 | if (nblank(dprintk(x))) |
801 | len = snprintf(buf, PAGE_SIZE, "dprintk\n"); | 802 | len = snprintf(buf, PAGE_SIZE, "dprintk\n"); |
@@ -811,10 +812,11 @@ static ssize_t aac_show_flags(struct class_device *class_dev, char *buf) | |||
811 | return len; | 812 | return len; |
812 | } | 813 | } |
813 | 814 | ||
814 | static ssize_t aac_show_kernel_version(struct class_device *class_dev, | 815 | static ssize_t aac_show_kernel_version(struct device *device, |
815 | char *buf) | 816 | struct device_attribute *attr, |
817 | char *buf) | ||
816 | { | 818 | { |
817 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 819 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
818 | int len, tmp; | 820 | int len, tmp; |
819 | 821 | ||
820 | tmp = le32_to_cpu(dev->adapter_info.kernelrev); | 822 | tmp = le32_to_cpu(dev->adapter_info.kernelrev); |
@@ -824,10 +826,11 @@ static ssize_t aac_show_kernel_version(struct class_device *class_dev, | |||
824 | return len; | 826 | return len; |
825 | } | 827 | } |
826 | 828 | ||
827 | static ssize_t aac_show_monitor_version(struct class_device *class_dev, | 829 | static ssize_t aac_show_monitor_version(struct device *device, |
828 | char *buf) | 830 | struct device_attribute *attr, |
831 | char *buf) | ||
829 | { | 832 | { |
830 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 833 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
831 | int len, tmp; | 834 | int len, tmp; |
832 | 835 | ||
833 | tmp = le32_to_cpu(dev->adapter_info.monitorrev); | 836 | tmp = le32_to_cpu(dev->adapter_info.monitorrev); |
@@ -837,10 +840,11 @@ static ssize_t aac_show_monitor_version(struct class_device *class_dev, | |||
837 | return len; | 840 | return len; |
838 | } | 841 | } |
839 | 842 | ||
840 | static ssize_t aac_show_bios_version(struct class_device *class_dev, | 843 | static ssize_t aac_show_bios_version(struct device *device, |
841 | char *buf) | 844 | struct device_attribute *attr, |
845 | char *buf) | ||
842 | { | 846 | { |
843 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 847 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
844 | int len, tmp; | 848 | int len, tmp; |
845 | 849 | ||
846 | tmp = le32_to_cpu(dev->adapter_info.biosrev); | 850 | tmp = le32_to_cpu(dev->adapter_info.biosrev); |
@@ -850,9 +854,10 @@ static ssize_t aac_show_bios_version(struct class_device *class_dev, | |||
850 | return len; | 854 | return len; |
851 | } | 855 | } |
852 | 856 | ||
853 | ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf) | 857 | ssize_t aac_show_serial_number(struct device *device, |
858 | struct device_attribute *attr, char *buf) | ||
854 | { | 859 | { |
855 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 860 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
856 | int len = 0; | 861 | int len = 0; |
857 | 862 | ||
858 | if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0) | 863 | if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0) |
@@ -868,35 +873,39 @@ ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf) | |||
868 | return len; | 873 | return len; |
869 | } | 874 | } |
870 | 875 | ||
871 | static ssize_t aac_show_max_channel(struct class_device *class_dev, char *buf) | 876 | static ssize_t aac_show_max_channel(struct device *device, |
877 | struct device_attribute *attr, char *buf) | ||
872 | { | 878 | { |
873 | return snprintf(buf, PAGE_SIZE, "%d\n", | 879 | return snprintf(buf, PAGE_SIZE, "%d\n", |
874 | class_to_shost(class_dev)->max_channel); | 880 | class_to_shost(device)->max_channel); |
875 | } | 881 | } |
876 | 882 | ||
877 | static ssize_t aac_show_max_id(struct class_device *class_dev, char *buf) | 883 | static ssize_t aac_show_max_id(struct device *device, |
884 | struct device_attribute *attr, char *buf) | ||
878 | { | 885 | { |
879 | return snprintf(buf, PAGE_SIZE, "%d\n", | 886 | return snprintf(buf, PAGE_SIZE, "%d\n", |
880 | class_to_shost(class_dev)->max_id); | 887 | class_to_shost(device)->max_id); |
881 | } | 888 | } |
882 | 889 | ||
883 | static ssize_t aac_store_reset_adapter(struct class_device *class_dev, | 890 | static ssize_t aac_store_reset_adapter(struct device *device, |
884 | const char *buf, size_t count) | 891 | struct device_attribute *attr, |
892 | const char *buf, size_t count) | ||
885 | { | 893 | { |
886 | int retval = -EACCES; | 894 | int retval = -EACCES; |
887 | 895 | ||
888 | if (!capable(CAP_SYS_ADMIN)) | 896 | if (!capable(CAP_SYS_ADMIN)) |
889 | return retval; | 897 | return retval; |
890 | retval = aac_reset_adapter((struct aac_dev*)class_to_shost(class_dev)->hostdata, buf[0] == '!'); | 898 | retval = aac_reset_adapter((struct aac_dev*)class_to_shost(device)->hostdata, buf[0] == '!'); |
891 | if (retval >= 0) | 899 | if (retval >= 0) |
892 | retval = count; | 900 | retval = count; |
893 | return retval; | 901 | return retval; |
894 | } | 902 | } |
895 | 903 | ||
896 | static ssize_t aac_show_reset_adapter(struct class_device *class_dev, | 904 | static ssize_t aac_show_reset_adapter(struct device *device, |
897 | char *buf) | 905 | struct device_attribute *attr, |
906 | char *buf) | ||
898 | { | 907 | { |
899 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; | 908 | struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; |
900 | int len, tmp; | 909 | int len, tmp; |
901 | 910 | ||
902 | tmp = aac_adapter_check_health(dev); | 911 | tmp = aac_adapter_check_health(dev); |
@@ -906,70 +915,70 @@ static ssize_t aac_show_reset_adapter(struct class_device *class_dev, | |||
906 | return len; | 915 | return len; |
907 | } | 916 | } |
908 | 917 | ||
909 | static struct class_device_attribute aac_model = { | 918 | static struct device_attribute aac_model = { |
910 | .attr = { | 919 | .attr = { |
911 | .name = "model", | 920 | .name = "model", |
912 | .mode = S_IRUGO, | 921 | .mode = S_IRUGO, |
913 | }, | 922 | }, |
914 | .show = aac_show_model, | 923 | .show = aac_show_model, |
915 | }; | 924 | }; |
916 | static struct class_device_attribute aac_vendor = { | 925 | static struct device_attribute aac_vendor = { |
917 | .attr = { | 926 | .attr = { |
918 | .name = "vendor", | 927 | .name = "vendor", |
919 | .mode = S_IRUGO, | 928 | .mode = S_IRUGO, |
920 | }, | 929 | }, |
921 | .show = aac_show_vendor, | 930 | .show = aac_show_vendor, |
922 | }; | 931 | }; |
923 | static struct class_device_attribute aac_flags = { | 932 | static struct device_attribute aac_flags = { |
924 | .attr = { | 933 | .attr = { |
925 | .name = "flags", | 934 | .name = "flags", |
926 | .mode = S_IRUGO, | 935 | .mode = S_IRUGO, |
927 | }, | 936 | }, |
928 | .show = aac_show_flags, | 937 | .show = aac_show_flags, |
929 | }; | 938 | }; |
930 | static struct class_device_attribute aac_kernel_version = { | 939 | static struct device_attribute aac_kernel_version = { |
931 | .attr = { | 940 | .attr = { |
932 | .name = "hba_kernel_version", | 941 | .name = "hba_kernel_version", |
933 | .mode = S_IRUGO, | 942 | .mode = S_IRUGO, |
934 | }, | 943 | }, |
935 | .show = aac_show_kernel_version, | 944 | .show = aac_show_kernel_version, |
936 | }; | 945 | }; |
937 | static struct class_device_attribute aac_monitor_version = { | 946 | static struct device_attribute aac_monitor_version = { |
938 | .attr = { | 947 | .attr = { |
939 | .name = "hba_monitor_version", | 948 | .name = "hba_monitor_version", |
940 | .mode = S_IRUGO, | 949 | .mode = S_IRUGO, |
941 | }, | 950 | }, |
942 | .show = aac_show_monitor_version, | 951 | .show = aac_show_monitor_version, |
943 | }; | 952 | }; |
944 | static struct class_device_attribute aac_bios_version = { | 953 | static struct device_attribute aac_bios_version = { |
945 | .attr = { | 954 | .attr = { |
946 | .name = "hba_bios_version", | 955 | .name = "hba_bios_version", |
947 | .mode = S_IRUGO, | 956 | .mode = S_IRUGO, |
948 | }, | 957 | }, |
949 | .show = aac_show_bios_version, | 958 | .show = aac_show_bios_version, |
950 | }; | 959 | }; |
951 | static struct class_device_attribute aac_serial_number = { | 960 | static struct device_attribute aac_serial_number = { |
952 | .attr = { | 961 | .attr = { |
953 | .name = "serial_number", | 962 | .name = "serial_number", |
954 | .mode = S_IRUGO, | 963 | .mode = S_IRUGO, |
955 | }, | 964 | }, |
956 | .show = aac_show_serial_number, | 965 | .show = aac_show_serial_number, |
957 | }; | 966 | }; |
958 | static struct class_device_attribute aac_max_channel = { | 967 | static struct device_attribute aac_max_channel = { |
959 | .attr = { | 968 | .attr = { |
960 | .name = "max_channel", | 969 | .name = "max_channel", |
961 | .mode = S_IRUGO, | 970 | .mode = S_IRUGO, |
962 | }, | 971 | }, |
963 | .show = aac_show_max_channel, | 972 | .show = aac_show_max_channel, |
964 | }; | 973 | }; |
965 | static struct class_device_attribute aac_max_id = { | 974 | static struct device_attribute aac_max_id = { |
966 | .attr = { | 975 | .attr = { |
967 | .name = "max_id", | 976 | .name = "max_id", |
968 | .mode = S_IRUGO, | 977 | .mode = S_IRUGO, |
969 | }, | 978 | }, |
970 | .show = aac_show_max_id, | 979 | .show = aac_show_max_id, |
971 | }; | 980 | }; |
972 | static struct class_device_attribute aac_reset = { | 981 | static struct device_attribute aac_reset = { |
973 | .attr = { | 982 | .attr = { |
974 | .name = "reset_host", | 983 | .name = "reset_host", |
975 | .mode = S_IWUSR|S_IRUGO, | 984 | .mode = S_IWUSR|S_IRUGO, |
@@ -978,7 +987,7 @@ static struct class_device_attribute aac_reset = { | |||
978 | .show = aac_show_reset_adapter, | 987 | .show = aac_show_reset_adapter, |
979 | }; | 988 | }; |
980 | 989 | ||
981 | static struct class_device_attribute *aac_attrs[] = { | 990 | static struct device_attribute *aac_attrs[] = { |
982 | &aac_model, | 991 | &aac_model, |
983 | &aac_vendor, | 992 | &aac_vendor, |
984 | &aac_flags, | 993 | &aac_flags, |
@@ -992,6 +1001,10 @@ static struct class_device_attribute *aac_attrs[] = { | |||
992 | NULL | 1001 | NULL |
993 | }; | 1002 | }; |
994 | 1003 | ||
1004 | ssize_t aac_get_serial_number(struct device *device, char *buf) | ||
1005 | { | ||
1006 | return aac_show_serial_number(device, &aac_serial_number, buf); | ||
1007 | } | ||
995 | 1008 | ||
996 | static const struct file_operations aac_cfg_fops = { | 1009 | static const struct file_operations aac_cfg_fops = { |
997 | .owner = THIS_MODULE, | 1010 | .owner = THIS_MODULE, |
diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h index 3288be2e49f8..ab646e580d64 100644 --- a/drivers/scsi/arcmsr/arcmsr.h +++ b/drivers/scsi/arcmsr/arcmsr.h | |||
@@ -44,7 +44,7 @@ | |||
44 | */ | 44 | */ |
45 | #include <linux/interrupt.h> | 45 | #include <linux/interrupt.h> |
46 | 46 | ||
47 | struct class_device_attribute; | 47 | struct device_attribute; |
48 | /*The limit of outstanding scsi command that firmware can handle*/ | 48 | /*The limit of outstanding scsi command that firmware can handle*/ |
49 | #define ARCMSR_MAX_OUTSTANDING_CMD 256 | 49 | #define ARCMSR_MAX_OUTSTANDING_CMD 256 |
50 | #define ARCMSR_MAX_FREECCB_NUM 320 | 50 | #define ARCMSR_MAX_FREECCB_NUM 320 |
@@ -556,6 +556,6 @@ struct SENSE_DATA | |||
556 | extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); | 556 | extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); |
557 | extern void arcmsr_iop_message_read(struct AdapterControlBlock *); | 557 | extern void arcmsr_iop_message_read(struct AdapterControlBlock *); |
558 | extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); | 558 | extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); |
559 | extern struct class_device_attribute *arcmsr_host_attrs[]; | 559 | extern struct device_attribute *arcmsr_host_attrs[]; |
560 | extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); | 560 | extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); |
561 | void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); | 561 | void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); |
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index 7d7b0a554276..69f8346aa288 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c | |||
@@ -57,15 +57,15 @@ | |||
57 | #include <scsi/scsi_transport.h> | 57 | #include <scsi/scsi_transport.h> |
58 | #include "arcmsr.h" | 58 | #include "arcmsr.h" |
59 | 59 | ||
60 | struct class_device_attribute *arcmsr_host_attrs[]; | 60 | struct device_attribute *arcmsr_host_attrs[]; |
61 | 61 | ||
62 | static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, | 62 | static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, |
63 | struct bin_attribute *bin, | 63 | struct bin_attribute *bin, |
64 | char *buf, loff_t off, | 64 | char *buf, loff_t off, |
65 | size_t count) | 65 | size_t count) |
66 | { | 66 | { |
67 | struct class_device *cdev = container_of(kobj,struct class_device,kobj); | 67 | struct device *dev = container_of(kobj,struct device,kobj); |
68 | struct Scsi_Host *host = class_to_shost(cdev); | 68 | struct Scsi_Host *host = class_to_shost(dev); |
69 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 69 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; |
70 | uint8_t *pQbuffer,*ptmpQbuffer; | 70 | uint8_t *pQbuffer,*ptmpQbuffer; |
71 | int32_t allxfer_len = 0; | 71 | int32_t allxfer_len = 0; |
@@ -110,8 +110,8 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct kobject *kobj, | |||
110 | char *buf, loff_t off, | 110 | char *buf, loff_t off, |
111 | size_t count) | 111 | size_t count) |
112 | { | 112 | { |
113 | struct class_device *cdev = container_of(kobj,struct class_device,kobj); | 113 | struct device *dev = container_of(kobj,struct device,kobj); |
114 | struct Scsi_Host *host = class_to_shost(cdev); | 114 | struct Scsi_Host *host = class_to_shost(dev); |
115 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 115 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; |
116 | int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex; | 116 | int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex; |
117 | uint8_t *pQbuffer, *ptmpuserbuffer; | 117 | uint8_t *pQbuffer, *ptmpuserbuffer; |
@@ -158,8 +158,8 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct kobject *kobj, | |||
158 | char *buf, loff_t off, | 158 | char *buf, loff_t off, |
159 | size_t count) | 159 | size_t count) |
160 | { | 160 | { |
161 | struct class_device *cdev = container_of(kobj,struct class_device,kobj); | 161 | struct device *dev = container_of(kobj,struct device,kobj); |
162 | struct Scsi_Host *host = class_to_shost(cdev); | 162 | struct Scsi_Host *host = class_to_shost(dev); |
163 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 163 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; |
164 | uint8_t *pQbuffer; | 164 | uint8_t *pQbuffer; |
165 | 165 | ||
@@ -220,87 +220,104 @@ int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb) | |||
220 | struct Scsi_Host *host = acb->host; | 220 | struct Scsi_Host *host = acb->host; |
221 | int error; | 221 | int error; |
222 | 222 | ||
223 | error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); | 223 | error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); |
224 | if (error) { | 224 | if (error) { |
225 | printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); | 225 | printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); |
226 | goto error_bin_file_message_read; | 226 | goto error_bin_file_message_read; |
227 | } | 227 | } |
228 | error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); | 228 | error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); |
229 | if (error) { | 229 | if (error) { |
230 | printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); | 230 | printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); |
231 | goto error_bin_file_message_write; | 231 | goto error_bin_file_message_write; |
232 | } | 232 | } |
233 | error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); | 233 | error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); |
234 | if (error) { | 234 | if (error) { |
235 | printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); | 235 | printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); |
236 | goto error_bin_file_message_clear; | 236 | goto error_bin_file_message_clear; |
237 | } | 237 | } |
238 | return 0; | 238 | return 0; |
239 | error_bin_file_message_clear: | 239 | error_bin_file_message_clear: |
240 | sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); | 240 | sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); |
241 | error_bin_file_message_write: | 241 | error_bin_file_message_write: |
242 | sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); | 242 | sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); |
243 | error_bin_file_message_read: | 243 | error_bin_file_message_read: |
244 | return error; | 244 | return error; |
245 | } | 245 | } |
246 | 246 | ||
247 | void | 247 | void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) |
248 | arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) { | 248 | { |
249 | struct Scsi_Host *host = acb->host; | 249 | struct Scsi_Host *host = acb->host; |
250 | 250 | ||
251 | sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); | 251 | sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); |
252 | sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); | 252 | sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); |
253 | sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); | 253 | sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | static ssize_t | 257 | static ssize_t |
258 | arcmsr_attr_host_driver_version(struct class_device *cdev, char *buf) { | 258 | arcmsr_attr_host_driver_version(struct device *dev, |
259 | struct device_attribute *attr, char *buf) | ||
260 | { | ||
259 | return snprintf(buf, PAGE_SIZE, | 261 | return snprintf(buf, PAGE_SIZE, |
260 | "%s\n", | 262 | "%s\n", |
261 | ARCMSR_DRIVER_VERSION); | 263 | ARCMSR_DRIVER_VERSION); |
262 | } | 264 | } |
263 | 265 | ||
264 | static ssize_t | 266 | static ssize_t |
265 | arcmsr_attr_host_driver_posted_cmd(struct class_device *cdev, char *buf) { | 267 | arcmsr_attr_host_driver_posted_cmd(struct device *dev, |
266 | struct Scsi_Host *host = class_to_shost(cdev); | 268 | struct device_attribute *attr, char *buf) |
267 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 269 | { |
270 | struct Scsi_Host *host = class_to_shost(dev); | ||
271 | struct AdapterControlBlock *acb = | ||
272 | (struct AdapterControlBlock *) host->hostdata; | ||
268 | return snprintf(buf, PAGE_SIZE, | 273 | return snprintf(buf, PAGE_SIZE, |
269 | "%4d\n", | 274 | "%4d\n", |
270 | atomic_read(&acb->ccboutstandingcount)); | 275 | atomic_read(&acb->ccboutstandingcount)); |
271 | } | 276 | } |
272 | 277 | ||
273 | static ssize_t | 278 | static ssize_t |
274 | arcmsr_attr_host_driver_reset(struct class_device *cdev, char *buf) { | 279 | arcmsr_attr_host_driver_reset(struct device *dev, |
275 | struct Scsi_Host *host = class_to_shost(cdev); | 280 | struct device_attribute *attr, char *buf) |
276 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 281 | { |
282 | struct Scsi_Host *host = class_to_shost(dev); | ||
283 | struct AdapterControlBlock *acb = | ||
284 | (struct AdapterControlBlock *) host->hostdata; | ||
277 | return snprintf(buf, PAGE_SIZE, | 285 | return snprintf(buf, PAGE_SIZE, |
278 | "%4d\n", | 286 | "%4d\n", |
279 | acb->num_resets); | 287 | acb->num_resets); |
280 | } | 288 | } |
281 | 289 | ||
282 | static ssize_t | 290 | static ssize_t |
283 | arcmsr_attr_host_driver_abort(struct class_device *cdev, char *buf) { | 291 | arcmsr_attr_host_driver_abort(struct device *dev, |
284 | struct Scsi_Host *host = class_to_shost(cdev); | 292 | struct device_attribute *attr, char *buf) |
285 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 293 | { |
294 | struct Scsi_Host *host = class_to_shost(dev); | ||
295 | struct AdapterControlBlock *acb = | ||
296 | (struct AdapterControlBlock *) host->hostdata; | ||
286 | return snprintf(buf, PAGE_SIZE, | 297 | return snprintf(buf, PAGE_SIZE, |
287 | "%4d\n", | 298 | "%4d\n", |
288 | acb->num_aborts); | 299 | acb->num_aborts); |
289 | } | 300 | } |
290 | 301 | ||
291 | static ssize_t | 302 | static ssize_t |
292 | arcmsr_attr_host_fw_model(struct class_device *cdev, char *buf) { | 303 | arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, |
293 | struct Scsi_Host *host = class_to_shost(cdev); | 304 | char *buf) |
294 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 305 | { |
306 | struct Scsi_Host *host = class_to_shost(dev); | ||
307 | struct AdapterControlBlock *acb = | ||
308 | (struct AdapterControlBlock *) host->hostdata; | ||
295 | return snprintf(buf, PAGE_SIZE, | 309 | return snprintf(buf, PAGE_SIZE, |
296 | "%s\n", | 310 | "%s\n", |
297 | acb->firm_model); | 311 | acb->firm_model); |
298 | } | 312 | } |
299 | 313 | ||
300 | static ssize_t | 314 | static ssize_t |
301 | arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) { | 315 | arcmsr_attr_host_fw_version(struct device *dev, |
302 | struct Scsi_Host *host = class_to_shost(cdev); | 316 | struct device_attribute *attr, char *buf) |
303 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 317 | { |
318 | struct Scsi_Host *host = class_to_shost(dev); | ||
319 | struct AdapterControlBlock *acb = | ||
320 | (struct AdapterControlBlock *) host->hostdata; | ||
304 | 321 | ||
305 | return snprintf(buf, PAGE_SIZE, | 322 | return snprintf(buf, PAGE_SIZE, |
306 | "%s\n", | 323 | "%s\n", |
@@ -308,9 +325,12 @@ arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) { | |||
308 | } | 325 | } |
309 | 326 | ||
310 | static ssize_t | 327 | static ssize_t |
311 | arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) { | 328 | arcmsr_attr_host_fw_request_len(struct device *dev, |
312 | struct Scsi_Host *host = class_to_shost(cdev); | 329 | struct device_attribute *attr, char *buf) |
313 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 330 | { |
331 | struct Scsi_Host *host = class_to_shost(dev); | ||
332 | struct AdapterControlBlock *acb = | ||
333 | (struct AdapterControlBlock *) host->hostdata; | ||
314 | 334 | ||
315 | return snprintf(buf, PAGE_SIZE, | 335 | return snprintf(buf, PAGE_SIZE, |
316 | "%4d\n", | 336 | "%4d\n", |
@@ -318,9 +338,12 @@ arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) { | |||
318 | } | 338 | } |
319 | 339 | ||
320 | static ssize_t | 340 | static ssize_t |
321 | arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) { | 341 | arcmsr_attr_host_fw_numbers_queue(struct device *dev, |
322 | struct Scsi_Host *host = class_to_shost(cdev); | 342 | struct device_attribute *attr, char *buf) |
323 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 343 | { |
344 | struct Scsi_Host *host = class_to_shost(dev); | ||
345 | struct AdapterControlBlock *acb = | ||
346 | (struct AdapterControlBlock *) host->hostdata; | ||
324 | 347 | ||
325 | return snprintf(buf, PAGE_SIZE, | 348 | return snprintf(buf, PAGE_SIZE, |
326 | "%4d\n", | 349 | "%4d\n", |
@@ -328,9 +351,12 @@ arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) { | |||
328 | } | 351 | } |
329 | 352 | ||
330 | static ssize_t | 353 | static ssize_t |
331 | arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) { | 354 | arcmsr_attr_host_fw_sdram_size(struct device *dev, |
332 | struct Scsi_Host *host = class_to_shost(cdev); | 355 | struct device_attribute *attr, char *buf) |
333 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 356 | { |
357 | struct Scsi_Host *host = class_to_shost(dev); | ||
358 | struct AdapterControlBlock *acb = | ||
359 | (struct AdapterControlBlock *) host->hostdata; | ||
334 | 360 | ||
335 | return snprintf(buf, PAGE_SIZE, | 361 | return snprintf(buf, PAGE_SIZE, |
336 | "%4d\n", | 362 | "%4d\n", |
@@ -338,36 +364,39 @@ arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) { | |||
338 | } | 364 | } |
339 | 365 | ||
340 | static ssize_t | 366 | static ssize_t |
341 | arcmsr_attr_host_fw_hd_channels(struct class_device *cdev, char *buf) { | 367 | arcmsr_attr_host_fw_hd_channels(struct device *dev, |
342 | struct Scsi_Host *host = class_to_shost(cdev); | 368 | struct device_attribute *attr, char *buf) |
343 | struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; | 369 | { |
370 | struct Scsi_Host *host = class_to_shost(dev); | ||
371 | struct AdapterControlBlock *acb = | ||
372 | (struct AdapterControlBlock *) host->hostdata; | ||
344 | 373 | ||
345 | return snprintf(buf, PAGE_SIZE, | 374 | return snprintf(buf, PAGE_SIZE, |
346 | "%4d\n", | 375 | "%4d\n", |
347 | acb->firm_hd_channels); | 376 | acb->firm_hd_channels); |
348 | } | 377 | } |
349 | 378 | ||
350 | static CLASS_DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); | 379 | static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); |
351 | static CLASS_DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); | 380 | static DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); |
352 | static CLASS_DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); | 381 | static DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); |
353 | static CLASS_DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); | 382 | static DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); |
354 | static CLASS_DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); | 383 | static DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); |
355 | static CLASS_DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); | 384 | static DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); |
356 | static CLASS_DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); | 385 | static DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); |
357 | static CLASS_DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); | 386 | static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); |
358 | static CLASS_DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); | 387 | static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); |
359 | static CLASS_DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); | 388 | static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); |
360 | 389 | ||
361 | struct class_device_attribute *arcmsr_host_attrs[] = { | 390 | struct device_attribute *arcmsr_host_attrs[] = { |
362 | &class_device_attr_host_driver_version, | 391 | &dev_attr_host_driver_version, |
363 | &class_device_attr_host_driver_posted_cmd, | 392 | &dev_attr_host_driver_posted_cmd, |
364 | &class_device_attr_host_driver_reset, | 393 | &dev_attr_host_driver_reset, |
365 | &class_device_attr_host_driver_abort, | 394 | &dev_attr_host_driver_abort, |
366 | &class_device_attr_host_fw_model, | 395 | &dev_attr_host_fw_model, |
367 | &class_device_attr_host_fw_version, | 396 | &dev_attr_host_fw_version, |
368 | &class_device_attr_host_fw_request_len, | 397 | &dev_attr_host_fw_request_len, |
369 | &class_device_attr_host_fw_numbers_queue, | 398 | &dev_attr_host_fw_numbers_queue, |
370 | &class_device_attr_host_fw_sdram_size, | 399 | &dev_attr_host_fw_sdram_size, |
371 | &class_device_attr_host_fw_hd_channels, | 400 | &dev_attr_host_fw_hd_channels, |
372 | NULL, | 401 | NULL, |
373 | }; | 402 | }; |
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 92d1cb1b21cb..75c84d7b9ce8 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -881,7 +881,7 @@ static long ch_ioctl_compat(struct file * file, | |||
881 | static int ch_probe(struct device *dev) | 881 | static int ch_probe(struct device *dev) |
882 | { | 882 | { |
883 | struct scsi_device *sd = to_scsi_device(dev); | 883 | struct scsi_device *sd = to_scsi_device(dev); |
884 | struct class_device *class_dev; | 884 | struct device *class_dev; |
885 | int minor, ret = -ENOMEM; | 885 | int minor, ret = -ENOMEM; |
886 | scsi_changer *ch; | 886 | scsi_changer *ch; |
887 | 887 | ||
@@ -910,11 +910,11 @@ static int ch_probe(struct device *dev) | |||
910 | ch->minor = minor; | 910 | ch->minor = minor; |
911 | sprintf(ch->name,"ch%d",ch->minor); | 911 | sprintf(ch->name,"ch%d",ch->minor); |
912 | 912 | ||
913 | class_dev = class_device_create(ch_sysfs_class, NULL, | 913 | class_dev = device_create(ch_sysfs_class, dev, |
914 | MKDEV(SCSI_CHANGER_MAJOR, ch->minor), | 914 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), |
915 | dev, "s%s", ch->name); | 915 | "s%s", ch->name); |
916 | if (IS_ERR(class_dev)) { | 916 | if (IS_ERR(class_dev)) { |
917 | printk(KERN_WARNING "ch%d: class_device_create failed\n", | 917 | printk(KERN_WARNING "ch%d: device_create failed\n", |
918 | ch->minor); | 918 | ch->minor); |
919 | ret = PTR_ERR(class_dev); | 919 | ret = PTR_ERR(class_dev); |
920 | goto remove_idr; | 920 | goto remove_idr; |
@@ -945,8 +945,7 @@ static int ch_remove(struct device *dev) | |||
945 | idr_remove(&ch_index_idr, ch->minor); | 945 | idr_remove(&ch_index_idr, ch->minor); |
946 | spin_unlock(&ch_index_lock); | 946 | spin_unlock(&ch_index_lock); |
947 | 947 | ||
948 | class_device_destroy(ch_sysfs_class, | 948 | device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); |
949 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); | ||
950 | kfree(ch->dt); | 949 | kfree(ch->dt); |
951 | kfree(ch); | 950 | kfree(ch); |
952 | return 0; | 951 | return 0; |
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 1592640a87b5..c264a8c5f01e 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -43,14 +43,14 @@ | |||
43 | static int scsi_host_next_hn; /* host_no for next new host */ | 43 | static int scsi_host_next_hn; /* host_no for next new host */ |
44 | 44 | ||
45 | 45 | ||
46 | static void scsi_host_cls_release(struct class_device *class_dev) | 46 | static void scsi_host_cls_release(struct device *dev) |
47 | { | 47 | { |
48 | put_device(&class_to_shost(class_dev)->shost_gendev); | 48 | put_device(&class_to_shost(dev)->shost_gendev); |
49 | } | 49 | } |
50 | 50 | ||
51 | static struct class shost_class = { | 51 | static struct class shost_class = { |
52 | .name = "scsi_host", | 52 | .name = "scsi_host", |
53 | .release = scsi_host_cls_release, | 53 | .dev_release = scsi_host_cls_release, |
54 | }; | 54 | }; |
55 | 55 | ||
56 | /** | 56 | /** |
@@ -174,7 +174,7 @@ void scsi_remove_host(struct Scsi_Host *shost) | |||
174 | spin_unlock_irqrestore(shost->host_lock, flags); | 174 | spin_unlock_irqrestore(shost->host_lock, flags); |
175 | 175 | ||
176 | transport_unregister_device(&shost->shost_gendev); | 176 | transport_unregister_device(&shost->shost_gendev); |
177 | class_device_unregister(&shost->shost_classdev); | 177 | device_unregister(&shost->shost_dev); |
178 | device_del(&shost->shost_gendev); | 178 | device_del(&shost->shost_gendev); |
179 | scsi_proc_hostdir_rm(shost->hostt); | 179 | scsi_proc_hostdir_rm(shost->hostt); |
180 | } | 180 | } |
@@ -212,7 +212,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) | |||
212 | scsi_host_set_state(shost, SHOST_RUNNING); | 212 | scsi_host_set_state(shost, SHOST_RUNNING); |
213 | get_device(shost->shost_gendev.parent); | 213 | get_device(shost->shost_gendev.parent); |
214 | 214 | ||
215 | error = class_device_add(&shost->shost_classdev); | 215 | error = device_add(&shost->shost_dev); |
216 | if (error) | 216 | if (error) |
217 | goto out_del_gendev; | 217 | goto out_del_gendev; |
218 | 218 | ||
@@ -223,7 +223,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) | |||
223 | GFP_KERNEL); | 223 | GFP_KERNEL); |
224 | if (shost->shost_data == NULL) { | 224 | if (shost->shost_data == NULL) { |
225 | error = -ENOMEM; | 225 | error = -ENOMEM; |
226 | goto out_del_classdev; | 226 | goto out_del_dev; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
@@ -250,8 +250,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) | |||
250 | destroy_workqueue(shost->work_q); | 250 | destroy_workqueue(shost->work_q); |
251 | out_free_shost_data: | 251 | out_free_shost_data: |
252 | kfree(shost->shost_data); | 252 | kfree(shost->shost_data); |
253 | out_del_classdev: | 253 | out_del_dev: |
254 | class_device_del(&shost->shost_classdev); | 254 | device_del(&shost->shost_dev); |
255 | out_del_gendev: | 255 | out_del_gendev: |
256 | device_del(&shost->shost_gendev); | 256 | device_del(&shost->shost_gendev); |
257 | out: | 257 | out: |
@@ -385,11 +385,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
385 | shost->host_no); | 385 | shost->host_no); |
386 | shost->shost_gendev.release = scsi_host_dev_release; | 386 | shost->shost_gendev.release = scsi_host_dev_release; |
387 | 387 | ||
388 | class_device_initialize(&shost->shost_classdev); | 388 | device_initialize(&shost->shost_dev); |
389 | shost->shost_classdev.dev = &shost->shost_gendev; | 389 | shost->shost_dev.parent = &shost->shost_gendev; |
390 | shost->shost_classdev.class = &shost_class; | 390 | shost->shost_dev.class = &shost_class; |
391 | snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d", | 391 | snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d", |
392 | shost->host_no); | 392 | shost->host_no); |
393 | 393 | ||
394 | shost->ehandler = kthread_run(scsi_error_handler, shost, | 394 | shost->ehandler = kthread_run(scsi_error_handler, shost, |
395 | "scsi_eh_%d", shost->host_no); | 395 | "scsi_eh_%d", shost->host_no); |
@@ -432,12 +432,12 @@ void scsi_unregister(struct Scsi_Host *shost) | |||
432 | } | 432 | } |
433 | EXPORT_SYMBOL(scsi_unregister); | 433 | EXPORT_SYMBOL(scsi_unregister); |
434 | 434 | ||
435 | static int __scsi_host_match(struct class_device *cdev, void *data) | 435 | static int __scsi_host_match(struct device *dev, void *data) |
436 | { | 436 | { |
437 | struct Scsi_Host *p; | 437 | struct Scsi_Host *p; |
438 | unsigned short *hostnum = (unsigned short *)data; | 438 | unsigned short *hostnum = (unsigned short *)data; |
439 | 439 | ||
440 | p = class_to_shost(cdev); | 440 | p = class_to_shost(dev); |
441 | return p->host_no == *hostnum; | 441 | return p->host_no == *hostnum; |
442 | } | 442 | } |
443 | 443 | ||
@@ -450,10 +450,10 @@ static int __scsi_host_match(struct class_device *cdev, void *data) | |||
450 | **/ | 450 | **/ |
451 | struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) | 451 | struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) |
452 | { | 452 | { |
453 | struct class_device *cdev; | 453 | struct device *cdev; |
454 | struct Scsi_Host *shost = ERR_PTR(-ENXIO); | 454 | struct Scsi_Host *shost = ERR_PTR(-ENXIO); |
455 | 455 | ||
456 | cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match); | 456 | cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); |
457 | if (cdev) | 457 | if (cdev) |
458 | shost = scsi_host_get(class_to_shost(cdev)); | 458 | shost = scsi_host_get(class_to_shost(cdev)); |
459 | 459 | ||
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index beecda991682..5b7be1e9841c 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c | |||
@@ -859,14 +859,16 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev, | |||
859 | return queue_depth; | 859 | return queue_depth; |
860 | } | 860 | } |
861 | 861 | ||
862 | static ssize_t hptiop_show_version(struct class_device *class_dev, char *buf) | 862 | static ssize_t hptiop_show_version(struct device *dev, |
863 | struct device_attribute *attr, char *buf) | ||
863 | { | 864 | { |
864 | return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver); | 865 | return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver); |
865 | } | 866 | } |
866 | 867 | ||
867 | static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf) | 868 | static ssize_t hptiop_show_fw_version(struct device *dev, |
869 | struct device_attribute *attr, char *buf) | ||
868 | { | 870 | { |
869 | struct Scsi_Host *host = class_to_shost(class_dev); | 871 | struct Scsi_Host *host = class_to_shost(dev); |
870 | struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; | 872 | struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; |
871 | 873 | ||
872 | return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", | 874 | return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", |
@@ -876,7 +878,7 @@ static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf) | |||
876 | hba->firmware_version & 0xff); | 878 | hba->firmware_version & 0xff); |
877 | } | 879 | } |
878 | 880 | ||
879 | static struct class_device_attribute hptiop_attr_version = { | 881 | static struct device_attribute hptiop_attr_version = { |
880 | .attr = { | 882 | .attr = { |
881 | .name = "driver-version", | 883 | .name = "driver-version", |
882 | .mode = S_IRUGO, | 884 | .mode = S_IRUGO, |
@@ -884,7 +886,7 @@ static struct class_device_attribute hptiop_attr_version = { | |||
884 | .show = hptiop_show_version, | 886 | .show = hptiop_show_version, |
885 | }; | 887 | }; |
886 | 888 | ||
887 | static struct class_device_attribute hptiop_attr_fw_version = { | 889 | static struct device_attribute hptiop_attr_fw_version = { |
888 | .attr = { | 890 | .attr = { |
889 | .name = "firmware-version", | 891 | .name = "firmware-version", |
890 | .mode = S_IRUGO, | 892 | .mode = S_IRUGO, |
@@ -892,7 +894,7 @@ static struct class_device_attribute hptiop_attr_fw_version = { | |||
892 | .show = hptiop_show_fw_version, | 894 | .show = hptiop_show_fw_version, |
893 | }; | 895 | }; |
894 | 896 | ||
895 | static struct class_device_attribute *hptiop_attrs[] = { | 897 | static struct device_attribute *hptiop_attrs[] = { |
896 | &hptiop_attr_version, | 898 | &hptiop_attr_version, |
897 | &hptiop_attr_fw_version, | 899 | &hptiop_attr_fw_version, |
898 | NULL | 900 | NULL |
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 78d46a900bb5..4a922c57125e 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -1456,9 +1456,10 @@ static int ibmvscsi_change_queue_depth(struct scsi_device *sdev, int qdepth) | |||
1456 | /* ------------------------------------------------------------ | 1456 | /* ------------------------------------------------------------ |
1457 | * sysfs attributes | 1457 | * sysfs attributes |
1458 | */ | 1458 | */ |
1459 | static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf) | 1459 | static ssize_t show_host_srp_version(struct device *dev, |
1460 | struct device_attribute *attr, char *buf) | ||
1460 | { | 1461 | { |
1461 | struct Scsi_Host *shost = class_to_shost(class_dev); | 1462 | struct Scsi_Host *shost = class_to_shost(dev); |
1462 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); | 1463 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); |
1463 | int len; | 1464 | int len; |
1464 | 1465 | ||
@@ -1467,7 +1468,7 @@ static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf) | |||
1467 | return len; | 1468 | return len; |
1468 | } | 1469 | } |
1469 | 1470 | ||
1470 | static struct class_device_attribute ibmvscsi_host_srp_version = { | 1471 | static struct device_attribute ibmvscsi_host_srp_version = { |
1471 | .attr = { | 1472 | .attr = { |
1472 | .name = "srp_version", | 1473 | .name = "srp_version", |
1473 | .mode = S_IRUGO, | 1474 | .mode = S_IRUGO, |
@@ -1475,10 +1476,11 @@ static struct class_device_attribute ibmvscsi_host_srp_version = { | |||
1475 | .show = show_host_srp_version, | 1476 | .show = show_host_srp_version, |
1476 | }; | 1477 | }; |
1477 | 1478 | ||
1478 | static ssize_t show_host_partition_name(struct class_device *class_dev, | 1479 | static ssize_t show_host_partition_name(struct device *dev, |
1480 | struct device_attribute *attr, | ||
1479 | char *buf) | 1481 | char *buf) |
1480 | { | 1482 | { |
1481 | struct Scsi_Host *shost = class_to_shost(class_dev); | 1483 | struct Scsi_Host *shost = class_to_shost(dev); |
1482 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); | 1484 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); |
1483 | int len; | 1485 | int len; |
1484 | 1486 | ||
@@ -1487,7 +1489,7 @@ static ssize_t show_host_partition_name(struct class_device *class_dev, | |||
1487 | return len; | 1489 | return len; |
1488 | } | 1490 | } |
1489 | 1491 | ||
1490 | static struct class_device_attribute ibmvscsi_host_partition_name = { | 1492 | static struct device_attribute ibmvscsi_host_partition_name = { |
1491 | .attr = { | 1493 | .attr = { |
1492 | .name = "partition_name", | 1494 | .name = "partition_name", |
1493 | .mode = S_IRUGO, | 1495 | .mode = S_IRUGO, |
@@ -1495,10 +1497,11 @@ static struct class_device_attribute ibmvscsi_host_partition_name = { | |||
1495 | .show = show_host_partition_name, | 1497 | .show = show_host_partition_name, |
1496 | }; | 1498 | }; |
1497 | 1499 | ||
1498 | static ssize_t show_host_partition_number(struct class_device *class_dev, | 1500 | static ssize_t show_host_partition_number(struct device *dev, |
1501 | struct device_attribute *attr, | ||
1499 | char *buf) | 1502 | char *buf) |
1500 | { | 1503 | { |
1501 | struct Scsi_Host *shost = class_to_shost(class_dev); | 1504 | struct Scsi_Host *shost = class_to_shost(dev); |
1502 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); | 1505 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); |
1503 | int len; | 1506 | int len; |
1504 | 1507 | ||
@@ -1507,7 +1510,7 @@ static ssize_t show_host_partition_number(struct class_device *class_dev, | |||
1507 | return len; | 1510 | return len; |
1508 | } | 1511 | } |
1509 | 1512 | ||
1510 | static struct class_device_attribute ibmvscsi_host_partition_number = { | 1513 | static struct device_attribute ibmvscsi_host_partition_number = { |
1511 | .attr = { | 1514 | .attr = { |
1512 | .name = "partition_number", | 1515 | .name = "partition_number", |
1513 | .mode = S_IRUGO, | 1516 | .mode = S_IRUGO, |
@@ -1515,9 +1518,10 @@ static struct class_device_attribute ibmvscsi_host_partition_number = { | |||
1515 | .show = show_host_partition_number, | 1518 | .show = show_host_partition_number, |
1516 | }; | 1519 | }; |
1517 | 1520 | ||
1518 | static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf) | 1521 | static ssize_t show_host_mad_version(struct device *dev, |
1522 | struct device_attribute *attr, char *buf) | ||
1519 | { | 1523 | { |
1520 | struct Scsi_Host *shost = class_to_shost(class_dev); | 1524 | struct Scsi_Host *shost = class_to_shost(dev); |
1521 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); | 1525 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); |
1522 | int len; | 1526 | int len; |
1523 | 1527 | ||
@@ -1526,7 +1530,7 @@ static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf) | |||
1526 | return len; | 1530 | return len; |
1527 | } | 1531 | } |
1528 | 1532 | ||
1529 | static struct class_device_attribute ibmvscsi_host_mad_version = { | 1533 | static struct device_attribute ibmvscsi_host_mad_version = { |
1530 | .attr = { | 1534 | .attr = { |
1531 | .name = "mad_version", | 1535 | .name = "mad_version", |
1532 | .mode = S_IRUGO, | 1536 | .mode = S_IRUGO, |
@@ -1534,9 +1538,10 @@ static struct class_device_attribute ibmvscsi_host_mad_version = { | |||
1534 | .show = show_host_mad_version, | 1538 | .show = show_host_mad_version, |
1535 | }; | 1539 | }; |
1536 | 1540 | ||
1537 | static ssize_t show_host_os_type(struct class_device *class_dev, char *buf) | 1541 | static ssize_t show_host_os_type(struct device *dev, |
1542 | struct device_attribute *attr, char *buf) | ||
1538 | { | 1543 | { |
1539 | struct Scsi_Host *shost = class_to_shost(class_dev); | 1544 | struct Scsi_Host *shost = class_to_shost(dev); |
1540 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); | 1545 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); |
1541 | int len; | 1546 | int len; |
1542 | 1547 | ||
@@ -1544,7 +1549,7 @@ static ssize_t show_host_os_type(struct class_device *class_dev, char *buf) | |||
1544 | return len; | 1549 | return len; |
1545 | } | 1550 | } |
1546 | 1551 | ||
1547 | static struct class_device_attribute ibmvscsi_host_os_type = { | 1552 | static struct device_attribute ibmvscsi_host_os_type = { |
1548 | .attr = { | 1553 | .attr = { |
1549 | .name = "os_type", | 1554 | .name = "os_type", |
1550 | .mode = S_IRUGO, | 1555 | .mode = S_IRUGO, |
@@ -1552,9 +1557,10 @@ static struct class_device_attribute ibmvscsi_host_os_type = { | |||
1552 | .show = show_host_os_type, | 1557 | .show = show_host_os_type, |
1553 | }; | 1558 | }; |
1554 | 1559 | ||
1555 | static ssize_t show_host_config(struct class_device *class_dev, char *buf) | 1560 | static ssize_t show_host_config(struct device *dev, |
1561 | struct device_attribute *attr, char *buf) | ||
1556 | { | 1562 | { |
1557 | struct Scsi_Host *shost = class_to_shost(class_dev); | 1563 | struct Scsi_Host *shost = class_to_shost(dev); |
1558 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); | 1564 | struct ibmvscsi_host_data *hostdata = shost_priv(shost); |
1559 | 1565 | ||
1560 | /* returns null-terminated host config data */ | 1566 | /* returns null-terminated host config data */ |
@@ -1564,7 +1570,7 @@ static ssize_t show_host_config(struct class_device *class_dev, char *buf) | |||
1564 | return 0; | 1570 | return 0; |
1565 | } | 1571 | } |
1566 | 1572 | ||
1567 | static struct class_device_attribute ibmvscsi_host_config = { | 1573 | static struct device_attribute ibmvscsi_host_config = { |
1568 | .attr = { | 1574 | .attr = { |
1569 | .name = "config", | 1575 | .name = "config", |
1570 | .mode = S_IRUGO, | 1576 | .mode = S_IRUGO, |
@@ -1572,7 +1578,7 @@ static struct class_device_attribute ibmvscsi_host_config = { | |||
1572 | .show = show_host_config, | 1578 | .show = show_host_config, |
1573 | }; | 1579 | }; |
1574 | 1580 | ||
1575 | static struct class_device_attribute *ibmvscsi_attrs[] = { | 1581 | static struct device_attribute *ibmvscsi_attrs[] = { |
1576 | &ibmvscsi_host_srp_version, | 1582 | &ibmvscsi_host_srp_version, |
1577 | &ibmvscsi_host_partition_name, | 1583 | &ibmvscsi_host_partition_name, |
1578 | &ibmvscsi_host_partition_number, | 1584 | &ibmvscsi_host_partition_number, |
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c index e5881e92d0fb..3b9514c8f1f1 100644 --- a/drivers/scsi/ibmvscsi/ibmvstgt.c +++ b/drivers/scsi/ibmvscsi/ibmvstgt.c | |||
@@ -780,32 +780,35 @@ static int ibmvstgt_it_nexus_response(struct Scsi_Host *shost, u64 itn_id, | |||
780 | return 0; | 780 | return 0; |
781 | } | 781 | } |
782 | 782 | ||
783 | static ssize_t system_id_show(struct class_device *cdev, char *buf) | 783 | static ssize_t system_id_show(struct device *dev, |
784 | struct device_attribute *attr, char *buf) | ||
784 | { | 785 | { |
785 | return snprintf(buf, PAGE_SIZE, "%s\n", system_id); | 786 | return snprintf(buf, PAGE_SIZE, "%s\n", system_id); |
786 | } | 787 | } |
787 | 788 | ||
788 | static ssize_t partition_number_show(struct class_device *cdev, char *buf) | 789 | static ssize_t partition_number_show(struct device *dev, |
790 | struct device_attribute *attr, char *buf) | ||
789 | { | 791 | { |
790 | return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); | 792 | return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); |
791 | } | 793 | } |
792 | 794 | ||
793 | static ssize_t unit_address_show(struct class_device *cdev, char *buf) | 795 | static ssize_t unit_address_show(struct device *dev, |
796 | struct device_attribute *attr, char *buf) | ||
794 | { | 797 | { |
795 | struct Scsi_Host *shost = class_to_shost(cdev); | 798 | struct Scsi_Host *shost = class_to_shost(dev); |
796 | struct srp_target *target = host_to_srp_target(shost); | 799 | struct srp_target *target = host_to_srp_target(shost); |
797 | struct vio_port *vport = target_to_port(target); | 800 | struct vio_port *vport = target_to_port(target); |
798 | return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address); | 801 | return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address); |
799 | } | 802 | } |
800 | 803 | ||
801 | static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL); | 804 | static DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL); |
802 | static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL); | 805 | static DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL); |
803 | static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL); | 806 | static DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL); |
804 | 807 | ||
805 | static struct class_device_attribute *ibmvstgt_attrs[] = { | 808 | static struct device_attribute *ibmvstgt_attrs[] = { |
806 | &class_device_attr_system_id, | 809 | &dev_attr_system_id, |
807 | &class_device_attr_partition_number, | 810 | &dev_attr_partition_number, |
808 | &class_device_attr_unit_address, | 811 | &dev_attr_unit_address, |
809 | NULL, | 812 | NULL, |
810 | }; | 813 | }; |
811 | 814 | ||
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 65dc18dea845..de5ae6a65029 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -2431,7 +2431,7 @@ restart: | |||
2431 | } | 2431 | } |
2432 | 2432 | ||
2433 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | 2433 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); |
2434 | kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); | 2434 | kobject_uevent(&ioa_cfg->host->shost_dev.kobj, KOBJ_CHANGE); |
2435 | LEAVE; | 2435 | LEAVE; |
2436 | } | 2436 | } |
2437 | 2437 | ||
@@ -2451,8 +2451,8 @@ static ssize_t ipr_read_trace(struct kobject *kobj, | |||
2451 | struct bin_attribute *bin_attr, | 2451 | struct bin_attribute *bin_attr, |
2452 | char *buf, loff_t off, size_t count) | 2452 | char *buf, loff_t off, size_t count) |
2453 | { | 2453 | { |
2454 | struct class_device *cdev = container_of(kobj,struct class_device,kobj); | 2454 | struct device *dev = container_of(kobj, struct device, kobj); |
2455 | struct Scsi_Host *shost = class_to_shost(cdev); | 2455 | struct Scsi_Host *shost = class_to_shost(dev); |
2456 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2456 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2457 | unsigned long lock_flags = 0; | 2457 | unsigned long lock_flags = 0; |
2458 | int size = IPR_TRACE_SIZE; | 2458 | int size = IPR_TRACE_SIZE; |
@@ -2492,15 +2492,16 @@ static const struct { | |||
2492 | 2492 | ||
2493 | /** | 2493 | /** |
2494 | * ipr_show_write_caching - Show the write caching attribute | 2494 | * ipr_show_write_caching - Show the write caching attribute |
2495 | * @class_dev: class device struct | 2495 | * @dev: device struct |
2496 | * @buf: buffer | 2496 | * @buf: buffer |
2497 | * | 2497 | * |
2498 | * Return value: | 2498 | * Return value: |
2499 | * number of bytes printed to buffer | 2499 | * number of bytes printed to buffer |
2500 | **/ | 2500 | **/ |
2501 | static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf) | 2501 | static ssize_t ipr_show_write_caching(struct device *dev, |
2502 | struct device_attribute *attr, char *buf) | ||
2502 | { | 2503 | { |
2503 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2504 | struct Scsi_Host *shost = class_to_shost(dev); |
2504 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2505 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2505 | unsigned long lock_flags = 0; | 2506 | unsigned long lock_flags = 0; |
2506 | int i, len = 0; | 2507 | int i, len = 0; |
@@ -2519,19 +2520,20 @@ static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf) | |||
2519 | 2520 | ||
2520 | /** | 2521 | /** |
2521 | * ipr_store_write_caching - Enable/disable adapter write cache | 2522 | * ipr_store_write_caching - Enable/disable adapter write cache |
2522 | * @class_dev: class_device struct | 2523 | * @dev: device struct |
2523 | * @buf: buffer | 2524 | * @buf: buffer |
2524 | * @count: buffer size | 2525 | * @count: buffer size |
2525 | * | 2526 | * |
2526 | * This function will enable/disable adapter write cache. | 2527 | * This function will enable/disable adapter write cache. |
2527 | * | 2528 | * |
2528 | * Return value: | 2529 | * Return value: |
2529 | * count on success / other on failure | 2530 | * count on success / other on failure |
2530 | **/ | 2531 | **/ |
2531 | static ssize_t ipr_store_write_caching(struct class_device *class_dev, | 2532 | static ssize_t ipr_store_write_caching(struct device *dev, |
2532 | const char *buf, size_t count) | 2533 | struct device_attribute *attr, |
2534 | const char *buf, size_t count) | ||
2533 | { | 2535 | { |
2534 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2536 | struct Scsi_Host *shost = class_to_shost(dev); |
2535 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2537 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2536 | unsigned long lock_flags = 0; | 2538 | unsigned long lock_flags = 0; |
2537 | enum ipr_cache_state new_state = CACHE_INVALID; | 2539 | enum ipr_cache_state new_state = CACHE_INVALID; |
@@ -2569,7 +2571,7 @@ static ssize_t ipr_store_write_caching(struct class_device *class_dev, | |||
2569 | return count; | 2571 | return count; |
2570 | } | 2572 | } |
2571 | 2573 | ||
2572 | static struct class_device_attribute ipr_ioa_cache_attr = { | 2574 | static struct device_attribute ipr_ioa_cache_attr = { |
2573 | .attr = { | 2575 | .attr = { |
2574 | .name = "write_cache", | 2576 | .name = "write_cache", |
2575 | .mode = S_IRUGO | S_IWUSR, | 2577 | .mode = S_IRUGO | S_IWUSR, |
@@ -2580,15 +2582,16 @@ static struct class_device_attribute ipr_ioa_cache_attr = { | |||
2580 | 2582 | ||
2581 | /** | 2583 | /** |
2582 | * ipr_show_fw_version - Show the firmware version | 2584 | * ipr_show_fw_version - Show the firmware version |
2583 | * @class_dev: class device struct | 2585 | * @dev: class device struct |
2584 | * @buf: buffer | 2586 | * @buf: buffer |
2585 | * | 2587 | * |
2586 | * Return value: | 2588 | * Return value: |
2587 | * number of bytes printed to buffer | 2589 | * number of bytes printed to buffer |
2588 | **/ | 2590 | **/ |
2589 | static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf) | 2591 | static ssize_t ipr_show_fw_version(struct device *dev, |
2592 | struct device_attribute *attr, char *buf) | ||
2590 | { | 2593 | { |
2591 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2594 | struct Scsi_Host *shost = class_to_shost(dev); |
2592 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2595 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2593 | struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data; | 2596 | struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data; |
2594 | unsigned long lock_flags = 0; | 2597 | unsigned long lock_flags = 0; |
@@ -2603,7 +2606,7 @@ static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf) | |||
2603 | return len; | 2606 | return len; |
2604 | } | 2607 | } |
2605 | 2608 | ||
2606 | static struct class_device_attribute ipr_fw_version_attr = { | 2609 | static struct device_attribute ipr_fw_version_attr = { |
2607 | .attr = { | 2610 | .attr = { |
2608 | .name = "fw_version", | 2611 | .name = "fw_version", |
2609 | .mode = S_IRUGO, | 2612 | .mode = S_IRUGO, |
@@ -2613,15 +2616,16 @@ static struct class_device_attribute ipr_fw_version_attr = { | |||
2613 | 2616 | ||
2614 | /** | 2617 | /** |
2615 | * ipr_show_log_level - Show the adapter's error logging level | 2618 | * ipr_show_log_level - Show the adapter's error logging level |
2616 | * @class_dev: class device struct | 2619 | * @dev: class device struct |
2617 | * @buf: buffer | 2620 | * @buf: buffer |
2618 | * | 2621 | * |
2619 | * Return value: | 2622 | * Return value: |
2620 | * number of bytes printed to buffer | 2623 | * number of bytes printed to buffer |
2621 | **/ | 2624 | **/ |
2622 | static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf) | 2625 | static ssize_t ipr_show_log_level(struct device *dev, |
2626 | struct device_attribute *attr, char *buf) | ||
2623 | { | 2627 | { |
2624 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2628 | struct Scsi_Host *shost = class_to_shost(dev); |
2625 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2629 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2626 | unsigned long lock_flags = 0; | 2630 | unsigned long lock_flags = 0; |
2627 | int len; | 2631 | int len; |
@@ -2634,16 +2638,17 @@ static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf) | |||
2634 | 2638 | ||
2635 | /** | 2639 | /** |
2636 | * ipr_store_log_level - Change the adapter's error logging level | 2640 | * ipr_store_log_level - Change the adapter's error logging level |
2637 | * @class_dev: class device struct | 2641 | * @dev: class device struct |
2638 | * @buf: buffer | 2642 | * @buf: buffer |
2639 | * | 2643 | * |
2640 | * Return value: | 2644 | * Return value: |
2641 | * number of bytes printed to buffer | 2645 | * number of bytes printed to buffer |
2642 | **/ | 2646 | **/ |
2643 | static ssize_t ipr_store_log_level(struct class_device *class_dev, | 2647 | static ssize_t ipr_store_log_level(struct device *dev, |
2648 | struct device_attribute *attr, | ||
2644 | const char *buf, size_t count) | 2649 | const char *buf, size_t count) |
2645 | { | 2650 | { |
2646 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2651 | struct Scsi_Host *shost = class_to_shost(dev); |
2647 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2652 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2648 | unsigned long lock_flags = 0; | 2653 | unsigned long lock_flags = 0; |
2649 | 2654 | ||
@@ -2653,7 +2658,7 @@ static ssize_t ipr_store_log_level(struct class_device *class_dev, | |||
2653 | return strlen(buf); | 2658 | return strlen(buf); |
2654 | } | 2659 | } |
2655 | 2660 | ||
2656 | static struct class_device_attribute ipr_log_level_attr = { | 2661 | static struct device_attribute ipr_log_level_attr = { |
2657 | .attr = { | 2662 | .attr = { |
2658 | .name = "log_level", | 2663 | .name = "log_level", |
2659 | .mode = S_IRUGO | S_IWUSR, | 2664 | .mode = S_IRUGO | S_IWUSR, |
@@ -2664,9 +2669,9 @@ static struct class_device_attribute ipr_log_level_attr = { | |||
2664 | 2669 | ||
2665 | /** | 2670 | /** |
2666 | * ipr_store_diagnostics - IOA Diagnostics interface | 2671 | * ipr_store_diagnostics - IOA Diagnostics interface |
2667 | * @class_dev: class_device struct | 2672 | * @dev: device struct |
2668 | * @buf: buffer | 2673 | * @buf: buffer |
2669 | * @count: buffer size | 2674 | * @count: buffer size |
2670 | * | 2675 | * |
2671 | * This function will reset the adapter and wait a reasonable | 2676 | * This function will reset the adapter and wait a reasonable |
2672 | * amount of time for any errors that the adapter might log. | 2677 | * amount of time for any errors that the adapter might log. |
@@ -2674,10 +2679,11 @@ static struct class_device_attribute ipr_log_level_attr = { | |||
2674 | * Return value: | 2679 | * Return value: |
2675 | * count on success / other on failure | 2680 | * count on success / other on failure |
2676 | **/ | 2681 | **/ |
2677 | static ssize_t ipr_store_diagnostics(struct class_device *class_dev, | 2682 | static ssize_t ipr_store_diagnostics(struct device *dev, |
2683 | struct device_attribute *attr, | ||
2678 | const char *buf, size_t count) | 2684 | const char *buf, size_t count) |
2679 | { | 2685 | { |
2680 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2686 | struct Scsi_Host *shost = class_to_shost(dev); |
2681 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2687 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2682 | unsigned long lock_flags = 0; | 2688 | unsigned long lock_flags = 0; |
2683 | int rc = count; | 2689 | int rc = count; |
@@ -2714,7 +2720,7 @@ static ssize_t ipr_store_diagnostics(struct class_device *class_dev, | |||
2714 | return rc; | 2720 | return rc; |
2715 | } | 2721 | } |
2716 | 2722 | ||
2717 | static struct class_device_attribute ipr_diagnostics_attr = { | 2723 | static struct device_attribute ipr_diagnostics_attr = { |
2718 | .attr = { | 2724 | .attr = { |
2719 | .name = "run_diagnostics", | 2725 | .name = "run_diagnostics", |
2720 | .mode = S_IWUSR, | 2726 | .mode = S_IWUSR, |
@@ -2724,15 +2730,16 @@ static struct class_device_attribute ipr_diagnostics_attr = { | |||
2724 | 2730 | ||
2725 | /** | 2731 | /** |
2726 | * ipr_show_adapter_state - Show the adapter's state | 2732 | * ipr_show_adapter_state - Show the adapter's state |
2727 | * @class_dev: class device struct | 2733 | * @class_dev: device struct |
2728 | * @buf: buffer | 2734 | * @buf: buffer |
2729 | * | 2735 | * |
2730 | * Return value: | 2736 | * Return value: |
2731 | * number of bytes printed to buffer | 2737 | * number of bytes printed to buffer |
2732 | **/ | 2738 | **/ |
2733 | static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf) | 2739 | static ssize_t ipr_show_adapter_state(struct device *dev, |
2740 | struct device_attribute *attr, char *buf) | ||
2734 | { | 2741 | { |
2735 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2742 | struct Scsi_Host *shost = class_to_shost(dev); |
2736 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2743 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2737 | unsigned long lock_flags = 0; | 2744 | unsigned long lock_flags = 0; |
2738 | int len; | 2745 | int len; |
@@ -2748,19 +2755,20 @@ static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf) | |||
2748 | 2755 | ||
2749 | /** | 2756 | /** |
2750 | * ipr_store_adapter_state - Change adapter state | 2757 | * ipr_store_adapter_state - Change adapter state |
2751 | * @class_dev: class_device struct | 2758 | * @dev: device struct |
2752 | * @buf: buffer | 2759 | * @buf: buffer |
2753 | * @count: buffer size | 2760 | * @count: buffer size |
2754 | * | 2761 | * |
2755 | * This function will change the adapter's state. | 2762 | * This function will change the adapter's state. |
2756 | * | 2763 | * |
2757 | * Return value: | 2764 | * Return value: |
2758 | * count on success / other on failure | 2765 | * count on success / other on failure |
2759 | **/ | 2766 | **/ |
2760 | static ssize_t ipr_store_adapter_state(struct class_device *class_dev, | 2767 | static ssize_t ipr_store_adapter_state(struct device *dev, |
2768 | struct device_attribute *attr, | ||
2761 | const char *buf, size_t count) | 2769 | const char *buf, size_t count) |
2762 | { | 2770 | { |
2763 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2771 | struct Scsi_Host *shost = class_to_shost(dev); |
2764 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2772 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2765 | unsigned long lock_flags; | 2773 | unsigned long lock_flags; |
2766 | int result = count; | 2774 | int result = count; |
@@ -2781,7 +2789,7 @@ static ssize_t ipr_store_adapter_state(struct class_device *class_dev, | |||
2781 | return result; | 2789 | return result; |
2782 | } | 2790 | } |
2783 | 2791 | ||
2784 | static struct class_device_attribute ipr_ioa_state_attr = { | 2792 | static struct device_attribute ipr_ioa_state_attr = { |
2785 | .attr = { | 2793 | .attr = { |
2786 | .name = "state", | 2794 | .name = "state", |
2787 | .mode = S_IRUGO | S_IWUSR, | 2795 | .mode = S_IRUGO | S_IWUSR, |
@@ -2792,19 +2800,20 @@ static struct class_device_attribute ipr_ioa_state_attr = { | |||
2792 | 2800 | ||
2793 | /** | 2801 | /** |
2794 | * ipr_store_reset_adapter - Reset the adapter | 2802 | * ipr_store_reset_adapter - Reset the adapter |
2795 | * @class_dev: class_device struct | 2803 | * @dev: device struct |
2796 | * @buf: buffer | 2804 | * @buf: buffer |
2797 | * @count: buffer size | 2805 | * @count: buffer size |
2798 | * | 2806 | * |
2799 | * This function will reset the adapter. | 2807 | * This function will reset the adapter. |
2800 | * | 2808 | * |
2801 | * Return value: | 2809 | * Return value: |
2802 | * count on success / other on failure | 2810 | * count on success / other on failure |
2803 | **/ | 2811 | **/ |
2804 | static ssize_t ipr_store_reset_adapter(struct class_device *class_dev, | 2812 | static ssize_t ipr_store_reset_adapter(struct device *dev, |
2813 | struct device_attribute *attr, | ||
2805 | const char *buf, size_t count) | 2814 | const char *buf, size_t count) |
2806 | { | 2815 | { |
2807 | struct Scsi_Host *shost = class_to_shost(class_dev); | 2816 | struct Scsi_Host *shost = class_to_shost(dev); |
2808 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 2817 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
2809 | unsigned long lock_flags; | 2818 | unsigned long lock_flags; |
2810 | int result = count; | 2819 | int result = count; |
@@ -2821,7 +2830,7 @@ static ssize_t ipr_store_reset_adapter(struct class_device *class_dev, | |||
2821 | return result; | 2830 | return result; |
2822 | } | 2831 | } |
2823 | 2832 | ||
2824 | static struct class_device_attribute ipr_ioa_reset_attr = { | 2833 | static struct device_attribute ipr_ioa_reset_attr = { |
2825 | .attr = { | 2834 | .attr = { |
2826 | .name = "reset_host", | 2835 | .name = "reset_host", |
2827 | .mode = S_IWUSR, | 2836 | .mode = S_IWUSR, |
@@ -3054,19 +3063,20 @@ static int ipr_update_ioa_ucode(struct ipr_ioa_cfg *ioa_cfg, | |||
3054 | 3063 | ||
3055 | /** | 3064 | /** |
3056 | * ipr_store_update_fw - Update the firmware on the adapter | 3065 | * ipr_store_update_fw - Update the firmware on the adapter |
3057 | * @class_dev: class_device struct | 3066 | * @class_dev: device struct |
3058 | * @buf: buffer | 3067 | * @buf: buffer |
3059 | * @count: buffer size | 3068 | * @count: buffer size |
3060 | * | 3069 | * |
3061 | * This function will update the firmware on the adapter. | 3070 | * This function will update the firmware on the adapter. |
3062 | * | 3071 | * |
3063 | * Return value: | 3072 | * Return value: |
3064 | * count on success / other on failure | 3073 | * count on success / other on failure |
3065 | **/ | 3074 | **/ |
3066 | static ssize_t ipr_store_update_fw(struct class_device *class_dev, | 3075 | static ssize_t ipr_store_update_fw(struct device *dev, |
3067 | const char *buf, size_t count) | 3076 | struct device_attribute *attr, |
3077 | const char *buf, size_t count) | ||
3068 | { | 3078 | { |
3069 | struct Scsi_Host *shost = class_to_shost(class_dev); | 3079 | struct Scsi_Host *shost = class_to_shost(dev); |
3070 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 3080 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
3071 | struct ipr_ucode_image_header *image_hdr; | 3081 | struct ipr_ucode_image_header *image_hdr; |
3072 | const struct firmware *fw_entry; | 3082 | const struct firmware *fw_entry; |
@@ -3124,7 +3134,7 @@ out: | |||
3124 | return result; | 3134 | return result; |
3125 | } | 3135 | } |
3126 | 3136 | ||
3127 | static struct class_device_attribute ipr_update_fw_attr = { | 3137 | static struct device_attribute ipr_update_fw_attr = { |
3128 | .attr = { | 3138 | .attr = { |
3129 | .name = "update_fw", | 3139 | .name = "update_fw", |
3130 | .mode = S_IWUSR, | 3140 | .mode = S_IWUSR, |
@@ -3132,7 +3142,7 @@ static struct class_device_attribute ipr_update_fw_attr = { | |||
3132 | .store = ipr_store_update_fw | 3142 | .store = ipr_store_update_fw |
3133 | }; | 3143 | }; |
3134 | 3144 | ||
3135 | static struct class_device_attribute *ipr_ioa_attrs[] = { | 3145 | static struct device_attribute *ipr_ioa_attrs[] = { |
3136 | &ipr_fw_version_attr, | 3146 | &ipr_fw_version_attr, |
3137 | &ipr_log_level_attr, | 3147 | &ipr_log_level_attr, |
3138 | &ipr_diagnostics_attr, | 3148 | &ipr_diagnostics_attr, |
@@ -3159,7 +3169,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj, | |||
3159 | struct bin_attribute *bin_attr, | 3169 | struct bin_attribute *bin_attr, |
3160 | char *buf, loff_t off, size_t count) | 3170 | char *buf, loff_t off, size_t count) |
3161 | { | 3171 | { |
3162 | struct class_device *cdev = container_of(kobj,struct class_device,kobj); | 3172 | struct device *cdev = container_of(kobj, struct device, kobj); |
3163 | struct Scsi_Host *shost = class_to_shost(cdev); | 3173 | struct Scsi_Host *shost = class_to_shost(cdev); |
3164 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 3174 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
3165 | struct ipr_dump *dump; | 3175 | struct ipr_dump *dump; |
@@ -3322,7 +3332,7 @@ static ssize_t ipr_write_dump(struct kobject *kobj, | |||
3322 | struct bin_attribute *bin_attr, | 3332 | struct bin_attribute *bin_attr, |
3323 | char *buf, loff_t off, size_t count) | 3333 | char *buf, loff_t off, size_t count) |
3324 | { | 3334 | { |
3325 | struct class_device *cdev = container_of(kobj,struct class_device,kobj); | 3335 | struct device *cdev = container_of(kobj, struct device, kobj); |
3326 | struct Scsi_Host *shost = class_to_shost(cdev); | 3336 | struct Scsi_Host *shost = class_to_shost(cdev); |
3327 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | 3337 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; |
3328 | int rc; | 3338 | int rc; |
@@ -7671,9 +7681,9 @@ static void ipr_remove(struct pci_dev *pdev) | |||
7671 | 7681 | ||
7672 | ENTER; | 7682 | ENTER; |
7673 | 7683 | ||
7674 | ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj, | 7684 | ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj, |
7675 | &ipr_trace_attr); | 7685 | &ipr_trace_attr); |
7676 | ipr_remove_dump_file(&ioa_cfg->host->shost_classdev.kobj, | 7686 | ipr_remove_dump_file(&ioa_cfg->host->shost_dev.kobj, |
7677 | &ipr_dump_attr); | 7687 | &ipr_dump_attr); |
7678 | scsi_remove_host(ioa_cfg->host); | 7688 | scsi_remove_host(ioa_cfg->host); |
7679 | 7689 | ||
@@ -7714,7 +7724,7 @@ static int __devinit ipr_probe(struct pci_dev *pdev, | |||
7714 | return rc; | 7724 | return rc; |
7715 | } | 7725 | } |
7716 | 7726 | ||
7717 | rc = ipr_create_trace_file(&ioa_cfg->host->shost_classdev.kobj, | 7727 | rc = ipr_create_trace_file(&ioa_cfg->host->shost_dev.kobj, |
7718 | &ipr_trace_attr); | 7728 | &ipr_trace_attr); |
7719 | 7729 | ||
7720 | if (rc) { | 7730 | if (rc) { |
@@ -7723,11 +7733,11 @@ static int __devinit ipr_probe(struct pci_dev *pdev, | |||
7723 | return rc; | 7733 | return rc; |
7724 | } | 7734 | } |
7725 | 7735 | ||
7726 | rc = ipr_create_dump_file(&ioa_cfg->host->shost_classdev.kobj, | 7736 | rc = ipr_create_dump_file(&ioa_cfg->host->shost_dev.kobj, |
7727 | &ipr_dump_attr); | 7737 | &ipr_dump_attr); |
7728 | 7738 | ||
7729 | if (rc) { | 7739 | if (rc) { |
7730 | ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj, | 7740 | ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj, |
7731 | &ipr_trace_attr); | 7741 | &ipr_trace_attr); |
7732 | scsi_remove_host(ioa_cfg->host); | 7742 | scsi_remove_host(ioa_cfg->host); |
7733 | __ipr_remove(pdev); | 7743 | __ipr_remove(pdev); |
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 74c9fc204211..a9fbb3f88659 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -66,23 +66,26 @@ lpfc_jedec_to_ascii(int incr, char hdw[]) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | static ssize_t | 68 | static ssize_t |
69 | lpfc_drvr_version_show(struct class_device *cdev, char *buf) | 69 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
70 | char *buf) | ||
70 | { | 71 | { |
71 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); | 72 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
72 | } | 73 | } |
73 | 74 | ||
74 | static ssize_t | 75 | static ssize_t |
75 | lpfc_info_show(struct class_device *cdev, char *buf) | 76 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
77 | char *buf) | ||
76 | { | 78 | { |
77 | struct Scsi_Host *host = class_to_shost(cdev); | 79 | struct Scsi_Host *host = class_to_shost(dev); |
78 | 80 | ||
79 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); | 81 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
80 | } | 82 | } |
81 | 83 | ||
82 | static ssize_t | 84 | static ssize_t |
83 | lpfc_serialnum_show(struct class_device *cdev, char *buf) | 85 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
86 | char *buf) | ||
84 | { | 87 | { |
85 | struct Scsi_Host *shost = class_to_shost(cdev); | 88 | struct Scsi_Host *shost = class_to_shost(dev); |
86 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 89 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
87 | struct lpfc_hba *phba = vport->phba; | 90 | struct lpfc_hba *phba = vport->phba; |
88 | 91 | ||
@@ -90,18 +93,20 @@ lpfc_serialnum_show(struct class_device *cdev, char *buf) | |||
90 | } | 93 | } |
91 | 94 | ||
92 | static ssize_t | 95 | static ssize_t |
93 | lpfc_temp_sensor_show(struct class_device *cdev, char *buf) | 96 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
97 | char *buf) | ||
94 | { | 98 | { |
95 | struct Scsi_Host *shost = class_to_shost(cdev); | 99 | struct Scsi_Host *shost = class_to_shost(dev); |
96 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 100 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
97 | struct lpfc_hba *phba = vport->phba; | 101 | struct lpfc_hba *phba = vport->phba; |
98 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); | 102 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
99 | } | 103 | } |
100 | 104 | ||
101 | static ssize_t | 105 | static ssize_t |
102 | lpfc_modeldesc_show(struct class_device *cdev, char *buf) | 106 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
107 | char *buf) | ||
103 | { | 108 | { |
104 | struct Scsi_Host *shost = class_to_shost(cdev); | 109 | struct Scsi_Host *shost = class_to_shost(dev); |
105 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 110 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
106 | struct lpfc_hba *phba = vport->phba; | 111 | struct lpfc_hba *phba = vport->phba; |
107 | 112 | ||
@@ -109,9 +114,10 @@ lpfc_modeldesc_show(struct class_device *cdev, char *buf) | |||
109 | } | 114 | } |
110 | 115 | ||
111 | static ssize_t | 116 | static ssize_t |
112 | lpfc_modelname_show(struct class_device *cdev, char *buf) | 117 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
118 | char *buf) | ||
113 | { | 119 | { |
114 | struct Scsi_Host *shost = class_to_shost(cdev); | 120 | struct Scsi_Host *shost = class_to_shost(dev); |
115 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 121 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
116 | struct lpfc_hba *phba = vport->phba; | 122 | struct lpfc_hba *phba = vport->phba; |
117 | 123 | ||
@@ -119,9 +125,10 @@ lpfc_modelname_show(struct class_device *cdev, char *buf) | |||
119 | } | 125 | } |
120 | 126 | ||
121 | static ssize_t | 127 | static ssize_t |
122 | lpfc_programtype_show(struct class_device *cdev, char *buf) | 128 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
129 | char *buf) | ||
123 | { | 130 | { |
124 | struct Scsi_Host *shost = class_to_shost(cdev); | 131 | struct Scsi_Host *shost = class_to_shost(dev); |
125 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 132 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
126 | struct lpfc_hba *phba = vport->phba; | 133 | struct lpfc_hba *phba = vport->phba; |
127 | 134 | ||
@@ -129,9 +136,10 @@ lpfc_programtype_show(struct class_device *cdev, char *buf) | |||
129 | } | 136 | } |
130 | 137 | ||
131 | static ssize_t | 138 | static ssize_t |
132 | lpfc_vportnum_show(struct class_device *cdev, char *buf) | 139 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
140 | char *buf) | ||
133 | { | 141 | { |
134 | struct Scsi_Host *shost = class_to_shost(cdev); | 142 | struct Scsi_Host *shost = class_to_shost(dev); |
135 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 143 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
136 | struct lpfc_hba *phba = vport->phba; | 144 | struct lpfc_hba *phba = vport->phba; |
137 | 145 | ||
@@ -139,9 +147,10 @@ lpfc_vportnum_show(struct class_device *cdev, char *buf) | |||
139 | } | 147 | } |
140 | 148 | ||
141 | static ssize_t | 149 | static ssize_t |
142 | lpfc_fwrev_show(struct class_device *cdev, char *buf) | 150 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
151 | char *buf) | ||
143 | { | 152 | { |
144 | struct Scsi_Host *shost = class_to_shost(cdev); | 153 | struct Scsi_Host *shost = class_to_shost(dev); |
145 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 154 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
146 | struct lpfc_hba *phba = vport->phba; | 155 | struct lpfc_hba *phba = vport->phba; |
147 | char fwrev[32]; | 156 | char fwrev[32]; |
@@ -151,10 +160,10 @@ lpfc_fwrev_show(struct class_device *cdev, char *buf) | |||
151 | } | 160 | } |
152 | 161 | ||
153 | static ssize_t | 162 | static ssize_t |
154 | lpfc_hdw_show(struct class_device *cdev, char *buf) | 163 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
155 | { | 164 | { |
156 | char hdw[9]; | 165 | char hdw[9]; |
157 | struct Scsi_Host *shost = class_to_shost(cdev); | 166 | struct Scsi_Host *shost = class_to_shost(dev); |
158 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 167 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
159 | struct lpfc_hba *phba = vport->phba; | 168 | struct lpfc_hba *phba = vport->phba; |
160 | lpfc_vpd_t *vp = &phba->vpd; | 169 | lpfc_vpd_t *vp = &phba->vpd; |
@@ -163,18 +172,20 @@ lpfc_hdw_show(struct class_device *cdev, char *buf) | |||
163 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); | 172 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
164 | } | 173 | } |
165 | static ssize_t | 174 | static ssize_t |
166 | lpfc_option_rom_version_show(struct class_device *cdev, char *buf) | 175 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
176 | char *buf) | ||
167 | { | 177 | { |
168 | struct Scsi_Host *shost = class_to_shost(cdev); | 178 | struct Scsi_Host *shost = class_to_shost(dev); |
169 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 179 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
170 | struct lpfc_hba *phba = vport->phba; | 180 | struct lpfc_hba *phba = vport->phba; |
171 | 181 | ||
172 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); | 182 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
173 | } | 183 | } |
174 | static ssize_t | 184 | static ssize_t |
175 | lpfc_state_show(struct class_device *cdev, char *buf) | 185 | lpfc_state_show(struct device *dev, struct device_attribute *attr, |
186 | char *buf) | ||
176 | { | 187 | { |
177 | struct Scsi_Host *shost = class_to_shost(cdev); | 188 | struct Scsi_Host *shost = class_to_shost(dev); |
178 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 189 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
179 | struct lpfc_hba *phba = vport->phba; | 190 | struct lpfc_hba *phba = vport->phba; |
180 | int len = 0; | 191 | int len = 0; |
@@ -243,9 +254,10 @@ lpfc_state_show(struct class_device *cdev, char *buf) | |||
243 | } | 254 | } |
244 | 255 | ||
245 | static ssize_t | 256 | static ssize_t |
246 | lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf) | 257 | lpfc_num_discovered_ports_show(struct device *dev, |
258 | struct device_attribute *attr, char *buf) | ||
247 | { | 259 | { |
248 | struct Scsi_Host *shost = class_to_shost(cdev); | 260 | struct Scsi_Host *shost = class_to_shost(dev); |
249 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 261 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
250 | 262 | ||
251 | return snprintf(buf, PAGE_SIZE, "%d\n", | 263 | return snprintf(buf, PAGE_SIZE, "%d\n", |
@@ -367,9 +379,10 @@ lpfc_selective_reset(struct lpfc_hba *phba) | |||
367 | } | 379 | } |
368 | 380 | ||
369 | static ssize_t | 381 | static ssize_t |
370 | lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count) | 382 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
383 | const char *buf, size_t count) | ||
371 | { | 384 | { |
372 | struct Scsi_Host *shost = class_to_shost(cdev); | 385 | struct Scsi_Host *shost = class_to_shost(dev); |
373 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 386 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
374 | struct lpfc_hba *phba = vport->phba; | 387 | struct lpfc_hba *phba = vport->phba; |
375 | 388 | ||
@@ -385,9 +398,10 @@ lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count) | |||
385 | } | 398 | } |
386 | 399 | ||
387 | static ssize_t | 400 | static ssize_t |
388 | lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) | 401 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
402 | char *buf) | ||
389 | { | 403 | { |
390 | struct Scsi_Host *shost = class_to_shost(cdev); | 404 | struct Scsi_Host *shost = class_to_shost(dev); |
391 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 405 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
392 | struct lpfc_hba *phba = vport->phba; | 406 | struct lpfc_hba *phba = vport->phba; |
393 | 407 | ||
@@ -395,9 +409,10 @@ lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) | |||
395 | } | 409 | } |
396 | 410 | ||
397 | static ssize_t | 411 | static ssize_t |
398 | lpfc_board_mode_show(struct class_device *cdev, char *buf) | 412 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
413 | char *buf) | ||
399 | { | 414 | { |
400 | struct Scsi_Host *shost = class_to_shost(cdev); | 415 | struct Scsi_Host *shost = class_to_shost(dev); |
401 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 416 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
402 | struct lpfc_hba *phba = vport->phba; | 417 | struct lpfc_hba *phba = vport->phba; |
403 | char * state; | 418 | char * state; |
@@ -415,9 +430,10 @@ lpfc_board_mode_show(struct class_device *cdev, char *buf) | |||
415 | } | 430 | } |
416 | 431 | ||
417 | static ssize_t | 432 | static ssize_t |
418 | lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count) | 433 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
434 | const char *buf, size_t count) | ||
419 | { | 435 | { |
420 | struct Scsi_Host *shost = class_to_shost(cdev); | 436 | struct Scsi_Host *shost = class_to_shost(dev); |
421 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 437 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
422 | struct lpfc_hba *phba = vport->phba; | 438 | struct lpfc_hba *phba = vport->phba; |
423 | struct completion online_compl; | 439 | struct completion online_compl; |
@@ -509,9 +525,10 @@ lpfc_get_hba_info(struct lpfc_hba *phba, | |||
509 | } | 525 | } |
510 | 526 | ||
511 | static ssize_t | 527 | static ssize_t |
512 | lpfc_max_rpi_show(struct class_device *cdev, char *buf) | 528 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
529 | char *buf) | ||
513 | { | 530 | { |
514 | struct Scsi_Host *shost = class_to_shost(cdev); | 531 | struct Scsi_Host *shost = class_to_shost(dev); |
515 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 532 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
516 | struct lpfc_hba *phba = vport->phba; | 533 | struct lpfc_hba *phba = vport->phba; |
517 | uint32_t cnt; | 534 | uint32_t cnt; |
@@ -522,9 +539,10 @@ lpfc_max_rpi_show(struct class_device *cdev, char *buf) | |||
522 | } | 539 | } |
523 | 540 | ||
524 | static ssize_t | 541 | static ssize_t |
525 | lpfc_used_rpi_show(struct class_device *cdev, char *buf) | 542 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
543 | char *buf) | ||
526 | { | 544 | { |
527 | struct Scsi_Host *shost = class_to_shost(cdev); | 545 | struct Scsi_Host *shost = class_to_shost(dev); |
528 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 546 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
529 | struct lpfc_hba *phba = vport->phba; | 547 | struct lpfc_hba *phba = vport->phba; |
530 | uint32_t cnt, acnt; | 548 | uint32_t cnt, acnt; |
@@ -535,9 +553,10 @@ lpfc_used_rpi_show(struct class_device *cdev, char *buf) | |||
535 | } | 553 | } |
536 | 554 | ||
537 | static ssize_t | 555 | static ssize_t |
538 | lpfc_max_xri_show(struct class_device *cdev, char *buf) | 556 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
557 | char *buf) | ||
539 | { | 558 | { |
540 | struct Scsi_Host *shost = class_to_shost(cdev); | 559 | struct Scsi_Host *shost = class_to_shost(dev); |
541 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 560 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
542 | struct lpfc_hba *phba = vport->phba; | 561 | struct lpfc_hba *phba = vport->phba; |
543 | uint32_t cnt; | 562 | uint32_t cnt; |
@@ -548,9 +567,10 @@ lpfc_max_xri_show(struct class_device *cdev, char *buf) | |||
548 | } | 567 | } |
549 | 568 | ||
550 | static ssize_t | 569 | static ssize_t |
551 | lpfc_used_xri_show(struct class_device *cdev, char *buf) | 570 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
571 | char *buf) | ||
552 | { | 572 | { |
553 | struct Scsi_Host *shost = class_to_shost(cdev); | 573 | struct Scsi_Host *shost = class_to_shost(dev); |
554 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 574 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
555 | struct lpfc_hba *phba = vport->phba; | 575 | struct lpfc_hba *phba = vport->phba; |
556 | uint32_t cnt, acnt; | 576 | uint32_t cnt, acnt; |
@@ -561,9 +581,10 @@ lpfc_used_xri_show(struct class_device *cdev, char *buf) | |||
561 | } | 581 | } |
562 | 582 | ||
563 | static ssize_t | 583 | static ssize_t |
564 | lpfc_max_vpi_show(struct class_device *cdev, char *buf) | 584 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
585 | char *buf) | ||
565 | { | 586 | { |
566 | struct Scsi_Host *shost = class_to_shost(cdev); | 587 | struct Scsi_Host *shost = class_to_shost(dev); |
567 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 588 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
568 | struct lpfc_hba *phba = vport->phba; | 589 | struct lpfc_hba *phba = vport->phba; |
569 | uint32_t cnt; | 590 | uint32_t cnt; |
@@ -574,9 +595,10 @@ lpfc_max_vpi_show(struct class_device *cdev, char *buf) | |||
574 | } | 595 | } |
575 | 596 | ||
576 | static ssize_t | 597 | static ssize_t |
577 | lpfc_used_vpi_show(struct class_device *cdev, char *buf) | 598 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
599 | char *buf) | ||
578 | { | 600 | { |
579 | struct Scsi_Host *shost = class_to_shost(cdev); | 601 | struct Scsi_Host *shost = class_to_shost(dev); |
580 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 602 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
581 | struct lpfc_hba *phba = vport->phba; | 603 | struct lpfc_hba *phba = vport->phba; |
582 | uint32_t cnt, acnt; | 604 | uint32_t cnt, acnt; |
@@ -587,9 +609,10 @@ lpfc_used_vpi_show(struct class_device *cdev, char *buf) | |||
587 | } | 609 | } |
588 | 610 | ||
589 | static ssize_t | 611 | static ssize_t |
590 | lpfc_npiv_info_show(struct class_device *cdev, char *buf) | 612 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
613 | char *buf) | ||
591 | { | 614 | { |
592 | struct Scsi_Host *shost = class_to_shost(cdev); | 615 | struct Scsi_Host *shost = class_to_shost(dev); |
593 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 616 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
594 | struct lpfc_hba *phba = vport->phba; | 617 | struct lpfc_hba *phba = vport->phba; |
595 | 618 | ||
@@ -601,9 +624,10 @@ lpfc_npiv_info_show(struct class_device *cdev, char *buf) | |||
601 | } | 624 | } |
602 | 625 | ||
603 | static ssize_t | 626 | static ssize_t |
604 | lpfc_poll_show(struct class_device *cdev, char *buf) | 627 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
628 | char *buf) | ||
605 | { | 629 | { |
606 | struct Scsi_Host *shost = class_to_shost(cdev); | 630 | struct Scsi_Host *shost = class_to_shost(dev); |
607 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 631 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
608 | struct lpfc_hba *phba = vport->phba; | 632 | struct lpfc_hba *phba = vport->phba; |
609 | 633 | ||
@@ -611,10 +635,10 @@ lpfc_poll_show(struct class_device *cdev, char *buf) | |||
611 | } | 635 | } |
612 | 636 | ||
613 | static ssize_t | 637 | static ssize_t |
614 | lpfc_poll_store(struct class_device *cdev, const char *buf, | 638 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
615 | size_t count) | 639 | const char *buf, size_t count) |
616 | { | 640 | { |
617 | struct Scsi_Host *shost = class_to_shost(cdev); | 641 | struct Scsi_Host *shost = class_to_shost(dev); |
618 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 642 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
619 | struct lpfc_hba *phba = vport->phba; | 643 | struct lpfc_hba *phba = vport->phba; |
620 | uint32_t creg_val; | 644 | uint32_t creg_val; |
@@ -670,9 +694,10 @@ lpfc_poll_store(struct class_device *cdev, const char *buf, | |||
670 | 694 | ||
671 | #define lpfc_param_show(attr) \ | 695 | #define lpfc_param_show(attr) \ |
672 | static ssize_t \ | 696 | static ssize_t \ |
673 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | 697 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
698 | char *buf) \ | ||
674 | { \ | 699 | { \ |
675 | struct Scsi_Host *shost = class_to_shost(cdev);\ | 700 | struct Scsi_Host *shost = class_to_shost(dev);\ |
676 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ | 701 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
677 | struct lpfc_hba *phba = vport->phba;\ | 702 | struct lpfc_hba *phba = vport->phba;\ |
678 | int val = 0;\ | 703 | int val = 0;\ |
@@ -683,9 +708,10 @@ lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | |||
683 | 708 | ||
684 | #define lpfc_param_hex_show(attr) \ | 709 | #define lpfc_param_hex_show(attr) \ |
685 | static ssize_t \ | 710 | static ssize_t \ |
686 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | 711 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
712 | char *buf) \ | ||
687 | { \ | 713 | { \ |
688 | struct Scsi_Host *shost = class_to_shost(cdev);\ | 714 | struct Scsi_Host *shost = class_to_shost(dev);\ |
689 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ | 715 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
690 | struct lpfc_hba *phba = vport->phba;\ | 716 | struct lpfc_hba *phba = vport->phba;\ |
691 | int val = 0;\ | 717 | int val = 0;\ |
@@ -725,9 +751,10 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ | |||
725 | 751 | ||
726 | #define lpfc_param_store(attr) \ | 752 | #define lpfc_param_store(attr) \ |
727 | static ssize_t \ | 753 | static ssize_t \ |
728 | lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ | 754 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
755 | const char *buf, size_t count) \ | ||
729 | { \ | 756 | { \ |
730 | struct Scsi_Host *shost = class_to_shost(cdev);\ | 757 | struct Scsi_Host *shost = class_to_shost(dev);\ |
731 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ | 758 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
732 | struct lpfc_hba *phba = vport->phba;\ | 759 | struct lpfc_hba *phba = vport->phba;\ |
733 | int val=0;\ | 760 | int val=0;\ |
@@ -743,9 +770,10 @@ lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ | |||
743 | 770 | ||
744 | #define lpfc_vport_param_show(attr) \ | 771 | #define lpfc_vport_param_show(attr) \ |
745 | static ssize_t \ | 772 | static ssize_t \ |
746 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | 773 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
774 | char *buf) \ | ||
747 | { \ | 775 | { \ |
748 | struct Scsi_Host *shost = class_to_shost(cdev);\ | 776 | struct Scsi_Host *shost = class_to_shost(dev);\ |
749 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ | 777 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
750 | int val = 0;\ | 778 | int val = 0;\ |
751 | val = vport->cfg_##attr;\ | 779 | val = vport->cfg_##attr;\ |
@@ -754,9 +782,10 @@ lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | |||
754 | 782 | ||
755 | #define lpfc_vport_param_hex_show(attr) \ | 783 | #define lpfc_vport_param_hex_show(attr) \ |
756 | static ssize_t \ | 784 | static ssize_t \ |
757 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ | 785 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
786 | char *buf) \ | ||
758 | { \ | 787 | { \ |
759 | struct Scsi_Host *shost = class_to_shost(cdev);\ | 788 | struct Scsi_Host *shost = class_to_shost(dev);\ |
760 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ | 789 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
761 | int val = 0;\ | 790 | int val = 0;\ |
762 | val = vport->cfg_##attr;\ | 791 | val = vport->cfg_##attr;\ |
@@ -794,9 +823,10 @@ lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ | |||
794 | 823 | ||
795 | #define lpfc_vport_param_store(attr) \ | 824 | #define lpfc_vport_param_store(attr) \ |
796 | static ssize_t \ | 825 | static ssize_t \ |
797 | lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ | 826 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
827 | const char *buf, size_t count) \ | ||
798 | { \ | 828 | { \ |
799 | struct Scsi_Host *shost = class_to_shost(cdev);\ | 829 | struct Scsi_Host *shost = class_to_shost(dev);\ |
800 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ | 830 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
801 | int val=0;\ | 831 | int val=0;\ |
802 | if (!isdigit(buf[0]))\ | 832 | if (!isdigit(buf[0]))\ |
@@ -822,7 +852,7 @@ module_param(lpfc_##name, int, 0);\ | |||
822 | MODULE_PARM_DESC(lpfc_##name, desc);\ | 852 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
823 | lpfc_param_show(name)\ | 853 | lpfc_param_show(name)\ |
824 | lpfc_param_init(name, defval, minval, maxval)\ | 854 | lpfc_param_init(name, defval, minval, maxval)\ |
825 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) | 855 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
826 | 856 | ||
827 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ | 857 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
828 | static int lpfc_##name = defval;\ | 858 | static int lpfc_##name = defval;\ |
@@ -832,8 +862,8 @@ lpfc_param_show(name)\ | |||
832 | lpfc_param_init(name, defval, minval, maxval)\ | 862 | lpfc_param_init(name, defval, minval, maxval)\ |
833 | lpfc_param_set(name, defval, minval, maxval)\ | 863 | lpfc_param_set(name, defval, minval, maxval)\ |
834 | lpfc_param_store(name)\ | 864 | lpfc_param_store(name)\ |
835 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ | 865 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
836 | lpfc_##name##_show, lpfc_##name##_store) | 866 | lpfc_##name##_show, lpfc_##name##_store) |
837 | 867 | ||
838 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ | 868 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
839 | static int lpfc_##name = defval;\ | 869 | static int lpfc_##name = defval;\ |
@@ -841,7 +871,7 @@ module_param(lpfc_##name, int, 0);\ | |||
841 | MODULE_PARM_DESC(lpfc_##name, desc);\ | 871 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
842 | lpfc_param_hex_show(name)\ | 872 | lpfc_param_hex_show(name)\ |
843 | lpfc_param_init(name, defval, minval, maxval)\ | 873 | lpfc_param_init(name, defval, minval, maxval)\ |
844 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) | 874 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
845 | 875 | ||
846 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ | 876 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
847 | static int lpfc_##name = defval;\ | 877 | static int lpfc_##name = defval;\ |
@@ -851,8 +881,8 @@ lpfc_param_hex_show(name)\ | |||
851 | lpfc_param_init(name, defval, minval, maxval)\ | 881 | lpfc_param_init(name, defval, minval, maxval)\ |
852 | lpfc_param_set(name, defval, minval, maxval)\ | 882 | lpfc_param_set(name, defval, minval, maxval)\ |
853 | lpfc_param_store(name)\ | 883 | lpfc_param_store(name)\ |
854 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ | 884 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
855 | lpfc_##name##_show, lpfc_##name##_store) | 885 | lpfc_##name##_show, lpfc_##name##_store) |
856 | 886 | ||
857 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ | 887 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
858 | static int lpfc_##name = defval;\ | 888 | static int lpfc_##name = defval;\ |
@@ -866,7 +896,7 @@ module_param(lpfc_##name, int, 0);\ | |||
866 | MODULE_PARM_DESC(lpfc_##name, desc);\ | 896 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
867 | lpfc_vport_param_show(name)\ | 897 | lpfc_vport_param_show(name)\ |
868 | lpfc_vport_param_init(name, defval, minval, maxval)\ | 898 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
869 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) | 899 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
870 | 900 | ||
871 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ | 901 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ |
872 | static int lpfc_##name = defval;\ | 902 | static int lpfc_##name = defval;\ |
@@ -876,8 +906,8 @@ lpfc_vport_param_show(name)\ | |||
876 | lpfc_vport_param_init(name, defval, minval, maxval)\ | 906 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
877 | lpfc_vport_param_set(name, defval, minval, maxval)\ | 907 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
878 | lpfc_vport_param_store(name)\ | 908 | lpfc_vport_param_store(name)\ |
879 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ | 909 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
880 | lpfc_##name##_show, lpfc_##name##_store) | 910 | lpfc_##name##_show, lpfc_##name##_store) |
881 | 911 | ||
882 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ | 912 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
883 | static int lpfc_##name = defval;\ | 913 | static int lpfc_##name = defval;\ |
@@ -885,7 +915,7 @@ module_param(lpfc_##name, int, 0);\ | |||
885 | MODULE_PARM_DESC(lpfc_##name, desc);\ | 915 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
886 | lpfc_vport_param_hex_show(name)\ | 916 | lpfc_vport_param_hex_show(name)\ |
887 | lpfc_vport_param_init(name, defval, minval, maxval)\ | 917 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
888 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) | 918 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
889 | 919 | ||
890 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ | 920 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
891 | static int lpfc_##name = defval;\ | 921 | static int lpfc_##name = defval;\ |
@@ -895,46 +925,44 @@ lpfc_vport_param_hex_show(name)\ | |||
895 | lpfc_vport_param_init(name, defval, minval, maxval)\ | 925 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
896 | lpfc_vport_param_set(name, defval, minval, maxval)\ | 926 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
897 | lpfc_vport_param_store(name)\ | 927 | lpfc_vport_param_store(name)\ |
898 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ | 928 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
899 | lpfc_##name##_show, lpfc_##name##_store) | 929 | lpfc_##name##_show, lpfc_##name##_store) |
900 | 930 | ||
901 | static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); | 931 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
902 | static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); | 932 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
903 | static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); | 933 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
904 | static CLASS_DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); | 934 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
905 | static CLASS_DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); | 935 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
906 | static CLASS_DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); | 936 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
907 | static CLASS_DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); | 937 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
908 | static CLASS_DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); | 938 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
909 | static CLASS_DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL); | 939 | static DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL); |
910 | static CLASS_DEVICE_ATTR(option_rom_version, S_IRUGO, | 940 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
911 | lpfc_option_rom_version_show, NULL); | 941 | lpfc_option_rom_version_show, NULL); |
912 | static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO, | 942 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
913 | lpfc_num_discovered_ports_show, NULL); | 943 | lpfc_num_discovered_ports_show, NULL); |
914 | static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); | 944 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
915 | static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, | 945 | static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); |
916 | NULL); | 946 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
917 | static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, | 947 | lpfc_board_mode_show, lpfc_board_mode_store); |
918 | lpfc_board_mode_show, lpfc_board_mode_store); | 948 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
919 | static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); | 949 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
920 | static CLASS_DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); | 950 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
921 | static CLASS_DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); | 951 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
922 | static CLASS_DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); | 952 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
923 | static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); | 953 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
924 | static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); | 954 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
925 | static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); | 955 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
926 | static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); | 956 | static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); |
927 | static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, | ||
928 | NULL); | ||
929 | 957 | ||
930 | 958 | ||
931 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; | 959 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
932 | 960 | ||
933 | static ssize_t | 961 | static ssize_t |
934 | lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, | 962 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
935 | size_t count) | 963 | const char *buf, size_t count) |
936 | { | 964 | { |
937 | struct Scsi_Host *shost = class_to_shost(cdev); | 965 | struct Scsi_Host *shost = class_to_shost(dev); |
938 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 966 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
939 | struct lpfc_hba *phba = vport->phba; | 967 | struct lpfc_hba *phba = vport->phba; |
940 | unsigned int cnt = count; | 968 | unsigned int cnt = count; |
@@ -963,13 +991,14 @@ lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, | |||
963 | phba->soft_wwn_enable = 1; | 991 | phba->soft_wwn_enable = 1; |
964 | return count; | 992 | return count; |
965 | } | 993 | } |
966 | static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, | 994 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
967 | lpfc_soft_wwn_enable_store); | 995 | lpfc_soft_wwn_enable_store); |
968 | 996 | ||
969 | static ssize_t | 997 | static ssize_t |
970 | lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) | 998 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
999 | char *buf) | ||
971 | { | 1000 | { |
972 | struct Scsi_Host *shost = class_to_shost(cdev); | 1001 | struct Scsi_Host *shost = class_to_shost(dev); |
973 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1002 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
974 | struct lpfc_hba *phba = vport->phba; | 1003 | struct lpfc_hba *phba = vport->phba; |
975 | 1004 | ||
@@ -979,9 +1008,10 @@ lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) | |||
979 | 1008 | ||
980 | 1009 | ||
981 | static ssize_t | 1010 | static ssize_t |
982 | lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) | 1011 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
1012 | const char *buf, size_t count) | ||
983 | { | 1013 | { |
984 | struct Scsi_Host *shost = class_to_shost(cdev); | 1014 | struct Scsi_Host *shost = class_to_shost(dev); |
985 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1015 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
986 | struct lpfc_hba *phba = vport->phba; | 1016 | struct lpfc_hba *phba = vport->phba; |
987 | struct completion online_compl; | 1017 | struct completion online_compl; |
@@ -1047,13 +1077,14 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) | |||
1047 | "reinit adapter - %d\n", stat2); | 1077 | "reinit adapter - %d\n", stat2); |
1048 | return (stat1 || stat2) ? -EIO : count; | 1078 | return (stat1 || stat2) ? -EIO : count; |
1049 | } | 1079 | } |
1050 | static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ | 1080 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ |
1051 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); | 1081 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
1052 | 1082 | ||
1053 | static ssize_t | 1083 | static ssize_t |
1054 | lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) | 1084 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
1085 | char *buf) | ||
1055 | { | 1086 | { |
1056 | struct Scsi_Host *shost = class_to_shost(cdev); | 1087 | struct Scsi_Host *shost = class_to_shost(dev); |
1057 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; | 1088 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
1058 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", | 1089 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
1059 | (unsigned long long)phba->cfg_soft_wwnn); | 1090 | (unsigned long long)phba->cfg_soft_wwnn); |
@@ -1061,9 +1092,10 @@ lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) | |||
1061 | 1092 | ||
1062 | 1093 | ||
1063 | static ssize_t | 1094 | static ssize_t |
1064 | lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) | 1095 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
1096 | const char *buf, size_t count) | ||
1065 | { | 1097 | { |
1066 | struct Scsi_Host *shost = class_to_shost(cdev); | 1098 | struct Scsi_Host *shost = class_to_shost(dev); |
1067 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; | 1099 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
1068 | unsigned int i, j, cnt=count; | 1100 | unsigned int i, j, cnt=count; |
1069 | u8 wwnn[8]; | 1101 | u8 wwnn[8]; |
@@ -1107,8 +1139,8 @@ lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) | |||
1107 | 1139 | ||
1108 | return count; | 1140 | return count; |
1109 | } | 1141 | } |
1110 | static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ | 1142 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ |
1111 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); | 1143 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
1112 | 1144 | ||
1113 | 1145 | ||
1114 | static int lpfc_poll = 0; | 1146 | static int lpfc_poll = 0; |
@@ -1118,8 +1150,8 @@ MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" | |||
1118 | " 1 - poll with interrupts enabled" | 1150 | " 1 - poll with interrupts enabled" |
1119 | " 3 - poll and disable FCP ring interrupts"); | 1151 | " 3 - poll and disable FCP ring interrupts"); |
1120 | 1152 | ||
1121 | static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, | 1153 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
1122 | lpfc_poll_show, lpfc_poll_store); | 1154 | lpfc_poll_show, lpfc_poll_store); |
1123 | 1155 | ||
1124 | int lpfc_sli_mode = 0; | 1156 | int lpfc_sli_mode = 0; |
1125 | module_param(lpfc_sli_mode, int, 0); | 1157 | module_param(lpfc_sli_mode, int, 0); |
@@ -1133,7 +1165,7 @@ module_param(lpfc_enable_npiv, int, 0); | |||
1133 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); | 1165 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); |
1134 | lpfc_param_show(enable_npiv); | 1166 | lpfc_param_show(enable_npiv); |
1135 | lpfc_param_init(enable_npiv, 0, 0, 1); | 1167 | lpfc_param_init(enable_npiv, 0, 0, 1); |
1136 | static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, | 1168 | static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, |
1137 | lpfc_enable_npiv_show, NULL); | 1169 | lpfc_enable_npiv_show, NULL); |
1138 | 1170 | ||
1139 | /* | 1171 | /* |
@@ -1147,9 +1179,10 @@ MODULE_PARM_DESC(lpfc_nodev_tmo, | |||
1147 | "Seconds driver will hold I/O waiting " | 1179 | "Seconds driver will hold I/O waiting " |
1148 | "for a device to come back"); | 1180 | "for a device to come back"); |
1149 | static ssize_t | 1181 | static ssize_t |
1150 | lpfc_nodev_tmo_show(struct class_device *cdev, char *buf) | 1182 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
1183 | char *buf) | ||
1151 | { | 1184 | { |
1152 | struct Scsi_Host *shost = class_to_shost(cdev); | 1185 | struct Scsi_Host *shost = class_to_shost(dev); |
1153 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1186 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1154 | int val = 0; | 1187 | int val = 0; |
1155 | val = vport->cfg_devloss_tmo; | 1188 | val = vport->cfg_devloss_tmo; |
@@ -1221,8 +1254,8 @@ lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) | |||
1221 | 1254 | ||
1222 | lpfc_vport_param_store(nodev_tmo) | 1255 | lpfc_vport_param_store(nodev_tmo) |
1223 | 1256 | ||
1224 | static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, | 1257 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
1225 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); | 1258 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
1226 | 1259 | ||
1227 | /* | 1260 | /* |
1228 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that | 1261 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
@@ -1255,8 +1288,8 @@ lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) | |||
1255 | } | 1288 | } |
1256 | 1289 | ||
1257 | lpfc_vport_param_store(devloss_tmo) | 1290 | lpfc_vport_param_store(devloss_tmo) |
1258 | static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, | 1291 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
1259 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); | 1292 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
1260 | 1293 | ||
1261 | /* | 1294 | /* |
1262 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being | 1295 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
@@ -1374,8 +1407,8 @@ lpfc_restrict_login_set(struct lpfc_vport *vport, int val) | |||
1374 | return 0; | 1407 | return 0; |
1375 | } | 1408 | } |
1376 | lpfc_vport_param_store(restrict_login); | 1409 | lpfc_vport_param_store(restrict_login); |
1377 | static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, | 1410 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
1378 | lpfc_restrict_login_show, lpfc_restrict_login_store); | 1411 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
1379 | 1412 | ||
1380 | /* | 1413 | /* |
1381 | # Some disk devices have a "select ID" or "select Target" capability. | 1414 | # Some disk devices have a "select ID" or "select Target" capability. |
@@ -1433,7 +1466,7 @@ MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); | |||
1433 | lpfc_param_show(topology) | 1466 | lpfc_param_show(topology) |
1434 | lpfc_param_init(topology, 0, 0, 6) | 1467 | lpfc_param_init(topology, 0, 0, 6) |
1435 | lpfc_param_store(topology) | 1468 | lpfc_param_store(topology) |
1436 | static CLASS_DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, | 1469 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
1437 | lpfc_topology_show, lpfc_topology_store); | 1470 | lpfc_topology_show, lpfc_topology_store); |
1438 | 1471 | ||
1439 | /* | 1472 | /* |
@@ -1497,7 +1530,7 @@ lpfc_link_speed_init(struct lpfc_hba *phba, int val) | |||
1497 | } | 1530 | } |
1498 | 1531 | ||
1499 | lpfc_param_store(link_speed) | 1532 | lpfc_param_store(link_speed) |
1500 | static CLASS_DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, | 1533 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
1501 | lpfc_link_speed_show, lpfc_link_speed_store); | 1534 | lpfc_link_speed_show, lpfc_link_speed_store); |
1502 | 1535 | ||
1503 | /* | 1536 | /* |
@@ -1623,82 +1656,81 @@ LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat."); | |||
1623 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, | 1656 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
1624 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); | 1657 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
1625 | 1658 | ||
1626 | struct class_device_attribute *lpfc_hba_attrs[] = { | 1659 | struct device_attribute *lpfc_hba_attrs[] = { |
1627 | &class_device_attr_info, | 1660 | &dev_attr_info, |
1628 | &class_device_attr_serialnum, | 1661 | &dev_attr_serialnum, |
1629 | &class_device_attr_modeldesc, | 1662 | &dev_attr_modeldesc, |
1630 | &class_device_attr_modelname, | 1663 | &dev_attr_modelname, |
1631 | &class_device_attr_programtype, | 1664 | &dev_attr_programtype, |
1632 | &class_device_attr_portnum, | 1665 | &dev_attr_portnum, |
1633 | &class_device_attr_fwrev, | 1666 | &dev_attr_fwrev, |
1634 | &class_device_attr_hdw, | 1667 | &dev_attr_hdw, |
1635 | &class_device_attr_option_rom_version, | 1668 | &dev_attr_option_rom_version, |
1636 | &class_device_attr_state, | 1669 | &dev_attr_state, |
1637 | &class_device_attr_num_discovered_ports, | 1670 | &dev_attr_num_discovered_ports, |
1638 | &class_device_attr_lpfc_drvr_version, | 1671 | &dev_attr_lpfc_drvr_version, |
1639 | &class_device_attr_lpfc_temp_sensor, | 1672 | &dev_attr_lpfc_temp_sensor, |
1640 | &class_device_attr_lpfc_log_verbose, | 1673 | &dev_attr_lpfc_log_verbose, |
1641 | &class_device_attr_lpfc_lun_queue_depth, | 1674 | &dev_attr_lpfc_lun_queue_depth, |
1642 | &class_device_attr_lpfc_hba_queue_depth, | 1675 | &dev_attr_lpfc_hba_queue_depth, |
1643 | &class_device_attr_lpfc_peer_port_login, | 1676 | &dev_attr_lpfc_peer_port_login, |
1644 | &class_device_attr_lpfc_nodev_tmo, | 1677 | &dev_attr_lpfc_nodev_tmo, |
1645 | &class_device_attr_lpfc_devloss_tmo, | 1678 | &dev_attr_lpfc_devloss_tmo, |
1646 | &class_device_attr_lpfc_fcp_class, | 1679 | &dev_attr_lpfc_fcp_class, |
1647 | &class_device_attr_lpfc_use_adisc, | 1680 | &dev_attr_lpfc_use_adisc, |
1648 | &class_device_attr_lpfc_ack0, | 1681 | &dev_attr_lpfc_ack0, |
1649 | &class_device_attr_lpfc_topology, | 1682 | &dev_attr_lpfc_topology, |
1650 | &class_device_attr_lpfc_scan_down, | 1683 | &dev_attr_lpfc_scan_down, |
1651 | &class_device_attr_lpfc_link_speed, | 1684 | &dev_attr_lpfc_link_speed, |
1652 | &class_device_attr_lpfc_cr_delay, | 1685 | &dev_attr_lpfc_cr_delay, |
1653 | &class_device_attr_lpfc_cr_count, | 1686 | &dev_attr_lpfc_cr_count, |
1654 | &class_device_attr_lpfc_multi_ring_support, | 1687 | &dev_attr_lpfc_multi_ring_support, |
1655 | &class_device_attr_lpfc_multi_ring_rctl, | 1688 | &dev_attr_lpfc_multi_ring_rctl, |
1656 | &class_device_attr_lpfc_multi_ring_type, | 1689 | &dev_attr_lpfc_multi_ring_type, |
1657 | &class_device_attr_lpfc_fdmi_on, | 1690 | &dev_attr_lpfc_fdmi_on, |
1658 | &class_device_attr_lpfc_max_luns, | 1691 | &dev_attr_lpfc_max_luns, |
1659 | &class_device_attr_lpfc_enable_npiv, | 1692 | &dev_attr_lpfc_enable_npiv, |
1660 | &class_device_attr_nport_evt_cnt, | 1693 | &dev_attr_nport_evt_cnt, |
1661 | &class_device_attr_board_mode, | 1694 | &dev_attr_board_mode, |
1662 | &class_device_attr_max_vpi, | 1695 | &dev_attr_max_vpi, |
1663 | &class_device_attr_used_vpi, | 1696 | &dev_attr_used_vpi, |
1664 | &class_device_attr_max_rpi, | 1697 | &dev_attr_max_rpi, |
1665 | &class_device_attr_used_rpi, | 1698 | &dev_attr_used_rpi, |
1666 | &class_device_attr_max_xri, | 1699 | &dev_attr_max_xri, |
1667 | &class_device_attr_used_xri, | 1700 | &dev_attr_used_xri, |
1668 | &class_device_attr_npiv_info, | 1701 | &dev_attr_npiv_info, |
1669 | &class_device_attr_issue_reset, | 1702 | &dev_attr_issue_reset, |
1670 | &class_device_attr_lpfc_poll, | 1703 | &dev_attr_lpfc_poll, |
1671 | &class_device_attr_lpfc_poll_tmo, | 1704 | &dev_attr_lpfc_poll_tmo, |
1672 | &class_device_attr_lpfc_use_msi, | 1705 | &dev_attr_lpfc_use_msi, |
1673 | &class_device_attr_lpfc_soft_wwnn, | 1706 | &dev_attr_lpfc_soft_wwnn, |
1674 | &class_device_attr_lpfc_soft_wwpn, | 1707 | &dev_attr_lpfc_soft_wwpn, |
1675 | &class_device_attr_lpfc_soft_wwn_enable, | 1708 | &dev_attr_lpfc_soft_wwn_enable, |
1676 | &class_device_attr_lpfc_enable_hba_reset, | 1709 | &dev_attr_lpfc_enable_hba_reset, |
1677 | &class_device_attr_lpfc_enable_hba_heartbeat, | 1710 | &dev_attr_lpfc_enable_hba_heartbeat, |
1678 | &class_device_attr_lpfc_sg_seg_cnt, | 1711 | &dev_attr_lpfc_sg_seg_cnt, |
1679 | NULL, | 1712 | NULL, |
1680 | }; | 1713 | }; |
1681 | 1714 | ||
1682 | struct class_device_attribute *lpfc_vport_attrs[] = { | 1715 | struct device_attribute *lpfc_vport_attrs[] = { |
1683 | &class_device_attr_info, | 1716 | &dev_attr_info, |
1684 | &class_device_attr_state, | 1717 | &dev_attr_state, |
1685 | &class_device_attr_num_discovered_ports, | 1718 | &dev_attr_num_discovered_ports, |
1686 | &class_device_attr_lpfc_drvr_version, | 1719 | &dev_attr_lpfc_drvr_version, |
1687 | 1720 | &dev_attr_lpfc_log_verbose, | |
1688 | &class_device_attr_lpfc_log_verbose, | 1721 | &dev_attr_lpfc_lun_queue_depth, |
1689 | &class_device_attr_lpfc_lun_queue_depth, | 1722 | &dev_attr_lpfc_nodev_tmo, |
1690 | &class_device_attr_lpfc_nodev_tmo, | 1723 | &dev_attr_lpfc_devloss_tmo, |
1691 | &class_device_attr_lpfc_devloss_tmo, | 1724 | &dev_attr_lpfc_hba_queue_depth, |
1692 | &class_device_attr_lpfc_hba_queue_depth, | 1725 | &dev_attr_lpfc_peer_port_login, |
1693 | &class_device_attr_lpfc_peer_port_login, | 1726 | &dev_attr_lpfc_restrict_login, |
1694 | &class_device_attr_lpfc_restrict_login, | 1727 | &dev_attr_lpfc_fcp_class, |
1695 | &class_device_attr_lpfc_fcp_class, | 1728 | &dev_attr_lpfc_use_adisc, |
1696 | &class_device_attr_lpfc_use_adisc, | 1729 | &dev_attr_lpfc_fdmi_on, |
1697 | &class_device_attr_lpfc_fdmi_on, | 1730 | &dev_attr_lpfc_max_luns, |
1698 | &class_device_attr_lpfc_max_luns, | 1731 | &dev_attr_nport_evt_cnt, |
1699 | &class_device_attr_nport_evt_cnt, | 1732 | &dev_attr_npiv_info, |
1700 | &class_device_attr_npiv_info, | 1733 | &dev_attr_lpfc_enable_da_id, |
1701 | &class_device_attr_lpfc_enable_da_id, | ||
1702 | NULL, | 1734 | NULL, |
1703 | }; | 1735 | }; |
1704 | 1736 | ||
@@ -1707,9 +1739,8 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
1707 | char *buf, loff_t off, size_t count) | 1739 | char *buf, loff_t off, size_t count) |
1708 | { | 1740 | { |
1709 | size_t buf_off; | 1741 | size_t buf_off; |
1710 | struct class_device *cdev = container_of(kobj, struct class_device, | 1742 | struct device *dev = container_of(kobj, struct device, kobj); |
1711 | kobj); | 1743 | struct Scsi_Host *shost = class_to_shost(dev); |
1712 | struct Scsi_Host *shost = class_to_shost(cdev); | ||
1713 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1744 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1714 | struct lpfc_hba *phba = vport->phba; | 1745 | struct lpfc_hba *phba = vport->phba; |
1715 | 1746 | ||
@@ -1741,9 +1772,8 @@ sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
1741 | { | 1772 | { |
1742 | size_t buf_off; | 1773 | size_t buf_off; |
1743 | uint32_t * tmp_ptr; | 1774 | uint32_t * tmp_ptr; |
1744 | struct class_device *cdev = container_of(kobj, struct class_device, | 1775 | struct device *dev = container_of(kobj, struct device, kobj); |
1745 | kobj); | 1776 | struct Scsi_Host *shost = class_to_shost(dev); |
1746 | struct Scsi_Host *shost = class_to_shost(cdev); | ||
1747 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1777 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1748 | struct lpfc_hba *phba = vport->phba; | 1778 | struct lpfc_hba *phba = vport->phba; |
1749 | 1779 | ||
@@ -1798,9 +1828,8 @@ static ssize_t | |||
1798 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 1828 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, |
1799 | char *buf, loff_t off, size_t count) | 1829 | char *buf, loff_t off, size_t count) |
1800 | { | 1830 | { |
1801 | struct class_device *cdev = container_of(kobj, struct class_device, | 1831 | struct device *dev = container_of(kobj, struct device, kobj); |
1802 | kobj); | 1832 | struct Scsi_Host *shost = class_to_shost(dev); |
1803 | struct Scsi_Host *shost = class_to_shost(cdev); | ||
1804 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1833 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1805 | struct lpfc_hba *phba = vport->phba; | 1834 | struct lpfc_hba *phba = vport->phba; |
1806 | struct lpfcMboxq *mbox = NULL; | 1835 | struct lpfcMboxq *mbox = NULL; |
@@ -1853,9 +1882,8 @@ static ssize_t | |||
1853 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 1882 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, |
1854 | char *buf, loff_t off, size_t count) | 1883 | char *buf, loff_t off, size_t count) |
1855 | { | 1884 | { |
1856 | struct class_device *cdev = container_of(kobj, struct class_device, | 1885 | struct device *dev = container_of(kobj, struct device, kobj); |
1857 | kobj); | 1886 | struct Scsi_Host *shost = class_to_shost(dev); |
1858 | struct Scsi_Host *shost = class_to_shost(cdev); | ||
1859 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 1887 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
1860 | struct lpfc_hba *phba = vport->phba; | 1888 | struct lpfc_hba *phba = vport->phba; |
1861 | int rc; | 1889 | int rc; |
@@ -2038,19 +2066,19 @@ lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) | |||
2038 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | 2066 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
2039 | int error; | 2067 | int error; |
2040 | 2068 | ||
2041 | error = sysfs_create_bin_file(&shost->shost_classdev.kobj, | 2069 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
2042 | &sysfs_ctlreg_attr); | 2070 | &sysfs_ctlreg_attr); |
2043 | if (error) | 2071 | if (error) |
2044 | goto out; | 2072 | goto out; |
2045 | 2073 | ||
2046 | error = sysfs_create_bin_file(&shost->shost_classdev.kobj, | 2074 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
2047 | &sysfs_mbox_attr); | 2075 | &sysfs_mbox_attr); |
2048 | if (error) | 2076 | if (error) |
2049 | goto out_remove_ctlreg_attr; | 2077 | goto out_remove_ctlreg_attr; |
2050 | 2078 | ||
2051 | return 0; | 2079 | return 0; |
2052 | out_remove_ctlreg_attr: | 2080 | out_remove_ctlreg_attr: |
2053 | sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); | 2081 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
2054 | out: | 2082 | out: |
2055 | return error; | 2083 | return error; |
2056 | } | 2084 | } |
@@ -2060,8 +2088,8 @@ lpfc_free_sysfs_attr(struct lpfc_vport *vport) | |||
2060 | { | 2088 | { |
2061 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | 2089 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
2062 | 2090 | ||
2063 | sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_mbox_attr); | 2091 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
2064 | sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); | 2092 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
2065 | } | 2093 | } |
2066 | 2094 | ||
2067 | 2095 | ||
@@ -2443,9 +2471,11 @@ lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | |||
2443 | 2471 | ||
2444 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ | 2472 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
2445 | static ssize_t \ | 2473 | static ssize_t \ |
2446 | lpfc_show_rport_##field (struct class_device *cdev, char *buf) \ | 2474 | lpfc_show_rport_##field (struct device *dev, \ |
2475 | struct device_attribute *attr, \ | ||
2476 | char *buf) \ | ||
2447 | { \ | 2477 | { \ |
2448 | struct fc_rport *rport = transport_class_to_rport(cdev); \ | 2478 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
2449 | struct lpfc_rport_data *rdata = rport->hostdata; \ | 2479 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
2450 | return snprintf(buf, sz, format_string, \ | 2480 | return snprintf(buf, sz, format_string, \ |
2451 | (rdata->target) ? cast rdata->target->field : 0); \ | 2481 | (rdata->target) ? cast rdata->target->field : 0); \ |
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 0819f5f39de5..7c9f8317d972 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h | |||
@@ -253,8 +253,8 @@ void lpfc_get_cfgparam(struct lpfc_hba *); | |||
253 | void lpfc_get_vport_cfgparam(struct lpfc_vport *); | 253 | void lpfc_get_vport_cfgparam(struct lpfc_vport *); |
254 | int lpfc_alloc_sysfs_attr(struct lpfc_vport *); | 254 | int lpfc_alloc_sysfs_attr(struct lpfc_vport *); |
255 | void lpfc_free_sysfs_attr(struct lpfc_vport *); | 255 | void lpfc_free_sysfs_attr(struct lpfc_vport *); |
256 | extern struct class_device_attribute *lpfc_hba_attrs[]; | 256 | extern struct device_attribute *lpfc_hba_attrs[]; |
257 | extern struct class_device_attribute *lpfc_vport_attrs[]; | 257 | extern struct device_attribute *lpfc_vport_attrs[]; |
258 | extern struct scsi_host_template lpfc_template; | 258 | extern struct scsi_host_template lpfc_template; |
259 | extern struct scsi_host_template lpfc_vport_template; | 259 | extern struct scsi_host_template lpfc_vport_template; |
260 | extern struct fc_function_template lpfc_transport_functions; | 260 | extern struct fc_function_template lpfc_transport_functions; |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 9f041929aca5..820f91fb63ba 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -125,7 +125,7 @@ static irqreturn_t megaraid_isr(int, void *); | |||
125 | 125 | ||
126 | static void megaraid_mbox_dpc(unsigned long); | 126 | static void megaraid_mbox_dpc(unsigned long); |
127 | 127 | ||
128 | static ssize_t megaraid_sysfs_show_app_hndl(struct class_device *, char *); | 128 | static ssize_t megaraid_sysfs_show_app_hndl(struct device *, struct device_attribute *attr, char *); |
129 | static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *); | 129 | static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *); |
130 | 130 | ||
131 | static int megaraid_cmm_register(adapter_t *); | 131 | static int megaraid_cmm_register(adapter_t *); |
@@ -313,12 +313,12 @@ static struct pci_driver megaraid_pci_driver = { | |||
313 | // definitions for the device attributes for exporting logical drive number | 313 | // definitions for the device attributes for exporting logical drive number |
314 | // for a scsi address (Host, Channel, Id, Lun) | 314 | // for a scsi address (Host, Channel, Id, Lun) |
315 | 315 | ||
316 | CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, | 316 | DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, |
317 | NULL); | 317 | NULL); |
318 | 318 | ||
319 | // Host template initializer for megaraid mbox sysfs device attributes | 319 | // Host template initializer for megaraid mbox sysfs device attributes |
320 | static struct class_device_attribute *megaraid_shost_attrs[] = { | 320 | static struct device_attribute *megaraid_shost_attrs[] = { |
321 | &class_device_attr_megaraid_mbox_app_hndl, | 321 | &dev_attr_megaraid_mbox_app_hndl, |
322 | NULL, | 322 | NULL, |
323 | }; | 323 | }; |
324 | 324 | ||
@@ -4063,9 +4063,10 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter) | |||
4063 | * handle, since we do not interface with applications directly. | 4063 | * handle, since we do not interface with applications directly. |
4064 | */ | 4064 | */ |
4065 | static ssize_t | 4065 | static ssize_t |
4066 | megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf) | 4066 | megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr, |
4067 | char *buf) | ||
4067 | { | 4068 | { |
4068 | struct Scsi_Host *shost = class_to_shost(cdev); | 4069 | struct Scsi_Host *shost = class_to_shost(dev); |
4069 | adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost); | 4070 | adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost); |
4070 | uint32_t app_hndl; | 4071 | uint32_t app_hndl; |
4071 | 4072 | ||
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index c5ebf018b378..d89289400425 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c | |||
@@ -8243,7 +8243,8 @@ static void process_waiting_list(struct ncb *np, int sts) | |||
8243 | 8243 | ||
8244 | #undef next_wcmd | 8244 | #undef next_wcmd |
8245 | 8245 | ||
8246 | static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf) | 8246 | static ssize_t show_ncr53c8xx_revision(struct device *dev, |
8247 | struct device_attribute *attr, char *buf) | ||
8247 | { | 8248 | { |
8248 | struct Scsi_Host *host = class_to_shost(dev); | 8249 | struct Scsi_Host *host = class_to_shost(dev); |
8249 | struct host_data *host_data = (struct host_data *)host->hostdata; | 8250 | struct host_data *host_data = (struct host_data *)host->hostdata; |
@@ -8251,12 +8252,12 @@ static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf) | |||
8251 | return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id); | 8252 | return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id); |
8252 | } | 8253 | } |
8253 | 8254 | ||
8254 | static struct class_device_attribute ncr53c8xx_revision_attr = { | 8255 | static struct device_attribute ncr53c8xx_revision_attr = { |
8255 | .attr = { .name = "revision", .mode = S_IRUGO, }, | 8256 | .attr = { .name = "revision", .mode = S_IRUGO, }, |
8256 | .show = show_ncr53c8xx_revision, | 8257 | .show = show_ncr53c8xx_revision, |
8257 | }; | 8258 | }; |
8258 | 8259 | ||
8259 | static struct class_device_attribute *ncr53c8xx_host_attrs[] = { | 8260 | static struct device_attribute *ncr53c8xx_host_attrs[] = { |
8260 | &ncr53c8xx_revision_attr, | 8261 | &ncr53c8xx_revision_attr, |
8261 | NULL | 8262 | NULL |
8262 | }; | 8263 | }; |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index abef7048f25b..31f7aec44d90 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5591,9 +5591,10 @@ static void osst_remove_sysfs_files(struct device_driver *sysfs) | |||
5591 | * sysfs support for accessing ADR header information | 5591 | * sysfs support for accessing ADR header information |
5592 | */ | 5592 | */ |
5593 | 5593 | ||
5594 | static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf) | 5594 | static ssize_t osst_adr_rev_show(struct device *dev, |
5595 | struct device_attribute *attr, char *buf) | ||
5595 | { | 5596 | { |
5596 | struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); | 5597 | struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); |
5597 | ssize_t l = 0; | 5598 | ssize_t l = 0; |
5598 | 5599 | ||
5599 | if (STp && STp->header_ok && STp->linux_media) | 5600 | if (STp && STp->header_ok && STp->linux_media) |
@@ -5601,11 +5602,13 @@ static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf) | |||
5601 | return l; | 5602 | return l; |
5602 | } | 5603 | } |
5603 | 5604 | ||
5604 | CLASS_DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL); | 5605 | DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL); |
5605 | 5606 | ||
5606 | static ssize_t osst_linux_media_version_show(struct class_device *class_dev, char *buf) | 5607 | static ssize_t osst_linux_media_version_show(struct device *dev, |
5608 | struct device_attribute *attr, | ||
5609 | char *buf) | ||
5607 | { | 5610 | { |
5608 | struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); | 5611 | struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); |
5609 | ssize_t l = 0; | 5612 | ssize_t l = 0; |
5610 | 5613 | ||
5611 | if (STp && STp->header_ok && STp->linux_media) | 5614 | if (STp && STp->header_ok && STp->linux_media) |
@@ -5613,11 +5616,12 @@ static ssize_t osst_linux_media_version_show(struct class_device *class_dev, cha | |||
5613 | return l; | 5616 | return l; |
5614 | } | 5617 | } |
5615 | 5618 | ||
5616 | CLASS_DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL); | 5619 | DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL); |
5617 | 5620 | ||
5618 | static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf) | 5621 | static ssize_t osst_capacity_show(struct device *dev, |
5622 | struct device_attribute *attr, char *buf) | ||
5619 | { | 5623 | { |
5620 | struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); | 5624 | struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); |
5621 | ssize_t l = 0; | 5625 | ssize_t l = 0; |
5622 | 5626 | ||
5623 | if (STp && STp->header_ok && STp->linux_media) | 5627 | if (STp && STp->header_ok && STp->linux_media) |
@@ -5625,11 +5629,13 @@ static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf) | |||
5625 | return l; | 5629 | return l; |
5626 | } | 5630 | } |
5627 | 5631 | ||
5628 | CLASS_DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL); | 5632 | DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL); |
5629 | 5633 | ||
5630 | static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *buf) | 5634 | static ssize_t osst_first_data_ppos_show(struct device *dev, |
5635 | struct device_attribute *attr, | ||
5636 | char *buf) | ||
5631 | { | 5637 | { |
5632 | struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); | 5638 | struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); |
5633 | ssize_t l = 0; | 5639 | ssize_t l = 0; |
5634 | 5640 | ||
5635 | if (STp && STp->header_ok && STp->linux_media) | 5641 | if (STp && STp->header_ok && STp->linux_media) |
@@ -5637,11 +5643,13 @@ static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *b | |||
5637 | return l; | 5643 | return l; |
5638 | } | 5644 | } |
5639 | 5645 | ||
5640 | CLASS_DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL); | 5646 | DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL); |
5641 | 5647 | ||
5642 | static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *buf) | 5648 | static ssize_t osst_eod_frame_ppos_show(struct device *dev, |
5649 | struct device_attribute *attr, | ||
5650 | char *buf) | ||
5643 | { | 5651 | { |
5644 | struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); | 5652 | struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); |
5645 | ssize_t l = 0; | 5653 | ssize_t l = 0; |
5646 | 5654 | ||
5647 | if (STp && STp->header_ok && STp->linux_media) | 5655 | if (STp && STp->header_ok && STp->linux_media) |
@@ -5649,11 +5657,12 @@ static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *bu | |||
5649 | return l; | 5657 | return l; |
5650 | } | 5658 | } |
5651 | 5659 | ||
5652 | CLASS_DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL); | 5660 | DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL); |
5653 | 5661 | ||
5654 | static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf) | 5662 | static ssize_t osst_filemark_cnt_show(struct device *dev, |
5663 | struct device_attribute *attr, char *buf) | ||
5655 | { | 5664 | { |
5656 | struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); | 5665 | struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev); |
5657 | ssize_t l = 0; | 5666 | ssize_t l = 0; |
5658 | 5667 | ||
5659 | if (STp && STp->header_ok && STp->linux_media) | 5668 | if (STp && STp->header_ok && STp->linux_media) |
@@ -5661,7 +5670,7 @@ static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf) | |||
5661 | return l; | 5670 | return l; |
5662 | } | 5671 | } |
5663 | 5672 | ||
5664 | CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL); | 5673 | DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL); |
5665 | 5674 | ||
5666 | static struct class *osst_sysfs_class; | 5675 | static struct class *osst_sysfs_class; |
5667 | 5676 | ||
@@ -5678,44 +5687,37 @@ static int osst_sysfs_init(void) | |||
5678 | 5687 | ||
5679 | static void osst_sysfs_destroy(dev_t dev) | 5688 | static void osst_sysfs_destroy(dev_t dev) |
5680 | { | 5689 | { |
5681 | class_device_destroy(osst_sysfs_class, dev); | 5690 | device_destroy(osst_sysfs_class, dev); |
5682 | } | 5691 | } |
5683 | 5692 | ||
5684 | static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name) | 5693 | static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name) |
5685 | { | 5694 | { |
5686 | struct class_device *osst_class_member; | 5695 | struct device *osst_member; |
5687 | int err; | 5696 | int err; |
5688 | 5697 | ||
5689 | osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, | 5698 | osst_member = device_create(osst_sysfs_class, device, dev, "%s", name); |
5690 | device, "%s", name); | 5699 | if (IS_ERR(osst_member)) { |
5691 | if (IS_ERR(osst_class_member)) { | ||
5692 | printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); | 5700 | printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); |
5693 | return PTR_ERR(osst_class_member); | 5701 | return PTR_ERR(osst_member); |
5694 | } | 5702 | } |
5695 | 5703 | ||
5696 | class_set_devdata(osst_class_member, STp); | 5704 | dev_set_drvdata(osst_member, STp); |
5697 | err = class_device_create_file(osst_class_member, | 5705 | err = device_create_file(osst_member, &dev_attr_ADR_rev); |
5698 | &class_device_attr_ADR_rev); | ||
5699 | if (err) | 5706 | if (err) |
5700 | goto err_out; | 5707 | goto err_out; |
5701 | err = class_device_create_file(osst_class_member, | 5708 | err = device_create_file(osst_member, &dev_attr_media_version); |
5702 | &class_device_attr_media_version); | ||
5703 | if (err) | 5709 | if (err) |
5704 | goto err_out; | 5710 | goto err_out; |
5705 | err = class_device_create_file(osst_class_member, | 5711 | err = device_create_file(osst_member, &dev_attr_capacity); |
5706 | &class_device_attr_capacity); | ||
5707 | if (err) | 5712 | if (err) |
5708 | goto err_out; | 5713 | goto err_out; |
5709 | err = class_device_create_file(osst_class_member, | 5714 | err = device_create_file(osst_member, &dev_attr_BOT_frame); |
5710 | &class_device_attr_BOT_frame); | ||
5711 | if (err) | 5715 | if (err) |
5712 | goto err_out; | 5716 | goto err_out; |
5713 | err = class_device_create_file(osst_class_member, | 5717 | err = device_create_file(osst_member, &dev_attr_EOD_frame); |
5714 | &class_device_attr_EOD_frame); | ||
5715 | if (err) | 5718 | if (err) |
5716 | goto err_out; | 5719 | goto err_out; |
5717 | err = class_device_create_file(osst_class_member, | 5720 | err = device_create_file(osst_member, &dev_attr_file_count); |
5718 | &class_device_attr_file_count); | ||
5719 | if (err) | 5721 | if (err) |
5720 | goto err_out; | 5722 | goto err_out; |
5721 | 5723 | ||
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 3454a5714749..0be232b58ffb 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
@@ -632,9 +632,10 @@ SYM53C500_biosparm(struct scsi_device *disk, | |||
632 | } | 632 | } |
633 | 633 | ||
634 | static ssize_t | 634 | static ssize_t |
635 | SYM53C500_show_pio(struct class_device *cdev, char *buf) | 635 | SYM53C500_show_pio(struct device *dev, struct device_attribute *attr, |
636 | char *buf) | ||
636 | { | 637 | { |
637 | struct Scsi_Host *SHp = class_to_shost(cdev); | 638 | struct Scsi_Host *SHp = class_to_shost(dev); |
638 | struct sym53c500_data *data = | 639 | struct sym53c500_data *data = |
639 | (struct sym53c500_data *)SHp->hostdata; | 640 | (struct sym53c500_data *)SHp->hostdata; |
640 | 641 | ||
@@ -642,10 +643,11 @@ SYM53C500_show_pio(struct class_device *cdev, char *buf) | |||
642 | } | 643 | } |
643 | 644 | ||
644 | static ssize_t | 645 | static ssize_t |
645 | SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count) | 646 | SYM53C500_store_pio(struct device *dev, struct device_attribute *attr, |
647 | const char *buf, size_t count) | ||
646 | { | 648 | { |
647 | int pio; | 649 | int pio; |
648 | struct Scsi_Host *SHp = class_to_shost(cdev); | 650 | struct Scsi_Host *SHp = class_to_shost(dev); |
649 | struct sym53c500_data *data = | 651 | struct sym53c500_data *data = |
650 | (struct sym53c500_data *)SHp->hostdata; | 652 | (struct sym53c500_data *)SHp->hostdata; |
651 | 653 | ||
@@ -662,7 +664,7 @@ SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count) | |||
662 | * SCSI HBA device attributes we want to | 664 | * SCSI HBA device attributes we want to |
663 | * make available via sysfs. | 665 | * make available via sysfs. |
664 | */ | 666 | */ |
665 | static struct class_device_attribute SYM53C500_pio_attr = { | 667 | static struct device_attribute SYM53C500_pio_attr = { |
666 | .attr = { | 668 | .attr = { |
667 | .name = "fast_pio", | 669 | .name = "fast_pio", |
668 | .mode = (S_IRUGO | S_IWUSR), | 670 | .mode = (S_IRUGO | S_IWUSR), |
@@ -671,7 +673,7 @@ static struct class_device_attribute SYM53C500_pio_attr = { | |||
671 | .store = SYM53C500_store_pio, | 673 | .store = SYM53C500_store_pio, |
672 | }; | 674 | }; |
673 | 675 | ||
674 | static struct class_device_attribute *SYM53C500_shost_attrs[] = { | 676 | static struct device_attribute *SYM53C500_shost_attrs[] = { |
675 | &SYM53C500_pio_attr, | 677 | &SYM53C500_pio_attr, |
676 | NULL, | 678 | NULL, |
677 | }; | 679 | }; |
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 413d8cd6a324..d61df036910c 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -530,15 +530,17 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) | |||
530 | /* Scsi_Host attributes. */ | 530 | /* Scsi_Host attributes. */ |
531 | 531 | ||
532 | static ssize_t | 532 | static ssize_t |
533 | qla2x00_drvr_version_show(struct class_device *cdev, char *buf) | 533 | qla2x00_drvr_version_show(struct device *dev, |
534 | struct device_attribute *attr, char *buf) | ||
534 | { | 535 | { |
535 | return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); | 536 | return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); |
536 | } | 537 | } |
537 | 538 | ||
538 | static ssize_t | 539 | static ssize_t |
539 | qla2x00_fw_version_show(struct class_device *cdev, char *buf) | 540 | qla2x00_fw_version_show(struct device *dev, |
541 | struct device_attribute *attr, char *buf) | ||
540 | { | 542 | { |
541 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 543 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
542 | char fw_str[30]; | 544 | char fw_str[30]; |
543 | 545 | ||
544 | return snprintf(buf, PAGE_SIZE, "%s\n", | 546 | return snprintf(buf, PAGE_SIZE, "%s\n", |
@@ -546,9 +548,10 @@ qla2x00_fw_version_show(struct class_device *cdev, char *buf) | |||
546 | } | 548 | } |
547 | 549 | ||
548 | static ssize_t | 550 | static ssize_t |
549 | qla2x00_serial_num_show(struct class_device *cdev, char *buf) | 551 | qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr, |
552 | char *buf) | ||
550 | { | 553 | { |
551 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 554 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
552 | uint32_t sn; | 555 | uint32_t sn; |
553 | 556 | ||
554 | if (IS_FWI2_CAPABLE(ha)) | 557 | if (IS_FWI2_CAPABLE(ha)) |
@@ -560,40 +563,45 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf) | |||
560 | } | 563 | } |
561 | 564 | ||
562 | static ssize_t | 565 | static ssize_t |
563 | qla2x00_isp_name_show(struct class_device *cdev, char *buf) | 566 | qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr, |
567 | char *buf) | ||
564 | { | 568 | { |
565 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 569 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
566 | return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); | 570 | return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); |
567 | } | 571 | } |
568 | 572 | ||
569 | static ssize_t | 573 | static ssize_t |
570 | qla2x00_isp_id_show(struct class_device *cdev, char *buf) | 574 | qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr, |
575 | char *buf) | ||
571 | { | 576 | { |
572 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 577 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
573 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", | 578 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", |
574 | ha->product_id[0], ha->product_id[1], ha->product_id[2], | 579 | ha->product_id[0], ha->product_id[1], ha->product_id[2], |
575 | ha->product_id[3]); | 580 | ha->product_id[3]); |
576 | } | 581 | } |
577 | 582 | ||
578 | static ssize_t | 583 | static ssize_t |
579 | qla2x00_model_name_show(struct class_device *cdev, char *buf) | 584 | qla2x00_model_name_show(struct device *dev, struct device_attribute *attr, |
585 | char *buf) | ||
580 | { | 586 | { |
581 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 587 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
582 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); | 588 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); |
583 | } | 589 | } |
584 | 590 | ||
585 | static ssize_t | 591 | static ssize_t |
586 | qla2x00_model_desc_show(struct class_device *cdev, char *buf) | 592 | qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr, |
593 | char *buf) | ||
587 | { | 594 | { |
588 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 595 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
589 | return snprintf(buf, PAGE_SIZE, "%s\n", | 596 | return snprintf(buf, PAGE_SIZE, "%s\n", |
590 | ha->model_desc ? ha->model_desc: ""); | 597 | ha->model_desc ? ha->model_desc: ""); |
591 | } | 598 | } |
592 | 599 | ||
593 | static ssize_t | 600 | static ssize_t |
594 | qla2x00_pci_info_show(struct class_device *cdev, char *buf) | 601 | qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr, |
602 | char *buf) | ||
595 | { | 603 | { |
596 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 604 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
597 | char pci_info[30]; | 605 | char pci_info[30]; |
598 | 606 | ||
599 | return snprintf(buf, PAGE_SIZE, "%s\n", | 607 | return snprintf(buf, PAGE_SIZE, "%s\n", |
@@ -601,9 +609,10 @@ qla2x00_pci_info_show(struct class_device *cdev, char *buf) | |||
601 | } | 609 | } |
602 | 610 | ||
603 | static ssize_t | 611 | static ssize_t |
604 | qla2x00_state_show(struct class_device *cdev, char *buf) | 612 | qla2x00_state_show(struct device *dev, struct device_attribute *attr, |
613 | char *buf) | ||
605 | { | 614 | { |
606 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 615 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
607 | int len = 0; | 616 | int len = 0; |
608 | 617 | ||
609 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || | 618 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || |
@@ -639,9 +648,10 @@ qla2x00_state_show(struct class_device *cdev, char *buf) | |||
639 | } | 648 | } |
640 | 649 | ||
641 | static ssize_t | 650 | static ssize_t |
642 | qla2x00_zio_show(struct class_device *cdev, char *buf) | 651 | qla2x00_zio_show(struct device *dev, struct device_attribute *attr, |
652 | char *buf) | ||
643 | { | 653 | { |
644 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 654 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
645 | int len = 0; | 655 | int len = 0; |
646 | 656 | ||
647 | switch (ha->zio_mode) { | 657 | switch (ha->zio_mode) { |
@@ -656,9 +666,10 @@ qla2x00_zio_show(struct class_device *cdev, char *buf) | |||
656 | } | 666 | } |
657 | 667 | ||
658 | static ssize_t | 668 | static ssize_t |
659 | qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) | 669 | qla2x00_zio_store(struct device *dev, struct device_attribute *attr, |
670 | const char *buf, size_t count) | ||
660 | { | 671 | { |
661 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 672 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
662 | int val = 0; | 673 | int val = 0; |
663 | uint16_t zio_mode; | 674 | uint16_t zio_mode; |
664 | 675 | ||
@@ -682,18 +693,19 @@ qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) | |||
682 | } | 693 | } |
683 | 694 | ||
684 | static ssize_t | 695 | static ssize_t |
685 | qla2x00_zio_timer_show(struct class_device *cdev, char *buf) | 696 | qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr, |
697 | char *buf) | ||
686 | { | 698 | { |
687 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 699 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
688 | 700 | ||
689 | return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); | 701 | return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); |
690 | } | 702 | } |
691 | 703 | ||
692 | static ssize_t | 704 | static ssize_t |
693 | qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, | 705 | qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr, |
694 | size_t count) | 706 | const char *buf, size_t count) |
695 | { | 707 | { |
696 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 708 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
697 | int val = 0; | 709 | int val = 0; |
698 | uint16_t zio_timer; | 710 | uint16_t zio_timer; |
699 | 711 | ||
@@ -709,9 +721,10 @@ qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, | |||
709 | } | 721 | } |
710 | 722 | ||
711 | static ssize_t | 723 | static ssize_t |
712 | qla2x00_beacon_show(struct class_device *cdev, char *buf) | 724 | qla2x00_beacon_show(struct device *dev, struct device_attribute *attr, |
725 | char *buf) | ||
713 | { | 726 | { |
714 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 727 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
715 | int len = 0; | 728 | int len = 0; |
716 | 729 | ||
717 | if (ha->beacon_blink_led) | 730 | if (ha->beacon_blink_led) |
@@ -722,10 +735,10 @@ qla2x00_beacon_show(struct class_device *cdev, char *buf) | |||
722 | } | 735 | } |
723 | 736 | ||
724 | static ssize_t | 737 | static ssize_t |
725 | qla2x00_beacon_store(struct class_device *cdev, const char *buf, | 738 | qla2x00_beacon_store(struct device *dev, struct device_attribute *attr, |
726 | size_t count) | 739 | const char *buf, size_t count) |
727 | { | 740 | { |
728 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 741 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
729 | int val = 0; | 742 | int val = 0; |
730 | int rval; | 743 | int rval; |
731 | 744 | ||
@@ -753,84 +766,86 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf, | |||
753 | } | 766 | } |
754 | 767 | ||
755 | static ssize_t | 768 | static ssize_t |
756 | qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf) | 769 | qla2x00_optrom_bios_version_show(struct device *dev, |
770 | struct device_attribute *attr, char *buf) | ||
757 | { | 771 | { |
758 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 772 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
759 | 773 | ||
760 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], | 774 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], |
761 | ha->bios_revision[0]); | 775 | ha->bios_revision[0]); |
762 | } | 776 | } |
763 | 777 | ||
764 | static ssize_t | 778 | static ssize_t |
765 | qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf) | 779 | qla2x00_optrom_efi_version_show(struct device *dev, |
780 | struct device_attribute *attr, char *buf) | ||
766 | { | 781 | { |
767 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 782 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
768 | 783 | ||
769 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], | 784 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], |
770 | ha->efi_revision[0]); | 785 | ha->efi_revision[0]); |
771 | } | 786 | } |
772 | 787 | ||
773 | static ssize_t | 788 | static ssize_t |
774 | qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf) | 789 | qla2x00_optrom_fcode_version_show(struct device *dev, |
790 | struct device_attribute *attr, char *buf) | ||
775 | { | 791 | { |
776 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 792 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
777 | 793 | ||
778 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], | 794 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], |
779 | ha->fcode_revision[0]); | 795 | ha->fcode_revision[0]); |
780 | } | 796 | } |
781 | 797 | ||
782 | static ssize_t | 798 | static ssize_t |
783 | qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf) | 799 | qla2x00_optrom_fw_version_show(struct device *dev, |
800 | struct device_attribute *attr, char *buf) | ||
784 | { | 801 | { |
785 | scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); | 802 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
786 | 803 | ||
787 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", | 804 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", |
788 | ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], | 805 | ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], |
789 | ha->fw_revision[3]); | 806 | ha->fw_revision[3]); |
790 | } | 807 | } |
791 | 808 | ||
792 | static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, | 809 | static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); |
793 | NULL); | 810 | static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); |
794 | static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); | 811 | static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); |
795 | static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); | 812 | static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); |
796 | static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); | 813 | static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); |
797 | static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); | 814 | static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); |
798 | static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); | 815 | static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); |
799 | static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); | 816 | static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); |
800 | static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); | 817 | static DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); |
801 | static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); | 818 | static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store); |
802 | static CLASS_DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, | 819 | static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, |
803 | qla2x00_zio_store); | 820 | qla2x00_zio_timer_store); |
804 | static CLASS_DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, | 821 | static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, |
805 | qla2x00_zio_timer_store); | 822 | qla2x00_beacon_store); |
806 | static CLASS_DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, | 823 | static DEVICE_ATTR(optrom_bios_version, S_IRUGO, |
807 | qla2x00_beacon_store); | 824 | qla2x00_optrom_bios_version_show, NULL); |
808 | static CLASS_DEVICE_ATTR(optrom_bios_version, S_IRUGO, | 825 | static DEVICE_ATTR(optrom_efi_version, S_IRUGO, |
809 | qla2x00_optrom_bios_version_show, NULL); | 826 | qla2x00_optrom_efi_version_show, NULL); |
810 | static CLASS_DEVICE_ATTR(optrom_efi_version, S_IRUGO, | 827 | static DEVICE_ATTR(optrom_fcode_version, S_IRUGO, |
811 | qla2x00_optrom_efi_version_show, NULL); | 828 | qla2x00_optrom_fcode_version_show, NULL); |
812 | static CLASS_DEVICE_ATTR(optrom_fcode_version, S_IRUGO, | 829 | static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show, |
813 | qla2x00_optrom_fcode_version_show, NULL); | 830 | NULL); |
814 | static CLASS_DEVICE_ATTR(optrom_fw_version, S_IRUGO, | 831 | |
815 | qla2x00_optrom_fw_version_show, NULL); | 832 | struct device_attribute *qla2x00_host_attrs[] = { |
816 | 833 | &dev_attr_driver_version, | |
817 | struct class_device_attribute *qla2x00_host_attrs[] = { | 834 | &dev_attr_fw_version, |
818 | &class_device_attr_driver_version, | 835 | &dev_attr_serial_num, |
819 | &class_device_attr_fw_version, | 836 | &dev_attr_isp_name, |
820 | &class_device_attr_serial_num, | 837 | &dev_attr_isp_id, |
821 | &class_device_attr_isp_name, | 838 | &dev_attr_model_name, |
822 | &class_device_attr_isp_id, | 839 | &dev_attr_model_desc, |
823 | &class_device_attr_model_name, | 840 | &dev_attr_pci_info, |
824 | &class_device_attr_model_desc, | 841 | &dev_attr_state, |
825 | &class_device_attr_pci_info, | 842 | &dev_attr_zio, |
826 | &class_device_attr_state, | 843 | &dev_attr_zio_timer, |
827 | &class_device_attr_zio, | 844 | &dev_attr_beacon, |
828 | &class_device_attr_zio_timer, | 845 | &dev_attr_optrom_bios_version, |
829 | &class_device_attr_beacon, | 846 | &dev_attr_optrom_efi_version, |
830 | &class_device_attr_optrom_bios_version, | 847 | &dev_attr_optrom_fcode_version, |
831 | &class_device_attr_optrom_efi_version, | 848 | &dev_attr_optrom_fw_version, |
832 | &class_device_attr_optrom_fcode_version, | ||
833 | &class_device_attr_optrom_fw_version, | ||
834 | NULL, | 849 | NULL, |
835 | }; | 850 | }; |
836 | 851 | ||
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index a9571c214a9e..76eb4fecce65 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h | |||
@@ -347,8 +347,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *); | |||
347 | /* | 347 | /* |
348 | * Global Function Prototypes in qla_attr.c source file. | 348 | * Global Function Prototypes in qla_attr.c source file. |
349 | */ | 349 | */ |
350 | struct class_device_attribute; | 350 | struct device_attribute; |
351 | extern struct class_device_attribute *qla2x00_host_attrs[]; | 351 | extern struct device_attribute *qla2x00_host_attrs[]; |
352 | struct fc_function_template; | 352 | struct fc_function_template; |
353 | extern struct fc_function_template qla2xxx_transport_functions; | 353 | extern struct fc_function_template qla2xxx_transport_functions; |
354 | extern struct fc_function_template qla2xxx_transport_vport_functions; | 354 | extern struct fc_function_template qla2xxx_transport_vport_functions; |
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c index 52182a744ba6..913a931176ef 100644 --- a/drivers/scsi/raid_class.c +++ b/drivers/scsi/raid_class.c | |||
@@ -24,15 +24,15 @@ struct raid_internal { | |||
24 | struct raid_template r; | 24 | struct raid_template r; |
25 | struct raid_function_template *f; | 25 | struct raid_function_template *f; |
26 | /* The actual attributes */ | 26 | /* The actual attributes */ |
27 | struct class_device_attribute private_attrs[RAID_NUM_ATTRS]; | 27 | struct device_attribute private_attrs[RAID_NUM_ATTRS]; |
28 | /* The array of null terminated pointers to attributes | 28 | /* The array of null terminated pointers to attributes |
29 | * needed by scsi_sysfs.c */ | 29 | * needed by scsi_sysfs.c */ |
30 | struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1]; | 30 | struct device_attribute *attrs[RAID_NUM_ATTRS + 1]; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | struct raid_component { | 33 | struct raid_component { |
34 | struct list_head node; | 34 | struct list_head node; |
35 | struct class_device cdev; | 35 | struct device dev; |
36 | int num; | 36 | int num; |
37 | }; | 37 | }; |
38 | 38 | ||
@@ -50,9 +50,9 @@ struct raid_component { | |||
50 | tc_to_raid_internal(tc); \ | 50 | tc_to_raid_internal(tc); \ |
51 | }) | 51 | }) |
52 | 52 | ||
53 | #define class_device_to_raid_internal(cdev) ({ \ | 53 | #define device_to_raid_internal(dev) ({ \ |
54 | struct attribute_container *ac = \ | 54 | struct attribute_container *ac = \ |
55 | attribute_container_classdev_to_container(cdev); \ | 55 | attribute_container_classdev_to_container(dev); \ |
56 | ac_to_raid_internal(ac); \ | 56 | ac_to_raid_internal(ac); \ |
57 | }) | 57 | }) |
58 | 58 | ||
@@ -76,33 +76,33 @@ static int raid_match(struct attribute_container *cont, struct device *dev) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | static int raid_setup(struct transport_container *tc, struct device *dev, | 78 | static int raid_setup(struct transport_container *tc, struct device *dev, |
79 | struct class_device *cdev) | 79 | struct device *cdev) |
80 | { | 80 | { |
81 | struct raid_data *rd; | 81 | struct raid_data *rd; |
82 | 82 | ||
83 | BUG_ON(class_get_devdata(cdev)); | 83 | BUG_ON(dev_get_drvdata(cdev)); |
84 | 84 | ||
85 | rd = kzalloc(sizeof(*rd), GFP_KERNEL); | 85 | rd = kzalloc(sizeof(*rd), GFP_KERNEL); |
86 | if (!rd) | 86 | if (!rd) |
87 | return -ENOMEM; | 87 | return -ENOMEM; |
88 | 88 | ||
89 | INIT_LIST_HEAD(&rd->component_list); | 89 | INIT_LIST_HEAD(&rd->component_list); |
90 | class_set_devdata(cdev, rd); | 90 | dev_set_drvdata(cdev, rd); |
91 | 91 | ||
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | static int raid_remove(struct transport_container *tc, struct device *dev, | 95 | static int raid_remove(struct transport_container *tc, struct device *dev, |
96 | struct class_device *cdev) | 96 | struct device *cdev) |
97 | { | 97 | { |
98 | struct raid_data *rd = class_get_devdata(cdev); | 98 | struct raid_data *rd = dev_get_drvdata(cdev); |
99 | struct raid_component *rc, *next; | 99 | struct raid_component *rc, *next; |
100 | dev_printk(KERN_ERR, dev, "RAID REMOVE\n"); | 100 | dev_printk(KERN_ERR, dev, "RAID REMOVE\n"); |
101 | class_set_devdata(cdev, NULL); | 101 | dev_set_drvdata(cdev, NULL); |
102 | list_for_each_entry_safe(rc, next, &rd->component_list, node) { | 102 | list_for_each_entry_safe(rc, next, &rd->component_list, node) { |
103 | list_del(&rc->node); | 103 | list_del(&rc->node); |
104 | dev_printk(KERN_ERR, rc->cdev.dev, "RAID COMPONENT REMOVE\n"); | 104 | dev_printk(KERN_ERR, rc->dev.parent, "RAID COMPONENT REMOVE\n"); |
105 | class_device_unregister(&rc->cdev); | 105 | device_unregister(&rc->dev); |
106 | } | 106 | } |
107 | dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n"); | 107 | dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n"); |
108 | kfree(rd); | 108 | kfree(rd); |
@@ -171,9 +171,11 @@ static const char *raid_level_name(enum raid_level level) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | #define raid_attr_show_internal(attr, fmt, var, code) \ | 173 | #define raid_attr_show_internal(attr, fmt, var, code) \ |
174 | static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \ | 174 | static ssize_t raid_show_##attr(struct device *dev, \ |
175 | struct device_attribute *attr, \ | ||
176 | char *buf) \ | ||
175 | { \ | 177 | { \ |
176 | struct raid_data *rd = class_get_devdata(cdev); \ | 178 | struct raid_data *rd = dev_get_drvdata(dev); \ |
177 | code \ | 179 | code \ |
178 | return snprintf(buf, 20, #fmt "\n", var); \ | 180 | return snprintf(buf, 20, #fmt "\n", var); \ |
179 | } | 181 | } |
@@ -184,17 +186,17 @@ raid_attr_show_internal(attr, %s, name, \ | |||
184 | code \ | 186 | code \ |
185 | name = raid_##states##_name(rd->attr); \ | 187 | name = raid_##states##_name(rd->attr); \ |
186 | ) \ | 188 | ) \ |
187 | static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) | 189 | static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) |
188 | 190 | ||
189 | 191 | ||
190 | #define raid_attr_ro_internal(attr, code) \ | 192 | #define raid_attr_ro_internal(attr, code) \ |
191 | raid_attr_show_internal(attr, %d, rd->attr, code) \ | 193 | raid_attr_show_internal(attr, %d, rd->attr, code) \ |
192 | static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) | 194 | static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) |
193 | 195 | ||
194 | #define ATTR_CODE(attr) \ | 196 | #define ATTR_CODE(attr) \ |
195 | struct raid_internal *i = class_device_to_raid_internal(cdev); \ | 197 | struct raid_internal *i = device_to_raid_internal(dev); \ |
196 | if (i->f->get_##attr) \ | 198 | if (i->f->get_##attr) \ |
197 | i->f->get_##attr(cdev->dev); | 199 | i->f->get_##attr(dev->parent); |
198 | 200 | ||
199 | #define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) | 201 | #define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) |
200 | #define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) | 202 | #define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) |
@@ -206,23 +208,23 @@ raid_attr_ro_state(level); | |||
206 | raid_attr_ro_fn(resync); | 208 | raid_attr_ro_fn(resync); |
207 | raid_attr_ro_state_fn(state); | 209 | raid_attr_ro_state_fn(state); |
208 | 210 | ||
209 | static void raid_component_release(struct class_device *cdev) | 211 | static void raid_component_release(struct device *dev) |
210 | { | 212 | { |
211 | struct raid_component *rc = container_of(cdev, struct raid_component, | 213 | struct raid_component *rc = |
212 | cdev); | 214 | container_of(dev, struct raid_component, dev); |
213 | dev_printk(KERN_ERR, rc->cdev.dev, "COMPONENT RELEASE\n"); | 215 | dev_printk(KERN_ERR, rc->dev.parent, "COMPONENT RELEASE\n"); |
214 | put_device(rc->cdev.dev); | 216 | put_device(rc->dev.parent); |
215 | kfree(rc); | 217 | kfree(rc); |
216 | } | 218 | } |
217 | 219 | ||
218 | int raid_component_add(struct raid_template *r,struct device *raid_dev, | 220 | int raid_component_add(struct raid_template *r,struct device *raid_dev, |
219 | struct device *component_dev) | 221 | struct device *component_dev) |
220 | { | 222 | { |
221 | struct class_device *cdev = | 223 | struct device *cdev = |
222 | attribute_container_find_class_device(&r->raid_attrs.ac, | 224 | attribute_container_find_class_device(&r->raid_attrs.ac, |
223 | raid_dev); | 225 | raid_dev); |
224 | struct raid_component *rc; | 226 | struct raid_component *rc; |
225 | struct raid_data *rd = class_get_devdata(cdev); | 227 | struct raid_data *rd = dev_get_drvdata(cdev); |
226 | int err; | 228 | int err; |
227 | 229 | ||
228 | rc = kzalloc(sizeof(*rc), GFP_KERNEL); | 230 | rc = kzalloc(sizeof(*rc), GFP_KERNEL); |
@@ -230,17 +232,16 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev, | |||
230 | return -ENOMEM; | 232 | return -ENOMEM; |
231 | 233 | ||
232 | INIT_LIST_HEAD(&rc->node); | 234 | INIT_LIST_HEAD(&rc->node); |
233 | class_device_initialize(&rc->cdev); | 235 | device_initialize(&rc->dev); |
234 | rc->cdev.release = raid_component_release; | 236 | rc->dev.release = raid_component_release; |
235 | rc->cdev.dev = get_device(component_dev); | 237 | rc->dev.parent = get_device(component_dev); |
236 | rc->num = rd->component_count++; | 238 | rc->num = rd->component_count++; |
237 | 239 | ||
238 | snprintf(rc->cdev.class_id, sizeof(rc->cdev.class_id), | 240 | snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id), |
239 | "component-%d", rc->num); | 241 | "component-%d", rc->num); |
240 | list_add_tail(&rc->node, &rd->component_list); | 242 | list_add_tail(&rc->node, &rd->component_list); |
241 | rc->cdev.parent = cdev; | 243 | rc->dev.class = &raid_class.class; |
242 | rc->cdev.class = &raid_class.class; | 244 | err = device_add(&rc->dev); |
243 | err = class_device_add(&rc->cdev); | ||
244 | if (err) | 245 | if (err) |
245 | goto err_out; | 246 | goto err_out; |
246 | 247 | ||
@@ -273,9 +274,9 @@ raid_class_attach(struct raid_function_template *ft) | |||
273 | 274 | ||
274 | attribute_container_register(&i->r.raid_attrs.ac); | 275 | attribute_container_register(&i->r.raid_attrs.ac); |
275 | 276 | ||
276 | i->attrs[count++] = &class_device_attr_level; | 277 | i->attrs[count++] = &dev_attr_level; |
277 | i->attrs[count++] = &class_device_attr_resync; | 278 | i->attrs[count++] = &dev_attr_resync; |
278 | i->attrs[count++] = &class_device_attr_state; | 279 | i->attrs[count++] = &dev_attr_state; |
279 | 280 | ||
280 | i->attrs[count] = NULL; | 281 | i->attrs[count] = NULL; |
281 | BUG_ON(count > RAID_NUM_ATTRS); | 282 | BUG_ON(count > RAID_NUM_ATTRS); |
diff --git a/drivers/scsi/scsi_sas_internal.h b/drivers/scsi/scsi_sas_internal.h index e1edab45a37b..998cb5be6833 100644 --- a/drivers/scsi/scsi_sas_internal.h +++ b/drivers/scsi/scsi_sas_internal.h | |||
@@ -13,12 +13,12 @@ struct sas_internal { | |||
13 | struct sas_function_template *f; | 13 | struct sas_function_template *f; |
14 | struct sas_domain_function_template *dft; | 14 | struct sas_domain_function_template *dft; |
15 | 15 | ||
16 | struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS]; | 16 | struct device_attribute private_host_attrs[SAS_HOST_ATTRS]; |
17 | struct class_device_attribute private_phy_attrs[SAS_PHY_ATTRS]; | 17 | struct device_attribute private_phy_attrs[SAS_PHY_ATTRS]; |
18 | struct class_device_attribute private_port_attrs[SAS_PORT_ATTRS]; | 18 | struct device_attribute private_port_attrs[SAS_PORT_ATTRS]; |
19 | struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS]; | 19 | struct device_attribute private_rphy_attrs[SAS_RPORT_ATTRS]; |
20 | struct class_device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS]; | 20 | struct device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS]; |
21 | struct class_device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS]; | 21 | struct device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS]; |
22 | 22 | ||
23 | struct transport_container phy_attr_cont; | 23 | struct transport_container phy_attr_cont; |
24 | struct transport_container port_attr_cont; | 24 | struct transport_container port_attr_cont; |
@@ -30,12 +30,12 @@ struct sas_internal { | |||
30 | * The array of null terminated pointers to attributes | 30 | * The array of null terminated pointers to attributes |
31 | * needed by scsi_sysfs.c | 31 | * needed by scsi_sysfs.c |
32 | */ | 32 | */ |
33 | struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1]; | 33 | struct device_attribute *host_attrs[SAS_HOST_ATTRS + 1]; |
34 | struct class_device_attribute *phy_attrs[SAS_PHY_ATTRS + 1]; | 34 | struct device_attribute *phy_attrs[SAS_PHY_ATTRS + 1]; |
35 | struct class_device_attribute *port_attrs[SAS_PORT_ATTRS + 1]; | 35 | struct device_attribute *port_attrs[SAS_PORT_ATTRS + 1]; |
36 | struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1]; | 36 | struct device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1]; |
37 | struct class_device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1]; | 37 | struct device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1]; |
38 | struct class_device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1]; | 38 | struct device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1]; |
39 | }; | 39 | }; |
40 | #define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t) | 40 | #define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t) |
41 | 41 | ||
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index ed83cdb6e67d..67bb20ed45d2 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -119,9 +119,10 @@ static int scsi_scan(struct Scsi_Host *shost, const char *str) | |||
119 | */ | 119 | */ |
120 | #define shost_show_function(name, field, format_string) \ | 120 | #define shost_show_function(name, field, format_string) \ |
121 | static ssize_t \ | 121 | static ssize_t \ |
122 | show_##name (struct class_device *class_dev, char *buf) \ | 122 | show_##name (struct device *dev, struct device_attribute *attr, \ |
123 | char *buf) \ | ||
123 | { \ | 124 | { \ |
124 | struct Scsi_Host *shost = class_to_shost(class_dev); \ | 125 | struct Scsi_Host *shost = class_to_shost(dev); \ |
125 | return snprintf (buf, 20, format_string, shost->field); \ | 126 | return snprintf (buf, 20, format_string, shost->field); \ |
126 | } | 127 | } |
127 | 128 | ||
@@ -131,7 +132,7 @@ show_##name (struct class_device *class_dev, char *buf) \ | |||
131 | */ | 132 | */ |
132 | #define shost_rd_attr2(name, field, format_string) \ | 133 | #define shost_rd_attr2(name, field, format_string) \ |
133 | shost_show_function(name, field, format_string) \ | 134 | shost_show_function(name, field, format_string) \ |
134 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); | 135 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); |
135 | 136 | ||
136 | #define shost_rd_attr(field, format_string) \ | 137 | #define shost_rd_attr(field, format_string) \ |
137 | shost_rd_attr2(field, field, format_string) | 138 | shost_rd_attr2(field, field, format_string) |
@@ -140,10 +141,11 @@ shost_rd_attr2(field, field, format_string) | |||
140 | * Create the actual show/store functions and data structures. | 141 | * Create the actual show/store functions and data structures. |
141 | */ | 142 | */ |
142 | 143 | ||
143 | static ssize_t store_scan(struct class_device *class_dev, const char *buf, | 144 | static ssize_t |
144 | size_t count) | 145 | store_scan(struct device *dev, struct device_attribute *attr, |
146 | const char *buf, size_t count) | ||
145 | { | 147 | { |
146 | struct Scsi_Host *shost = class_to_shost(class_dev); | 148 | struct Scsi_Host *shost = class_to_shost(dev); |
147 | int res; | 149 | int res; |
148 | 150 | ||
149 | res = scsi_scan(shost, buf); | 151 | res = scsi_scan(shost, buf); |
@@ -151,13 +153,14 @@ static ssize_t store_scan(struct class_device *class_dev, const char *buf, | |||
151 | res = count; | 153 | res = count; |
152 | return res; | 154 | return res; |
153 | }; | 155 | }; |
154 | static CLASS_DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); | 156 | static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); |
155 | 157 | ||
156 | static ssize_t | 158 | static ssize_t |
157 | store_shost_state(struct class_device *class_dev, const char *buf, size_t count) | 159 | store_shost_state(struct device *dev, struct device_attribute *attr, |
160 | const char *buf, size_t count) | ||
158 | { | 161 | { |
159 | int i; | 162 | int i; |
160 | struct Scsi_Host *shost = class_to_shost(class_dev); | 163 | struct Scsi_Host *shost = class_to_shost(dev); |
161 | enum scsi_host_state state = 0; | 164 | enum scsi_host_state state = 0; |
162 | 165 | ||
163 | for (i = 0; i < ARRAY_SIZE(shost_states); i++) { | 166 | for (i = 0; i < ARRAY_SIZE(shost_states); i++) { |
@@ -177,9 +180,9 @@ store_shost_state(struct class_device *class_dev, const char *buf, size_t count) | |||
177 | } | 180 | } |
178 | 181 | ||
179 | static ssize_t | 182 | static ssize_t |
180 | show_shost_state(struct class_device *class_dev, char *buf) | 183 | show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) |
181 | { | 184 | { |
182 | struct Scsi_Host *shost = class_to_shost(class_dev); | 185 | struct Scsi_Host *shost = class_to_shost(dev); |
183 | const char *name = scsi_host_state_name(shost->shost_state); | 186 | const char *name = scsi_host_state_name(shost->shost_state); |
184 | 187 | ||
185 | if (!name) | 188 | if (!name) |
@@ -188,7 +191,9 @@ show_shost_state(struct class_device *class_dev, char *buf) | |||
188 | return snprintf(buf, 20, "%s\n", name); | 191 | return snprintf(buf, 20, "%s\n", name); |
189 | } | 192 | } |
190 | 193 | ||
191 | static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); | 194 | /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ |
195 | struct device_attribute dev_attr_hstate = | ||
196 | __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); | ||
192 | 197 | ||
193 | static ssize_t | 198 | static ssize_t |
194 | show_shost_mode(unsigned int mode, char *buf) | 199 | show_shost_mode(unsigned int mode, char *buf) |
@@ -206,9 +211,11 @@ show_shost_mode(unsigned int mode, char *buf) | |||
206 | return len; | 211 | return len; |
207 | } | 212 | } |
208 | 213 | ||
209 | static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf) | 214 | static ssize_t |
215 | show_shost_supported_mode(struct device *dev, struct device_attribute *attr, | ||
216 | char *buf) | ||
210 | { | 217 | { |
211 | struct Scsi_Host *shost = class_to_shost(class_dev); | 218 | struct Scsi_Host *shost = class_to_shost(dev); |
212 | unsigned int supported_mode = shost->hostt->supported_mode; | 219 | unsigned int supported_mode = shost->hostt->supported_mode; |
213 | 220 | ||
214 | if (supported_mode == MODE_UNKNOWN) | 221 | if (supported_mode == MODE_UNKNOWN) |
@@ -218,11 +225,13 @@ static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *b | |||
218 | return show_shost_mode(supported_mode, buf); | 225 | return show_shost_mode(supported_mode, buf); |
219 | } | 226 | } |
220 | 227 | ||
221 | static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); | 228 | static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); |
222 | 229 | ||
223 | static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf) | 230 | static ssize_t |
231 | show_shost_active_mode(struct device *dev, | ||
232 | struct device_attribute *attr, char *buf) | ||
224 | { | 233 | { |
225 | struct Scsi_Host *shost = class_to_shost(class_dev); | 234 | struct Scsi_Host *shost = class_to_shost(dev); |
226 | 235 | ||
227 | if (shost->active_mode == MODE_UNKNOWN) | 236 | if (shost->active_mode == MODE_UNKNOWN) |
228 | return snprintf(buf, 20, "unknown\n"); | 237 | return snprintf(buf, 20, "unknown\n"); |
@@ -230,7 +239,7 @@ static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf) | |||
230 | return show_shost_mode(shost->active_mode, buf); | 239 | return show_shost_mode(shost->active_mode, buf); |
231 | } | 240 | } |
232 | 241 | ||
233 | static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); | 242 | static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); |
234 | 243 | ||
235 | shost_rd_attr(unique_id, "%u\n"); | 244 | shost_rd_attr(unique_id, "%u\n"); |
236 | shost_rd_attr(host_busy, "%hu\n"); | 245 | shost_rd_attr(host_busy, "%hu\n"); |
@@ -240,22 +249,22 @@ shost_rd_attr(sg_tablesize, "%hu\n"); | |||
240 | shost_rd_attr(unchecked_isa_dma, "%d\n"); | 249 | shost_rd_attr(unchecked_isa_dma, "%d\n"); |
241 | shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); | 250 | shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); |
242 | 251 | ||
243 | static struct class_device_attribute *scsi_sysfs_shost_attrs[] = { | 252 | static struct device_attribute *scsi_sysfs_shost_attrs[] = { |
244 | &class_device_attr_unique_id, | 253 | &dev_attr_unique_id, |
245 | &class_device_attr_host_busy, | 254 | &dev_attr_host_busy, |
246 | &class_device_attr_cmd_per_lun, | 255 | &dev_attr_cmd_per_lun, |
247 | &class_device_attr_can_queue, | 256 | &dev_attr_can_queue, |
248 | &class_device_attr_sg_tablesize, | 257 | &dev_attr_sg_tablesize, |
249 | &class_device_attr_unchecked_isa_dma, | 258 | &dev_attr_unchecked_isa_dma, |
250 | &class_device_attr_proc_name, | 259 | &dev_attr_proc_name, |
251 | &class_device_attr_scan, | 260 | &dev_attr_scan, |
252 | &class_device_attr_state, | 261 | &dev_attr_hstate, |
253 | &class_device_attr_supported_mode, | 262 | &dev_attr_supported_mode, |
254 | &class_device_attr_active_mode, | 263 | &dev_attr_active_mode, |
255 | NULL | 264 | NULL |
256 | }; | 265 | }; |
257 | 266 | ||
258 | static void scsi_device_cls_release(struct class_device *class_dev) | 267 | static void scsi_device_cls_release(struct device *class_dev) |
259 | { | 268 | { |
260 | struct scsi_device *sdev; | 269 | struct scsi_device *sdev; |
261 | 270 | ||
@@ -320,7 +329,7 @@ static void scsi_device_dev_release(struct device *dev) | |||
320 | 329 | ||
321 | static struct class sdev_class = { | 330 | static struct class sdev_class = { |
322 | .name = "scsi_device", | 331 | .name = "scsi_device", |
323 | .release = scsi_device_cls_release, | 332 | .dev_release = scsi_device_cls_release, |
324 | }; | 333 | }; |
325 | 334 | ||
326 | /* all probing is done in the individual ->probe routines */ | 335 | /* all probing is done in the individual ->probe routines */ |
@@ -424,7 +433,8 @@ void scsi_sysfs_unregister(void) | |||
424 | */ | 433 | */ |
425 | #define sdev_show_function(field, format_string) \ | 434 | #define sdev_show_function(field, format_string) \ |
426 | static ssize_t \ | 435 | static ssize_t \ |
427 | sdev_show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ | 436 | sdev_show_##field (struct device *dev, struct device_attribute *attr, \ |
437 | char *buf) \ | ||
428 | { \ | 438 | { \ |
429 | struct scsi_device *sdev; \ | 439 | struct scsi_device *sdev; \ |
430 | sdev = to_scsi_device(dev); \ | 440 | sdev = to_scsi_device(dev); \ |
@@ -448,7 +458,8 @@ static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL); | |||
448 | sdev_show_function(field, format_string) \ | 458 | sdev_show_function(field, format_string) \ |
449 | \ | 459 | \ |
450 | static ssize_t \ | 460 | static ssize_t \ |
451 | sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ | 461 | sdev_store_##field (struct device *dev, struct device_attribute *attr, \ |
462 | const char *buf, size_t count) \ | ||
452 | { \ | 463 | { \ |
453 | struct scsi_device *sdev; \ | 464 | struct scsi_device *sdev; \ |
454 | sdev = to_scsi_device(dev); \ | 465 | sdev = to_scsi_device(dev); \ |
@@ -468,7 +479,8 @@ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##fie | |||
468 | sdev_show_function(field, "%d\n") \ | 479 | sdev_show_function(field, "%d\n") \ |
469 | \ | 480 | \ |
470 | static ssize_t \ | 481 | static ssize_t \ |
471 | sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ | 482 | sdev_store_##field (struct device *dev, struct device_attribute *attr, \ |
483 | const char *buf, size_t count) \ | ||
472 | { \ | 484 | { \ |
473 | int ret; \ | 485 | int ret; \ |
474 | struct scsi_device *sdev; \ | 486 | struct scsi_device *sdev; \ |
@@ -519,7 +531,8 @@ sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf) | |||
519 | } | 531 | } |
520 | 532 | ||
521 | static ssize_t | 533 | static ssize_t |
522 | sdev_store_timeout (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 534 | sdev_store_timeout (struct device *dev, struct device_attribute *attr, |
535 | const char *buf, size_t count) | ||
523 | { | 536 | { |
524 | struct scsi_device *sdev; | 537 | struct scsi_device *sdev; |
525 | int timeout; | 538 | int timeout; |
@@ -531,7 +544,8 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr, const cha | |||
531 | static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); | 544 | static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); |
532 | 545 | ||
533 | static ssize_t | 546 | static ssize_t |
534 | store_rescan_field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 547 | store_rescan_field (struct device *dev, struct device_attribute *attr, |
548 | const char *buf, size_t count) | ||
535 | { | 549 | { |
536 | scsi_rescan_device(dev); | 550 | scsi_rescan_device(dev); |
537 | return count; | 551 | return count; |
@@ -543,8 +557,9 @@ static void sdev_store_delete_callback(struct device *dev) | |||
543 | scsi_remove_device(to_scsi_device(dev)); | 557 | scsi_remove_device(to_scsi_device(dev)); |
544 | } | 558 | } |
545 | 559 | ||
546 | static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *attr, const char *buf, | 560 | static ssize_t |
547 | size_t count) | 561 | sdev_store_delete(struct device *dev, struct device_attribute *attr, |
562 | const char *buf, size_t count) | ||
548 | { | 563 | { |
549 | int rc; | 564 | int rc; |
550 | 565 | ||
@@ -559,7 +574,8 @@ static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *at | |||
559 | static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete); | 574 | static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete); |
560 | 575 | ||
561 | static ssize_t | 576 | static ssize_t |
562 | store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 577 | store_state_field(struct device *dev, struct device_attribute *attr, |
578 | const char *buf, size_t count) | ||
563 | { | 579 | { |
564 | int i; | 580 | int i; |
565 | struct scsi_device *sdev = to_scsi_device(dev); | 581 | struct scsi_device *sdev = to_scsi_device(dev); |
@@ -596,7 +612,8 @@ show_state_field(struct device *dev, struct device_attribute *attr, char *buf) | |||
596 | static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field); | 612 | static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field); |
597 | 613 | ||
598 | static ssize_t | 614 | static ssize_t |
599 | show_queue_type_field(struct device *dev, struct device_attribute *attr, char *buf) | 615 | show_queue_type_field(struct device *dev, struct device_attribute *attr, |
616 | char *buf) | ||
600 | { | 617 | { |
601 | struct scsi_device *sdev = to_scsi_device(dev); | 618 | struct scsi_device *sdev = to_scsi_device(dev); |
602 | const char *name = "none"; | 619 | const char *name = "none"; |
@@ -612,7 +629,7 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr, char *b | |||
612 | static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL); | 629 | static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL); |
613 | 630 | ||
614 | static ssize_t | 631 | static ssize_t |
615 | show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) | 632 | show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) |
616 | { | 633 | { |
617 | return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); | 634 | return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); |
618 | } | 635 | } |
@@ -621,7 +638,8 @@ static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL); | |||
621 | 638 | ||
622 | #define show_sdev_iostat(field) \ | 639 | #define show_sdev_iostat(field) \ |
623 | static ssize_t \ | 640 | static ssize_t \ |
624 | show_iostat_##field(struct device *dev, struct device_attribute *attr, char *buf) \ | 641 | show_iostat_##field(struct device *dev, struct device_attribute *attr, \ |
642 | char *buf) \ | ||
625 | { \ | 643 | { \ |
626 | struct scsi_device *sdev = to_scsi_device(dev); \ | 644 | struct scsi_device *sdev = to_scsi_device(dev); \ |
627 | unsigned long long count = atomic_read(&sdev->field); \ | 645 | unsigned long long count = atomic_read(&sdev->field); \ |
@@ -645,7 +663,7 @@ static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL); | |||
645 | #define DECLARE_EVT_SHOW(name, Cap_name) \ | 663 | #define DECLARE_EVT_SHOW(name, Cap_name) \ |
646 | static ssize_t \ | 664 | static ssize_t \ |
647 | sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \ | 665 | sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \ |
648 | char *buf) \ | 666 | char *buf) \ |
649 | { \ | 667 | { \ |
650 | struct scsi_device *sdev = to_scsi_device(dev); \ | 668 | struct scsi_device *sdev = to_scsi_device(dev); \ |
651 | int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\ | 669 | int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\ |
@@ -654,7 +672,7 @@ sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \ | |||
654 | 672 | ||
655 | #define DECLARE_EVT_STORE(name, Cap_name) \ | 673 | #define DECLARE_EVT_STORE(name, Cap_name) \ |
656 | static ssize_t \ | 674 | static ssize_t \ |
657 | sdev_store_evt_##name(struct device *dev, struct device_attribute *attr, \ | 675 | sdev_store_evt_##name(struct device *dev, struct device_attribute *attr,\ |
658 | const char *buf, size_t count) \ | 676 | const char *buf, size_t count) \ |
659 | { \ | 677 | { \ |
660 | struct scsi_device *sdev = to_scsi_device(dev); \ | 678 | struct scsi_device *sdev = to_scsi_device(dev); \ |
@@ -707,8 +725,9 @@ static struct attribute_group *scsi_sdev_attr_groups[] = { | |||
707 | NULL | 725 | NULL |
708 | }; | 726 | }; |
709 | 727 | ||
710 | static ssize_t sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, const char *buf, | 728 | static ssize_t |
711 | size_t count) | 729 | sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, |
730 | const char *buf, size_t count) | ||
712 | { | 731 | { |
713 | int depth, retval; | 732 | int depth, retval; |
714 | struct scsi_device *sdev = to_scsi_device(dev); | 733 | struct scsi_device *sdev = to_scsi_device(dev); |
@@ -733,8 +752,9 @@ static struct device_attribute sdev_attr_queue_depth_rw = | |||
733 | __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, | 752 | __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, |
734 | sdev_store_queue_depth_rw); | 753 | sdev_store_queue_depth_rw); |
735 | 754 | ||
736 | static ssize_t sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, const char *buf, | 755 | static ssize_t |
737 | size_t count) | 756 | sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, |
757 | const char *buf, size_t count) | ||
738 | { | 758 | { |
739 | struct scsi_device *sdev = to_scsi_device(dev); | 759 | struct scsi_device *sdev = to_scsi_device(dev); |
740 | struct scsi_host_template *sht = sdev->host->hostt; | 760 | struct scsi_host_template *sht = sdev->host->hostt; |
@@ -786,13 +806,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) | |||
786 | printk(KERN_INFO "error 1\n"); | 806 | printk(KERN_INFO "error 1\n"); |
787 | return error; | 807 | return error; |
788 | } | 808 | } |
789 | error = class_device_add(&sdev->sdev_classdev); | 809 | error = device_add(&sdev->sdev_dev); |
790 | if (error) { | 810 | if (error) { |
791 | printk(KERN_INFO "error 2\n"); | 811 | printk(KERN_INFO "error 2\n"); |
792 | goto clean_device; | 812 | goto clean_device; |
793 | } | 813 | } |
794 | 814 | ||
795 | /* take a reference for the sdev_classdev; this is | 815 | /* take a reference for the sdev_dev; this is |
796 | * released by the sdev_class .release */ | 816 | * released by the sdev_class .release */ |
797 | get_device(&sdev->sdev_gendev); | 817 | get_device(&sdev->sdev_gendev); |
798 | 818 | ||
@@ -858,7 +878,7 @@ void __scsi_remove_device(struct scsi_device *sdev) | |||
858 | return; | 878 | return; |
859 | 879 | ||
860 | bsg_unregister_queue(sdev->request_queue); | 880 | bsg_unregister_queue(sdev->request_queue); |
861 | class_device_unregister(&sdev->sdev_classdev); | 881 | device_unregister(&sdev->sdev_dev); |
862 | transport_remove_device(dev); | 882 | transport_remove_device(dev); |
863 | device_del(dev); | 883 | device_del(dev); |
864 | scsi_device_set_state(sdev, SDEV_DEL); | 884 | scsi_device_set_state(sdev, SDEV_DEL); |
@@ -952,9 +972,9 @@ int scsi_register_interface(struct class_interface *intf) | |||
952 | EXPORT_SYMBOL(scsi_register_interface); | 972 | EXPORT_SYMBOL(scsi_register_interface); |
953 | 973 | ||
954 | 974 | ||
955 | static struct class_device_attribute *class_attr_overridden( | 975 | static struct device_attribute *class_attr_overridden( |
956 | struct class_device_attribute **attrs, | 976 | struct device_attribute **attrs, |
957 | struct class_device_attribute *attr) | 977 | struct device_attribute *attr) |
958 | { | 978 | { |
959 | int i; | 979 | int i; |
960 | 980 | ||
@@ -966,10 +986,10 @@ static struct class_device_attribute *class_attr_overridden( | |||
966 | return NULL; | 986 | return NULL; |
967 | } | 987 | } |
968 | 988 | ||
969 | static int class_attr_add(struct class_device *classdev, | 989 | static int class_attr_add(struct device *classdev, |
970 | struct class_device_attribute *attr) | 990 | struct device_attribute *attr) |
971 | { | 991 | { |
972 | struct class_device_attribute *base_attr; | 992 | struct device_attribute *base_attr; |
973 | 993 | ||
974 | /* | 994 | /* |
975 | * Spare the caller from having to copy things it's not interested in. | 995 | * Spare the caller from having to copy things it's not interested in. |
@@ -986,7 +1006,7 @@ static int class_attr_add(struct class_device *classdev, | |||
986 | attr->store = base_attr->store; | 1006 | attr->store = base_attr->store; |
987 | } | 1007 | } |
988 | 1008 | ||
989 | return class_device_create_file(classdev, attr); | 1009 | return device_create_file(classdev, attr); |
990 | } | 1010 | } |
991 | 1011 | ||
992 | /** | 1012 | /** |
@@ -1000,7 +1020,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost) | |||
1000 | 1020 | ||
1001 | if (shost->hostt->shost_attrs) { | 1021 | if (shost->hostt->shost_attrs) { |
1002 | for (i = 0; shost->hostt->shost_attrs[i]; i++) { | 1022 | for (i = 0; shost->hostt->shost_attrs[i]; i++) { |
1003 | error = class_attr_add(&shost->shost_classdev, | 1023 | error = class_attr_add(&shost->shost_dev, |
1004 | shost->hostt->shost_attrs[i]); | 1024 | shost->hostt->shost_attrs[i]); |
1005 | if (error) | 1025 | if (error) |
1006 | return error; | 1026 | return error; |
@@ -1010,7 +1030,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost) | |||
1010 | for (i = 0; scsi_sysfs_shost_attrs[i]; i++) { | 1030 | for (i = 0; scsi_sysfs_shost_attrs[i]; i++) { |
1011 | if (!class_attr_overridden(shost->hostt->shost_attrs, | 1031 | if (!class_attr_overridden(shost->hostt->shost_attrs, |
1012 | scsi_sysfs_shost_attrs[i])) { | 1032 | scsi_sysfs_shost_attrs[i])) { |
1013 | error = class_device_create_file(&shost->shost_classdev, | 1033 | error = device_create_file(&shost->shost_dev, |
1014 | scsi_sysfs_shost_attrs[i]); | 1034 | scsi_sysfs_shost_attrs[i]); |
1015 | if (error) | 1035 | if (error) |
1016 | return error; | 1036 | return error; |
@@ -1041,10 +1061,10 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev) | |||
1041 | sdev->host->host_no, sdev->channel, sdev->id, | 1061 | sdev->host->host_no, sdev->channel, sdev->id, |
1042 | sdev->lun); | 1062 | sdev->lun); |
1043 | 1063 | ||
1044 | class_device_initialize(&sdev->sdev_classdev); | 1064 | device_initialize(&sdev->sdev_dev); |
1045 | sdev->sdev_classdev.dev = &sdev->sdev_gendev; | 1065 | sdev->sdev_dev.parent = &sdev->sdev_gendev; |
1046 | sdev->sdev_classdev.class = &sdev_class; | 1066 | sdev->sdev_dev.class = &sdev_class; |
1047 | snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE, | 1067 | snprintf(sdev->sdev_dev.bus_id, BUS_ID_SIZE, |
1048 | "%d:%d:%d:%d", sdev->host->host_no, | 1068 | "%d:%d:%d:%d", sdev->host->host_no, |
1049 | sdev->channel, sdev->id, sdev->lun); | 1069 | sdev->channel, sdev->id, sdev->lun); |
1050 | sdev->scsi_level = starget->scsi_level; | 1070 | sdev->scsi_level = starget->scsi_level; |
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index b1119da6e88c..6b092a6c295d 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -72,8 +72,8 @@ static int fc_vport_create(struct Scsi_Host *shost, int channel, | |||
72 | * Redefine so that we can have same named attributes in the | 72 | * Redefine so that we can have same named attributes in the |
73 | * sdev/starget/host objects. | 73 | * sdev/starget/host objects. |
74 | */ | 74 | */ |
75 | #define FC_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ | 75 | #define FC_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ |
76 | struct class_device_attribute class_device_attr_##_prefix##_##_name = \ | 76 | struct device_attribute device_attr_##_prefix##_##_name = \ |
77 | __ATTR(_name,_mode,_show,_store) | 77 | __ATTR(_name,_mode,_show,_store) |
78 | 78 | ||
79 | #define fc_enum_name_search(title, table_type, table) \ | 79 | #define fc_enum_name_search(title, table_type, table) \ |
@@ -326,26 +326,26 @@ struct fc_internal { | |||
326 | * part of the midlayer. As the remote port is specific to the | 326 | * part of the midlayer. As the remote port is specific to the |
327 | * fc transport, we must provide the attribute container. | 327 | * fc transport, we must provide the attribute container. |
328 | */ | 328 | */ |
329 | struct class_device_attribute private_starget_attrs[ | 329 | struct device_attribute private_starget_attrs[ |
330 | FC_STARGET_NUM_ATTRS]; | 330 | FC_STARGET_NUM_ATTRS]; |
331 | struct class_device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1]; | 331 | struct device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1]; |
332 | 332 | ||
333 | struct class_device_attribute private_host_attrs[FC_HOST_NUM_ATTRS]; | 333 | struct device_attribute private_host_attrs[FC_HOST_NUM_ATTRS]; |
334 | struct class_device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1]; | 334 | struct device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1]; |
335 | 335 | ||
336 | struct transport_container rport_attr_cont; | 336 | struct transport_container rport_attr_cont; |
337 | struct class_device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS]; | 337 | struct device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS]; |
338 | struct class_device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1]; | 338 | struct device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1]; |
339 | 339 | ||
340 | struct transport_container vport_attr_cont; | 340 | struct transport_container vport_attr_cont; |
341 | struct class_device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS]; | 341 | struct device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS]; |
342 | struct class_device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1]; | 342 | struct device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1]; |
343 | }; | 343 | }; |
344 | 344 | ||
345 | #define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t) | 345 | #define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t) |
346 | 346 | ||
347 | static int fc_target_setup(struct transport_container *tc, struct device *dev, | 347 | static int fc_target_setup(struct transport_container *tc, struct device *dev, |
348 | struct class_device *cdev) | 348 | struct device *cdev) |
349 | { | 349 | { |
350 | struct scsi_target *starget = to_scsi_target(dev); | 350 | struct scsi_target *starget = to_scsi_target(dev); |
351 | struct fc_rport *rport = starget_to_rport(starget); | 351 | struct fc_rport *rport = starget_to_rport(starget); |
@@ -375,7 +375,7 @@ static DECLARE_TRANSPORT_CLASS(fc_transport_class, | |||
375 | NULL); | 375 | NULL); |
376 | 376 | ||
377 | static int fc_host_setup(struct transport_container *tc, struct device *dev, | 377 | static int fc_host_setup(struct transport_container *tc, struct device *dev, |
378 | struct class_device *cdev) | 378 | struct device *cdev) |
379 | { | 379 | { |
380 | struct Scsi_Host *shost = dev_to_shost(dev); | 380 | struct Scsi_Host *shost = dev_to_shost(dev); |
381 | struct fc_host_attrs *fc_host = shost_to_fc_host(shost); | 381 | struct fc_host_attrs *fc_host = shost_to_fc_host(shost); |
@@ -682,9 +682,10 @@ static void __exit fc_transport_exit(void) | |||
682 | 682 | ||
683 | #define fc_rport_show_function(field, format_string, sz, cast) \ | 683 | #define fc_rport_show_function(field, format_string, sz, cast) \ |
684 | static ssize_t \ | 684 | static ssize_t \ |
685 | show_fc_rport_##field (struct class_device *cdev, char *buf) \ | 685 | show_fc_rport_##field (struct device *dev, \ |
686 | struct device_attribute *attr, char *buf) \ | ||
686 | { \ | 687 | { \ |
687 | struct fc_rport *rport = transport_class_to_rport(cdev); \ | 688 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
688 | struct Scsi_Host *shost = rport_to_shost(rport); \ | 689 | struct Scsi_Host *shost = rport_to_shost(rport); \ |
689 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 690 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
690 | if ((i->f->get_rport_##field) && \ | 691 | if ((i->f->get_rport_##field) && \ |
@@ -697,11 +698,12 @@ show_fc_rport_##field (struct class_device *cdev, char *buf) \ | |||
697 | 698 | ||
698 | #define fc_rport_store_function(field) \ | 699 | #define fc_rport_store_function(field) \ |
699 | static ssize_t \ | 700 | static ssize_t \ |
700 | store_fc_rport_##field(struct class_device *cdev, const char *buf, \ | 701 | store_fc_rport_##field(struct device *dev, \ |
701 | size_t count) \ | 702 | struct device_attribute *attr, \ |
703 | const char *buf, size_t count) \ | ||
702 | { \ | 704 | { \ |
703 | int val; \ | 705 | int val; \ |
704 | struct fc_rport *rport = transport_class_to_rport(cdev); \ | 706 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
705 | struct Scsi_Host *shost = rport_to_shost(rport); \ | 707 | struct Scsi_Host *shost = rport_to_shost(rport); \ |
706 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 708 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
707 | char *cp; \ | 709 | char *cp; \ |
@@ -718,58 +720,60 @@ store_fc_rport_##field(struct class_device *cdev, const char *buf, \ | |||
718 | 720 | ||
719 | #define fc_rport_rd_attr(field, format_string, sz) \ | 721 | #define fc_rport_rd_attr(field, format_string, sz) \ |
720 | fc_rport_show_function(field, format_string, sz, ) \ | 722 | fc_rport_show_function(field, format_string, sz, ) \ |
721 | static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ | 723 | static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ |
722 | show_fc_rport_##field, NULL) | 724 | show_fc_rport_##field, NULL) |
723 | 725 | ||
724 | #define fc_rport_rd_attr_cast(field, format_string, sz, cast) \ | 726 | #define fc_rport_rd_attr_cast(field, format_string, sz, cast) \ |
725 | fc_rport_show_function(field, format_string, sz, (cast)) \ | 727 | fc_rport_show_function(field, format_string, sz, (cast)) \ |
726 | static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ | 728 | static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ |
727 | show_fc_rport_##field, NULL) | 729 | show_fc_rport_##field, NULL) |
728 | 730 | ||
729 | #define fc_rport_rw_attr(field, format_string, sz) \ | 731 | #define fc_rport_rw_attr(field, format_string, sz) \ |
730 | fc_rport_show_function(field, format_string, sz, ) \ | 732 | fc_rport_show_function(field, format_string, sz, ) \ |
731 | fc_rport_store_function(field) \ | 733 | fc_rport_store_function(field) \ |
732 | static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \ | 734 | static FC_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \ |
733 | show_fc_rport_##field, \ | 735 | show_fc_rport_##field, \ |
734 | store_fc_rport_##field) | 736 | store_fc_rport_##field) |
735 | 737 | ||
736 | 738 | ||
737 | #define fc_private_rport_show_function(field, format_string, sz, cast) \ | 739 | #define fc_private_rport_show_function(field, format_string, sz, cast) \ |
738 | static ssize_t \ | 740 | static ssize_t \ |
739 | show_fc_rport_##field (struct class_device *cdev, char *buf) \ | 741 | show_fc_rport_##field (struct device *dev, \ |
742 | struct device_attribute *attr, char *buf) \ | ||
740 | { \ | 743 | { \ |
741 | struct fc_rport *rport = transport_class_to_rport(cdev); \ | 744 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
742 | return snprintf(buf, sz, format_string, cast rport->field); \ | 745 | return snprintf(buf, sz, format_string, cast rport->field); \ |
743 | } | 746 | } |
744 | 747 | ||
745 | #define fc_private_rport_rd_attr(field, format_string, sz) \ | 748 | #define fc_private_rport_rd_attr(field, format_string, sz) \ |
746 | fc_private_rport_show_function(field, format_string, sz, ) \ | 749 | fc_private_rport_show_function(field, format_string, sz, ) \ |
747 | static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ | 750 | static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ |
748 | show_fc_rport_##field, NULL) | 751 | show_fc_rport_##field, NULL) |
749 | 752 | ||
750 | #define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \ | 753 | #define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \ |
751 | fc_private_rport_show_function(field, format_string, sz, (cast)) \ | 754 | fc_private_rport_show_function(field, format_string, sz, (cast)) \ |
752 | static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ | 755 | static FC_DEVICE_ATTR(rport, field, S_IRUGO, \ |
753 | show_fc_rport_##field, NULL) | 756 | show_fc_rport_##field, NULL) |
754 | 757 | ||
755 | 758 | ||
756 | #define fc_private_rport_rd_enum_attr(title, maxlen) \ | 759 | #define fc_private_rport_rd_enum_attr(title, maxlen) \ |
757 | static ssize_t \ | 760 | static ssize_t \ |
758 | show_fc_rport_##title (struct class_device *cdev, char *buf) \ | 761 | show_fc_rport_##title (struct device *dev, \ |
762 | struct device_attribute *attr, char *buf) \ | ||
759 | { \ | 763 | { \ |
760 | struct fc_rport *rport = transport_class_to_rport(cdev); \ | 764 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
761 | const char *name; \ | 765 | const char *name; \ |
762 | name = get_fc_##title##_name(rport->title); \ | 766 | name = get_fc_##title##_name(rport->title); \ |
763 | if (!name) \ | 767 | if (!name) \ |
764 | return -EINVAL; \ | 768 | return -EINVAL; \ |
765 | return snprintf(buf, maxlen, "%s\n", name); \ | 769 | return snprintf(buf, maxlen, "%s\n", name); \ |
766 | } \ | 770 | } \ |
767 | static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \ | 771 | static FC_DEVICE_ATTR(rport, title, S_IRUGO, \ |
768 | show_fc_rport_##title, NULL) | 772 | show_fc_rport_##title, NULL) |
769 | 773 | ||
770 | 774 | ||
771 | #define SETUP_RPORT_ATTRIBUTE_RD(field) \ | 775 | #define SETUP_RPORT_ATTRIBUTE_RD(field) \ |
772 | i->private_rport_attrs[count] = class_device_attr_rport_##field; \ | 776 | i->private_rport_attrs[count] = device_attr_rport_##field; \ |
773 | i->private_rport_attrs[count].attr.mode = S_IRUGO; \ | 777 | i->private_rport_attrs[count].attr.mode = S_IRUGO; \ |
774 | i->private_rport_attrs[count].store = NULL; \ | 778 | i->private_rport_attrs[count].store = NULL; \ |
775 | i->rport_attrs[count] = &i->private_rport_attrs[count]; \ | 779 | i->rport_attrs[count] = &i->private_rport_attrs[count]; \ |
@@ -777,14 +781,14 @@ static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \ | |||
777 | count++ | 781 | count++ |
778 | 782 | ||
779 | #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \ | 783 | #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \ |
780 | i->private_rport_attrs[count] = class_device_attr_rport_##field; \ | 784 | i->private_rport_attrs[count] = device_attr_rport_##field; \ |
781 | i->private_rport_attrs[count].attr.mode = S_IRUGO; \ | 785 | i->private_rport_attrs[count].attr.mode = S_IRUGO; \ |
782 | i->private_rport_attrs[count].store = NULL; \ | 786 | i->private_rport_attrs[count].store = NULL; \ |
783 | i->rport_attrs[count] = &i->private_rport_attrs[count]; \ | 787 | i->rport_attrs[count] = &i->private_rport_attrs[count]; \ |
784 | count++ | 788 | count++ |
785 | 789 | ||
786 | #define SETUP_RPORT_ATTRIBUTE_RW(field) \ | 790 | #define SETUP_RPORT_ATTRIBUTE_RW(field) \ |
787 | i->private_rport_attrs[count] = class_device_attr_rport_##field; \ | 791 | i->private_rport_attrs[count] = device_attr_rport_##field; \ |
788 | if (!i->f->set_rport_##field) { \ | 792 | if (!i->f->set_rport_##field) { \ |
789 | i->private_rport_attrs[count].attr.mode = S_IRUGO; \ | 793 | i->private_rport_attrs[count].attr.mode = S_IRUGO; \ |
790 | i->private_rport_attrs[count].store = NULL; \ | 794 | i->private_rport_attrs[count].store = NULL; \ |
@@ -795,7 +799,7 @@ static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \ | |||
795 | 799 | ||
796 | #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(field) \ | 800 | #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(field) \ |
797 | { \ | 801 | { \ |
798 | i->private_rport_attrs[count] = class_device_attr_rport_##field; \ | 802 | i->private_rport_attrs[count] = device_attr_rport_##field; \ |
799 | i->rport_attrs[count] = &i->private_rport_attrs[count]; \ | 803 | i->rport_attrs[count] = &i->private_rport_attrs[count]; \ |
800 | count++; \ | 804 | count++; \ |
801 | } | 805 | } |
@@ -808,14 +812,15 @@ static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \ | |||
808 | fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20); | 812 | fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20); |
809 | 813 | ||
810 | static ssize_t | 814 | static ssize_t |
811 | show_fc_rport_supported_classes (struct class_device *cdev, char *buf) | 815 | show_fc_rport_supported_classes (struct device *dev, |
816 | struct device_attribute *attr, char *buf) | ||
812 | { | 817 | { |
813 | struct fc_rport *rport = transport_class_to_rport(cdev); | 818 | struct fc_rport *rport = transport_class_to_rport(dev); |
814 | if (rport->supported_classes == FC_COS_UNSPECIFIED) | 819 | if (rport->supported_classes == FC_COS_UNSPECIFIED) |
815 | return snprintf(buf, 20, "unspecified\n"); | 820 | return snprintf(buf, 20, "unspecified\n"); |
816 | return get_fc_cos_names(rport->supported_classes, buf); | 821 | return get_fc_cos_names(rport->supported_classes, buf); |
817 | } | 822 | } |
818 | static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO, | 823 | static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO, |
819 | show_fc_rport_supported_classes, NULL); | 824 | show_fc_rport_supported_classes, NULL); |
820 | 825 | ||
821 | /* Dynamic Remote Port Attributes */ | 826 | /* Dynamic Remote Port Attributes */ |
@@ -825,11 +830,11 @@ static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO, | |||
825 | */ | 830 | */ |
826 | fc_rport_show_function(dev_loss_tmo, "%d\n", 20, ) | 831 | fc_rport_show_function(dev_loss_tmo, "%d\n", 20, ) |
827 | static ssize_t | 832 | static ssize_t |
828 | store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf, | 833 | store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr, |
829 | size_t count) | 834 | const char *buf, size_t count) |
830 | { | 835 | { |
831 | int val; | 836 | int val; |
832 | struct fc_rport *rport = transport_class_to_rport(cdev); | 837 | struct fc_rport *rport = transport_class_to_rport(dev); |
833 | struct Scsi_Host *shost = rport_to_shost(rport); | 838 | struct Scsi_Host *shost = rport_to_shost(rport); |
834 | struct fc_internal *i = to_fc_internal(shost->transportt); | 839 | struct fc_internal *i = to_fc_internal(shost->transportt); |
835 | char *cp; | 840 | char *cp; |
@@ -844,7 +849,7 @@ store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf, | |||
844 | i->f->set_rport_dev_loss_tmo(rport, val); | 849 | i->f->set_rport_dev_loss_tmo(rport, val); |
845 | return count; | 850 | return count; |
846 | } | 851 | } |
847 | static FC_CLASS_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR, | 852 | static FC_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR, |
848 | show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo); | 853 | show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo); |
849 | 854 | ||
850 | 855 | ||
@@ -855,9 +860,10 @@ fc_private_rport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long); | |||
855 | fc_private_rport_rd_attr(port_id, "0x%06x\n", 20); | 860 | fc_private_rport_rd_attr(port_id, "0x%06x\n", 20); |
856 | 861 | ||
857 | static ssize_t | 862 | static ssize_t |
858 | show_fc_rport_roles (struct class_device *cdev, char *buf) | 863 | show_fc_rport_roles (struct device *dev, struct device_attribute *attr, |
864 | char *buf) | ||
859 | { | 865 | { |
860 | struct fc_rport *rport = transport_class_to_rport(cdev); | 866 | struct fc_rport *rport = transport_class_to_rport(dev); |
861 | 867 | ||
862 | /* identify any roles that are port_id specific */ | 868 | /* identify any roles that are port_id specific */ |
863 | if ((rport->port_id != -1) && | 869 | if ((rport->port_id != -1) && |
@@ -883,7 +889,7 @@ show_fc_rport_roles (struct class_device *cdev, char *buf) | |||
883 | return get_fc_port_roles_names(rport->roles, buf); | 889 | return get_fc_port_roles_names(rport->roles, buf); |
884 | } | 890 | } |
885 | } | 891 | } |
886 | static FC_CLASS_DEVICE_ATTR(rport, roles, S_IRUGO, | 892 | static FC_DEVICE_ATTR(rport, roles, S_IRUGO, |
887 | show_fc_rport_roles, NULL); | 893 | show_fc_rport_roles, NULL); |
888 | 894 | ||
889 | fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); | 895 | fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); |
@@ -893,9 +899,10 @@ fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20); | |||
893 | * fast_io_fail_tmo attribute | 899 | * fast_io_fail_tmo attribute |
894 | */ | 900 | */ |
895 | static ssize_t | 901 | static ssize_t |
896 | show_fc_rport_fast_io_fail_tmo (struct class_device *cdev, char *buf) | 902 | show_fc_rport_fast_io_fail_tmo (struct device *dev, |
903 | struct device_attribute *attr, char *buf) | ||
897 | { | 904 | { |
898 | struct fc_rport *rport = transport_class_to_rport(cdev); | 905 | struct fc_rport *rport = transport_class_to_rport(dev); |
899 | 906 | ||
900 | if (rport->fast_io_fail_tmo == -1) | 907 | if (rport->fast_io_fail_tmo == -1) |
901 | return snprintf(buf, 5, "off\n"); | 908 | return snprintf(buf, 5, "off\n"); |
@@ -903,12 +910,13 @@ show_fc_rport_fast_io_fail_tmo (struct class_device *cdev, char *buf) | |||
903 | } | 910 | } |
904 | 911 | ||
905 | static ssize_t | 912 | static ssize_t |
906 | store_fc_rport_fast_io_fail_tmo(struct class_device *cdev, const char *buf, | 913 | store_fc_rport_fast_io_fail_tmo(struct device *dev, |
907 | size_t count) | 914 | struct device_attribute *attr, const char *buf, |
915 | size_t count) | ||
908 | { | 916 | { |
909 | int val; | 917 | int val; |
910 | char *cp; | 918 | char *cp; |
911 | struct fc_rport *rport = transport_class_to_rport(cdev); | 919 | struct fc_rport *rport = transport_class_to_rport(dev); |
912 | 920 | ||
913 | if ((rport->port_state == FC_PORTSTATE_BLOCKED) || | 921 | if ((rport->port_state == FC_PORTSTATE_BLOCKED) || |
914 | (rport->port_state == FC_PORTSTATE_DELETED) || | 922 | (rport->port_state == FC_PORTSTATE_DELETED) || |
@@ -925,7 +933,7 @@ store_fc_rport_fast_io_fail_tmo(struct class_device *cdev, const char *buf, | |||
925 | } | 933 | } |
926 | return count; | 934 | return count; |
927 | } | 935 | } |
928 | static FC_CLASS_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, | 936 | static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, |
929 | show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo); | 937 | show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo); |
930 | 938 | ||
931 | 939 | ||
@@ -941,9 +949,10 @@ static FC_CLASS_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, | |||
941 | */ | 949 | */ |
942 | #define fc_starget_show_function(field, format_string, sz, cast) \ | 950 | #define fc_starget_show_function(field, format_string, sz, cast) \ |
943 | static ssize_t \ | 951 | static ssize_t \ |
944 | show_fc_starget_##field (struct class_device *cdev, char *buf) \ | 952 | show_fc_starget_##field (struct device *dev, \ |
953 | struct device_attribute *attr, char *buf) \ | ||
945 | { \ | 954 | { \ |
946 | struct scsi_target *starget = transport_class_to_starget(cdev); \ | 955 | struct scsi_target *starget = transport_class_to_starget(dev); \ |
947 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ | 956 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ |
948 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 957 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
949 | struct fc_rport *rport = starget_to_rport(starget); \ | 958 | struct fc_rport *rport = starget_to_rport(starget); \ |
@@ -957,16 +966,16 @@ show_fc_starget_##field (struct class_device *cdev, char *buf) \ | |||
957 | 966 | ||
958 | #define fc_starget_rd_attr(field, format_string, sz) \ | 967 | #define fc_starget_rd_attr(field, format_string, sz) \ |
959 | fc_starget_show_function(field, format_string, sz, ) \ | 968 | fc_starget_show_function(field, format_string, sz, ) \ |
960 | static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ | 969 | static FC_DEVICE_ATTR(starget, field, S_IRUGO, \ |
961 | show_fc_starget_##field, NULL) | 970 | show_fc_starget_##field, NULL) |
962 | 971 | ||
963 | #define fc_starget_rd_attr_cast(field, format_string, sz, cast) \ | 972 | #define fc_starget_rd_attr_cast(field, format_string, sz, cast) \ |
964 | fc_starget_show_function(field, format_string, sz, (cast)) \ | 973 | fc_starget_show_function(field, format_string, sz, (cast)) \ |
965 | static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ | 974 | static FC_DEVICE_ATTR(starget, field, S_IRUGO, \ |
966 | show_fc_starget_##field, NULL) | 975 | show_fc_starget_##field, NULL) |
967 | 976 | ||
968 | #define SETUP_STARGET_ATTRIBUTE_RD(field) \ | 977 | #define SETUP_STARGET_ATTRIBUTE_RD(field) \ |
969 | i->private_starget_attrs[count] = class_device_attr_starget_##field; \ | 978 | i->private_starget_attrs[count] = device_attr_starget_##field; \ |
970 | i->private_starget_attrs[count].attr.mode = S_IRUGO; \ | 979 | i->private_starget_attrs[count].attr.mode = S_IRUGO; \ |
971 | i->private_starget_attrs[count].store = NULL; \ | 980 | i->private_starget_attrs[count].store = NULL; \ |
972 | i->starget_attrs[count] = &i->private_starget_attrs[count]; \ | 981 | i->starget_attrs[count] = &i->private_starget_attrs[count]; \ |
@@ -974,7 +983,7 @@ static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ | |||
974 | count++ | 983 | count++ |
975 | 984 | ||
976 | #define SETUP_STARGET_ATTRIBUTE_RW(field) \ | 985 | #define SETUP_STARGET_ATTRIBUTE_RW(field) \ |
977 | i->private_starget_attrs[count] = class_device_attr_starget_##field; \ | 986 | i->private_starget_attrs[count] = device_attr_starget_##field; \ |
978 | if (!i->f->set_starget_##field) { \ | 987 | if (!i->f->set_starget_##field) { \ |
979 | i->private_starget_attrs[count].attr.mode = S_IRUGO; \ | 988 | i->private_starget_attrs[count].attr.mode = S_IRUGO; \ |
980 | i->private_starget_attrs[count].store = NULL; \ | 989 | i->private_starget_attrs[count].store = NULL; \ |
@@ -995,9 +1004,10 @@ fc_starget_rd_attr(port_id, "0x%06x\n", 20); | |||
995 | 1004 | ||
996 | #define fc_vport_show_function(field, format_string, sz, cast) \ | 1005 | #define fc_vport_show_function(field, format_string, sz, cast) \ |
997 | static ssize_t \ | 1006 | static ssize_t \ |
998 | show_fc_vport_##field (struct class_device *cdev, char *buf) \ | 1007 | show_fc_vport_##field (struct device *dev, \ |
1008 | struct device_attribute *attr, char *buf) \ | ||
999 | { \ | 1009 | { \ |
1000 | struct fc_vport *vport = transport_class_to_vport(cdev); \ | 1010 | struct fc_vport *vport = transport_class_to_vport(dev); \ |
1001 | struct Scsi_Host *shost = vport_to_shost(vport); \ | 1011 | struct Scsi_Host *shost = vport_to_shost(vport); \ |
1002 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1012 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1003 | if ((i->f->get_vport_##field) && \ | 1013 | if ((i->f->get_vport_##field) && \ |
@@ -1008,11 +1018,12 @@ show_fc_vport_##field (struct class_device *cdev, char *buf) \ | |||
1008 | 1018 | ||
1009 | #define fc_vport_store_function(field) \ | 1019 | #define fc_vport_store_function(field) \ |
1010 | static ssize_t \ | 1020 | static ssize_t \ |
1011 | store_fc_vport_##field(struct class_device *cdev, const char *buf, \ | 1021 | store_fc_vport_##field(struct device *dev, \ |
1012 | size_t count) \ | 1022 | struct device_attribute *attr, \ |
1023 | const char *buf, size_t count) \ | ||
1013 | { \ | 1024 | { \ |
1014 | int val; \ | 1025 | int val; \ |
1015 | struct fc_vport *vport = transport_class_to_vport(cdev); \ | 1026 | struct fc_vport *vport = transport_class_to_vport(dev); \ |
1016 | struct Scsi_Host *shost = vport_to_shost(vport); \ | 1027 | struct Scsi_Host *shost = vport_to_shost(vport); \ |
1017 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1028 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1018 | char *cp; \ | 1029 | char *cp; \ |
@@ -1027,10 +1038,11 @@ store_fc_vport_##field(struct class_device *cdev, const char *buf, \ | |||
1027 | 1038 | ||
1028 | #define fc_vport_store_str_function(field, slen) \ | 1039 | #define fc_vport_store_str_function(field, slen) \ |
1029 | static ssize_t \ | 1040 | static ssize_t \ |
1030 | store_fc_vport_##field(struct class_device *cdev, const char *buf, \ | 1041 | store_fc_vport_##field(struct device *dev, \ |
1031 | size_t count) \ | 1042 | struct device_attribute *attr, \ |
1043 | const char *buf, size_t count) \ | ||
1032 | { \ | 1044 | { \ |
1033 | struct fc_vport *vport = transport_class_to_vport(cdev); \ | 1045 | struct fc_vport *vport = transport_class_to_vport(dev); \ |
1034 | struct Scsi_Host *shost = vport_to_shost(vport); \ | 1046 | struct Scsi_Host *shost = vport_to_shost(vport); \ |
1035 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1047 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1036 | unsigned int cnt=count; \ | 1048 | unsigned int cnt=count; \ |
@@ -1047,36 +1059,38 @@ store_fc_vport_##field(struct class_device *cdev, const char *buf, \ | |||
1047 | 1059 | ||
1048 | #define fc_vport_rd_attr(field, format_string, sz) \ | 1060 | #define fc_vport_rd_attr(field, format_string, sz) \ |
1049 | fc_vport_show_function(field, format_string, sz, ) \ | 1061 | fc_vport_show_function(field, format_string, sz, ) \ |
1050 | static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ | 1062 | static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ |
1051 | show_fc_vport_##field, NULL) | 1063 | show_fc_vport_##field, NULL) |
1052 | 1064 | ||
1053 | #define fc_vport_rd_attr_cast(field, format_string, sz, cast) \ | 1065 | #define fc_vport_rd_attr_cast(field, format_string, sz, cast) \ |
1054 | fc_vport_show_function(field, format_string, sz, (cast)) \ | 1066 | fc_vport_show_function(field, format_string, sz, (cast)) \ |
1055 | static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ | 1067 | static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ |
1056 | show_fc_vport_##field, NULL) | 1068 | show_fc_vport_##field, NULL) |
1057 | 1069 | ||
1058 | #define fc_vport_rw_attr(field, format_string, sz) \ | 1070 | #define fc_vport_rw_attr(field, format_string, sz) \ |
1059 | fc_vport_show_function(field, format_string, sz, ) \ | 1071 | fc_vport_show_function(field, format_string, sz, ) \ |
1060 | fc_vport_store_function(field) \ | 1072 | fc_vport_store_function(field) \ |
1061 | static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ | 1073 | static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ |
1062 | show_fc_vport_##field, \ | 1074 | show_fc_vport_##field, \ |
1063 | store_fc_vport_##field) | 1075 | store_fc_vport_##field) |
1064 | 1076 | ||
1065 | #define fc_private_vport_show_function(field, format_string, sz, cast) \ | 1077 | #define fc_private_vport_show_function(field, format_string, sz, cast) \ |
1066 | static ssize_t \ | 1078 | static ssize_t \ |
1067 | show_fc_vport_##field (struct class_device *cdev, char *buf) \ | 1079 | show_fc_vport_##field (struct device *dev, \ |
1080 | struct device_attribute *attr, char *buf) \ | ||
1068 | { \ | 1081 | { \ |
1069 | struct fc_vport *vport = transport_class_to_vport(cdev); \ | 1082 | struct fc_vport *vport = transport_class_to_vport(dev); \ |
1070 | return snprintf(buf, sz, format_string, cast vport->field); \ | 1083 | return snprintf(buf, sz, format_string, cast vport->field); \ |
1071 | } | 1084 | } |
1072 | 1085 | ||
1073 | #define fc_private_vport_store_u32_function(field) \ | 1086 | #define fc_private_vport_store_u32_function(field) \ |
1074 | static ssize_t \ | 1087 | static ssize_t \ |
1075 | store_fc_vport_##field(struct class_device *cdev, const char *buf, \ | 1088 | store_fc_vport_##field(struct device *dev, \ |
1076 | size_t count) \ | 1089 | struct device_attribute *attr, \ |
1090 | const char *buf, size_t count) \ | ||
1077 | { \ | 1091 | { \ |
1078 | u32 val; \ | 1092 | u32 val; \ |
1079 | struct fc_vport *vport = transport_class_to_vport(cdev); \ | 1093 | struct fc_vport *vport = transport_class_to_vport(dev); \ |
1080 | char *cp; \ | 1094 | char *cp; \ |
1081 | if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \ | 1095 | if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \ |
1082 | return -EBUSY; \ | 1096 | return -EBUSY; \ |
@@ -1090,39 +1104,41 @@ store_fc_vport_##field(struct class_device *cdev, const char *buf, \ | |||
1090 | 1104 | ||
1091 | #define fc_private_vport_rd_attr(field, format_string, sz) \ | 1105 | #define fc_private_vport_rd_attr(field, format_string, sz) \ |
1092 | fc_private_vport_show_function(field, format_string, sz, ) \ | 1106 | fc_private_vport_show_function(field, format_string, sz, ) \ |
1093 | static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ | 1107 | static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ |
1094 | show_fc_vport_##field, NULL) | 1108 | show_fc_vport_##field, NULL) |
1095 | 1109 | ||
1096 | #define fc_private_vport_rd_attr_cast(field, format_string, sz, cast) \ | 1110 | #define fc_private_vport_rd_attr_cast(field, format_string, sz, cast) \ |
1097 | fc_private_vport_show_function(field, format_string, sz, (cast)) \ | 1111 | fc_private_vport_show_function(field, format_string, sz, (cast)) \ |
1098 | static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ | 1112 | static FC_DEVICE_ATTR(vport, field, S_IRUGO, \ |
1099 | show_fc_vport_##field, NULL) | 1113 | show_fc_vport_##field, NULL) |
1100 | 1114 | ||
1101 | #define fc_private_vport_rw_u32_attr(field, format_string, sz) \ | 1115 | #define fc_private_vport_rw_u32_attr(field, format_string, sz) \ |
1102 | fc_private_vport_show_function(field, format_string, sz, ) \ | 1116 | fc_private_vport_show_function(field, format_string, sz, ) \ |
1103 | fc_private_vport_store_u32_function(field) \ | 1117 | fc_private_vport_store_u32_function(field) \ |
1104 | static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ | 1118 | static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ |
1105 | show_fc_vport_##field, \ | 1119 | show_fc_vport_##field, \ |
1106 | store_fc_vport_##field) | 1120 | store_fc_vport_##field) |
1107 | 1121 | ||
1108 | 1122 | ||
1109 | #define fc_private_vport_rd_enum_attr(title, maxlen) \ | 1123 | #define fc_private_vport_rd_enum_attr(title, maxlen) \ |
1110 | static ssize_t \ | 1124 | static ssize_t \ |
1111 | show_fc_vport_##title (struct class_device *cdev, char *buf) \ | 1125 | show_fc_vport_##title (struct device *dev, \ |
1126 | struct device_attribute *attr, \ | ||
1127 | char *buf) \ | ||
1112 | { \ | 1128 | { \ |
1113 | struct fc_vport *vport = transport_class_to_vport(cdev); \ | 1129 | struct fc_vport *vport = transport_class_to_vport(dev); \ |
1114 | const char *name; \ | 1130 | const char *name; \ |
1115 | name = get_fc_##title##_name(vport->title); \ | 1131 | name = get_fc_##title##_name(vport->title); \ |
1116 | if (!name) \ | 1132 | if (!name) \ |
1117 | return -EINVAL; \ | 1133 | return -EINVAL; \ |
1118 | return snprintf(buf, maxlen, "%s\n", name); \ | 1134 | return snprintf(buf, maxlen, "%s\n", name); \ |
1119 | } \ | 1135 | } \ |
1120 | static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \ | 1136 | static FC_DEVICE_ATTR(vport, title, S_IRUGO, \ |
1121 | show_fc_vport_##title, NULL) | 1137 | show_fc_vport_##title, NULL) |
1122 | 1138 | ||
1123 | 1139 | ||
1124 | #define SETUP_VPORT_ATTRIBUTE_RD(field) \ | 1140 | #define SETUP_VPORT_ATTRIBUTE_RD(field) \ |
1125 | i->private_vport_attrs[count] = class_device_attr_vport_##field; \ | 1141 | i->private_vport_attrs[count] = device_attr_vport_##field; \ |
1126 | i->private_vport_attrs[count].attr.mode = S_IRUGO; \ | 1142 | i->private_vport_attrs[count].attr.mode = S_IRUGO; \ |
1127 | i->private_vport_attrs[count].store = NULL; \ | 1143 | i->private_vport_attrs[count].store = NULL; \ |
1128 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ | 1144 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ |
@@ -1131,21 +1147,21 @@ static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \ | |||
1131 | /* NOTE: Above MACRO differs: checks function not show bit */ | 1147 | /* NOTE: Above MACRO differs: checks function not show bit */ |
1132 | 1148 | ||
1133 | #define SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(field) \ | 1149 | #define SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(field) \ |
1134 | i->private_vport_attrs[count] = class_device_attr_vport_##field; \ | 1150 | i->private_vport_attrs[count] = device_attr_vport_##field; \ |
1135 | i->private_vport_attrs[count].attr.mode = S_IRUGO; \ | 1151 | i->private_vport_attrs[count].attr.mode = S_IRUGO; \ |
1136 | i->private_vport_attrs[count].store = NULL; \ | 1152 | i->private_vport_attrs[count].store = NULL; \ |
1137 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ | 1153 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ |
1138 | count++ | 1154 | count++ |
1139 | 1155 | ||
1140 | #define SETUP_VPORT_ATTRIBUTE_WR(field) \ | 1156 | #define SETUP_VPORT_ATTRIBUTE_WR(field) \ |
1141 | i->private_vport_attrs[count] = class_device_attr_vport_##field; \ | 1157 | i->private_vport_attrs[count] = device_attr_vport_##field; \ |
1142 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ | 1158 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ |
1143 | if (i->f->field) \ | 1159 | if (i->f->field) \ |
1144 | count++ | 1160 | count++ |
1145 | /* NOTE: Above MACRO differs: checks function */ | 1161 | /* NOTE: Above MACRO differs: checks function */ |
1146 | 1162 | ||
1147 | #define SETUP_VPORT_ATTRIBUTE_RW(field) \ | 1163 | #define SETUP_VPORT_ATTRIBUTE_RW(field) \ |
1148 | i->private_vport_attrs[count] = class_device_attr_vport_##field; \ | 1164 | i->private_vport_attrs[count] = device_attr_vport_##field; \ |
1149 | if (!i->f->set_vport_##field) { \ | 1165 | if (!i->f->set_vport_##field) { \ |
1150 | i->private_vport_attrs[count].attr.mode = S_IRUGO; \ | 1166 | i->private_vport_attrs[count].attr.mode = S_IRUGO; \ |
1151 | i->private_vport_attrs[count].store = NULL; \ | 1167 | i->private_vport_attrs[count].store = NULL; \ |
@@ -1156,7 +1172,7 @@ static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \ | |||
1156 | 1172 | ||
1157 | #define SETUP_PRIVATE_VPORT_ATTRIBUTE_RW(field) \ | 1173 | #define SETUP_PRIVATE_VPORT_ATTRIBUTE_RW(field) \ |
1158 | { \ | 1174 | { \ |
1159 | i->private_vport_attrs[count] = class_device_attr_vport_##field; \ | 1175 | i->private_vport_attrs[count] = device_attr_vport_##field; \ |
1160 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ | 1176 | i->vport_attrs[count] = &i->private_vport_attrs[count]; \ |
1161 | count++; \ | 1177 | count++; \ |
1162 | } | 1178 | } |
@@ -1176,35 +1192,36 @@ fc_private_vport_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long); | |||
1176 | fc_private_vport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long); | 1192 | fc_private_vport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long); |
1177 | 1193 | ||
1178 | static ssize_t | 1194 | static ssize_t |
1179 | show_fc_vport_roles (struct class_device *cdev, char *buf) | 1195 | show_fc_vport_roles (struct device *dev, struct device_attribute *attr, |
1196 | char *buf) | ||
1180 | { | 1197 | { |
1181 | struct fc_vport *vport = transport_class_to_vport(cdev); | 1198 | struct fc_vport *vport = transport_class_to_vport(dev); |
1182 | 1199 | ||
1183 | if (vport->roles == FC_PORT_ROLE_UNKNOWN) | 1200 | if (vport->roles == FC_PORT_ROLE_UNKNOWN) |
1184 | return snprintf(buf, 20, "unknown\n"); | 1201 | return snprintf(buf, 20, "unknown\n"); |
1185 | return get_fc_port_roles_names(vport->roles, buf); | 1202 | return get_fc_port_roles_names(vport->roles, buf); |
1186 | } | 1203 | } |
1187 | static FC_CLASS_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL); | 1204 | static FC_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL); |
1188 | 1205 | ||
1189 | fc_private_vport_rd_enum_attr(vport_type, FC_PORTTYPE_MAX_NAMELEN); | 1206 | fc_private_vport_rd_enum_attr(vport_type, FC_PORTTYPE_MAX_NAMELEN); |
1190 | 1207 | ||
1191 | fc_private_vport_show_function(symbolic_name, "%s\n", | 1208 | fc_private_vport_show_function(symbolic_name, "%s\n", |
1192 | FC_VPORT_SYMBOLIC_NAMELEN + 1, ) | 1209 | FC_VPORT_SYMBOLIC_NAMELEN + 1, ) |
1193 | fc_vport_store_str_function(symbolic_name, FC_VPORT_SYMBOLIC_NAMELEN) | 1210 | fc_vport_store_str_function(symbolic_name, FC_VPORT_SYMBOLIC_NAMELEN) |
1194 | static FC_CLASS_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR, | 1211 | static FC_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR, |
1195 | show_fc_vport_symbolic_name, store_fc_vport_symbolic_name); | 1212 | show_fc_vport_symbolic_name, store_fc_vport_symbolic_name); |
1196 | 1213 | ||
1197 | static ssize_t | 1214 | static ssize_t |
1198 | store_fc_vport_delete(struct class_device *cdev, const char *buf, | 1215 | store_fc_vport_delete(struct device *dev, struct device_attribute *attr, |
1199 | size_t count) | 1216 | const char *buf, size_t count) |
1200 | { | 1217 | { |
1201 | struct fc_vport *vport = transport_class_to_vport(cdev); | 1218 | struct fc_vport *vport = transport_class_to_vport(dev); |
1202 | struct Scsi_Host *shost = vport_to_shost(vport); | 1219 | struct Scsi_Host *shost = vport_to_shost(vport); |
1203 | 1220 | ||
1204 | fc_queue_work(shost, &vport->vport_delete_work); | 1221 | fc_queue_work(shost, &vport->vport_delete_work); |
1205 | return count; | 1222 | return count; |
1206 | } | 1223 | } |
1207 | static FC_CLASS_DEVICE_ATTR(vport, vport_delete, S_IWUSR, | 1224 | static FC_DEVICE_ATTR(vport, vport_delete, S_IWUSR, |
1208 | NULL, store_fc_vport_delete); | 1225 | NULL, store_fc_vport_delete); |
1209 | 1226 | ||
1210 | 1227 | ||
@@ -1213,10 +1230,11 @@ static FC_CLASS_DEVICE_ATTR(vport, vport_delete, S_IWUSR, | |||
1213 | * Write "1" to disable, write "0" to enable | 1230 | * Write "1" to disable, write "0" to enable |
1214 | */ | 1231 | */ |
1215 | static ssize_t | 1232 | static ssize_t |
1216 | store_fc_vport_disable(struct class_device *cdev, const char *buf, | 1233 | store_fc_vport_disable(struct device *dev, struct device_attribute *attr, |
1234 | const char *buf, | ||
1217 | size_t count) | 1235 | size_t count) |
1218 | { | 1236 | { |
1219 | struct fc_vport *vport = transport_class_to_vport(cdev); | 1237 | struct fc_vport *vport = transport_class_to_vport(dev); |
1220 | struct Scsi_Host *shost = vport_to_shost(vport); | 1238 | struct Scsi_Host *shost = vport_to_shost(vport); |
1221 | struct fc_internal *i = to_fc_internal(shost->transportt); | 1239 | struct fc_internal *i = to_fc_internal(shost->transportt); |
1222 | int stat; | 1240 | int stat; |
@@ -1236,7 +1254,7 @@ store_fc_vport_disable(struct class_device *cdev, const char *buf, | |||
1236 | stat = i->f->vport_disable(vport, ((*buf == '0') ? false : true)); | 1254 | stat = i->f->vport_disable(vport, ((*buf == '0') ? false : true)); |
1237 | return stat ? stat : count; | 1255 | return stat ? stat : count; |
1238 | } | 1256 | } |
1239 | static FC_CLASS_DEVICE_ATTR(vport, vport_disable, S_IWUSR, | 1257 | static FC_DEVICE_ATTR(vport, vport_disable, S_IWUSR, |
1240 | NULL, store_fc_vport_disable); | 1258 | NULL, store_fc_vport_disable); |
1241 | 1259 | ||
1242 | 1260 | ||
@@ -1246,9 +1264,10 @@ static FC_CLASS_DEVICE_ATTR(vport, vport_disable, S_IWUSR, | |||
1246 | 1264 | ||
1247 | #define fc_host_show_function(field, format_string, sz, cast) \ | 1265 | #define fc_host_show_function(field, format_string, sz, cast) \ |
1248 | static ssize_t \ | 1266 | static ssize_t \ |
1249 | show_fc_host_##field (struct class_device *cdev, char *buf) \ | 1267 | show_fc_host_##field (struct device *dev, \ |
1268 | struct device_attribute *attr, char *buf) \ | ||
1250 | { \ | 1269 | { \ |
1251 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1270 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1252 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1271 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1253 | if (i->f->get_host_##field) \ | 1272 | if (i->f->get_host_##field) \ |
1254 | i->f->get_host_##field(shost); \ | 1273 | i->f->get_host_##field(shost); \ |
@@ -1257,11 +1276,12 @@ show_fc_host_##field (struct class_device *cdev, char *buf) \ | |||
1257 | 1276 | ||
1258 | #define fc_host_store_function(field) \ | 1277 | #define fc_host_store_function(field) \ |
1259 | static ssize_t \ | 1278 | static ssize_t \ |
1260 | store_fc_host_##field(struct class_device *cdev, const char *buf, \ | 1279 | store_fc_host_##field(struct device *dev, \ |
1261 | size_t count) \ | 1280 | struct device_attribute *attr, \ |
1281 | const char *buf, size_t count) \ | ||
1262 | { \ | 1282 | { \ |
1263 | int val; \ | 1283 | int val; \ |
1264 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1284 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1265 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1285 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1266 | char *cp; \ | 1286 | char *cp; \ |
1267 | \ | 1287 | \ |
@@ -1274,10 +1294,11 @@ store_fc_host_##field(struct class_device *cdev, const char *buf, \ | |||
1274 | 1294 | ||
1275 | #define fc_host_store_str_function(field, slen) \ | 1295 | #define fc_host_store_str_function(field, slen) \ |
1276 | static ssize_t \ | 1296 | static ssize_t \ |
1277 | store_fc_host_##field(struct class_device *cdev, const char *buf, \ | 1297 | store_fc_host_##field(struct device *dev, \ |
1278 | size_t count) \ | 1298 | struct device_attribute *attr, \ |
1299 | const char *buf, size_t count) \ | ||
1279 | { \ | 1300 | { \ |
1280 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1301 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1281 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1302 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1282 | unsigned int cnt=count; \ | 1303 | unsigned int cnt=count; \ |
1283 | \ | 1304 | \ |
@@ -1293,26 +1314,27 @@ store_fc_host_##field(struct class_device *cdev, const char *buf, \ | |||
1293 | 1314 | ||
1294 | #define fc_host_rd_attr(field, format_string, sz) \ | 1315 | #define fc_host_rd_attr(field, format_string, sz) \ |
1295 | fc_host_show_function(field, format_string, sz, ) \ | 1316 | fc_host_show_function(field, format_string, sz, ) \ |
1296 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | 1317 | static FC_DEVICE_ATTR(host, field, S_IRUGO, \ |
1297 | show_fc_host_##field, NULL) | 1318 | show_fc_host_##field, NULL) |
1298 | 1319 | ||
1299 | #define fc_host_rd_attr_cast(field, format_string, sz, cast) \ | 1320 | #define fc_host_rd_attr_cast(field, format_string, sz, cast) \ |
1300 | fc_host_show_function(field, format_string, sz, (cast)) \ | 1321 | fc_host_show_function(field, format_string, sz, (cast)) \ |
1301 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | 1322 | static FC_DEVICE_ATTR(host, field, S_IRUGO, \ |
1302 | show_fc_host_##field, NULL) | 1323 | show_fc_host_##field, NULL) |
1303 | 1324 | ||
1304 | #define fc_host_rw_attr(field, format_string, sz) \ | 1325 | #define fc_host_rw_attr(field, format_string, sz) \ |
1305 | fc_host_show_function(field, format_string, sz, ) \ | 1326 | fc_host_show_function(field, format_string, sz, ) \ |
1306 | fc_host_store_function(field) \ | 1327 | fc_host_store_function(field) \ |
1307 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \ | 1328 | static FC_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \ |
1308 | show_fc_host_##field, \ | 1329 | show_fc_host_##field, \ |
1309 | store_fc_host_##field) | 1330 | store_fc_host_##field) |
1310 | 1331 | ||
1311 | #define fc_host_rd_enum_attr(title, maxlen) \ | 1332 | #define fc_host_rd_enum_attr(title, maxlen) \ |
1312 | static ssize_t \ | 1333 | static ssize_t \ |
1313 | show_fc_host_##title (struct class_device *cdev, char *buf) \ | 1334 | show_fc_host_##title (struct device *dev, \ |
1335 | struct device_attribute *attr, char *buf) \ | ||
1314 | { \ | 1336 | { \ |
1315 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1337 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1316 | struct fc_internal *i = to_fc_internal(shost->transportt); \ | 1338 | struct fc_internal *i = to_fc_internal(shost->transportt); \ |
1317 | const char *name; \ | 1339 | const char *name; \ |
1318 | if (i->f->get_host_##title) \ | 1340 | if (i->f->get_host_##title) \ |
@@ -1322,10 +1344,10 @@ show_fc_host_##title (struct class_device *cdev, char *buf) \ | |||
1322 | return -EINVAL; \ | 1344 | return -EINVAL; \ |
1323 | return snprintf(buf, maxlen, "%s\n", name); \ | 1345 | return snprintf(buf, maxlen, "%s\n", name); \ |
1324 | } \ | 1346 | } \ |
1325 | static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) | 1347 | static FC_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) |
1326 | 1348 | ||
1327 | #define SETUP_HOST_ATTRIBUTE_RD(field) \ | 1349 | #define SETUP_HOST_ATTRIBUTE_RD(field) \ |
1328 | i->private_host_attrs[count] = class_device_attr_host_##field; \ | 1350 | i->private_host_attrs[count] = device_attr_host_##field; \ |
1329 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ | 1351 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ |
1330 | i->private_host_attrs[count].store = NULL; \ | 1352 | i->private_host_attrs[count].store = NULL; \ |
1331 | i->host_attrs[count] = &i->private_host_attrs[count]; \ | 1353 | i->host_attrs[count] = &i->private_host_attrs[count]; \ |
@@ -1333,14 +1355,14 @@ static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) | |||
1333 | count++ | 1355 | count++ |
1334 | 1356 | ||
1335 | #define SETUP_HOST_ATTRIBUTE_RD_NS(field) \ | 1357 | #define SETUP_HOST_ATTRIBUTE_RD_NS(field) \ |
1336 | i->private_host_attrs[count] = class_device_attr_host_##field; \ | 1358 | i->private_host_attrs[count] = device_attr_host_##field; \ |
1337 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ | 1359 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ |
1338 | i->private_host_attrs[count].store = NULL; \ | 1360 | i->private_host_attrs[count].store = NULL; \ |
1339 | i->host_attrs[count] = &i->private_host_attrs[count]; \ | 1361 | i->host_attrs[count] = &i->private_host_attrs[count]; \ |
1340 | count++ | 1362 | count++ |
1341 | 1363 | ||
1342 | #define SETUP_HOST_ATTRIBUTE_RW(field) \ | 1364 | #define SETUP_HOST_ATTRIBUTE_RW(field) \ |
1343 | i->private_host_attrs[count] = class_device_attr_host_##field; \ | 1365 | i->private_host_attrs[count] = device_attr_host_##field; \ |
1344 | if (!i->f->set_host_##field) { \ | 1366 | if (!i->f->set_host_##field) { \ |
1345 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ | 1367 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ |
1346 | i->private_host_attrs[count].store = NULL; \ | 1368 | i->private_host_attrs[count].store = NULL; \ |
@@ -1352,24 +1374,25 @@ static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) | |||
1352 | 1374 | ||
1353 | #define fc_private_host_show_function(field, format_string, sz, cast) \ | 1375 | #define fc_private_host_show_function(field, format_string, sz, cast) \ |
1354 | static ssize_t \ | 1376 | static ssize_t \ |
1355 | show_fc_host_##field (struct class_device *cdev, char *buf) \ | 1377 | show_fc_host_##field (struct device *dev, \ |
1378 | struct device_attribute *attr, char *buf) \ | ||
1356 | { \ | 1379 | { \ |
1357 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1380 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1358 | return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \ | 1381 | return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \ |
1359 | } | 1382 | } |
1360 | 1383 | ||
1361 | #define fc_private_host_rd_attr(field, format_string, sz) \ | 1384 | #define fc_private_host_rd_attr(field, format_string, sz) \ |
1362 | fc_private_host_show_function(field, format_string, sz, ) \ | 1385 | fc_private_host_show_function(field, format_string, sz, ) \ |
1363 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | 1386 | static FC_DEVICE_ATTR(host, field, S_IRUGO, \ |
1364 | show_fc_host_##field, NULL) | 1387 | show_fc_host_##field, NULL) |
1365 | 1388 | ||
1366 | #define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \ | 1389 | #define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \ |
1367 | fc_private_host_show_function(field, format_string, sz, (cast)) \ | 1390 | fc_private_host_show_function(field, format_string, sz, (cast)) \ |
1368 | static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | 1391 | static FC_DEVICE_ATTR(host, field, S_IRUGO, \ |
1369 | show_fc_host_##field, NULL) | 1392 | show_fc_host_##field, NULL) |
1370 | 1393 | ||
1371 | #define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \ | 1394 | #define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \ |
1372 | i->private_host_attrs[count] = class_device_attr_host_##field; \ | 1395 | i->private_host_attrs[count] = device_attr_host_##field; \ |
1373 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ | 1396 | i->private_host_attrs[count].attr.mode = S_IRUGO; \ |
1374 | i->private_host_attrs[count].store = NULL; \ | 1397 | i->private_host_attrs[count].store = NULL; \ |
1375 | i->host_attrs[count] = &i->private_host_attrs[count]; \ | 1398 | i->host_attrs[count] = &i->private_host_attrs[count]; \ |
@@ -1377,7 +1400,7 @@ static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | |||
1377 | 1400 | ||
1378 | #define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \ | 1401 | #define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \ |
1379 | { \ | 1402 | { \ |
1380 | i->private_host_attrs[count] = class_device_attr_host_##field; \ | 1403 | i->private_host_attrs[count] = device_attr_host_##field; \ |
1381 | i->host_attrs[count] = &i->private_host_attrs[count]; \ | 1404 | i->host_attrs[count] = &i->private_host_attrs[count]; \ |
1382 | count++; \ | 1405 | count++; \ |
1383 | } | 1406 | } |
@@ -1386,38 +1409,41 @@ static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ | |||
1386 | /* Fixed Host Attributes */ | 1409 | /* Fixed Host Attributes */ |
1387 | 1410 | ||
1388 | static ssize_t | 1411 | static ssize_t |
1389 | show_fc_host_supported_classes (struct class_device *cdev, char *buf) | 1412 | show_fc_host_supported_classes (struct device *dev, |
1413 | struct device_attribute *attr, char *buf) | ||
1390 | { | 1414 | { |
1391 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1415 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1392 | 1416 | ||
1393 | if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED) | 1417 | if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED) |
1394 | return snprintf(buf, 20, "unspecified\n"); | 1418 | return snprintf(buf, 20, "unspecified\n"); |
1395 | 1419 | ||
1396 | return get_fc_cos_names(fc_host_supported_classes(shost), buf); | 1420 | return get_fc_cos_names(fc_host_supported_classes(shost), buf); |
1397 | } | 1421 | } |
1398 | static FC_CLASS_DEVICE_ATTR(host, supported_classes, S_IRUGO, | 1422 | static FC_DEVICE_ATTR(host, supported_classes, S_IRUGO, |
1399 | show_fc_host_supported_classes, NULL); | 1423 | show_fc_host_supported_classes, NULL); |
1400 | 1424 | ||
1401 | static ssize_t | 1425 | static ssize_t |
1402 | show_fc_host_supported_fc4s (struct class_device *cdev, char *buf) | 1426 | show_fc_host_supported_fc4s (struct device *dev, |
1427 | struct device_attribute *attr, char *buf) | ||
1403 | { | 1428 | { |
1404 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1429 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1405 | return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost)); | 1430 | return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost)); |
1406 | } | 1431 | } |
1407 | static FC_CLASS_DEVICE_ATTR(host, supported_fc4s, S_IRUGO, | 1432 | static FC_DEVICE_ATTR(host, supported_fc4s, S_IRUGO, |
1408 | show_fc_host_supported_fc4s, NULL); | 1433 | show_fc_host_supported_fc4s, NULL); |
1409 | 1434 | ||
1410 | static ssize_t | 1435 | static ssize_t |
1411 | show_fc_host_supported_speeds (struct class_device *cdev, char *buf) | 1436 | show_fc_host_supported_speeds (struct device *dev, |
1437 | struct device_attribute *attr, char *buf) | ||
1412 | { | 1438 | { |
1413 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1439 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1414 | 1440 | ||
1415 | if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN) | 1441 | if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN) |
1416 | return snprintf(buf, 20, "unknown\n"); | 1442 | return snprintf(buf, 20, "unknown\n"); |
1417 | 1443 | ||
1418 | return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf); | 1444 | return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf); |
1419 | } | 1445 | } |
1420 | static FC_CLASS_DEVICE_ATTR(host, supported_speeds, S_IRUGO, | 1446 | static FC_DEVICE_ATTR(host, supported_speeds, S_IRUGO, |
1421 | show_fc_host_supported_speeds, NULL); | 1447 | show_fc_host_supported_speeds, NULL); |
1422 | 1448 | ||
1423 | 1449 | ||
@@ -1433,9 +1459,10 @@ fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1)); | |||
1433 | /* Dynamic Host Attributes */ | 1459 | /* Dynamic Host Attributes */ |
1434 | 1460 | ||
1435 | static ssize_t | 1461 | static ssize_t |
1436 | show_fc_host_active_fc4s (struct class_device *cdev, char *buf) | 1462 | show_fc_host_active_fc4s (struct device *dev, |
1463 | struct device_attribute *attr, char *buf) | ||
1437 | { | 1464 | { |
1438 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1465 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1439 | struct fc_internal *i = to_fc_internal(shost->transportt); | 1466 | struct fc_internal *i = to_fc_internal(shost->transportt); |
1440 | 1467 | ||
1441 | if (i->f->get_host_active_fc4s) | 1468 | if (i->f->get_host_active_fc4s) |
@@ -1443,13 +1470,14 @@ show_fc_host_active_fc4s (struct class_device *cdev, char *buf) | |||
1443 | 1470 | ||
1444 | return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost)); | 1471 | return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost)); |
1445 | } | 1472 | } |
1446 | static FC_CLASS_DEVICE_ATTR(host, active_fc4s, S_IRUGO, | 1473 | static FC_DEVICE_ATTR(host, active_fc4s, S_IRUGO, |
1447 | show_fc_host_active_fc4s, NULL); | 1474 | show_fc_host_active_fc4s, NULL); |
1448 | 1475 | ||
1449 | static ssize_t | 1476 | static ssize_t |
1450 | show_fc_host_speed (struct class_device *cdev, char *buf) | 1477 | show_fc_host_speed (struct device *dev, |
1478 | struct device_attribute *attr, char *buf) | ||
1451 | { | 1479 | { |
1452 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1480 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1453 | struct fc_internal *i = to_fc_internal(shost->transportt); | 1481 | struct fc_internal *i = to_fc_internal(shost->transportt); |
1454 | 1482 | ||
1455 | if (i->f->get_host_speed) | 1483 | if (i->f->get_host_speed) |
@@ -1460,7 +1488,7 @@ show_fc_host_speed (struct class_device *cdev, char *buf) | |||
1460 | 1488 | ||
1461 | return get_fc_port_speed_names(fc_host_speed(shost), buf); | 1489 | return get_fc_port_speed_names(fc_host_speed(shost), buf); |
1462 | } | 1490 | } |
1463 | static FC_CLASS_DEVICE_ATTR(host, speed, S_IRUGO, | 1491 | static FC_DEVICE_ATTR(host, speed, S_IRUGO, |
1464 | show_fc_host_speed, NULL); | 1492 | show_fc_host_speed, NULL); |
1465 | 1493 | ||
1466 | 1494 | ||
@@ -1473,16 +1501,17 @@ fc_host_rd_attr(symbolic_name, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1); | |||
1473 | fc_private_host_show_function(system_hostname, "%s\n", | 1501 | fc_private_host_show_function(system_hostname, "%s\n", |
1474 | FC_SYMBOLIC_NAME_SIZE + 1, ) | 1502 | FC_SYMBOLIC_NAME_SIZE + 1, ) |
1475 | fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE) | 1503 | fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE) |
1476 | static FC_CLASS_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR, | 1504 | static FC_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR, |
1477 | show_fc_host_system_hostname, store_fc_host_system_hostname); | 1505 | show_fc_host_system_hostname, store_fc_host_system_hostname); |
1478 | 1506 | ||
1479 | 1507 | ||
1480 | /* Private Host Attributes */ | 1508 | /* Private Host Attributes */ |
1481 | 1509 | ||
1482 | static ssize_t | 1510 | static ssize_t |
1483 | show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf) | 1511 | show_fc_private_host_tgtid_bind_type(struct device *dev, |
1512 | struct device_attribute *attr, char *buf) | ||
1484 | { | 1513 | { |
1485 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1514 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1486 | const char *name; | 1515 | const char *name; |
1487 | 1516 | ||
1488 | name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost)); | 1517 | name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost)); |
@@ -1495,10 +1524,10 @@ show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf) | |||
1495 | pos = list_entry((head)->next, typeof(*pos), member) | 1524 | pos = list_entry((head)->next, typeof(*pos), member) |
1496 | 1525 | ||
1497 | static ssize_t | 1526 | static ssize_t |
1498 | store_fc_private_host_tgtid_bind_type(struct class_device *cdev, | 1527 | store_fc_private_host_tgtid_bind_type(struct device *dev, |
1499 | const char *buf, size_t count) | 1528 | struct device_attribute *attr, const char *buf, size_t count) |
1500 | { | 1529 | { |
1501 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1530 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1502 | struct fc_rport *rport; | 1531 | struct fc_rport *rport; |
1503 | enum fc_tgtid_binding_type val; | 1532 | enum fc_tgtid_binding_type val; |
1504 | unsigned long flags; | 1533 | unsigned long flags; |
@@ -1523,15 +1552,15 @@ store_fc_private_host_tgtid_bind_type(struct class_device *cdev, | |||
1523 | return count; | 1552 | return count; |
1524 | } | 1553 | } |
1525 | 1554 | ||
1526 | static FC_CLASS_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR, | 1555 | static FC_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR, |
1527 | show_fc_private_host_tgtid_bind_type, | 1556 | show_fc_private_host_tgtid_bind_type, |
1528 | store_fc_private_host_tgtid_bind_type); | 1557 | store_fc_private_host_tgtid_bind_type); |
1529 | 1558 | ||
1530 | static ssize_t | 1559 | static ssize_t |
1531 | store_fc_private_host_issue_lip(struct class_device *cdev, | 1560 | store_fc_private_host_issue_lip(struct device *dev, |
1532 | const char *buf, size_t count) | 1561 | struct device_attribute *attr, const char *buf, size_t count) |
1533 | { | 1562 | { |
1534 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1563 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1535 | struct fc_internal *i = to_fc_internal(shost->transportt); | 1564 | struct fc_internal *i = to_fc_internal(shost->transportt); |
1536 | int ret; | 1565 | int ret; |
1537 | 1566 | ||
@@ -1544,7 +1573,7 @@ store_fc_private_host_issue_lip(struct class_device *cdev, | |||
1544 | return -ENOENT; | 1573 | return -ENOENT; |
1545 | } | 1574 | } |
1546 | 1575 | ||
1547 | static FC_CLASS_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL, | 1576 | static FC_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL, |
1548 | store_fc_private_host_issue_lip); | 1577 | store_fc_private_host_issue_lip); |
1549 | 1578 | ||
1550 | fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20); | 1579 | fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20); |
@@ -1556,9 +1585,9 @@ fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20); | |||
1556 | 1585 | ||
1557 | /* Show a given an attribute in the statistics group */ | 1586 | /* Show a given an attribute in the statistics group */ |
1558 | static ssize_t | 1587 | static ssize_t |
1559 | fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset) | 1588 | fc_stat_show(const struct device *dev, char *buf, unsigned long offset) |
1560 | { | 1589 | { |
1561 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1590 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1562 | struct fc_internal *i = to_fc_internal(shost->transportt); | 1591 | struct fc_internal *i = to_fc_internal(shost->transportt); |
1563 | struct fc_host_statistics *stats; | 1592 | struct fc_host_statistics *stats; |
1564 | ssize_t ret = -ENOENT; | 1593 | ssize_t ret = -ENOENT; |
@@ -1579,12 +1608,14 @@ fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset) | |||
1579 | 1608 | ||
1580 | /* generate a read-only statistics attribute */ | 1609 | /* generate a read-only statistics attribute */ |
1581 | #define fc_host_statistic(name) \ | 1610 | #define fc_host_statistic(name) \ |
1582 | static ssize_t show_fcstat_##name(struct class_device *cd, char *buf) \ | 1611 | static ssize_t show_fcstat_##name(struct device *cd, \ |
1612 | struct device_attribute *attr, \ | ||
1613 | char *buf) \ | ||
1583 | { \ | 1614 | { \ |
1584 | return fc_stat_show(cd, buf, \ | 1615 | return fc_stat_show(cd, buf, \ |
1585 | offsetof(struct fc_host_statistics, name)); \ | 1616 | offsetof(struct fc_host_statistics, name)); \ |
1586 | } \ | 1617 | } \ |
1587 | static FC_CLASS_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL) | 1618 | static FC_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL) |
1588 | 1619 | ||
1589 | fc_host_statistic(seconds_since_last_reset); | 1620 | fc_host_statistic(seconds_since_last_reset); |
1590 | fc_host_statistic(tx_frames); | 1621 | fc_host_statistic(tx_frames); |
@@ -1608,10 +1639,10 @@ fc_host_statistic(fcp_input_megabytes); | |||
1608 | fc_host_statistic(fcp_output_megabytes); | 1639 | fc_host_statistic(fcp_output_megabytes); |
1609 | 1640 | ||
1610 | static ssize_t | 1641 | static ssize_t |
1611 | fc_reset_statistics(struct class_device *cdev, const char *buf, | 1642 | fc_reset_statistics(struct device *dev, struct device_attribute *attr, |
1612 | size_t count) | 1643 | const char *buf, size_t count) |
1613 | { | 1644 | { |
1614 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1645 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1615 | struct fc_internal *i = to_fc_internal(shost->transportt); | 1646 | struct fc_internal *i = to_fc_internal(shost->transportt); |
1616 | 1647 | ||
1617 | /* ignore any data value written to the attribute */ | 1648 | /* ignore any data value written to the attribute */ |
@@ -1622,31 +1653,31 @@ fc_reset_statistics(struct class_device *cdev, const char *buf, | |||
1622 | 1653 | ||
1623 | return -ENOENT; | 1654 | return -ENOENT; |
1624 | } | 1655 | } |
1625 | static FC_CLASS_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL, | 1656 | static FC_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL, |
1626 | fc_reset_statistics); | 1657 | fc_reset_statistics); |
1627 | 1658 | ||
1628 | static struct attribute *fc_statistics_attrs[] = { | 1659 | static struct attribute *fc_statistics_attrs[] = { |
1629 | &class_device_attr_host_seconds_since_last_reset.attr, | 1660 | &device_attr_host_seconds_since_last_reset.attr, |
1630 | &class_device_attr_host_tx_frames.attr, | 1661 | &device_attr_host_tx_frames.attr, |
1631 | &class_device_attr_host_tx_words.attr, | 1662 | &device_attr_host_tx_words.attr, |
1632 | &class_device_attr_host_rx_frames.attr, | 1663 | &device_attr_host_rx_frames.attr, |
1633 | &class_device_attr_host_rx_words.attr, | 1664 | &device_attr_host_rx_words.attr, |
1634 | &class_device_attr_host_lip_count.attr, | 1665 | &device_attr_host_lip_count.attr, |
1635 | &class_device_attr_host_nos_count.attr, | 1666 | &device_attr_host_nos_count.attr, |
1636 | &class_device_attr_host_error_frames.attr, | 1667 | &device_attr_host_error_frames.attr, |
1637 | &class_device_attr_host_dumped_frames.attr, | 1668 | &device_attr_host_dumped_frames.attr, |
1638 | &class_device_attr_host_link_failure_count.attr, | 1669 | &device_attr_host_link_failure_count.attr, |
1639 | &class_device_attr_host_loss_of_sync_count.attr, | 1670 | &device_attr_host_loss_of_sync_count.attr, |
1640 | &class_device_attr_host_loss_of_signal_count.attr, | 1671 | &device_attr_host_loss_of_signal_count.attr, |
1641 | &class_device_attr_host_prim_seq_protocol_err_count.attr, | 1672 | &device_attr_host_prim_seq_protocol_err_count.attr, |
1642 | &class_device_attr_host_invalid_tx_word_count.attr, | 1673 | &device_attr_host_invalid_tx_word_count.attr, |
1643 | &class_device_attr_host_invalid_crc_count.attr, | 1674 | &device_attr_host_invalid_crc_count.attr, |
1644 | &class_device_attr_host_fcp_input_requests.attr, | 1675 | &device_attr_host_fcp_input_requests.attr, |
1645 | &class_device_attr_host_fcp_output_requests.attr, | 1676 | &device_attr_host_fcp_output_requests.attr, |
1646 | &class_device_attr_host_fcp_control_requests.attr, | 1677 | &device_attr_host_fcp_control_requests.attr, |
1647 | &class_device_attr_host_fcp_input_megabytes.attr, | 1678 | &device_attr_host_fcp_input_megabytes.attr, |
1648 | &class_device_attr_host_fcp_output_megabytes.attr, | 1679 | &device_attr_host_fcp_output_megabytes.attr, |
1649 | &class_device_attr_host_reset_statistics.attr, | 1680 | &device_attr_host_reset_statistics.attr, |
1650 | NULL | 1681 | NULL |
1651 | }; | 1682 | }; |
1652 | 1683 | ||
@@ -1695,10 +1726,10 @@ fc_parse_wwn(const char *ns, u64 *nm) | |||
1695 | * as hex characters, and may *not* contain any prefixes (e.g. 0x, x, etc) | 1726 | * as hex characters, and may *not* contain any prefixes (e.g. 0x, x, etc) |
1696 | */ | 1727 | */ |
1697 | static ssize_t | 1728 | static ssize_t |
1698 | store_fc_host_vport_create(struct class_device *cdev, const char *buf, | 1729 | store_fc_host_vport_create(struct device *dev, struct device_attribute *attr, |
1699 | size_t count) | 1730 | const char *buf, size_t count) |
1700 | { | 1731 | { |
1701 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1732 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1702 | struct fc_vport_identifiers vid; | 1733 | struct fc_vport_identifiers vid; |
1703 | struct fc_vport *vport; | 1734 | struct fc_vport *vport; |
1704 | unsigned int cnt=count; | 1735 | unsigned int cnt=count; |
@@ -1731,7 +1762,7 @@ store_fc_host_vport_create(struct class_device *cdev, const char *buf, | |||
1731 | stat = fc_vport_create(shost, 0, &shost->shost_gendev, &vid, &vport); | 1762 | stat = fc_vport_create(shost, 0, &shost->shost_gendev, &vid, &vport); |
1732 | return stat ? stat : count; | 1763 | return stat ? stat : count; |
1733 | } | 1764 | } |
1734 | static FC_CLASS_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL, | 1765 | static FC_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL, |
1735 | store_fc_host_vport_create); | 1766 | store_fc_host_vport_create); |
1736 | 1767 | ||
1737 | 1768 | ||
@@ -1742,10 +1773,10 @@ static FC_CLASS_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL, | |||
1742 | * any prefixes (e.g. 0x, x, etc) | 1773 | * any prefixes (e.g. 0x, x, etc) |
1743 | */ | 1774 | */ |
1744 | static ssize_t | 1775 | static ssize_t |
1745 | store_fc_host_vport_delete(struct class_device *cdev, const char *buf, | 1776 | store_fc_host_vport_delete(struct device *dev, struct device_attribute *attr, |
1746 | size_t count) | 1777 | const char *buf, size_t count) |
1747 | { | 1778 | { |
1748 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1779 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
1749 | struct fc_host_attrs *fc_host = shost_to_fc_host(shost); | 1780 | struct fc_host_attrs *fc_host = shost_to_fc_host(shost); |
1750 | struct fc_vport *vport; | 1781 | struct fc_vport *vport; |
1751 | u64 wwpn, wwnn; | 1782 | u64 wwpn, wwnn; |
@@ -1787,7 +1818,7 @@ store_fc_host_vport_delete(struct class_device *cdev, const char *buf, | |||
1787 | stat = fc_vport_terminate(vport); | 1818 | stat = fc_vport_terminate(vport); |
1788 | return stat ? stat : count; | 1819 | return stat ? stat : count; |
1789 | } | 1820 | } |
1790 | static FC_CLASS_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL, | 1821 | static FC_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL, |
1791 | store_fc_host_vport_delete); | 1822 | store_fc_host_vport_delete); |
1792 | 1823 | ||
1793 | 1824 | ||
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index ca7bb6f63bde..65d1737eb664 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -40,13 +40,13 @@ struct iscsi_internal { | |||
40 | struct scsi_transport_template t; | 40 | struct scsi_transport_template t; |
41 | struct iscsi_transport *iscsi_transport; | 41 | struct iscsi_transport *iscsi_transport; |
42 | struct list_head list; | 42 | struct list_head list; |
43 | struct class_device cdev; | 43 | struct device dev; |
44 | 44 | ||
45 | struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; | 45 | struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; |
46 | struct transport_container conn_cont; | 46 | struct transport_container conn_cont; |
47 | struct class_device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; | 47 | struct device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; |
48 | struct transport_container session_cont; | 48 | struct transport_container session_cont; |
49 | struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; | 49 | struct device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ | 52 | static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ |
@@ -63,12 +63,12 @@ static DEFINE_SPINLOCK(iscsi_transport_lock); | |||
63 | #define to_iscsi_internal(tmpl) \ | 63 | #define to_iscsi_internal(tmpl) \ |
64 | container_of(tmpl, struct iscsi_internal, t) | 64 | container_of(tmpl, struct iscsi_internal, t) |
65 | 65 | ||
66 | #define cdev_to_iscsi_internal(_cdev) \ | 66 | #define dev_to_iscsi_internal(_dev) \ |
67 | container_of(_cdev, struct iscsi_internal, cdev) | 67 | container_of(_dev, struct iscsi_internal, dev) |
68 | 68 | ||
69 | static void iscsi_transport_release(struct class_device *cdev) | 69 | static void iscsi_transport_release(struct device *dev) |
70 | { | 70 | { |
71 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); | 71 | struct iscsi_internal *priv = dev_to_iscsi_internal(dev); |
72 | kfree(priv); | 72 | kfree(priv); |
73 | } | 73 | } |
74 | 74 | ||
@@ -78,25 +78,27 @@ static void iscsi_transport_release(struct class_device *cdev) | |||
78 | */ | 78 | */ |
79 | static struct class iscsi_transport_class = { | 79 | static struct class iscsi_transport_class = { |
80 | .name = "iscsi_transport", | 80 | .name = "iscsi_transport", |
81 | .release = iscsi_transport_release, | 81 | .dev_release = iscsi_transport_release, |
82 | }; | 82 | }; |
83 | 83 | ||
84 | static ssize_t | 84 | static ssize_t |
85 | show_transport_handle(struct class_device *cdev, char *buf) | 85 | show_transport_handle(struct device *dev, struct device_attribute *attr, |
86 | char *buf) | ||
86 | { | 87 | { |
87 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); | 88 | struct iscsi_internal *priv = dev_to_iscsi_internal(dev); |
88 | return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); | 89 | return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); |
89 | } | 90 | } |
90 | static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); | 91 | static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); |
91 | 92 | ||
92 | #define show_transport_attr(name, format) \ | 93 | #define show_transport_attr(name, format) \ |
93 | static ssize_t \ | 94 | static ssize_t \ |
94 | show_transport_##name(struct class_device *cdev, char *buf) \ | 95 | show_transport_##name(struct device *dev, \ |
96 | struct device_attribute *attr,char *buf) \ | ||
95 | { \ | 97 | { \ |
96 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); \ | 98 | struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \ |
97 | return sprintf(buf, format"\n", priv->iscsi_transport->name); \ | 99 | return sprintf(buf, format"\n", priv->iscsi_transport->name); \ |
98 | } \ | 100 | } \ |
99 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); | 101 | static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); |
100 | 102 | ||
101 | show_transport_attr(caps, "0x%x"); | 103 | show_transport_attr(caps, "0x%x"); |
102 | show_transport_attr(max_lun, "%d"); | 104 | show_transport_attr(max_lun, "%d"); |
@@ -104,11 +106,11 @@ show_transport_attr(max_conn, "%d"); | |||
104 | show_transport_attr(max_cmd_len, "%d"); | 106 | show_transport_attr(max_cmd_len, "%d"); |
105 | 107 | ||
106 | static struct attribute *iscsi_transport_attrs[] = { | 108 | static struct attribute *iscsi_transport_attrs[] = { |
107 | &class_device_attr_handle.attr, | 109 | &dev_attr_handle.attr, |
108 | &class_device_attr_caps.attr, | 110 | &dev_attr_caps.attr, |
109 | &class_device_attr_max_lun.attr, | 111 | &dev_attr_max_lun.attr, |
110 | &class_device_attr_max_conn.attr, | 112 | &dev_attr_max_conn.attr, |
111 | &class_device_attr_max_cmd_len.attr, | 113 | &dev_attr_max_cmd_len.attr, |
112 | NULL, | 114 | NULL, |
113 | }; | 115 | }; |
114 | 116 | ||
@@ -119,7 +121,7 @@ static struct attribute_group iscsi_transport_group = { | |||
119 | 121 | ||
120 | 122 | ||
121 | static int iscsi_setup_host(struct transport_container *tc, struct device *dev, | 123 | static int iscsi_setup_host(struct transport_container *tc, struct device *dev, |
122 | struct class_device *cdev) | 124 | struct device *cdev) |
123 | { | 125 | { |
124 | struct Scsi_Host *shost = dev_to_shost(dev); | 126 | struct Scsi_Host *shost = dev_to_shost(dev); |
125 | struct iscsi_host *ihost = shost->shost_data; | 127 | struct iscsi_host *ihost = shost->shost_data; |
@@ -139,7 +141,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, | |||
139 | } | 141 | } |
140 | 142 | ||
141 | static int iscsi_remove_host(struct transport_container *tc, struct device *dev, | 143 | static int iscsi_remove_host(struct transport_container *tc, struct device *dev, |
142 | struct class_device *cdev) | 144 | struct device *cdev) |
143 | { | 145 | { |
144 | struct Scsi_Host *shost = dev_to_shost(dev); | 146 | struct Scsi_Host *shost = dev_to_shost(dev); |
145 | struct iscsi_host *ihost = shost->shost_data; | 147 | struct iscsi_host *ihost = shost->shost_data; |
@@ -1337,11 +1339,8 @@ iscsi_if_rx(struct sk_buff *skb) | |||
1337 | mutex_unlock(&rx_queue_mutex); | 1339 | mutex_unlock(&rx_queue_mutex); |
1338 | } | 1340 | } |
1339 | 1341 | ||
1340 | #define iscsi_cdev_to_conn(_cdev) \ | ||
1341 | iscsi_dev_to_conn(_cdev->dev) | ||
1342 | |||
1343 | #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ | 1342 | #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ |
1344 | struct class_device_attribute class_device_attr_##_prefix##_##_name = \ | 1343 | struct device_attribute dev_attr_##_prefix##_##_name = \ |
1345 | __ATTR(_name,_mode,_show,_store) | 1344 | __ATTR(_name,_mode,_show,_store) |
1346 | 1345 | ||
1347 | /* | 1346 | /* |
@@ -1349,9 +1348,10 @@ struct class_device_attribute class_device_attr_##_prefix##_##_name = \ | |||
1349 | */ | 1348 | */ |
1350 | #define iscsi_conn_attr_show(param) \ | 1349 | #define iscsi_conn_attr_show(param) \ |
1351 | static ssize_t \ | 1350 | static ssize_t \ |
1352 | show_conn_param_##param(struct class_device *cdev, char *buf) \ | 1351 | show_conn_param_##param(struct device *dev, \ |
1352 | struct device_attribute *attr, char *buf) \ | ||
1353 | { \ | 1353 | { \ |
1354 | struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ | 1354 | struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \ |
1355 | struct iscsi_transport *t = conn->transport; \ | 1355 | struct iscsi_transport *t = conn->transport; \ |
1356 | return t->get_conn_param(conn, param, buf); \ | 1356 | return t->get_conn_param(conn, param, buf); \ |
1357 | } | 1357 | } |
@@ -1375,17 +1375,16 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); | |||
1375 | iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); | 1375 | iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); |
1376 | iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); | 1376 | iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); |
1377 | 1377 | ||
1378 | #define iscsi_cdev_to_session(_cdev) \ | ||
1379 | iscsi_dev_to_session(_cdev->dev) | ||
1380 | |||
1381 | /* | 1378 | /* |
1382 | * iSCSI session attrs | 1379 | * iSCSI session attrs |
1383 | */ | 1380 | */ |
1384 | #define iscsi_session_attr_show(param, perm) \ | 1381 | #define iscsi_session_attr_show(param, perm) \ |
1385 | static ssize_t \ | 1382 | static ssize_t \ |
1386 | show_session_param_##param(struct class_device *cdev, char *buf) \ | 1383 | show_session_param_##param(struct device *dev, \ |
1384 | struct device_attribute *attr, char *buf) \ | ||
1387 | { \ | 1385 | { \ |
1388 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ | 1386 | struct iscsi_cls_session *session = \ |
1387 | iscsi_dev_to_session(dev->parent); \ | ||
1389 | struct iscsi_transport *t = session->transport; \ | 1388 | struct iscsi_transport *t = session->transport; \ |
1390 | \ | 1389 | \ |
1391 | if (perm && !capable(CAP_SYS_ADMIN)) \ | 1390 | if (perm && !capable(CAP_SYS_ADMIN)) \ |
@@ -1417,9 +1416,10 @@ iscsi_session_attr(abort_tmo, ISCSI_PARAM_ABORT_TMO, 0); | |||
1417 | iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); | 1416 | iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); |
1418 | 1417 | ||
1419 | static ssize_t | 1418 | static ssize_t |
1420 | show_priv_session_state(struct class_device *cdev, char *buf) | 1419 | show_priv_session_state(struct device *dev, struct device_attribute *attr, |
1420 | char *buf) | ||
1421 | { | 1421 | { |
1422 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); | 1422 | struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent); |
1423 | return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); | 1423 | return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); |
1424 | } | 1424 | } |
1425 | static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, | 1425 | static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, |
@@ -1427,9 +1427,11 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, | |||
1427 | 1427 | ||
1428 | #define iscsi_priv_session_attr_show(field, format) \ | 1428 | #define iscsi_priv_session_attr_show(field, format) \ |
1429 | static ssize_t \ | 1429 | static ssize_t \ |
1430 | show_priv_session_##field(struct class_device *cdev, char *buf) \ | 1430 | show_priv_session_##field(struct device *dev, \ |
1431 | struct device_attribute *attr, char *buf) \ | ||
1431 | { \ | 1432 | { \ |
1432 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\ | 1433 | struct iscsi_cls_session *session = \ |
1434 | iscsi_dev_to_session(dev->parent); \ | ||
1433 | return sprintf(buf, format"\n", session->field); \ | 1435 | return sprintf(buf, format"\n", session->field); \ |
1434 | } | 1436 | } |
1435 | 1437 | ||
@@ -1444,9 +1446,10 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); | |||
1444 | */ | 1446 | */ |
1445 | #define iscsi_host_attr_show(param) \ | 1447 | #define iscsi_host_attr_show(param) \ |
1446 | static ssize_t \ | 1448 | static ssize_t \ |
1447 | show_host_param_##param(struct class_device *cdev, char *buf) \ | 1449 | show_host_param_##param(struct device *dev, \ |
1450 | struct device_attribute *attr, char *buf) \ | ||
1448 | { \ | 1451 | { \ |
1449 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ | 1452 | struct Scsi_Host *shost = transport_class_to_shost(dev); \ |
1450 | struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ | 1453 | struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ |
1451 | return priv->iscsi_transport->get_host_param(shost, param, buf); \ | 1454 | return priv->iscsi_transport->get_host_param(shost, param, buf); \ |
1452 | } | 1455 | } |
@@ -1463,7 +1466,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); | |||
1463 | 1466 | ||
1464 | #define SETUP_PRIV_SESSION_RD_ATTR(field) \ | 1467 | #define SETUP_PRIV_SESSION_RD_ATTR(field) \ |
1465 | do { \ | 1468 | do { \ |
1466 | priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \ | 1469 | priv->session_attrs[count] = &dev_attr_priv_sess_##field; \ |
1467 | count++; \ | 1470 | count++; \ |
1468 | } while (0) | 1471 | } while (0) |
1469 | 1472 | ||
@@ -1471,7 +1474,7 @@ do { \ | |||
1471 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ | 1474 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ |
1472 | do { \ | 1475 | do { \ |
1473 | if (tt->param_mask & param_flag) { \ | 1476 | if (tt->param_mask & param_flag) { \ |
1474 | priv->session_attrs[count] = &class_device_attr_sess_##field; \ | 1477 | priv->session_attrs[count] = &dev_attr_sess_##field; \ |
1475 | count++; \ | 1478 | count++; \ |
1476 | } \ | 1479 | } \ |
1477 | } while (0) | 1480 | } while (0) |
@@ -1479,7 +1482,7 @@ do { \ | |||
1479 | #define SETUP_CONN_RD_ATTR(field, param_flag) \ | 1482 | #define SETUP_CONN_RD_ATTR(field, param_flag) \ |
1480 | do { \ | 1483 | do { \ |
1481 | if (tt->param_mask & param_flag) { \ | 1484 | if (tt->param_mask & param_flag) { \ |
1482 | priv->conn_attrs[count] = &class_device_attr_conn_##field; \ | 1485 | priv->conn_attrs[count] = &dev_attr_conn_##field; \ |
1483 | count++; \ | 1486 | count++; \ |
1484 | } \ | 1487 | } \ |
1485 | } while (0) | 1488 | } while (0) |
@@ -1487,7 +1490,7 @@ do { \ | |||
1487 | #define SETUP_HOST_RD_ATTR(field, param_flag) \ | 1490 | #define SETUP_HOST_RD_ATTR(field, param_flag) \ |
1488 | do { \ | 1491 | do { \ |
1489 | if (tt->host_param_mask & param_flag) { \ | 1492 | if (tt->host_param_mask & param_flag) { \ |
1490 | priv->host_attrs[count] = &class_device_attr_host_##field; \ | 1493 | priv->host_attrs[count] = &dev_attr_host_##field; \ |
1491 | count++; \ | 1494 | count++; \ |
1492 | } \ | 1495 | } \ |
1493 | } while (0) | 1496 | } while (0) |
@@ -1578,15 +1581,15 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
1578 | priv->iscsi_transport = tt; | 1581 | priv->iscsi_transport = tt; |
1579 | priv->t.user_scan = iscsi_user_scan; | 1582 | priv->t.user_scan = iscsi_user_scan; |
1580 | 1583 | ||
1581 | priv->cdev.class = &iscsi_transport_class; | 1584 | priv->dev.class = &iscsi_transport_class; |
1582 | snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name); | 1585 | snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name); |
1583 | err = class_device_register(&priv->cdev); | 1586 | err = device_register(&priv->dev); |
1584 | if (err) | 1587 | if (err) |
1585 | goto free_priv; | 1588 | goto free_priv; |
1586 | 1589 | ||
1587 | err = sysfs_create_group(&priv->cdev.kobj, &iscsi_transport_group); | 1590 | err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group); |
1588 | if (err) | 1591 | if (err) |
1589 | goto unregister_cdev; | 1592 | goto unregister_dev; |
1590 | 1593 | ||
1591 | /* host parameters */ | 1594 | /* host parameters */ |
1592 | priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; | 1595 | priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; |
@@ -1663,8 +1666,8 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
1663 | printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); | 1666 | printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); |
1664 | return &priv->t; | 1667 | return &priv->t; |
1665 | 1668 | ||
1666 | unregister_cdev: | 1669 | unregister_dev: |
1667 | class_device_unregister(&priv->cdev); | 1670 | device_unregister(&priv->dev); |
1668 | free_priv: | 1671 | free_priv: |
1669 | kfree(priv); | 1672 | kfree(priv); |
1670 | return NULL; | 1673 | return NULL; |
@@ -1691,8 +1694,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) | |||
1691 | transport_container_unregister(&priv->session_cont); | 1694 | transport_container_unregister(&priv->session_cont); |
1692 | transport_container_unregister(&priv->t.host_attrs); | 1695 | transport_container_unregister(&priv->t.host_attrs); |
1693 | 1696 | ||
1694 | sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); | 1697 | sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group); |
1695 | class_device_unregister(&priv->cdev); | 1698 | device_unregister(&priv->dev); |
1696 | mutex_unlock(&rx_queue_mutex); | 1699 | mutex_unlock(&rx_queue_mutex); |
1697 | 1700 | ||
1698 | return 0; | 1701 | return 0; |
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 43a964d635b4..27ec625ab771 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c | |||
@@ -53,8 +53,8 @@ struct sas_host_attrs { | |||
53 | /* | 53 | /* |
54 | * Hack to allow attributes of the same name in different objects. | 54 | * Hack to allow attributes of the same name in different objects. |
55 | */ | 55 | */ |
56 | #define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ | 56 | #define SAS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ |
57 | struct class_device_attribute class_device_attr_##_prefix##_##_name = \ | 57 | struct device_attribute dev_attr_##_prefix##_##_name = \ |
58 | __ATTR(_name,_mode,_show,_store) | 58 | __ATTR(_name,_mode,_show,_store) |
59 | 59 | ||
60 | 60 | ||
@@ -261,7 +261,7 @@ static void sas_bsg_remove(struct Scsi_Host *shost, struct sas_rphy *rphy) | |||
261 | */ | 261 | */ |
262 | 262 | ||
263 | static int sas_host_setup(struct transport_container *tc, struct device *dev, | 263 | static int sas_host_setup(struct transport_container *tc, struct device *dev, |
264 | struct class_device *cdev) | 264 | struct device *cdev) |
265 | { | 265 | { |
266 | struct Scsi_Host *shost = dev_to_shost(dev); | 266 | struct Scsi_Host *shost = dev_to_shost(dev); |
267 | struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); | 267 | struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); |
@@ -280,7 +280,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev, | |||
280 | } | 280 | } |
281 | 281 | ||
282 | static int sas_host_remove(struct transport_container *tc, struct device *dev, | 282 | static int sas_host_remove(struct transport_container *tc, struct device *dev, |
283 | struct class_device *cdev) | 283 | struct device *cdev) |
284 | { | 284 | { |
285 | struct Scsi_Host *shost = dev_to_shost(dev); | 285 | struct Scsi_Host *shost = dev_to_shost(dev); |
286 | 286 | ||
@@ -356,22 +356,24 @@ EXPORT_SYMBOL(sas_remove_host); | |||
356 | 356 | ||
357 | #define sas_phy_show_simple(field, name, format_string, cast) \ | 357 | #define sas_phy_show_simple(field, name, format_string, cast) \ |
358 | static ssize_t \ | 358 | static ssize_t \ |
359 | show_sas_phy_##name(struct class_device *cdev, char *buf) \ | 359 | show_sas_phy_##name(struct device *dev, \ |
360 | struct device_attribute *attr, char *buf) \ | ||
360 | { \ | 361 | { \ |
361 | struct sas_phy *phy = transport_class_to_phy(cdev); \ | 362 | struct sas_phy *phy = transport_class_to_phy(dev); \ |
362 | \ | 363 | \ |
363 | return snprintf(buf, 20, format_string, cast phy->field); \ | 364 | return snprintf(buf, 20, format_string, cast phy->field); \ |
364 | } | 365 | } |
365 | 366 | ||
366 | #define sas_phy_simple_attr(field, name, format_string, type) \ | 367 | #define sas_phy_simple_attr(field, name, format_string, type) \ |
367 | sas_phy_show_simple(field, name, format_string, (type)) \ | 368 | sas_phy_show_simple(field, name, format_string, (type)) \ |
368 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) | 369 | static DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) |
369 | 370 | ||
370 | #define sas_phy_show_protocol(field, name) \ | 371 | #define sas_phy_show_protocol(field, name) \ |
371 | static ssize_t \ | 372 | static ssize_t \ |
372 | show_sas_phy_##name(struct class_device *cdev, char *buf) \ | 373 | show_sas_phy_##name(struct device *dev, \ |
374 | struct device_attribute *attr, char *buf) \ | ||
373 | { \ | 375 | { \ |
374 | struct sas_phy *phy = transport_class_to_phy(cdev); \ | 376 | struct sas_phy *phy = transport_class_to_phy(dev); \ |
375 | \ | 377 | \ |
376 | if (!phy->field) \ | 378 | if (!phy->field) \ |
377 | return snprintf(buf, 20, "none\n"); \ | 379 | return snprintf(buf, 20, "none\n"); \ |
@@ -380,13 +382,14 @@ show_sas_phy_##name(struct class_device *cdev, char *buf) \ | |||
380 | 382 | ||
381 | #define sas_phy_protocol_attr(field, name) \ | 383 | #define sas_phy_protocol_attr(field, name) \ |
382 | sas_phy_show_protocol(field, name) \ | 384 | sas_phy_show_protocol(field, name) \ |
383 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) | 385 | static DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) |
384 | 386 | ||
385 | #define sas_phy_show_linkspeed(field) \ | 387 | #define sas_phy_show_linkspeed(field) \ |
386 | static ssize_t \ | 388 | static ssize_t \ |
387 | show_sas_phy_##field(struct class_device *cdev, char *buf) \ | 389 | show_sas_phy_##field(struct device *dev, \ |
390 | struct device_attribute *attr, char *buf) \ | ||
388 | { \ | 391 | { \ |
389 | struct sas_phy *phy = transport_class_to_phy(cdev); \ | 392 | struct sas_phy *phy = transport_class_to_phy(dev); \ |
390 | \ | 393 | \ |
391 | return get_sas_linkspeed_names(phy->field, buf); \ | 394 | return get_sas_linkspeed_names(phy->field, buf); \ |
392 | } | 395 | } |
@@ -394,10 +397,11 @@ show_sas_phy_##field(struct class_device *cdev, char *buf) \ | |||
394 | /* Fudge to tell if we're minimum or maximum */ | 397 | /* Fudge to tell if we're minimum or maximum */ |
395 | #define sas_phy_store_linkspeed(field) \ | 398 | #define sas_phy_store_linkspeed(field) \ |
396 | static ssize_t \ | 399 | static ssize_t \ |
397 | store_sas_phy_##field(struct class_device *cdev, const char *buf, \ | 400 | store_sas_phy_##field(struct device *dev, \ |
398 | size_t count) \ | 401 | struct device_attribute *attr, \ |
402 | const char *buf, size_t count) \ | ||
399 | { \ | 403 | { \ |
400 | struct sas_phy *phy = transport_class_to_phy(cdev); \ | 404 | struct sas_phy *phy = transport_class_to_phy(dev); \ |
401 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ | 405 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ |
402 | struct sas_internal *i = to_sas_internal(shost->transportt); \ | 406 | struct sas_internal *i = to_sas_internal(shost->transportt); \ |
403 | u32 value; \ | 407 | u32 value; \ |
@@ -416,19 +420,20 @@ store_sas_phy_##field(struct class_device *cdev, const char *buf, \ | |||
416 | #define sas_phy_linkspeed_rw_attr(field) \ | 420 | #define sas_phy_linkspeed_rw_attr(field) \ |
417 | sas_phy_show_linkspeed(field) \ | 421 | sas_phy_show_linkspeed(field) \ |
418 | sas_phy_store_linkspeed(field) \ | 422 | sas_phy_store_linkspeed(field) \ |
419 | static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, \ | 423 | static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, \ |
420 | store_sas_phy_##field) | 424 | store_sas_phy_##field) |
421 | 425 | ||
422 | #define sas_phy_linkspeed_attr(field) \ | 426 | #define sas_phy_linkspeed_attr(field) \ |
423 | sas_phy_show_linkspeed(field) \ | 427 | sas_phy_show_linkspeed(field) \ |
424 | static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) | 428 | static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) |
425 | 429 | ||
426 | 430 | ||
427 | #define sas_phy_show_linkerror(field) \ | 431 | #define sas_phy_show_linkerror(field) \ |
428 | static ssize_t \ | 432 | static ssize_t \ |
429 | show_sas_phy_##field(struct class_device *cdev, char *buf) \ | 433 | show_sas_phy_##field(struct device *dev, \ |
434 | struct device_attribute *attr, char *buf) \ | ||
430 | { \ | 435 | { \ |
431 | struct sas_phy *phy = transport_class_to_phy(cdev); \ | 436 | struct sas_phy *phy = transport_class_to_phy(dev); \ |
432 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ | 437 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ |
433 | struct sas_internal *i = to_sas_internal(shost->transportt); \ | 438 | struct sas_internal *i = to_sas_internal(shost->transportt); \ |
434 | int error; \ | 439 | int error; \ |
@@ -441,24 +446,25 @@ show_sas_phy_##field(struct class_device *cdev, char *buf) \ | |||
441 | 446 | ||
442 | #define sas_phy_linkerror_attr(field) \ | 447 | #define sas_phy_linkerror_attr(field) \ |
443 | sas_phy_show_linkerror(field) \ | 448 | sas_phy_show_linkerror(field) \ |
444 | static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) | 449 | static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) |
445 | 450 | ||
446 | 451 | ||
447 | static ssize_t | 452 | static ssize_t |
448 | show_sas_device_type(struct class_device *cdev, char *buf) | 453 | show_sas_device_type(struct device *dev, |
454 | struct device_attribute *attr, char *buf) | ||
449 | { | 455 | { |
450 | struct sas_phy *phy = transport_class_to_phy(cdev); | 456 | struct sas_phy *phy = transport_class_to_phy(dev); |
451 | 457 | ||
452 | if (!phy->identify.device_type) | 458 | if (!phy->identify.device_type) |
453 | return snprintf(buf, 20, "none\n"); | 459 | return snprintf(buf, 20, "none\n"); |
454 | return get_sas_device_type_names(phy->identify.device_type, buf); | 460 | return get_sas_device_type_names(phy->identify.device_type, buf); |
455 | } | 461 | } |
456 | static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); | 462 | static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); |
457 | 463 | ||
458 | static ssize_t do_sas_phy_enable(struct class_device *cdev, | 464 | static ssize_t do_sas_phy_enable(struct device *dev, |
459 | size_t count, int enable) | 465 | size_t count, int enable) |
460 | { | 466 | { |
461 | struct sas_phy *phy = transport_class_to_phy(cdev); | 467 | struct sas_phy *phy = transport_class_to_phy(dev); |
462 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); | 468 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); |
463 | struct sas_internal *i = to_sas_internal(shost->transportt); | 469 | struct sas_internal *i = to_sas_internal(shost->transportt); |
464 | int error; | 470 | int error; |
@@ -470,18 +476,19 @@ static ssize_t do_sas_phy_enable(struct class_device *cdev, | |||
470 | return count; | 476 | return count; |
471 | }; | 477 | }; |
472 | 478 | ||
473 | static ssize_t store_sas_phy_enable(struct class_device *cdev, | 479 | static ssize_t |
474 | const char *buf, size_t count) | 480 | store_sas_phy_enable(struct device *dev, struct device_attribute *attr, |
481 | const char *buf, size_t count) | ||
475 | { | 482 | { |
476 | if (count < 1) | 483 | if (count < 1) |
477 | return -EINVAL; | 484 | return -EINVAL; |
478 | 485 | ||
479 | switch (buf[0]) { | 486 | switch (buf[0]) { |
480 | case '0': | 487 | case '0': |
481 | do_sas_phy_enable(cdev, count, 0); | 488 | do_sas_phy_enable(dev, count, 0); |
482 | break; | 489 | break; |
483 | case '1': | 490 | case '1': |
484 | do_sas_phy_enable(cdev, count, 1); | 491 | do_sas_phy_enable(dev, count, 1); |
485 | break; | 492 | break; |
486 | default: | 493 | default: |
487 | return -EINVAL; | 494 | return -EINVAL; |
@@ -490,20 +497,22 @@ static ssize_t store_sas_phy_enable(struct class_device *cdev, | |||
490 | return count; | 497 | return count; |
491 | } | 498 | } |
492 | 499 | ||
493 | static ssize_t show_sas_phy_enable(struct class_device *cdev, char *buf) | 500 | static ssize_t |
501 | show_sas_phy_enable(struct device *dev, struct device_attribute *attr, | ||
502 | char *buf) | ||
494 | { | 503 | { |
495 | struct sas_phy *phy = transport_class_to_phy(cdev); | 504 | struct sas_phy *phy = transport_class_to_phy(dev); |
496 | 505 | ||
497 | return snprintf(buf, 20, "%d", phy->enabled); | 506 | return snprintf(buf, 20, "%d", phy->enabled); |
498 | } | 507 | } |
499 | 508 | ||
500 | static CLASS_DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, | 509 | static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, |
501 | store_sas_phy_enable); | 510 | store_sas_phy_enable); |
502 | 511 | ||
503 | static ssize_t do_sas_phy_reset(struct class_device *cdev, | 512 | static ssize_t |
504 | size_t count, int hard_reset) | 513 | do_sas_phy_reset(struct device *dev, size_t count, int hard_reset) |
505 | { | 514 | { |
506 | struct sas_phy *phy = transport_class_to_phy(cdev); | 515 | struct sas_phy *phy = transport_class_to_phy(dev); |
507 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); | 516 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); |
508 | struct sas_internal *i = to_sas_internal(shost->transportt); | 517 | struct sas_internal *i = to_sas_internal(shost->transportt); |
509 | int error; | 518 | int error; |
@@ -514,19 +523,21 @@ static ssize_t do_sas_phy_reset(struct class_device *cdev, | |||
514 | return count; | 523 | return count; |
515 | }; | 524 | }; |
516 | 525 | ||
517 | static ssize_t store_sas_link_reset(struct class_device *cdev, | 526 | static ssize_t |
518 | const char *buf, size_t count) | 527 | store_sas_link_reset(struct device *dev, struct device_attribute *attr, |
528 | const char *buf, size_t count) | ||
519 | { | 529 | { |
520 | return do_sas_phy_reset(cdev, count, 0); | 530 | return do_sas_phy_reset(dev, count, 0); |
521 | } | 531 | } |
522 | static CLASS_DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset); | 532 | static DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset); |
523 | 533 | ||
524 | static ssize_t store_sas_hard_reset(struct class_device *cdev, | 534 | static ssize_t |
525 | const char *buf, size_t count) | 535 | store_sas_hard_reset(struct device *dev, struct device_attribute *attr, |
536 | const char *buf, size_t count) | ||
526 | { | 537 | { |
527 | return do_sas_phy_reset(cdev, count, 1); | 538 | return do_sas_phy_reset(dev, count, 1); |
528 | } | 539 | } |
529 | static CLASS_DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset); | 540 | static DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset); |
530 | 541 | ||
531 | sas_phy_protocol_attr(identify.initiator_port_protocols, | 542 | sas_phy_protocol_attr(identify.initiator_port_protocols, |
532 | initiator_port_protocols); | 543 | initiator_port_protocols); |
@@ -695,16 +706,17 @@ EXPORT_SYMBOL(scsi_is_sas_phy); | |||
695 | */ | 706 | */ |
696 | #define sas_port_show_simple(field, name, format_string, cast) \ | 707 | #define sas_port_show_simple(field, name, format_string, cast) \ |
697 | static ssize_t \ | 708 | static ssize_t \ |
698 | show_sas_port_##name(struct class_device *cdev, char *buf) \ | 709 | show_sas_port_##name(struct device *dev, \ |
710 | struct device_attribute *attr, char *buf) \ | ||
699 | { \ | 711 | { \ |
700 | struct sas_port *port = transport_class_to_sas_port(cdev); \ | 712 | struct sas_port *port = transport_class_to_sas_port(dev); \ |
701 | \ | 713 | \ |
702 | return snprintf(buf, 20, format_string, cast port->field); \ | 714 | return snprintf(buf, 20, format_string, cast port->field); \ |
703 | } | 715 | } |
704 | 716 | ||
705 | #define sas_port_simple_attr(field, name, format_string, type) \ | 717 | #define sas_port_simple_attr(field, name, format_string, type) \ |
706 | sas_port_show_simple(field, name, format_string, (type)) \ | 718 | sas_port_show_simple(field, name, format_string, (type)) \ |
707 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL) | 719 | static DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL) |
708 | 720 | ||
709 | sas_port_simple_attr(num_phys, num_phys, "%d\n", int); | 721 | sas_port_simple_attr(num_phys, num_phys, "%d\n", int); |
710 | 722 | ||
@@ -1017,23 +1029,25 @@ EXPORT_SYMBOL(sas_port_mark_backlink); | |||
1017 | 1029 | ||
1018 | #define sas_rphy_show_simple(field, name, format_string, cast) \ | 1030 | #define sas_rphy_show_simple(field, name, format_string, cast) \ |
1019 | static ssize_t \ | 1031 | static ssize_t \ |
1020 | show_sas_rphy_##name(struct class_device *cdev, char *buf) \ | 1032 | show_sas_rphy_##name(struct device *dev, \ |
1033 | struct device_attribute *attr, char *buf) \ | ||
1021 | { \ | 1034 | { \ |
1022 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ | 1035 | struct sas_rphy *rphy = transport_class_to_rphy(dev); \ |
1023 | \ | 1036 | \ |
1024 | return snprintf(buf, 20, format_string, cast rphy->field); \ | 1037 | return snprintf(buf, 20, format_string, cast rphy->field); \ |
1025 | } | 1038 | } |
1026 | 1039 | ||
1027 | #define sas_rphy_simple_attr(field, name, format_string, type) \ | 1040 | #define sas_rphy_simple_attr(field, name, format_string, type) \ |
1028 | sas_rphy_show_simple(field, name, format_string, (type)) \ | 1041 | sas_rphy_show_simple(field, name, format_string, (type)) \ |
1029 | static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \ | 1042 | static SAS_DEVICE_ATTR(rphy, name, S_IRUGO, \ |
1030 | show_sas_rphy_##name, NULL) | 1043 | show_sas_rphy_##name, NULL) |
1031 | 1044 | ||
1032 | #define sas_rphy_show_protocol(field, name) \ | 1045 | #define sas_rphy_show_protocol(field, name) \ |
1033 | static ssize_t \ | 1046 | static ssize_t \ |
1034 | show_sas_rphy_##name(struct class_device *cdev, char *buf) \ | 1047 | show_sas_rphy_##name(struct device *dev, \ |
1048 | struct device_attribute *attr, char *buf) \ | ||
1035 | { \ | 1049 | { \ |
1036 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ | 1050 | struct sas_rphy *rphy = transport_class_to_rphy(dev); \ |
1037 | \ | 1051 | \ |
1038 | if (!rphy->field) \ | 1052 | if (!rphy->field) \ |
1039 | return snprintf(buf, 20, "none\n"); \ | 1053 | return snprintf(buf, 20, "none\n"); \ |
@@ -1042,13 +1056,14 @@ show_sas_rphy_##name(struct class_device *cdev, char *buf) \ | |||
1042 | 1056 | ||
1043 | #define sas_rphy_protocol_attr(field, name) \ | 1057 | #define sas_rphy_protocol_attr(field, name) \ |
1044 | sas_rphy_show_protocol(field, name) \ | 1058 | sas_rphy_show_protocol(field, name) \ |
1045 | static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \ | 1059 | static SAS_DEVICE_ATTR(rphy, name, S_IRUGO, \ |
1046 | show_sas_rphy_##name, NULL) | 1060 | show_sas_rphy_##name, NULL) |
1047 | 1061 | ||
1048 | static ssize_t | 1062 | static ssize_t |
1049 | show_sas_rphy_device_type(struct class_device *cdev, char *buf) | 1063 | show_sas_rphy_device_type(struct device *dev, |
1064 | struct device_attribute *attr, char *buf) | ||
1050 | { | 1065 | { |
1051 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); | 1066 | struct sas_rphy *rphy = transport_class_to_rphy(dev); |
1052 | 1067 | ||
1053 | if (!rphy->identify.device_type) | 1068 | if (!rphy->identify.device_type) |
1054 | return snprintf(buf, 20, "none\n"); | 1069 | return snprintf(buf, 20, "none\n"); |
@@ -1056,13 +1071,14 @@ show_sas_rphy_device_type(struct class_device *cdev, char *buf) | |||
1056 | rphy->identify.device_type, buf); | 1071 | rphy->identify.device_type, buf); |
1057 | } | 1072 | } |
1058 | 1073 | ||
1059 | static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO, | 1074 | static SAS_DEVICE_ATTR(rphy, device_type, S_IRUGO, |
1060 | show_sas_rphy_device_type, NULL); | 1075 | show_sas_rphy_device_type, NULL); |
1061 | 1076 | ||
1062 | static ssize_t | 1077 | static ssize_t |
1063 | show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf) | 1078 | show_sas_rphy_enclosure_identifier(struct device *dev, |
1079 | struct device_attribute *attr, char *buf) | ||
1064 | { | 1080 | { |
1065 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); | 1081 | struct sas_rphy *rphy = transport_class_to_rphy(dev); |
1066 | struct sas_phy *phy = dev_to_phy(rphy->dev.parent); | 1082 | struct sas_phy *phy = dev_to_phy(rphy->dev.parent); |
1067 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); | 1083 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); |
1068 | struct sas_internal *i = to_sas_internal(shost->transportt); | 1084 | struct sas_internal *i = to_sas_internal(shost->transportt); |
@@ -1082,13 +1098,14 @@ show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf) | |||
1082 | return sprintf(buf, "0x%llx\n", (unsigned long long)identifier); | 1098 | return sprintf(buf, "0x%llx\n", (unsigned long long)identifier); |
1083 | } | 1099 | } |
1084 | 1100 | ||
1085 | static SAS_CLASS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO, | 1101 | static SAS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO, |
1086 | show_sas_rphy_enclosure_identifier, NULL); | 1102 | show_sas_rphy_enclosure_identifier, NULL); |
1087 | 1103 | ||
1088 | static ssize_t | 1104 | static ssize_t |
1089 | show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf) | 1105 | show_sas_rphy_bay_identifier(struct device *dev, |
1106 | struct device_attribute *attr, char *buf) | ||
1090 | { | 1107 | { |
1091 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); | 1108 | struct sas_rphy *rphy = transport_class_to_rphy(dev); |
1092 | struct sas_phy *phy = dev_to_phy(rphy->dev.parent); | 1109 | struct sas_phy *phy = dev_to_phy(rphy->dev.parent); |
1093 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); | 1110 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); |
1094 | struct sas_internal *i = to_sas_internal(shost->transportt); | 1111 | struct sas_internal *i = to_sas_internal(shost->transportt); |
@@ -1103,7 +1120,7 @@ show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf) | |||
1103 | return sprintf(buf, "%d\n", val); | 1120 | return sprintf(buf, "%d\n", val); |
1104 | } | 1121 | } |
1105 | 1122 | ||
1106 | static SAS_CLASS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO, | 1123 | static SAS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO, |
1107 | show_sas_rphy_bay_identifier, NULL); | 1124 | show_sas_rphy_bay_identifier, NULL); |
1108 | 1125 | ||
1109 | sas_rphy_protocol_attr(identify.initiator_port_protocols, | 1126 | sas_rphy_protocol_attr(identify.initiator_port_protocols, |
@@ -1161,9 +1178,10 @@ static DECLARE_TRANSPORT_CLASS(sas_end_dev_class, | |||
1161 | 1178 | ||
1162 | #define sas_end_dev_show_simple(field, name, format_string, cast) \ | 1179 | #define sas_end_dev_show_simple(field, name, format_string, cast) \ |
1163 | static ssize_t \ | 1180 | static ssize_t \ |
1164 | show_sas_end_dev_##name(struct class_device *cdev, char *buf) \ | 1181 | show_sas_end_dev_##name(struct device *dev, \ |
1182 | struct device_attribute *attr, char *buf) \ | ||
1165 | { \ | 1183 | { \ |
1166 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ | 1184 | struct sas_rphy *rphy = transport_class_to_rphy(dev); \ |
1167 | struct sas_end_device *rdev = rphy_to_end_device(rphy); \ | 1185 | struct sas_end_device *rdev = rphy_to_end_device(rphy); \ |
1168 | \ | 1186 | \ |
1169 | return snprintf(buf, 20, format_string, cast rdev->field); \ | 1187 | return snprintf(buf, 20, format_string, cast rdev->field); \ |
@@ -1171,7 +1189,7 @@ show_sas_end_dev_##name(struct class_device *cdev, char *buf) \ | |||
1171 | 1189 | ||
1172 | #define sas_end_dev_simple_attr(field, name, format_string, type) \ | 1190 | #define sas_end_dev_simple_attr(field, name, format_string, type) \ |
1173 | sas_end_dev_show_simple(field, name, format_string, (type)) \ | 1191 | sas_end_dev_show_simple(field, name, format_string, (type)) \ |
1174 | static SAS_CLASS_DEVICE_ATTR(end_dev, name, S_IRUGO, \ | 1192 | static SAS_DEVICE_ATTR(end_dev, name, S_IRUGO, \ |
1175 | show_sas_end_dev_##name, NULL) | 1193 | show_sas_end_dev_##name, NULL) |
1176 | 1194 | ||
1177 | sas_end_dev_simple_attr(ready_led_meaning, ready_led_meaning, "%d\n", int); | 1195 | sas_end_dev_simple_attr(ready_led_meaning, ready_led_meaning, "%d\n", int); |
@@ -1185,9 +1203,10 @@ static DECLARE_TRANSPORT_CLASS(sas_expander_class, | |||
1185 | 1203 | ||
1186 | #define sas_expander_show_simple(field, name, format_string, cast) \ | 1204 | #define sas_expander_show_simple(field, name, format_string, cast) \ |
1187 | static ssize_t \ | 1205 | static ssize_t \ |
1188 | show_sas_expander_##name(struct class_device *cdev, char *buf) \ | 1206 | show_sas_expander_##name(struct device *dev, \ |
1207 | struct device_attribute *attr, char *buf) \ | ||
1189 | { \ | 1208 | { \ |
1190 | struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ | 1209 | struct sas_rphy *rphy = transport_class_to_rphy(dev); \ |
1191 | struct sas_expander_device *edev = rphy_to_expander_device(rphy); \ | 1210 | struct sas_expander_device *edev = rphy_to_expander_device(rphy); \ |
1192 | \ | 1211 | \ |
1193 | return snprintf(buf, 20, format_string, cast edev->field); \ | 1212 | return snprintf(buf, 20, format_string, cast edev->field); \ |
@@ -1195,7 +1214,7 @@ show_sas_expander_##name(struct class_device *cdev, char *buf) \ | |||
1195 | 1214 | ||
1196 | #define sas_expander_simple_attr(field, name, format_string, type) \ | 1215 | #define sas_expander_simple_attr(field, name, format_string, type) \ |
1197 | sas_expander_show_simple(field, name, format_string, (type)) \ | 1216 | sas_expander_show_simple(field, name, format_string, (type)) \ |
1198 | static SAS_CLASS_DEVICE_ATTR(expander, name, S_IRUGO, \ | 1217 | static SAS_DEVICE_ATTR(expander, name, S_IRUGO, \ |
1199 | show_sas_expander_##name, NULL) | 1218 | show_sas_expander_##name, NULL) |
1200 | 1219 | ||
1201 | sas_expander_simple_attr(vendor_id, vendor_id, "%s\n", char *); | 1220 | sas_expander_simple_attr(vendor_id, vendor_id, "%s\n", char *); |
@@ -1554,14 +1573,14 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel, | |||
1554 | */ | 1573 | */ |
1555 | 1574 | ||
1556 | #define SETUP_TEMPLATE(attrb, field, perm, test) \ | 1575 | #define SETUP_TEMPLATE(attrb, field, perm, test) \ |
1557 | i->private_##attrb[count] = class_device_attr_##field; \ | 1576 | i->private_##attrb[count] = dev_attr_##field; \ |
1558 | i->private_##attrb[count].attr.mode = perm; \ | 1577 | i->private_##attrb[count].attr.mode = perm; \ |
1559 | i->attrb[count] = &i->private_##attrb[count]; \ | 1578 | i->attrb[count] = &i->private_##attrb[count]; \ |
1560 | if (test) \ | 1579 | if (test) \ |
1561 | count++ | 1580 | count++ |
1562 | 1581 | ||
1563 | #define SETUP_TEMPLATE_RW(attrb, field, perm, test, ro_test, ro_perm) \ | 1582 | #define SETUP_TEMPLATE_RW(attrb, field, perm, test, ro_test, ro_perm) \ |
1564 | i->private_##attrb[count] = class_device_attr_##field; \ | 1583 | i->private_##attrb[count] = dev_attr_##field; \ |
1565 | i->private_##attrb[count].attr.mode = perm; \ | 1584 | i->private_##attrb[count].attr.mode = perm; \ |
1566 | if (ro_test) { \ | 1585 | if (ro_test) { \ |
1567 | i->private_##attrb[count].attr.mode = ro_perm; \ | 1586 | i->private_##attrb[count].attr.mode = ro_perm; \ |
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 1fb60313a516..bc12b5d5d676 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c | |||
@@ -158,7 +158,7 @@ static inline enum spi_signal_type spi_signal_to_value(const char *name) | |||
158 | } | 158 | } |
159 | 159 | ||
160 | static int spi_host_setup(struct transport_container *tc, struct device *dev, | 160 | static int spi_host_setup(struct transport_container *tc, struct device *dev, |
161 | struct class_device *cdev) | 161 | struct device *cdev) |
162 | { | 162 | { |
163 | struct Scsi_Host *shost = dev_to_shost(dev); | 163 | struct Scsi_Host *shost = dev_to_shost(dev); |
164 | 164 | ||
@@ -169,7 +169,7 @@ static int spi_host_setup(struct transport_container *tc, struct device *dev, | |||
169 | 169 | ||
170 | static int spi_host_configure(struct transport_container *tc, | 170 | static int spi_host_configure(struct transport_container *tc, |
171 | struct device *dev, | 171 | struct device *dev, |
172 | struct class_device *cdev); | 172 | struct device *cdev); |
173 | 173 | ||
174 | static DECLARE_TRANSPORT_CLASS(spi_host_class, | 174 | static DECLARE_TRANSPORT_CLASS(spi_host_class, |
175 | "spi_host", | 175 | "spi_host", |
@@ -195,11 +195,11 @@ static int spi_host_match(struct attribute_container *cont, | |||
195 | 195 | ||
196 | static int spi_target_configure(struct transport_container *tc, | 196 | static int spi_target_configure(struct transport_container *tc, |
197 | struct device *dev, | 197 | struct device *dev, |
198 | struct class_device *cdev); | 198 | struct device *cdev); |
199 | 199 | ||
200 | static int spi_device_configure(struct transport_container *tc, | 200 | static int spi_device_configure(struct transport_container *tc, |
201 | struct device *dev, | 201 | struct device *dev, |
202 | struct class_device *cdev) | 202 | struct device *cdev) |
203 | { | 203 | { |
204 | struct scsi_device *sdev = to_scsi_device(dev); | 204 | struct scsi_device *sdev = to_scsi_device(dev); |
205 | struct scsi_target *starget = sdev->sdev_target; | 205 | struct scsi_target *starget = sdev->sdev_target; |
@@ -219,7 +219,7 @@ static int spi_device_configure(struct transport_container *tc, | |||
219 | 219 | ||
220 | static int spi_setup_transport_attrs(struct transport_container *tc, | 220 | static int spi_setup_transport_attrs(struct transport_container *tc, |
221 | struct device *dev, | 221 | struct device *dev, |
222 | struct class_device *cdev) | 222 | struct device *cdev) |
223 | { | 223 | { |
224 | struct scsi_target *starget = to_scsi_target(dev); | 224 | struct scsi_target *starget = to_scsi_target(dev); |
225 | 225 | ||
@@ -248,9 +248,10 @@ static int spi_setup_transport_attrs(struct transport_container *tc, | |||
248 | #define spi_transport_show_simple(field, format_string) \ | 248 | #define spi_transport_show_simple(field, format_string) \ |
249 | \ | 249 | \ |
250 | static ssize_t \ | 250 | static ssize_t \ |
251 | show_spi_transport_##field(struct class_device *cdev, char *buf) \ | 251 | show_spi_transport_##field(struct device *dev, \ |
252 | struct device_attribute *attr, char *buf) \ | ||
252 | { \ | 253 | { \ |
253 | struct scsi_target *starget = transport_class_to_starget(cdev); \ | 254 | struct scsi_target *starget = transport_class_to_starget(dev); \ |
254 | struct spi_transport_attrs *tp; \ | 255 | struct spi_transport_attrs *tp; \ |
255 | \ | 256 | \ |
256 | tp = (struct spi_transport_attrs *)&starget->starget_data; \ | 257 | tp = (struct spi_transport_attrs *)&starget->starget_data; \ |
@@ -260,11 +261,12 @@ show_spi_transport_##field(struct class_device *cdev, char *buf) \ | |||
260 | #define spi_transport_store_simple(field, format_string) \ | 261 | #define spi_transport_store_simple(field, format_string) \ |
261 | \ | 262 | \ |
262 | static ssize_t \ | 263 | static ssize_t \ |
263 | store_spi_transport_##field(struct class_device *cdev, const char *buf, \ | 264 | store_spi_transport_##field(struct device *dev, \ |
264 | size_t count) \ | 265 | struct device_attribute *attr, \ |
266 | const char *buf, size_t count) \ | ||
265 | { \ | 267 | { \ |
266 | int val; \ | 268 | int val; \ |
267 | struct scsi_target *starget = transport_class_to_starget(cdev); \ | 269 | struct scsi_target *starget = transport_class_to_starget(dev); \ |
268 | struct spi_transport_attrs *tp; \ | 270 | struct spi_transport_attrs *tp; \ |
269 | \ | 271 | \ |
270 | tp = (struct spi_transport_attrs *)&starget->starget_data; \ | 272 | tp = (struct spi_transport_attrs *)&starget->starget_data; \ |
@@ -276,9 +278,10 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \ | |||
276 | #define spi_transport_show_function(field, format_string) \ | 278 | #define spi_transport_show_function(field, format_string) \ |
277 | \ | 279 | \ |
278 | static ssize_t \ | 280 | static ssize_t \ |
279 | show_spi_transport_##field(struct class_device *cdev, char *buf) \ | 281 | show_spi_transport_##field(struct device *dev, \ |
282 | struct device_attribute *attr, char *buf) \ | ||
280 | { \ | 283 | { \ |
281 | struct scsi_target *starget = transport_class_to_starget(cdev); \ | 284 | struct scsi_target *starget = transport_class_to_starget(dev); \ |
282 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ | 285 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ |
283 | struct spi_transport_attrs *tp; \ | 286 | struct spi_transport_attrs *tp; \ |
284 | struct spi_internal *i = to_spi_internal(shost->transportt); \ | 287 | struct spi_internal *i = to_spi_internal(shost->transportt); \ |
@@ -290,11 +293,12 @@ show_spi_transport_##field(struct class_device *cdev, char *buf) \ | |||
290 | 293 | ||
291 | #define spi_transport_store_function(field, format_string) \ | 294 | #define spi_transport_store_function(field, format_string) \ |
292 | static ssize_t \ | 295 | static ssize_t \ |
293 | store_spi_transport_##field(struct class_device *cdev, const char *buf, \ | 296 | store_spi_transport_##field(struct device *dev, \ |
294 | size_t count) \ | 297 | struct device_attribute *attr, \ |
298 | const char *buf, size_t count) \ | ||
295 | { \ | 299 | { \ |
296 | int val; \ | 300 | int val; \ |
297 | struct scsi_target *starget = transport_class_to_starget(cdev); \ | 301 | struct scsi_target *starget = transport_class_to_starget(dev); \ |
298 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ | 302 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ |
299 | struct spi_internal *i = to_spi_internal(shost->transportt); \ | 303 | struct spi_internal *i = to_spi_internal(shost->transportt); \ |
300 | \ | 304 | \ |
@@ -307,11 +311,12 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \ | |||
307 | 311 | ||
308 | #define spi_transport_store_max(field, format_string) \ | 312 | #define spi_transport_store_max(field, format_string) \ |
309 | static ssize_t \ | 313 | static ssize_t \ |
310 | store_spi_transport_##field(struct class_device *cdev, const char *buf, \ | 314 | store_spi_transport_##field(struct device *dev, \ |
311 | size_t count) \ | 315 | struct device_attribute *attr, \ |
316 | const char *buf, size_t count) \ | ||
312 | { \ | 317 | { \ |
313 | int val; \ | 318 | int val; \ |
314 | struct scsi_target *starget = transport_class_to_starget(cdev); \ | 319 | struct scsi_target *starget = transport_class_to_starget(dev); \ |
315 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ | 320 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ |
316 | struct spi_internal *i = to_spi_internal(shost->transportt); \ | 321 | struct spi_internal *i = to_spi_internal(shost->transportt); \ |
317 | struct spi_transport_attrs *tp \ | 322 | struct spi_transport_attrs *tp \ |
@@ -329,24 +334,24 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \ | |||
329 | #define spi_transport_rd_attr(field, format_string) \ | 334 | #define spi_transport_rd_attr(field, format_string) \ |
330 | spi_transport_show_function(field, format_string) \ | 335 | spi_transport_show_function(field, format_string) \ |
331 | spi_transport_store_function(field, format_string) \ | 336 | spi_transport_store_function(field, format_string) \ |
332 | static CLASS_DEVICE_ATTR(field, S_IRUGO, \ | 337 | static DEVICE_ATTR(field, S_IRUGO, \ |
333 | show_spi_transport_##field, \ | 338 | show_spi_transport_##field, \ |
334 | store_spi_transport_##field); | 339 | store_spi_transport_##field); |
335 | 340 | ||
336 | #define spi_transport_simple_attr(field, format_string) \ | 341 | #define spi_transport_simple_attr(field, format_string) \ |
337 | spi_transport_show_simple(field, format_string) \ | 342 | spi_transport_show_simple(field, format_string) \ |
338 | spi_transport_store_simple(field, format_string) \ | 343 | spi_transport_store_simple(field, format_string) \ |
339 | static CLASS_DEVICE_ATTR(field, S_IRUGO, \ | 344 | static DEVICE_ATTR(field, S_IRUGO, \ |
340 | show_spi_transport_##field, \ | 345 | show_spi_transport_##field, \ |
341 | store_spi_transport_##field); | 346 | store_spi_transport_##field); |
342 | 347 | ||
343 | #define spi_transport_max_attr(field, format_string) \ | 348 | #define spi_transport_max_attr(field, format_string) \ |
344 | spi_transport_show_function(field, format_string) \ | 349 | spi_transport_show_function(field, format_string) \ |
345 | spi_transport_store_max(field, format_string) \ | 350 | spi_transport_store_max(field, format_string) \ |
346 | spi_transport_simple_attr(max_##field, format_string) \ | 351 | spi_transport_simple_attr(max_##field, format_string) \ |
347 | static CLASS_DEVICE_ATTR(field, S_IRUGO, \ | 352 | static DEVICE_ATTR(field, S_IRUGO, \ |
348 | show_spi_transport_##field, \ | 353 | show_spi_transport_##field, \ |
349 | store_spi_transport_##field); | 354 | store_spi_transport_##field); |
350 | 355 | ||
351 | /* The Parallel SCSI Tranport Attributes: */ | 356 | /* The Parallel SCSI Tranport Attributes: */ |
352 | spi_transport_max_attr(offset, "%d\n"); | 357 | spi_transport_max_attr(offset, "%d\n"); |
@@ -370,14 +375,15 @@ static int child_iter(struct device *dev, void *data) | |||
370 | } | 375 | } |
371 | 376 | ||
372 | static ssize_t | 377 | static ssize_t |
373 | store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count) | 378 | store_spi_revalidate(struct device *dev, struct device_attribute *attr, |
379 | const char *buf, size_t count) | ||
374 | { | 380 | { |
375 | struct scsi_target *starget = transport_class_to_starget(cdev); | 381 | struct scsi_target *starget = transport_class_to_starget(dev); |
376 | 382 | ||
377 | device_for_each_child(&starget->dev, NULL, child_iter); | 383 | device_for_each_child(&starget->dev, NULL, child_iter); |
378 | return count; | 384 | return count; |
379 | } | 385 | } |
380 | static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); | 386 | static DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); |
381 | 387 | ||
382 | /* Translate the period into ns according to the current spec | 388 | /* Translate the period into ns according to the current spec |
383 | * for SDTR/PPR messages */ | 389 | * for SDTR/PPR messages */ |
@@ -412,7 +418,7 @@ show_spi_transport_period_helper(char *buf, int period) | |||
412 | } | 418 | } |
413 | 419 | ||
414 | static ssize_t | 420 | static ssize_t |
415 | store_spi_transport_period_helper(struct class_device *cdev, const char *buf, | 421 | store_spi_transport_period_helper(struct device *dev, const char *buf, |
416 | size_t count, int *periodp) | 422 | size_t count, int *periodp) |
417 | { | 423 | { |
418 | int j, picosec, period = -1; | 424 | int j, picosec, period = -1; |
@@ -449,9 +455,10 @@ store_spi_transport_period_helper(struct class_device *cdev, const char *buf, | |||
449 | } | 455 | } |
450 | 456 | ||
451 | static ssize_t | 457 | static ssize_t |
452 | show_spi_transport_period(struct class_device *cdev, char *buf) | 458 | show_spi_transport_period(struct device *dev, |
459 | struct device_attribute *attr, char *buf) | ||
453 | { | 460 | { |
454 | struct scsi_target *starget = transport_class_to_starget(cdev); | 461 | struct scsi_target *starget = transport_class_to_starget(dev); |
455 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 462 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
456 | struct spi_internal *i = to_spi_internal(shost->transportt); | 463 | struct spi_internal *i = to_spi_internal(shost->transportt); |
457 | struct spi_transport_attrs *tp = | 464 | struct spi_transport_attrs *tp = |
@@ -464,8 +471,8 @@ show_spi_transport_period(struct class_device *cdev, char *buf) | |||
464 | } | 471 | } |
465 | 472 | ||
466 | static ssize_t | 473 | static ssize_t |
467 | store_spi_transport_period(struct class_device *cdev, const char *buf, | 474 | store_spi_transport_period(struct device *cdev, struct device_attribute *attr, |
468 | size_t count) | 475 | const char *buf, size_t count) |
469 | { | 476 | { |
470 | struct scsi_target *starget = transport_class_to_starget(cdev); | 477 | struct scsi_target *starget = transport_class_to_starget(cdev); |
471 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 478 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -487,12 +494,13 @@ store_spi_transport_period(struct class_device *cdev, const char *buf, | |||
487 | return retval; | 494 | return retval; |
488 | } | 495 | } |
489 | 496 | ||
490 | static CLASS_DEVICE_ATTR(period, S_IRUGO, | 497 | static DEVICE_ATTR(period, S_IRUGO, |
491 | show_spi_transport_period, | 498 | show_spi_transport_period, |
492 | store_spi_transport_period); | 499 | store_spi_transport_period); |
493 | 500 | ||
494 | static ssize_t | 501 | static ssize_t |
495 | show_spi_transport_min_period(struct class_device *cdev, char *buf) | 502 | show_spi_transport_min_period(struct device *cdev, |
503 | struct device_attribute *attr, char *buf) | ||
496 | { | 504 | { |
497 | struct scsi_target *starget = transport_class_to_starget(cdev); | 505 | struct scsi_target *starget = transport_class_to_starget(cdev); |
498 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 506 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -507,8 +515,9 @@ show_spi_transport_min_period(struct class_device *cdev, char *buf) | |||
507 | } | 515 | } |
508 | 516 | ||
509 | static ssize_t | 517 | static ssize_t |
510 | store_spi_transport_min_period(struct class_device *cdev, const char *buf, | 518 | store_spi_transport_min_period(struct device *cdev, |
511 | size_t count) | 519 | struct device_attribute *attr, |
520 | const char *buf, size_t count) | ||
512 | { | 521 | { |
513 | struct scsi_target *starget = transport_class_to_starget(cdev); | 522 | struct scsi_target *starget = transport_class_to_starget(cdev); |
514 | struct spi_transport_attrs *tp = | 523 | struct spi_transport_attrs *tp = |
@@ -519,12 +528,14 @@ store_spi_transport_min_period(struct class_device *cdev, const char *buf, | |||
519 | } | 528 | } |
520 | 529 | ||
521 | 530 | ||
522 | static CLASS_DEVICE_ATTR(min_period, S_IRUGO, | 531 | static DEVICE_ATTR(min_period, S_IRUGO, |
523 | show_spi_transport_min_period, | 532 | show_spi_transport_min_period, |
524 | store_spi_transport_min_period); | 533 | store_spi_transport_min_period); |
525 | 534 | ||
526 | 535 | ||
527 | static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) | 536 | static ssize_t show_spi_host_signalling(struct device *cdev, |
537 | struct device_attribute *attr, | ||
538 | char *buf) | ||
528 | { | 539 | { |
529 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 540 | struct Scsi_Host *shost = transport_class_to_shost(cdev); |
530 | struct spi_internal *i = to_spi_internal(shost->transportt); | 541 | struct spi_internal *i = to_spi_internal(shost->transportt); |
@@ -534,10 +545,11 @@ static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) | |||
534 | 545 | ||
535 | return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost))); | 546 | return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost))); |
536 | } | 547 | } |
537 | static ssize_t store_spi_host_signalling(struct class_device *cdev, | 548 | static ssize_t store_spi_host_signalling(struct device *dev, |
549 | struct device_attribute *attr, | ||
538 | const char *buf, size_t count) | 550 | const char *buf, size_t count) |
539 | { | 551 | { |
540 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 552 | struct Scsi_Host *shost = transport_class_to_shost(dev); |
541 | struct spi_internal *i = to_spi_internal(shost->transportt); | 553 | struct spi_internal *i = to_spi_internal(shost->transportt); |
542 | enum spi_signal_type type = spi_signal_to_value(buf); | 554 | enum spi_signal_type type = spi_signal_to_value(buf); |
543 | 555 | ||
@@ -549,9 +561,9 @@ static ssize_t store_spi_host_signalling(struct class_device *cdev, | |||
549 | 561 | ||
550 | return count; | 562 | return count; |
551 | } | 563 | } |
552 | static CLASS_DEVICE_ATTR(signalling, S_IRUGO, | 564 | static DEVICE_ATTR(signalling, S_IRUGO, |
553 | show_spi_host_signalling, | 565 | show_spi_host_signalling, |
554 | store_spi_host_signalling); | 566 | store_spi_host_signalling); |
555 | 567 | ||
556 | #define DV_SET(x, y) \ | 568 | #define DV_SET(x, y) \ |
557 | if(i->f->set_##x) \ | 569 | if(i->f->set_##x) \ |
@@ -1334,7 +1346,7 @@ static DECLARE_ANON_TRANSPORT_CLASS(spi_device_class, | |||
1334 | spi_device_configure); | 1346 | spi_device_configure); |
1335 | 1347 | ||
1336 | static struct attribute *host_attributes[] = { | 1348 | static struct attribute *host_attributes[] = { |
1337 | &class_device_attr_signalling.attr, | 1349 | &dev_attr_signalling.attr, |
1338 | NULL | 1350 | NULL |
1339 | }; | 1351 | }; |
1340 | 1352 | ||
@@ -1344,12 +1356,12 @@ static struct attribute_group host_attribute_group = { | |||
1344 | 1356 | ||
1345 | static int spi_host_configure(struct transport_container *tc, | 1357 | static int spi_host_configure(struct transport_container *tc, |
1346 | struct device *dev, | 1358 | struct device *dev, |
1347 | struct class_device *cdev) | 1359 | struct device *cdev) |
1348 | { | 1360 | { |
1349 | struct kobject *kobj = &cdev->kobj; | 1361 | struct kobject *kobj = &cdev->kobj; |
1350 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1362 | struct Scsi_Host *shost = transport_class_to_shost(cdev); |
1351 | struct spi_internal *si = to_spi_internal(shost->transportt); | 1363 | struct spi_internal *si = to_spi_internal(shost->transportt); |
1352 | struct attribute *attr = &class_device_attr_signalling.attr; | 1364 | struct attribute *attr = &dev_attr_signalling.attr; |
1353 | int rc = 0; | 1365 | int rc = 0; |
1354 | 1366 | ||
1355 | if (si->f->set_signalling) | 1367 | if (si->f->set_signalling) |
@@ -1368,76 +1380,75 @@ static int spi_host_configure(struct transport_container *tc, | |||
1368 | static int target_attribute_is_visible(struct kobject *kobj, | 1380 | static int target_attribute_is_visible(struct kobject *kobj, |
1369 | struct attribute *attr, int i) | 1381 | struct attribute *attr, int i) |
1370 | { | 1382 | { |
1371 | struct class_device *cdev = | 1383 | struct device *cdev = container_of(kobj, struct device, kobj); |
1372 | container_of(kobj, struct class_device, kobj); | ||
1373 | struct scsi_target *starget = transport_class_to_starget(cdev); | 1384 | struct scsi_target *starget = transport_class_to_starget(cdev); |
1374 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | 1385 | struct Scsi_Host *shost = transport_class_to_shost(cdev); |
1375 | struct spi_internal *si = to_spi_internal(shost->transportt); | 1386 | struct spi_internal *si = to_spi_internal(shost->transportt); |
1376 | 1387 | ||
1377 | if (attr == &class_device_attr_period.attr && | 1388 | if (attr == &dev_attr_period.attr && |
1378 | spi_support_sync(starget)) | 1389 | spi_support_sync(starget)) |
1379 | return TARGET_ATTRIBUTE_HELPER(period); | 1390 | return TARGET_ATTRIBUTE_HELPER(period); |
1380 | else if (attr == &class_device_attr_min_period.attr && | 1391 | else if (attr == &dev_attr_min_period.attr && |
1381 | spi_support_sync(starget)) | 1392 | spi_support_sync(starget)) |
1382 | return TARGET_ATTRIBUTE_HELPER(period); | 1393 | return TARGET_ATTRIBUTE_HELPER(period); |
1383 | else if (attr == &class_device_attr_offset.attr && | 1394 | else if (attr == &dev_attr_offset.attr && |
1384 | spi_support_sync(starget)) | 1395 | spi_support_sync(starget)) |
1385 | return TARGET_ATTRIBUTE_HELPER(offset); | 1396 | return TARGET_ATTRIBUTE_HELPER(offset); |
1386 | else if (attr == &class_device_attr_max_offset.attr && | 1397 | else if (attr == &dev_attr_max_offset.attr && |
1387 | spi_support_sync(starget)) | 1398 | spi_support_sync(starget)) |
1388 | return TARGET_ATTRIBUTE_HELPER(offset); | 1399 | return TARGET_ATTRIBUTE_HELPER(offset); |
1389 | else if (attr == &class_device_attr_width.attr && | 1400 | else if (attr == &dev_attr_width.attr && |
1390 | spi_support_wide(starget)) | 1401 | spi_support_wide(starget)) |
1391 | return TARGET_ATTRIBUTE_HELPER(width); | 1402 | return TARGET_ATTRIBUTE_HELPER(width); |
1392 | else if (attr == &class_device_attr_max_width.attr && | 1403 | else if (attr == &dev_attr_max_width.attr && |
1393 | spi_support_wide(starget)) | 1404 | spi_support_wide(starget)) |
1394 | return TARGET_ATTRIBUTE_HELPER(width); | 1405 | return TARGET_ATTRIBUTE_HELPER(width); |
1395 | else if (attr == &class_device_attr_iu.attr && | 1406 | else if (attr == &dev_attr_iu.attr && |
1396 | spi_support_ius(starget)) | 1407 | spi_support_ius(starget)) |
1397 | return TARGET_ATTRIBUTE_HELPER(iu); | 1408 | return TARGET_ATTRIBUTE_HELPER(iu); |
1398 | else if (attr == &class_device_attr_dt.attr && | 1409 | else if (attr == &dev_attr_dt.attr && |
1399 | spi_support_dt(starget)) | 1410 | spi_support_dt(starget)) |
1400 | return TARGET_ATTRIBUTE_HELPER(dt); | 1411 | return TARGET_ATTRIBUTE_HELPER(dt); |
1401 | else if (attr == &class_device_attr_qas.attr && | 1412 | else if (attr == &dev_attr_qas.attr && |
1402 | spi_support_qas(starget)) | 1413 | spi_support_qas(starget)) |
1403 | return TARGET_ATTRIBUTE_HELPER(qas); | 1414 | return TARGET_ATTRIBUTE_HELPER(qas); |
1404 | else if (attr == &class_device_attr_wr_flow.attr && | 1415 | else if (attr == &dev_attr_wr_flow.attr && |
1405 | spi_support_ius(starget)) | 1416 | spi_support_ius(starget)) |
1406 | return TARGET_ATTRIBUTE_HELPER(wr_flow); | 1417 | return TARGET_ATTRIBUTE_HELPER(wr_flow); |
1407 | else if (attr == &class_device_attr_rd_strm.attr && | 1418 | else if (attr == &dev_attr_rd_strm.attr && |
1408 | spi_support_ius(starget)) | 1419 | spi_support_ius(starget)) |
1409 | return TARGET_ATTRIBUTE_HELPER(rd_strm); | 1420 | return TARGET_ATTRIBUTE_HELPER(rd_strm); |
1410 | else if (attr == &class_device_attr_rti.attr && | 1421 | else if (attr == &dev_attr_rti.attr && |
1411 | spi_support_ius(starget)) | 1422 | spi_support_ius(starget)) |
1412 | return TARGET_ATTRIBUTE_HELPER(rti); | 1423 | return TARGET_ATTRIBUTE_HELPER(rti); |
1413 | else if (attr == &class_device_attr_pcomp_en.attr && | 1424 | else if (attr == &dev_attr_pcomp_en.attr && |
1414 | spi_support_ius(starget)) | 1425 | spi_support_ius(starget)) |
1415 | return TARGET_ATTRIBUTE_HELPER(pcomp_en); | 1426 | return TARGET_ATTRIBUTE_HELPER(pcomp_en); |
1416 | else if (attr == &class_device_attr_hold_mcs.attr && | 1427 | else if (attr == &dev_attr_hold_mcs.attr && |
1417 | spi_support_ius(starget)) | 1428 | spi_support_ius(starget)) |
1418 | return TARGET_ATTRIBUTE_HELPER(hold_mcs); | 1429 | return TARGET_ATTRIBUTE_HELPER(hold_mcs); |
1419 | else if (attr == &class_device_attr_revalidate.attr) | 1430 | else if (attr == &dev_attr_revalidate.attr) |
1420 | return 1; | 1431 | return 1; |
1421 | 1432 | ||
1422 | return 0; | 1433 | return 0; |
1423 | } | 1434 | } |
1424 | 1435 | ||
1425 | static struct attribute *target_attributes[] = { | 1436 | static struct attribute *target_attributes[] = { |
1426 | &class_device_attr_period.attr, | 1437 | &dev_attr_period.attr, |
1427 | &class_device_attr_min_period.attr, | 1438 | &dev_attr_min_period.attr, |
1428 | &class_device_attr_offset.attr, | 1439 | &dev_attr_offset.attr, |
1429 | &class_device_attr_max_offset.attr, | 1440 | &dev_attr_max_offset.attr, |
1430 | &class_device_attr_width.attr, | 1441 | &dev_attr_width.attr, |
1431 | &class_device_attr_max_width.attr, | 1442 | &dev_attr_max_width.attr, |
1432 | &class_device_attr_iu.attr, | 1443 | &dev_attr_iu.attr, |
1433 | &class_device_attr_dt.attr, | 1444 | &dev_attr_dt.attr, |
1434 | &class_device_attr_qas.attr, | 1445 | &dev_attr_qas.attr, |
1435 | &class_device_attr_wr_flow.attr, | 1446 | &dev_attr_wr_flow.attr, |
1436 | &class_device_attr_rd_strm.attr, | 1447 | &dev_attr_rd_strm.attr, |
1437 | &class_device_attr_rti.attr, | 1448 | &dev_attr_rti.attr, |
1438 | &class_device_attr_pcomp_en.attr, | 1449 | &dev_attr_pcomp_en.attr, |
1439 | &class_device_attr_hold_mcs.attr, | 1450 | &dev_attr_hold_mcs.attr, |
1440 | &class_device_attr_revalidate.attr, | 1451 | &dev_attr_revalidate.attr, |
1441 | NULL | 1452 | NULL |
1442 | }; | 1453 | }; |
1443 | 1454 | ||
@@ -1448,7 +1459,7 @@ static struct attribute_group target_attribute_group = { | |||
1448 | 1459 | ||
1449 | static int spi_target_configure(struct transport_container *tc, | 1460 | static int spi_target_configure(struct transport_container *tc, |
1450 | struct device *dev, | 1461 | struct device *dev, |
1451 | struct class_device *cdev) | 1462 | struct device *cdev) |
1452 | { | 1463 | { |
1453 | struct kobject *kobj = &cdev->kobj; | 1464 | struct kobject *kobj = &cdev->kobj; |
1454 | int i; | 1465 | int i; |
@@ -1462,7 +1473,7 @@ static int spi_target_configure(struct transport_container *tc, | |||
1462 | * to ignore, sysfs also does a WARN_ON and dumps a trace, | 1473 | * to ignore, sysfs also does a WARN_ON and dumps a trace, |
1463 | * which is bad, so temporarily, skip attributes that are | 1474 | * which is bad, so temporarily, skip attributes that are |
1464 | * already visible (the revalidate one) */ | 1475 | * already visible (the revalidate one) */ |
1465 | if (j && attr != &class_device_attr_revalidate.attr) | 1476 | if (j && attr != &dev_attr_revalidate.attr) |
1466 | rc = sysfs_add_file_to_group(kobj, attr, | 1477 | rc = sysfs_add_file_to_group(kobj, attr, |
1467 | target_attribute_group.name); | 1478 | target_attribute_group.name); |
1468 | /* and make the attribute writeable if we have a set | 1479 | /* and make the attribute writeable if we have a set |
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c index 2445c98ae95e..8a7af951d98a 100644 --- a/drivers/scsi/scsi_transport_srp.c +++ b/drivers/scsi/scsi_transport_srp.c | |||
@@ -44,20 +44,20 @@ struct srp_internal { | |||
44 | struct scsi_transport_template t; | 44 | struct scsi_transport_template t; |
45 | struct srp_function_template *f; | 45 | struct srp_function_template *f; |
46 | 46 | ||
47 | struct class_device_attribute *host_attrs[SRP_HOST_ATTRS + 1]; | 47 | struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1]; |
48 | 48 | ||
49 | struct class_device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1]; | 49 | struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1]; |
50 | struct class_device_attribute private_rport_attrs[SRP_RPORT_ATTRS]; | 50 | struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS]; |
51 | struct transport_container rport_attr_cont; | 51 | struct transport_container rport_attr_cont; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t) | 54 | #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t) |
55 | 55 | ||
56 | #define dev_to_rport(d) container_of(d, struct srp_rport, dev) | 56 | #define dev_to_rport(d) container_of(d, struct srp_rport, dev) |
57 | #define transport_class_to_srp_rport(cdev) dev_to_rport((cdev)->dev) | 57 | #define transport_class_to_srp_rport(dev) dev_to_rport((dev)->parent) |
58 | 58 | ||
59 | static int srp_host_setup(struct transport_container *tc, struct device *dev, | 59 | static int srp_host_setup(struct transport_container *tc, struct device *dev, |
60 | struct class_device *cdev) | 60 | struct device *cdev) |
61 | { | 61 | { |
62 | struct Scsi_Host *shost = dev_to_shost(dev); | 62 | struct Scsi_Host *shost = dev_to_shost(dev); |
63 | struct srp_host_attrs *srp_host = to_srp_host_attrs(shost); | 63 | struct srp_host_attrs *srp_host = to_srp_host_attrs(shost); |
@@ -73,7 +73,7 @@ static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports", | |||
73 | NULL, NULL, NULL); | 73 | NULL, NULL, NULL); |
74 | 74 | ||
75 | #define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \ | 75 | #define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \ |
76 | i->private_##attrb[count] = class_device_attr_##field; \ | 76 | i->private_##attrb[count] = dev_attr_##field; \ |
77 | i->private_##attrb[count].attr.mode = perm; \ | 77 | i->private_##attrb[count].attr.mode = perm; \ |
78 | if (ro_test) { \ | 78 | if (ro_test) { \ |
79 | i->private_##attrb[count].attr.mode = ro_perm; \ | 79 | i->private_##attrb[count].attr.mode = ro_perm; \ |
@@ -100,13 +100,14 @@ static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports", | |||
100 | "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" | 100 | "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" |
101 | 101 | ||
102 | static ssize_t | 102 | static ssize_t |
103 | show_srp_rport_id(struct class_device *cdev, char *buf) | 103 | show_srp_rport_id(struct device *dev, struct device_attribute *attr, |
104 | char *buf) | ||
104 | { | 105 | { |
105 | struct srp_rport *rport = transport_class_to_srp_rport(cdev); | 106 | struct srp_rport *rport = transport_class_to_srp_rport(dev); |
106 | return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport)); | 107 | return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport)); |
107 | } | 108 | } |
108 | 109 | ||
109 | static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); | 110 | static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); |
110 | 111 | ||
111 | static const struct { | 112 | static const struct { |
112 | u32 value; | 113 | u32 value; |
@@ -117,9 +118,10 @@ static const struct { | |||
117 | }; | 118 | }; |
118 | 119 | ||
119 | static ssize_t | 120 | static ssize_t |
120 | show_srp_rport_roles(struct class_device *cdev, char *buf) | 121 | show_srp_rport_roles(struct device *dev, struct device_attribute *attr, |
122 | char *buf) | ||
121 | { | 123 | { |
122 | struct srp_rport *rport = transport_class_to_srp_rport(cdev); | 124 | struct srp_rport *rport = transport_class_to_srp_rport(dev); |
123 | int i; | 125 | int i; |
124 | char *name = NULL; | 126 | char *name = NULL; |
125 | 127 | ||
@@ -131,7 +133,7 @@ show_srp_rport_roles(struct class_device *cdev, char *buf) | |||
131 | return sprintf(buf, "%s\n", name ? : "unknown"); | 133 | return sprintf(buf, "%s\n", name ? : "unknown"); |
132 | } | 134 | } |
133 | 135 | ||
134 | static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); | 136 | static DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); |
135 | 137 | ||
136 | static void srp_rport_release(struct device *dev) | 138 | static void srp_rport_release(struct device *dev) |
137 | { | 139 | { |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 5fe7aaed904c..3cea17dd5dba 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -95,7 +95,7 @@ static int sd_resume(struct device *); | |||
95 | static void sd_rescan(struct device *); | 95 | static void sd_rescan(struct device *); |
96 | static int sd_done(struct scsi_cmnd *); | 96 | static int sd_done(struct scsi_cmnd *); |
97 | static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); | 97 | static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); |
98 | static void scsi_disk_release(struct class_device *cdev); | 98 | static void scsi_disk_release(struct device *cdev); |
99 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); | 99 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); |
100 | static void sd_print_result(struct scsi_disk *, int); | 100 | static void sd_print_result(struct scsi_disk *, int); |
101 | 101 | ||
@@ -112,11 +112,12 @@ static const char *sd_cache_types[] = { | |||
112 | "write back, no read (daft)" | 112 | "write back, no read (daft)" |
113 | }; | 113 | }; |
114 | 114 | ||
115 | static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, | 115 | static ssize_t |
116 | size_t count) | 116 | sd_store_cache_type(struct device *dev, struct device_attribute *attr, |
117 | const char *buf, size_t count) | ||
117 | { | 118 | { |
118 | int i, ct = -1, rcd, wce, sp; | 119 | int i, ct = -1, rcd, wce, sp; |
119 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 120 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
120 | struct scsi_device *sdp = sdkp->device; | 121 | struct scsi_device *sdp = sdkp->device; |
121 | char buffer[64]; | 122 | char buffer[64]; |
122 | char *buffer_data; | 123 | char *buffer_data; |
@@ -163,10 +164,11 @@ static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, | |||
163 | return count; | 164 | return count; |
164 | } | 165 | } |
165 | 166 | ||
166 | static ssize_t sd_store_manage_start_stop(struct class_device *cdev, | 167 | static ssize_t |
167 | const char *buf, size_t count) | 168 | sd_store_manage_start_stop(struct device *dev, struct device_attribute *attr, |
169 | const char *buf, size_t count) | ||
168 | { | 170 | { |
169 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 171 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
170 | struct scsi_device *sdp = sdkp->device; | 172 | struct scsi_device *sdp = sdkp->device; |
171 | 173 | ||
172 | if (!capable(CAP_SYS_ADMIN)) | 174 | if (!capable(CAP_SYS_ADMIN)) |
@@ -177,10 +179,11 @@ static ssize_t sd_store_manage_start_stop(struct class_device *cdev, | |||
177 | return count; | 179 | return count; |
178 | } | 180 | } |
179 | 181 | ||
180 | static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf, | 182 | static ssize_t |
181 | size_t count) | 183 | sd_store_allow_restart(struct device *dev, struct device_attribute *attr, |
184 | const char *buf, size_t count) | ||
182 | { | 185 | { |
183 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 186 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
184 | struct scsi_device *sdp = sdkp->device; | 187 | struct scsi_device *sdp = sdkp->device; |
185 | 188 | ||
186 | if (!capable(CAP_SYS_ADMIN)) | 189 | if (!capable(CAP_SYS_ADMIN)) |
@@ -194,37 +197,44 @@ static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf | |||
194 | return count; | 197 | return count; |
195 | } | 198 | } |
196 | 199 | ||
197 | static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf) | 200 | static ssize_t |
201 | sd_show_cache_type(struct device *dev, struct device_attribute *attr, | ||
202 | char *buf) | ||
198 | { | 203 | { |
199 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 204 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
200 | int ct = sdkp->RCD + 2*sdkp->WCE; | 205 | int ct = sdkp->RCD + 2*sdkp->WCE; |
201 | 206 | ||
202 | return snprintf(buf, 40, "%s\n", sd_cache_types[ct]); | 207 | return snprintf(buf, 40, "%s\n", sd_cache_types[ct]); |
203 | } | 208 | } |
204 | 209 | ||
205 | static ssize_t sd_show_fua(struct class_device *cdev, char *buf) | 210 | static ssize_t |
211 | sd_show_fua(struct device *dev, struct device_attribute *attr, char *buf) | ||
206 | { | 212 | { |
207 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 213 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
208 | 214 | ||
209 | return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); | 215 | return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); |
210 | } | 216 | } |
211 | 217 | ||
212 | static ssize_t sd_show_manage_start_stop(struct class_device *cdev, char *buf) | 218 | static ssize_t |
219 | sd_show_manage_start_stop(struct device *dev, struct device_attribute *attr, | ||
220 | char *buf) | ||
213 | { | 221 | { |
214 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 222 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
215 | struct scsi_device *sdp = sdkp->device; | 223 | struct scsi_device *sdp = sdkp->device; |
216 | 224 | ||
217 | return snprintf(buf, 20, "%u\n", sdp->manage_start_stop); | 225 | return snprintf(buf, 20, "%u\n", sdp->manage_start_stop); |
218 | } | 226 | } |
219 | 227 | ||
220 | static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) | 228 | static ssize_t |
229 | sd_show_allow_restart(struct device *dev, struct device_attribute *attr, | ||
230 | char *buf) | ||
221 | { | 231 | { |
222 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 232 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
223 | 233 | ||
224 | return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); | 234 | return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); |
225 | } | 235 | } |
226 | 236 | ||
227 | static struct class_device_attribute sd_disk_attrs[] = { | 237 | static struct device_attribute sd_disk_attrs[] = { |
228 | __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, | 238 | __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, |
229 | sd_store_cache_type), | 239 | sd_store_cache_type), |
230 | __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), | 240 | __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), |
@@ -238,8 +248,8 @@ static struct class_device_attribute sd_disk_attrs[] = { | |||
238 | static struct class sd_disk_class = { | 248 | static struct class sd_disk_class = { |
239 | .name = "scsi_disk", | 249 | .name = "scsi_disk", |
240 | .owner = THIS_MODULE, | 250 | .owner = THIS_MODULE, |
241 | .release = scsi_disk_release, | 251 | .dev_release = scsi_disk_release, |
242 | .class_dev_attrs = sd_disk_attrs, | 252 | .dev_attrs = sd_disk_attrs, |
243 | }; | 253 | }; |
244 | 254 | ||
245 | static struct scsi_driver sd_template = { | 255 | static struct scsi_driver sd_template = { |
@@ -297,7 +307,7 @@ static struct scsi_disk *__scsi_disk_get(struct gendisk *disk) | |||
297 | if (disk->private_data) { | 307 | if (disk->private_data) { |
298 | sdkp = scsi_disk(disk); | 308 | sdkp = scsi_disk(disk); |
299 | if (scsi_device_get(sdkp->device) == 0) | 309 | if (scsi_device_get(sdkp->device) == 0) |
300 | class_device_get(&sdkp->cdev); | 310 | get_device(&sdkp->dev); |
301 | else | 311 | else |
302 | sdkp = NULL; | 312 | sdkp = NULL; |
303 | } | 313 | } |
@@ -331,7 +341,7 @@ static void scsi_disk_put(struct scsi_disk *sdkp) | |||
331 | struct scsi_device *sdev = sdkp->device; | 341 | struct scsi_device *sdev = sdkp->device; |
332 | 342 | ||
333 | mutex_lock(&sd_ref_mutex); | 343 | mutex_lock(&sd_ref_mutex); |
334 | class_device_put(&sdkp->cdev); | 344 | put_device(&sdkp->dev); |
335 | scsi_device_put(sdev); | 345 | scsi_device_put(sdev); |
336 | mutex_unlock(&sd_ref_mutex); | 346 | mutex_unlock(&sd_ref_mutex); |
337 | } | 347 | } |
@@ -1663,12 +1673,12 @@ static int sd_probe(struct device *dev) | |||
1663 | sdp->timeout = SD_MOD_TIMEOUT; | 1673 | sdp->timeout = SD_MOD_TIMEOUT; |
1664 | } | 1674 | } |
1665 | 1675 | ||
1666 | class_device_initialize(&sdkp->cdev); | 1676 | device_initialize(&sdkp->dev); |
1667 | sdkp->cdev.dev = &sdp->sdev_gendev; | 1677 | sdkp->dev.parent = &sdp->sdev_gendev; |
1668 | sdkp->cdev.class = &sd_disk_class; | 1678 | sdkp->dev.class = &sd_disk_class; |
1669 | strncpy(sdkp->cdev.class_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE); | 1679 | strncpy(sdkp->dev.bus_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE); |
1670 | 1680 | ||
1671 | if (class_device_add(&sdkp->cdev)) | 1681 | if (device_add(&sdkp->dev)) |
1672 | goto out_put; | 1682 | goto out_put; |
1673 | 1683 | ||
1674 | get_device(&sdp->sdev_gendev); | 1684 | get_device(&sdp->sdev_gendev); |
@@ -1734,13 +1744,13 @@ static int sd_remove(struct device *dev) | |||
1734 | { | 1744 | { |
1735 | struct scsi_disk *sdkp = dev_get_drvdata(dev); | 1745 | struct scsi_disk *sdkp = dev_get_drvdata(dev); |
1736 | 1746 | ||
1737 | class_device_del(&sdkp->cdev); | 1747 | device_del(&sdkp->dev); |
1738 | del_gendisk(sdkp->disk); | 1748 | del_gendisk(sdkp->disk); |
1739 | sd_shutdown(dev); | 1749 | sd_shutdown(dev); |
1740 | 1750 | ||
1741 | mutex_lock(&sd_ref_mutex); | 1751 | mutex_lock(&sd_ref_mutex); |
1742 | dev_set_drvdata(dev, NULL); | 1752 | dev_set_drvdata(dev, NULL); |
1743 | class_device_put(&sdkp->cdev); | 1753 | put_device(&sdkp->dev); |
1744 | mutex_unlock(&sd_ref_mutex); | 1754 | mutex_unlock(&sd_ref_mutex); |
1745 | 1755 | ||
1746 | return 0; | 1756 | return 0; |
@@ -1748,16 +1758,16 @@ static int sd_remove(struct device *dev) | |||
1748 | 1758 | ||
1749 | /** | 1759 | /** |
1750 | * scsi_disk_release - Called to free the scsi_disk structure | 1760 | * scsi_disk_release - Called to free the scsi_disk structure |
1751 | * @cdev: pointer to embedded class device | 1761 | * @dev: pointer to embedded class device |
1752 | * | 1762 | * |
1753 | * sd_ref_mutex must be held entering this routine. Because it is | 1763 | * sd_ref_mutex must be held entering this routine. Because it is |
1754 | * called on last put, you should always use the scsi_disk_get() | 1764 | * called on last put, you should always use the scsi_disk_get() |
1755 | * scsi_disk_put() helpers which manipulate the semaphore directly | 1765 | * scsi_disk_put() helpers which manipulate the semaphore directly |
1756 | * and never do a direct class_device_put(). | 1766 | * and never do a direct put_device. |
1757 | **/ | 1767 | **/ |
1758 | static void scsi_disk_release(struct class_device *cdev) | 1768 | static void scsi_disk_release(struct device *dev) |
1759 | { | 1769 | { |
1760 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 1770 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
1761 | struct gendisk *disk = sdkp->disk; | 1771 | struct gendisk *disk = sdkp->disk; |
1762 | 1772 | ||
1763 | spin_lock(&sd_index_lock); | 1773 | spin_lock(&sd_index_lock); |
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index a6d96694d0a5..45df83b9d847 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -107,7 +107,7 @@ static int ses_set_page2_descriptor(struct enclosure_device *edev, | |||
107 | unsigned char *desc) | 107 | unsigned char *desc) |
108 | { | 108 | { |
109 | int i, j, count = 0, descriptor = ecomp->number; | 109 | int i, j, count = 0, descriptor = ecomp->number; |
110 | struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); | 110 | struct scsi_device *sdev = to_scsi_device(edev->edev.parent); |
111 | struct ses_device *ses_dev = edev->scratch; | 111 | struct ses_device *ses_dev = edev->scratch; |
112 | unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; | 112 | unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; |
113 | unsigned char *desc_ptr = ses_dev->page2 + 8; | 113 | unsigned char *desc_ptr = ses_dev->page2 + 8; |
@@ -137,7 +137,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev, | |||
137 | struct enclosure_component *ecomp) | 137 | struct enclosure_component *ecomp) |
138 | { | 138 | { |
139 | int i, j, count = 0, descriptor = ecomp->number; | 139 | int i, j, count = 0, descriptor = ecomp->number; |
140 | struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); | 140 | struct scsi_device *sdev = to_scsi_device(edev->edev.parent); |
141 | struct ses_device *ses_dev = edev->scratch; | 141 | struct ses_device *ses_dev = edev->scratch; |
142 | unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; | 142 | unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; |
143 | unsigned char *desc_ptr = ses_dev->page2 + 8; | 143 | unsigned char *desc_ptr = ses_dev->page2 + 8; |
@@ -269,10 +269,10 @@ int ses_match_host(struct enclosure_device *edev, void *data) | |||
269 | struct ses_host_edev *sed = data; | 269 | struct ses_host_edev *sed = data; |
270 | struct scsi_device *sdev; | 270 | struct scsi_device *sdev; |
271 | 271 | ||
272 | if (!scsi_is_sdev_device(edev->cdev.dev)) | 272 | if (!scsi_is_sdev_device(edev->edev.parent)) |
273 | return 0; | 273 | return 0; |
274 | 274 | ||
275 | sdev = to_scsi_device(edev->cdev.dev); | 275 | sdev = to_scsi_device(edev->edev.parent); |
276 | 276 | ||
277 | if (sdev->host != sed->shost) | 277 | if (sdev->host != sed->shost) |
278 | return 0; | 278 | return 0; |
@@ -407,10 +407,10 @@ static void ses_match_to_enclosure(struct enclosure_device *edev, | |||
407 | 407 | ||
408 | #define INIT_ALLOC_SIZE 32 | 408 | #define INIT_ALLOC_SIZE 32 |
409 | 409 | ||
410 | static int ses_intf_add(struct class_device *cdev, | 410 | static int ses_intf_add(struct device *cdev, |
411 | struct class_interface *intf) | 411 | struct class_interface *intf) |
412 | { | 412 | { |
413 | struct scsi_device *sdev = to_scsi_device(cdev->dev); | 413 | struct scsi_device *sdev = to_scsi_device(cdev->parent); |
414 | struct scsi_device *tmp_sdev; | 414 | struct scsi_device *tmp_sdev; |
415 | unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL, | 415 | unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL, |
416 | *addl_desc_ptr = NULL; | 416 | *addl_desc_ptr = NULL; |
@@ -426,7 +426,7 @@ static int ses_intf_add(struct class_device *cdev, | |||
426 | edev = enclosure_find(&sdev->host->shost_gendev); | 426 | edev = enclosure_find(&sdev->host->shost_gendev); |
427 | if (edev) { | 427 | if (edev) { |
428 | ses_match_to_enclosure(edev, sdev); | 428 | ses_match_to_enclosure(edev, sdev); |
429 | class_device_put(&edev->cdev); | 429 | put_device(&edev->edev); |
430 | } | 430 | } |
431 | return -ENODEV; | 431 | return -ENODEV; |
432 | } | 432 | } |
@@ -515,7 +515,7 @@ static int ses_intf_add(struct class_device *cdev, | |||
515 | if (!scomp) | 515 | if (!scomp) |
516 | goto err_free; | 516 | goto err_free; |
517 | 517 | ||
518 | edev = enclosure_register(cdev->dev, sdev->sdev_gendev.bus_id, | 518 | edev = enclosure_register(cdev->parent, sdev->sdev_gendev.bus_id, |
519 | components, &ses_enclosure_callbacks); | 519 | components, &ses_enclosure_callbacks); |
520 | if (IS_ERR(edev)) { | 520 | if (IS_ERR(edev)) { |
521 | err = PTR_ERR(edev); | 521 | err = PTR_ERR(edev); |
@@ -625,17 +625,17 @@ static int ses_remove(struct device *dev) | |||
625 | return 0; | 625 | return 0; |
626 | } | 626 | } |
627 | 627 | ||
628 | static void ses_intf_remove(struct class_device *cdev, | 628 | static void ses_intf_remove(struct device *cdev, |
629 | struct class_interface *intf) | 629 | struct class_interface *intf) |
630 | { | 630 | { |
631 | struct scsi_device *sdev = to_scsi_device(cdev->dev); | 631 | struct scsi_device *sdev = to_scsi_device(cdev->parent); |
632 | struct enclosure_device *edev; | 632 | struct enclosure_device *edev; |
633 | struct ses_device *ses_dev; | 633 | struct ses_device *ses_dev; |
634 | 634 | ||
635 | if (!scsi_device_enclosure(sdev)) | 635 | if (!scsi_device_enclosure(sdev)) |
636 | return; | 636 | return; |
637 | 637 | ||
638 | edev = enclosure_find(cdev->dev); | 638 | edev = enclosure_find(cdev->parent); |
639 | if (!edev) | 639 | if (!edev) |
640 | return; | 640 | return; |
641 | 641 | ||
@@ -649,13 +649,13 @@ static void ses_intf_remove(struct class_device *cdev, | |||
649 | 649 | ||
650 | kfree(edev->component[0].scratch); | 650 | kfree(edev->component[0].scratch); |
651 | 651 | ||
652 | class_device_put(&edev->cdev); | 652 | put_device(&edev->edev); |
653 | enclosure_unregister(edev); | 653 | enclosure_unregister(edev); |
654 | } | 654 | } |
655 | 655 | ||
656 | static struct class_interface ses_interface = { | 656 | static struct class_interface ses_interface = { |
657 | .add = ses_intf_add, | 657 | .add_dev = ses_intf_add, |
658 | .remove = ses_intf_remove, | 658 | .remove_dev = ses_intf_remove, |
659 | }; | 659 | }; |
660 | 660 | ||
661 | static struct scsi_driver ses_template = { | 661 | static struct scsi_driver ses_template = { |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index e5156aa6dd20..2029422bc04d 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -101,16 +101,16 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ; | |||
101 | #define SG_SECTOR_SZ 512 | 101 | #define SG_SECTOR_SZ 512 |
102 | #define SG_SECTOR_MSK (SG_SECTOR_SZ - 1) | 102 | #define SG_SECTOR_MSK (SG_SECTOR_SZ - 1) |
103 | 103 | ||
104 | static int sg_add(struct class_device *, struct class_interface *); | 104 | static int sg_add(struct device *, struct class_interface *); |
105 | static void sg_remove(struct class_device *, struct class_interface *); | 105 | static void sg_remove(struct device *, struct class_interface *); |
106 | 106 | ||
107 | static DEFINE_IDR(sg_index_idr); | 107 | static DEFINE_IDR(sg_index_idr); |
108 | static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock | 108 | static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock |
109 | file descriptor list for device */ | 109 | file descriptor list for device */ |
110 | 110 | ||
111 | static struct class_interface sg_interface = { | 111 | static struct class_interface sg_interface = { |
112 | .add = sg_add, | 112 | .add_dev = sg_add, |
113 | .remove = sg_remove, | 113 | .remove_dev = sg_remove, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */ | 116 | typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */ |
@@ -1401,9 +1401,9 @@ static Sg_device *sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | static int | 1403 | static int |
1404 | sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) | 1404 | sg_add(struct device *cl_dev, struct class_interface *cl_intf) |
1405 | { | 1405 | { |
1406 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1406 | struct scsi_device *scsidp = to_scsi_device(cl_dev->parent); |
1407 | struct gendisk *disk; | 1407 | struct gendisk *disk; |
1408 | Sg_device *sdp = NULL; | 1408 | Sg_device *sdp = NULL; |
1409 | struct cdev * cdev = NULL; | 1409 | struct cdev * cdev = NULL; |
@@ -1439,19 +1439,19 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1439 | 1439 | ||
1440 | sdp->cdev = cdev; | 1440 | sdp->cdev = cdev; |
1441 | if (sg_sysfs_valid) { | 1441 | if (sg_sysfs_valid) { |
1442 | struct class_device * sg_class_member; | 1442 | struct device *sg_class_member; |
1443 | 1443 | ||
1444 | sg_class_member = class_device_create(sg_sysfs_class, NULL, | 1444 | sg_class_member = device_create(sg_sysfs_class, cl_dev->parent, |
1445 | MKDEV(SCSI_GENERIC_MAJOR, sdp->index), | 1445 | MKDEV(SCSI_GENERIC_MAJOR, |
1446 | cl_dev->dev, "%s", | 1446 | sdp->index), |
1447 | disk->disk_name); | 1447 | "%s", disk->disk_name); |
1448 | if (IS_ERR(sg_class_member)) { | 1448 | if (IS_ERR(sg_class_member)) { |
1449 | printk(KERN_ERR "sg_add: " | 1449 | printk(KERN_ERR "sg_add: " |
1450 | "class_device_create failed\n"); | 1450 | "device_create failed\n"); |
1451 | error = PTR_ERR(sg_class_member); | 1451 | error = PTR_ERR(sg_class_member); |
1452 | goto cdev_add_err; | 1452 | goto cdev_add_err; |
1453 | } | 1453 | } |
1454 | class_set_devdata(sg_class_member, sdp); | 1454 | dev_set_drvdata(sg_class_member, sdp); |
1455 | error = sysfs_create_link(&scsidp->sdev_gendev.kobj, | 1455 | error = sysfs_create_link(&scsidp->sdev_gendev.kobj, |
1456 | &sg_class_member->kobj, "generic"); | 1456 | &sg_class_member->kobj, "generic"); |
1457 | if (error) | 1457 | if (error) |
@@ -1464,7 +1464,7 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1464 | "Attached scsi generic sg%d type %d\n", sdp->index, | 1464 | "Attached scsi generic sg%d type %d\n", sdp->index, |
1465 | scsidp->type); | 1465 | scsidp->type); |
1466 | 1466 | ||
1467 | class_set_devdata(cl_dev, sdp); | 1467 | dev_set_drvdata(cl_dev, sdp); |
1468 | 1468 | ||
1469 | return 0; | 1469 | return 0; |
1470 | 1470 | ||
@@ -1482,10 +1482,10 @@ out: | |||
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | static void | 1484 | static void |
1485 | sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) | 1485 | sg_remove(struct device *cl_dev, struct class_interface *cl_intf) |
1486 | { | 1486 | { |
1487 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1487 | struct scsi_device *scsidp = to_scsi_device(cl_dev->parent); |
1488 | Sg_device *sdp = class_get_devdata(cl_dev); | 1488 | Sg_device *sdp = dev_get_drvdata(cl_dev); |
1489 | unsigned long iflags; | 1489 | unsigned long iflags; |
1490 | Sg_fd *sfp; | 1490 | Sg_fd *sfp; |
1491 | Sg_fd *tsfp; | 1491 | Sg_fd *tsfp; |
@@ -1528,7 +1528,7 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1528 | write_unlock_irqrestore(&sg_index_lock, iflags); | 1528 | write_unlock_irqrestore(&sg_index_lock, iflags); |
1529 | 1529 | ||
1530 | sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); | 1530 | sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); |
1531 | class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); | 1531 | device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); |
1532 | cdev_del(sdp->cdev); | 1532 | cdev_del(sdp->cdev); |
1533 | sdp->cdev = NULL; | 1533 | sdp->cdev = NULL; |
1534 | put_disk(sdp->disk); | 1534 | put_disk(sdp->disk); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index df83bea2c620..a860c3a9ae99 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -4108,9 +4108,9 @@ out_free_tape: | |||
4108 | if (STm->cdevs[j]) { | 4108 | if (STm->cdevs[j]) { |
4109 | if (cdev == STm->cdevs[j]) | 4109 | if (cdev == STm->cdevs[j]) |
4110 | cdev = NULL; | 4110 | cdev = NULL; |
4111 | class_device_destroy(st_sysfs_class, | 4111 | device_destroy(st_sysfs_class, |
4112 | MKDEV(SCSI_TAPE_MAJOR, | 4112 | MKDEV(SCSI_TAPE_MAJOR, |
4113 | TAPE_MINOR(i, mode, j))); | 4113 | TAPE_MINOR(i, mode, j))); |
4114 | cdev_del(STm->cdevs[j]); | 4114 | cdev_del(STm->cdevs[j]); |
4115 | } | 4115 | } |
4116 | } | 4116 | } |
@@ -4148,9 +4148,9 @@ static int st_remove(struct device *dev) | |||
4148 | "tape"); | 4148 | "tape"); |
4149 | for (mode = 0; mode < ST_NBR_MODES; ++mode) { | 4149 | for (mode = 0; mode < ST_NBR_MODES; ++mode) { |
4150 | for (j=0; j < 2; j++) { | 4150 | for (j=0; j < 2; j++) { |
4151 | class_device_destroy(st_sysfs_class, | 4151 | device_destroy(st_sysfs_class, |
4152 | MKDEV(SCSI_TAPE_MAJOR, | 4152 | MKDEV(SCSI_TAPE_MAJOR, |
4153 | TAPE_MINOR(i, mode, j))); | 4153 | TAPE_MINOR(i, mode, j))); |
4154 | cdev_del(tpnt->modes[mode].cdevs[j]); | 4154 | cdev_del(tpnt->modes[mode].cdevs[j]); |
4155 | tpnt->modes[mode].cdevs[j] = NULL; | 4155 | tpnt->modes[mode].cdevs[j] = NULL; |
4156 | } | 4156 | } |
@@ -4319,31 +4319,34 @@ static void do_remove_sysfs_files(void) | |||
4319 | 4319 | ||
4320 | 4320 | ||
4321 | /* The sysfs simple class interface */ | 4321 | /* The sysfs simple class interface */ |
4322 | static ssize_t st_defined_show(struct class_device *class_dev, char *buf) | 4322 | static ssize_t |
4323 | st_defined_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
4323 | { | 4324 | { |
4324 | struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); | 4325 | struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); |
4325 | ssize_t l = 0; | 4326 | ssize_t l = 0; |
4326 | 4327 | ||
4327 | l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined); | 4328 | l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined); |
4328 | return l; | 4329 | return l; |
4329 | } | 4330 | } |
4330 | 4331 | ||
4331 | CLASS_DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL); | 4332 | DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL); |
4332 | 4333 | ||
4333 | static ssize_t st_defblk_show(struct class_device *class_dev, char *buf) | 4334 | static ssize_t |
4335 | st_defblk_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
4334 | { | 4336 | { |
4335 | struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); | 4337 | struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); |
4336 | ssize_t l = 0; | 4338 | ssize_t l = 0; |
4337 | 4339 | ||
4338 | l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize); | 4340 | l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize); |
4339 | return l; | 4341 | return l; |
4340 | } | 4342 | } |
4341 | 4343 | ||
4342 | CLASS_DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL); | 4344 | DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL); |
4343 | 4345 | ||
4344 | static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf) | 4346 | static ssize_t |
4347 | st_defdensity_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
4345 | { | 4348 | { |
4346 | struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); | 4349 | struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); |
4347 | ssize_t l = 0; | 4350 | ssize_t l = 0; |
4348 | char *fmt; | 4351 | char *fmt; |
4349 | 4352 | ||
@@ -4352,22 +4355,25 @@ static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf) | |||
4352 | return l; | 4355 | return l; |
4353 | } | 4356 | } |
4354 | 4357 | ||
4355 | CLASS_DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL); | 4358 | DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL); |
4356 | 4359 | ||
4357 | static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf) | 4360 | static ssize_t |
4361 | st_defcompression_show(struct device *dev, struct device_attribute *attr, | ||
4362 | char *buf) | ||
4358 | { | 4363 | { |
4359 | struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); | 4364 | struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); |
4360 | ssize_t l = 0; | 4365 | ssize_t l = 0; |
4361 | 4366 | ||
4362 | l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1); | 4367 | l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1); |
4363 | return l; | 4368 | return l; |
4364 | } | 4369 | } |
4365 | 4370 | ||
4366 | CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); | 4371 | DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); |
4367 | 4372 | ||
4368 | static ssize_t st_options_show(struct class_device *class_dev, char *buf) | 4373 | static ssize_t |
4374 | st_options_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
4369 | { | 4375 | { |
4370 | struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); | 4376 | struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev); |
4371 | struct scsi_tape *STp; | 4377 | struct scsi_tape *STp; |
4372 | int i, j, options; | 4378 | int i, j, options; |
4373 | ssize_t l = 0; | 4379 | ssize_t l = 0; |
@@ -4403,13 +4409,13 @@ static ssize_t st_options_show(struct class_device *class_dev, char *buf) | |||
4403 | return l; | 4409 | return l; |
4404 | } | 4410 | } |
4405 | 4411 | ||
4406 | CLASS_DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL); | 4412 | DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL); |
4407 | 4413 | ||
4408 | static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) | 4414 | static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) |
4409 | { | 4415 | { |
4410 | int i, rew, error; | 4416 | int i, rew, error; |
4411 | char name[10]; | 4417 | char name[10]; |
4412 | struct class_device *st_class_member; | 4418 | struct device *st_class_member; |
4413 | 4419 | ||
4414 | for (rew=0; rew < 2; rew++) { | 4420 | for (rew=0; rew < 2; rew++) { |
4415 | /* Make sure that the minor numbers corresponding to the four | 4421 | /* Make sure that the minor numbers corresponding to the four |
@@ -4418,32 +4424,32 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) | |||
4418 | snprintf(name, 10, "%s%s%s", rew ? "n" : "", | 4424 | snprintf(name, 10, "%s%s%s", rew ? "n" : "", |
4419 | STp->disk->disk_name, st_formats[i]); | 4425 | STp->disk->disk_name, st_formats[i]); |
4420 | st_class_member = | 4426 | st_class_member = |
4421 | class_device_create(st_sysfs_class, NULL, | 4427 | device_create(st_sysfs_class, &STp->device->sdev_gendev, |
4422 | MKDEV(SCSI_TAPE_MAJOR, | 4428 | MKDEV(SCSI_TAPE_MAJOR, |
4423 | TAPE_MINOR(dev_num, mode, rew)), | 4429 | TAPE_MINOR(dev_num, mode, rew)), |
4424 | &STp->device->sdev_gendev, "%s", name); | 4430 | "%s", name); |
4425 | if (IS_ERR(st_class_member)) { | 4431 | if (IS_ERR(st_class_member)) { |
4426 | printk(KERN_WARNING "st%d: class_device_create failed\n", | 4432 | printk(KERN_WARNING "st%d: device_create failed\n", |
4427 | dev_num); | 4433 | dev_num); |
4428 | error = PTR_ERR(st_class_member); | 4434 | error = PTR_ERR(st_class_member); |
4429 | goto out; | 4435 | goto out; |
4430 | } | 4436 | } |
4431 | class_set_devdata(st_class_member, &STp->modes[mode]); | 4437 | dev_set_drvdata(st_class_member, &STp->modes[mode]); |
4432 | 4438 | ||
4433 | error = class_device_create_file(st_class_member, | 4439 | error = device_create_file(st_class_member, |
4434 | &class_device_attr_defined); | 4440 | &dev_attr_defined); |
4435 | if (error) goto out; | 4441 | if (error) goto out; |
4436 | error = class_device_create_file(st_class_member, | 4442 | error = device_create_file(st_class_member, |
4437 | &class_device_attr_default_blksize); | 4443 | &dev_attr_default_blksize); |
4438 | if (error) goto out; | 4444 | if (error) goto out; |
4439 | error = class_device_create_file(st_class_member, | 4445 | error = device_create_file(st_class_member, |
4440 | &class_device_attr_default_density); | 4446 | &dev_attr_default_density); |
4441 | if (error) goto out; | 4447 | if (error) goto out; |
4442 | error = class_device_create_file(st_class_member, | 4448 | error = device_create_file(st_class_member, |
4443 | &class_device_attr_default_compression); | 4449 | &dev_attr_default_compression); |
4444 | if (error) goto out; | 4450 | if (error) goto out; |
4445 | error = class_device_create_file(st_class_member, | 4451 | error = device_create_file(st_class_member, |
4446 | &class_device_attr_options); | 4452 | &dev_attr_options); |
4447 | if (error) goto out; | 4453 | if (error) goto out; |
4448 | 4454 | ||
4449 | if (mode == 0 && rew == 0) { | 4455 | if (mode == 0 && rew == 0) { |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index c32c1ca75f63..a9ca03ead3e5 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -2422,7 +2422,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2422 | */ | 2422 | */ |
2423 | tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev); | 2423 | tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev); |
2424 | if (likely(!IS_ERR(tty_dev))) { | 2424 | if (likely(!IS_ERR(tty_dev))) { |
2425 | device_can_wakeup(tty_dev) = 1; | 2425 | device_init_wakeup(tty_dev, 1); |
2426 | device_set_wakeup_enable(tty_dev, 0); | 2426 | device_set_wakeup_enable(tty_dev, 0); |
2427 | } else | 2427 | } else |
2428 | printk(KERN_ERR "Cannot register tty device on line %d\n", | 2428 | printk(KERN_ERR "Cannot register tty device on line %d\n", |
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index b778ed71f636..a4aaab9c7ddc 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig | |||
@@ -1,8 +1,6 @@ | |||
1 | menu "Userspace I/O" | 1 | menuconfig UIO |
2 | depends on !S390 | ||
3 | |||
4 | config UIO | ||
5 | tristate "Userspace I/O drivers" | 2 | tristate "Userspace I/O drivers" |
3 | depends on !S390 | ||
6 | default n | 4 | default n |
7 | help | 5 | help |
8 | Enable this to allow the userspace driver core code to be | 6 | Enable this to allow the userspace driver core code to be |
@@ -13,6 +11,8 @@ config UIO | |||
13 | 11 | ||
14 | If you don't know what to do here, say N. | 12 | If you don't know what to do here, say N. |
15 | 13 | ||
14 | if UIO | ||
15 | |||
16 | config UIO_CIF | 16 | config UIO_CIF |
17 | tristate "generic Hilscher CIF Card driver" | 17 | tristate "generic Hilscher CIF Card driver" |
18 | depends on UIO && PCI | 18 | depends on UIO && PCI |
@@ -26,4 +26,17 @@ config UIO_CIF | |||
26 | To compile this driver as a module, choose M here: the module | 26 | To compile this driver as a module, choose M here: the module |
27 | will be called uio_cif. | 27 | will be called uio_cif. |
28 | 28 | ||
29 | endmenu | 29 | config UIO_SMX |
30 | tristate "SMX cryptengine UIO interface" | ||
31 | depends on UIO | ||
32 | default n | ||
33 | help | ||
34 | Userspace IO interface to the Cryptography engine found on the | ||
35 | Nias Digital SMX boards. These will be available from Q4 2008 | ||
36 | from http://www.niasdigital.com. The userspace part of this | ||
37 | driver will be released under the GPL at the same time as the | ||
38 | hardware and will be able to be downloaded from the same site. | ||
39 | |||
40 | If you compile this as a module, it will be called uio_smx. | ||
41 | |||
42 | endif | ||
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index 7fecfb459da5..18c45662431e 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile | |||
@@ -1,2 +1,3 @@ | |||
1 | obj-$(CONFIG_UIO) += uio.o | 1 | obj-$(CONFIG_UIO) += uio.o |
2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o | 2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o |
3 | obj-$(CONFIG_UIO_SMX) += uio_smx.o | ||
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 11759080ca54..55cc7b80422a 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -301,23 +301,33 @@ static int uio_open(struct inode *inode, struct file *filep) | |||
301 | if (!idev) | 301 | if (!idev) |
302 | return -ENODEV; | 302 | return -ENODEV; |
303 | 303 | ||
304 | if (!try_module_get(idev->owner)) | ||
305 | return -ENODEV; | ||
306 | |||
304 | listener = kmalloc(sizeof(*listener), GFP_KERNEL); | 307 | listener = kmalloc(sizeof(*listener), GFP_KERNEL); |
305 | if (!listener) | 308 | if (!listener) { |
306 | return -ENOMEM; | 309 | ret = -ENOMEM; |
310 | goto err_alloc_listener; | ||
311 | } | ||
307 | 312 | ||
308 | listener->dev = idev; | 313 | listener->dev = idev; |
309 | listener->event_count = atomic_read(&idev->event); | 314 | listener->event_count = atomic_read(&idev->event); |
310 | filep->private_data = listener; | 315 | filep->private_data = listener; |
311 | 316 | ||
312 | if (idev->info->open) { | 317 | if (idev->info->open) { |
313 | if (!try_module_get(idev->owner)) | ||
314 | return -ENODEV; | ||
315 | ret = idev->info->open(idev->info, inode); | 318 | ret = idev->info->open(idev->info, inode); |
316 | module_put(idev->owner); | 319 | if (ret) |
320 | goto err_infoopen; | ||
317 | } | 321 | } |
318 | 322 | ||
319 | if (ret) | 323 | return 0; |
320 | kfree(listener); | 324 | |
325 | err_infoopen: | ||
326 | |||
327 | kfree(listener); | ||
328 | err_alloc_listener: | ||
329 | |||
330 | module_put(idev->owner); | ||
321 | 331 | ||
322 | return ret; | 332 | return ret; |
323 | } | 333 | } |
@@ -336,12 +346,11 @@ static int uio_release(struct inode *inode, struct file *filep) | |||
336 | struct uio_listener *listener = filep->private_data; | 346 | struct uio_listener *listener = filep->private_data; |
337 | struct uio_device *idev = listener->dev; | 347 | struct uio_device *idev = listener->dev; |
338 | 348 | ||
339 | if (idev->info->release) { | 349 | if (idev->info->release) |
340 | if (!try_module_get(idev->owner)) | ||
341 | return -ENODEV; | ||
342 | ret = idev->info->release(idev->info, inode); | 350 | ret = idev->info->release(idev->info, inode); |
343 | module_put(idev->owner); | 351 | |
344 | } | 352 | module_put(idev->owner); |
353 | |||
345 | if (filep->f_flags & FASYNC) | 354 | if (filep->f_flags & FASYNC) |
346 | ret = uio_fasync(-1, filep, 0); | 355 | ret = uio_fasync(-1, filep, 0); |
347 | kfree(listener); | 356 | kfree(listener); |
@@ -510,10 +519,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma) | |||
510 | return -EINVAL; | 519 | return -EINVAL; |
511 | 520 | ||
512 | if (idev->info->mmap) { | 521 | if (idev->info->mmap) { |
513 | if (!try_module_get(idev->owner)) | ||
514 | return -ENODEV; | ||
515 | ret = idev->info->mmap(idev->info, vma); | 522 | ret = idev->info->mmap(idev->info, vma); |
516 | module_put(idev->owner); | ||
517 | return ret; | 523 | return ret; |
518 | } | 524 | } |
519 | 525 | ||
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c index 838bae460831..57376060b978 100644 --- a/drivers/uio/uio_cif.c +++ b/drivers/uio/uio_cif.c | |||
@@ -15,10 +15,6 @@ | |||
15 | 15 | ||
16 | #include <asm/io.h> | 16 | #include <asm/io.h> |
17 | 17 | ||
18 | #ifndef PCI_DEVICE_ID_PLX_9030 | ||
19 | #define PCI_DEVICE_ID_PLX_9030 0x9030 | ||
20 | #endif | ||
21 | |||
22 | #define PLX9030_INTCSR 0x4C | 18 | #define PLX9030_INTCSR 0x4C |
23 | #define INTSCR_INT1_ENABLE 0x01 | 19 | #define INTSCR_INT1_ENABLE 0x01 |
24 | #define INTSCR_INT1_STATUS 0x04 | 20 | #define INTSCR_INT1_STATUS 0x04 |
@@ -116,7 +112,7 @@ static void hilscher_pci_remove(struct pci_dev *dev) | |||
116 | kfree (info); | 112 | kfree (info); |
117 | } | 113 | } |
118 | 114 | ||
119 | static struct pci_device_id hilscher_pci_ids[] = { | 115 | static struct pci_device_id hilscher_pci_ids[] __devinitdata = { |
120 | { | 116 | { |
121 | .vendor = PCI_VENDOR_ID_PLX, | 117 | .vendor = PCI_VENDOR_ID_PLX, |
122 | .device = PCI_DEVICE_ID_PLX_9030, | 118 | .device = PCI_DEVICE_ID_PLX_9030, |
diff --git a/drivers/uio/uio_smx.c b/drivers/uio/uio_smx.c new file mode 100644 index 000000000000..44054a650a8a --- /dev/null +++ b/drivers/uio/uio_smx.c | |||
@@ -0,0 +1,140 @@ | |||
1 | /* | ||
2 | * UIO SMX Cryptengine driver. | ||
3 | * | ||
4 | * (C) 2008 Nias Digital P/L <bn@niasdigital.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/device.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/uio_driver.h> | ||
16 | #include <linux/io.h> | ||
17 | |||
18 | #define DRV_NAME "smx-ce" | ||
19 | #define DRV_VERSION "0.03" | ||
20 | |||
21 | #define SMX_CSR 0x00000000 | ||
22 | #define SMX_EnD 0x00000001 | ||
23 | #define SMX_RUN 0x00000002 | ||
24 | #define SMX_DRDY 0x00000004 | ||
25 | #define SMX_ERR 0x00000008 | ||
26 | |||
27 | static irqreturn_t smx_handler(int irq, struct uio_info *dev_info) | ||
28 | { | ||
29 | void __iomem *csr = dev_info->mem[0].internal_addr + SMX_CSR; | ||
30 | |||
31 | u32 status = ioread32(csr); | ||
32 | |||
33 | if (!(status & SMX_DRDY)) | ||
34 | return IRQ_NONE; | ||
35 | |||
36 | /* Disable interrupt */ | ||
37 | iowrite32(status & ~SMX_DRDY, csr); | ||
38 | return IRQ_HANDLED; | ||
39 | } | ||
40 | |||
41 | static int __devinit smx_ce_probe(struct platform_device *dev) | ||
42 | { | ||
43 | |||
44 | int ret = -ENODEV; | ||
45 | struct uio_info *info; | ||
46 | struct resource *regs; | ||
47 | |||
48 | info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); | ||
49 | if (!info) | ||
50 | return -ENOMEM; | ||
51 | |||
52 | regs = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
53 | if (!regs) { | ||
54 | dev_err(&dev->dev, "No memory resource specified\n"); | ||
55 | goto out_free; | ||
56 | } | ||
57 | |||
58 | info->mem[0].addr = regs->start; | ||
59 | if (!info->mem[0].addr) { | ||
60 | dev_err(&dev->dev, "Invalid memory resource\n"); | ||
61 | goto out_free; | ||
62 | } | ||
63 | |||
64 | info->mem[0].size = regs->end - regs->start + 1; | ||
65 | info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size); | ||
66 | |||
67 | if (!info->mem[0].internal_addr) { | ||
68 | dev_err(&dev->dev, "Can't remap memory address range\n"); | ||
69 | goto out_free; | ||
70 | } | ||
71 | |||
72 | info->mem[0].memtype = UIO_MEM_PHYS; | ||
73 | |||
74 | info->name = "smx-ce"; | ||
75 | info->version = "0.03"; | ||
76 | |||
77 | info->irq = platform_get_irq(dev, 0); | ||
78 | if (info->irq < 0) { | ||
79 | ret = info->irq; | ||
80 | dev_err(&dev->dev, "No (or invalid) IRQ resource specified\n"); | ||
81 | goto out_unmap; | ||
82 | } | ||
83 | |||
84 | info->irq_flags = IRQF_SHARED; | ||
85 | info->handler = smx_handler; | ||
86 | |||
87 | platform_set_drvdata(dev, info); | ||
88 | |||
89 | ret = uio_register_device(&dev->dev, info); | ||
90 | |||
91 | if (ret) | ||
92 | goto out_unmap; | ||
93 | |||
94 | return 0; | ||
95 | |||
96 | out_unmap: | ||
97 | iounmap(info->mem[0].internal_addr); | ||
98 | out_free: | ||
99 | kfree(info); | ||
100 | |||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | static int __devexit smx_ce_remove(struct platform_device *dev) | ||
105 | { | ||
106 | struct uio_info *info = platform_get_drvdata(dev); | ||
107 | |||
108 | uio_unregister_device(info); | ||
109 | platform_set_drvdata(dev, NULL); | ||
110 | iounmap(info->mem[0].internal_addr); | ||
111 | |||
112 | kfree(info); | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static struct platform_driver smx_ce_driver = { | ||
118 | .probe = smx_ce_probe, | ||
119 | .remove = __devexit_p(smx_ce_remove), | ||
120 | .driver = { | ||
121 | .name = DRV_NAME, | ||
122 | .owner = THIS_MODULE, | ||
123 | }, | ||
124 | }; | ||
125 | |||
126 | static int __init smx_ce_init_module(void) | ||
127 | { | ||
128 | return platform_driver_register(&smx_ce_driver); | ||
129 | } | ||
130 | module_init(smx_ce_init_module); | ||
131 | |||
132 | static void __exit smx_ce_exit_module(void) | ||
133 | { | ||
134 | platform_driver_unregister(&smx_ce_driver); | ||
135 | } | ||
136 | module_exit(smx_ce_exit_module); | ||
137 | |||
138 | MODULE_LICENSE("GPL v2"); | ||
139 | MODULE_VERSION(DRV_VERSION); | ||
140 | MODULE_AUTHOR("Ben Nizette <bn@niasdigital.com>"); | ||