diff options
author | Moger, Babu <Babu.Moger@netapp.com> | 2011-12-01 15:03:12 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-12-15 01:55:00 -0500 |
commit | 2b132577a05ec2970581c99da70825430d5919df (patch) | |
tree | 5463487c144c396db13aade00bd560a61306cb08 /drivers/scsi/device_handler | |
parent | bee89eae8de143b1d9f82ab7ab6d9daef8e44760 (diff) |
[SCSI] scsi_dh: code cleanup and remove the references to scsi_dev_info
All the handlers have now implemented the match function so We don't need to
use scsi_dev_info any more for matching purposes.
Signed-off-by: Babu Moger <babu.moger@netapp.com>
Acked-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/device_handler')
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh.c | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c index 23149b9e297c..48e46f5b77cc 100644 --- a/drivers/scsi/device_handler/scsi_dh.c +++ b/drivers/scsi/device_handler/scsi_dh.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | static DEFINE_SPINLOCK(list_lock); | 29 | static DEFINE_SPINLOCK(list_lock); |
30 | static LIST_HEAD(scsi_dh_list); | 30 | static LIST_HEAD(scsi_dh_list); |
31 | static int scsi_dh_list_idx = 1; | ||
32 | 31 | ||
33 | static struct scsi_device_handler *get_device_handler(const char *name) | 32 | static struct scsi_device_handler *get_device_handler(const char *name) |
34 | { | 33 | { |
@@ -45,21 +44,6 @@ static struct scsi_device_handler *get_device_handler(const char *name) | |||
45 | return found; | 44 | return found; |
46 | } | 45 | } |
47 | 46 | ||
48 | static struct scsi_device_handler *get_device_handler_by_idx(int idx) | ||
49 | { | ||
50 | struct scsi_device_handler *tmp, *found = NULL; | ||
51 | |||
52 | spin_lock(&list_lock); | ||
53 | list_for_each_entry(tmp, &scsi_dh_list, list) { | ||
54 | if (tmp->idx == idx) { | ||
55 | found = tmp; | ||
56 | break; | ||
57 | } | ||
58 | } | ||
59 | spin_unlock(&list_lock); | ||
60 | return found; | ||
61 | } | ||
62 | |||
63 | /* | 47 | /* |
64 | * device_handler_match_function - Match a device handler to a device | 48 | * device_handler_match_function - Match a device handler to a device |
65 | * @sdev - SCSI device to be tested | 49 | * @sdev - SCSI device to be tested |
@@ -84,23 +68,6 @@ device_handler_match_function(struct scsi_device *sdev) | |||
84 | } | 68 | } |
85 | 69 | ||
86 | /* | 70 | /* |
87 | * device_handler_match_devlist - Match a device handler to a device | ||
88 | * @sdev - SCSI device to be tested | ||
89 | * | ||
90 | * Tests @sdev against all device_handler registered in the devlist. | ||
91 | * Returns the found device handler or NULL if not found. | ||
92 | */ | ||
93 | static struct scsi_device_handler * | ||
94 | device_handler_match_devlist(struct scsi_device *sdev) | ||
95 | { | ||
96 | int idx; | ||
97 | |||
98 | idx = scsi_get_device_flags_keyed(sdev, sdev->vendor, sdev->model, | ||
99 | SCSI_DEVINFO_DH); | ||
100 | return get_device_handler_by_idx(idx); | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * device_handler_match - Attach a device handler to a device | 71 | * device_handler_match - Attach a device handler to a device |
105 | * @scsi_dh - The device handler to match against or NULL | 72 | * @scsi_dh - The device handler to match against or NULL |
106 | * @sdev - SCSI device to be tested against @scsi_dh | 73 | * @sdev - SCSI device to be tested against @scsi_dh |
@@ -116,8 +83,6 @@ device_handler_match(struct scsi_device_handler *scsi_dh, | |||
116 | struct scsi_device_handler *found_dh; | 83 | struct scsi_device_handler *found_dh; |
117 | 84 | ||
118 | found_dh = device_handler_match_function(sdev); | 85 | found_dh = device_handler_match_function(sdev); |
119 | if (!found_dh) | ||
120 | found_dh = device_handler_match_devlist(sdev); | ||
121 | 86 | ||
122 | if (scsi_dh && found_dh != scsi_dh) | 87 | if (scsi_dh && found_dh != scsi_dh) |
123 | found_dh = NULL; | 88 | found_dh = NULL; |
@@ -361,25 +326,14 @@ static int scsi_dh_notifier_remove(struct device *dev, void *data) | |||
361 | */ | 326 | */ |
362 | int scsi_register_device_handler(struct scsi_device_handler *scsi_dh) | 327 | int scsi_register_device_handler(struct scsi_device_handler *scsi_dh) |
363 | { | 328 | { |
364 | int i; | ||
365 | 329 | ||
366 | if (get_device_handler(scsi_dh->name)) | 330 | if (get_device_handler(scsi_dh->name)) |
367 | return -EBUSY; | 331 | return -EBUSY; |
368 | 332 | ||
369 | spin_lock(&list_lock); | 333 | spin_lock(&list_lock); |
370 | scsi_dh->idx = scsi_dh_list_idx++; | ||
371 | list_add(&scsi_dh->list, &scsi_dh_list); | 334 | list_add(&scsi_dh->list, &scsi_dh_list); |
372 | spin_unlock(&list_lock); | 335 | spin_unlock(&list_lock); |
373 | 336 | ||
374 | for (i = 0; scsi_dh->devlist && scsi_dh->devlist[i].vendor; i++) { | ||
375 | scsi_dev_info_list_add_keyed(0, | ||
376 | scsi_dh->devlist[i].vendor, | ||
377 | scsi_dh->devlist[i].model, | ||
378 | NULL, | ||
379 | scsi_dh->idx, | ||
380 | SCSI_DEVINFO_DH); | ||
381 | } | ||
382 | |||
383 | bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, scsi_dh_notifier_add); | 337 | bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, scsi_dh_notifier_add); |
384 | printk(KERN_INFO "%s: device handler registered\n", scsi_dh->name); | 338 | printk(KERN_INFO "%s: device handler registered\n", scsi_dh->name); |
385 | 339 | ||
@@ -396,7 +350,6 @@ EXPORT_SYMBOL_GPL(scsi_register_device_handler); | |||
396 | */ | 350 | */ |
397 | int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) | 351 | int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) |
398 | { | 352 | { |
399 | int i; | ||
400 | 353 | ||
401 | if (!get_device_handler(scsi_dh->name)) | 354 | if (!get_device_handler(scsi_dh->name)) |
402 | return -ENODEV; | 355 | return -ENODEV; |
@@ -404,12 +357,6 @@ int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) | |||
404 | bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, | 357 | bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, |
405 | scsi_dh_notifier_remove); | 358 | scsi_dh_notifier_remove); |
406 | 359 | ||
407 | for (i = 0; scsi_dh->devlist && scsi_dh->devlist[i].vendor; i++) { | ||
408 | scsi_dev_info_list_del_keyed(scsi_dh->devlist[i].vendor, | ||
409 | scsi_dh->devlist[i].model, | ||
410 | SCSI_DEVINFO_DH); | ||
411 | } | ||
412 | |||
413 | spin_lock(&list_lock); | 360 | spin_lock(&list_lock); |
414 | list_del(&scsi_dh->list); | 361 | list_del(&scsi_dh->list); |
415 | spin_unlock(&list_lock); | 362 | spin_unlock(&list_lock); |
@@ -588,10 +535,6 @@ static int __init scsi_dh_init(void) | |||
588 | { | 535 | { |
589 | int r; | 536 | int r; |
590 | 537 | ||
591 | r = scsi_dev_info_add_list(SCSI_DEVINFO_DH, "SCSI Device Handler"); | ||
592 | if (r) | ||
593 | return r; | ||
594 | |||
595 | r = bus_register_notifier(&scsi_bus_type, &scsi_dh_nb); | 538 | r = bus_register_notifier(&scsi_bus_type, &scsi_dh_nb); |
596 | 539 | ||
597 | if (!r) | 540 | if (!r) |
@@ -606,7 +549,6 @@ static void __exit scsi_dh_exit(void) | |||
606 | bus_for_each_dev(&scsi_bus_type, NULL, NULL, | 549 | bus_for_each_dev(&scsi_bus_type, NULL, NULL, |
607 | scsi_dh_sysfs_attr_remove); | 550 | scsi_dh_sysfs_attr_remove); |
608 | bus_unregister_notifier(&scsi_bus_type, &scsi_dh_nb); | 551 | bus_unregister_notifier(&scsi_bus_type, &scsi_dh_nb); |
609 | scsi_dev_info_remove_list(SCSI_DEVINFO_DH); | ||
610 | } | 552 | } |
611 | 553 | ||
612 | module_init(scsi_dh_init); | 554 | module_init(scsi_dh_init); |