diff options
-rw-r--r-- | block/Kconfig | 2 | ||||
-rw-r--r-- | block/bsg.c | 30 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 13 |
3 files changed, 14 insertions, 31 deletions
diff --git a/block/Kconfig b/block/Kconfig index 0768741d6813..ca2ef4e08497 100644 --- a/block/Kconfig +++ b/block/Kconfig | |||
@@ -53,7 +53,7 @@ endif # BLOCK | |||
53 | 53 | ||
54 | config BLK_DEV_BSG | 54 | config BLK_DEV_BSG |
55 | bool "Block layer SG support v4 (EXPERIMENTAL)" | 55 | bool "Block layer SG support v4 (EXPERIMENTAL)" |
56 | depends on (SCSI=y) && EXPERIMENTAL | 56 | depends on EXPERIMENTAL |
57 | ---help--- | 57 | ---help--- |
58 | Saying Y here will enable generic SG (SCSI generic) v4 support | 58 | Saying Y here will enable generic SG (SCSI generic) v4 support |
59 | for any block device. | 59 | for any block device. |
diff --git a/block/bsg.c b/block/bsg.c index baa04e7adf19..4e0be1b2e2a0 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -1009,29 +1009,6 @@ err: | |||
1009 | } | 1009 | } |
1010 | EXPORT_SYMBOL_GPL(bsg_register_queue); | 1010 | EXPORT_SYMBOL_GPL(bsg_register_queue); |
1011 | 1011 | ||
1012 | static int bsg_add(struct class_device *cl_dev, struct class_interface *cl_intf) | ||
1013 | { | ||
1014 | int ret; | ||
1015 | struct scsi_device *sdp = to_scsi_device(cl_dev->dev); | ||
1016 | struct request_queue *rq = sdp->request_queue; | ||
1017 | |||
1018 | if (rq->kobj.parent) | ||
1019 | ret = bsg_register_queue(rq, kobject_name(rq->kobj.parent)); | ||
1020 | else | ||
1021 | ret = bsg_register_queue(rq, kobject_name(&sdp->sdev_gendev.kobj)); | ||
1022 | return ret; | ||
1023 | } | ||
1024 | |||
1025 | static void bsg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) | ||
1026 | { | ||
1027 | bsg_unregister_queue(to_scsi_device(cl_dev->dev)->request_queue); | ||
1028 | } | ||
1029 | |||
1030 | static struct class_interface bsg_intf = { | ||
1031 | .add = bsg_add, | ||
1032 | .remove = bsg_remove, | ||
1033 | }; | ||
1034 | |||
1035 | static struct cdev bsg_cdev = { | 1012 | static struct cdev bsg_cdev = { |
1036 | .kobj = {.name = "bsg", }, | 1013 | .kobj = {.name = "bsg", }, |
1037 | .owner = THIS_MODULE, | 1014 | .owner = THIS_MODULE, |
@@ -1069,16 +1046,9 @@ static int __init bsg_init(void) | |||
1069 | if (ret) | 1046 | if (ret) |
1070 | goto unregister_chrdev; | 1047 | goto unregister_chrdev; |
1071 | 1048 | ||
1072 | ret = scsi_register_interface(&bsg_intf); | ||
1073 | if (ret) | ||
1074 | goto remove_cdev; | ||
1075 | |||
1076 | printk(KERN_INFO BSG_DESCRIPTION " version " BSG_VERSION | 1049 | printk(KERN_INFO BSG_DESCRIPTION " version " BSG_VERSION |
1077 | " loaded (major %d)\n", bsg_major); | 1050 | " loaded (major %d)\n", bsg_major); |
1078 | return 0; | 1051 | return 0; |
1079 | remove_cdev: | ||
1080 | printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret); | ||
1081 | cdev_del(&bsg_cdev); | ||
1082 | unregister_chrdev: | 1052 | unregister_chrdev: |
1083 | unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS); | 1053 | unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS); |
1084 | destroy_bsg_class: | 1054 | destroy_bsg_class: |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 34e483d31c18..ad5f21fd5d45 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -715,6 +715,7 @@ static int attr_add(struct device *dev, struct device_attribute *attr) | |||
715 | int scsi_sysfs_add_sdev(struct scsi_device *sdev) | 715 | int scsi_sysfs_add_sdev(struct scsi_device *sdev) |
716 | { | 716 | { |
717 | int error, i; | 717 | int error, i; |
718 | struct request_queue *rq = sdev->request_queue; | ||
718 | 719 | ||
719 | if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0) | 720 | if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0) |
720 | return error; | 721 | return error; |
@@ -734,6 +735,17 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) | |||
734 | /* take a reference for the sdev_classdev; this is | 735 | /* take a reference for the sdev_classdev; this is |
735 | * released by the sdev_class .release */ | 736 | * released by the sdev_class .release */ |
736 | get_device(&sdev->sdev_gendev); | 737 | get_device(&sdev->sdev_gendev); |
738 | |||
739 | error = bsg_register_queue(rq, sdev->sdev_gendev.bus_id); | ||
740 | |||
741 | if (error) | ||
742 | sdev_printk(KERN_INFO, sdev, | ||
743 | "Failed to register bsg queue, errno=%d\n", error); | ||
744 | |||
745 | /* we're treating error on bsg register as non-fatal, so pretend | ||
746 | * nothing went wrong */ | ||
747 | error = 0; | ||
748 | |||
737 | if (sdev->host->hostt->sdev_attrs) { | 749 | if (sdev->host->hostt->sdev_attrs) { |
738 | for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { | 750 | for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { |
739 | error = attr_add(&sdev->sdev_gendev, | 751 | error = attr_add(&sdev->sdev_gendev, |
@@ -780,6 +792,7 @@ void __scsi_remove_device(struct scsi_device *sdev) | |||
780 | if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) | 792 | if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) |
781 | return; | 793 | return; |
782 | 794 | ||
795 | bsg_unregister_queue(sdev->request_queue); | ||
783 | class_device_unregister(&sdev->sdev_classdev); | 796 | class_device_unregister(&sdev->sdev_classdev); |
784 | transport_remove_device(dev); | 797 | transport_remove_device(dev); |
785 | device_del(dev); | 798 | device_del(dev); |