Commit 80ed71ce1a3369521c693ebf30abb9cfe1dc7e66

Authored by James Bottomley
Committed by James Bottomley
1 parent b02b6bc465

[SCSI] bsg: separate bsg and SCSI (so SCSI can be modular)

This patch moves the bsg registration into SCSI so that bsg no longer
has a dependency on the scsi_interface_register API.

This can be viewed as a temporary expedient until we can get universal
bsg binding sorted out properly.  Also use the sdev bus_id as the
generic bsg name (to avoid clashes with the queue name).

Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

Showing 3 changed files with 14 additions and 31 deletions Side-by-side Diff

... ... @@ -53,7 +53,7 @@
53 53  
54 54 config BLK_DEV_BSG
55 55 bool "Block layer SG support v4 (EXPERIMENTAL)"
56   - depends on (SCSI=y) && EXPERIMENTAL
  56 + depends on EXPERIMENTAL
57 57 ---help---
58 58 Saying Y here will enable generic SG (SCSI generic) v4 support
59 59 for any block device.
... ... @@ -1009,29 +1009,6 @@
1009 1009 }
1010 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 1012 static struct cdev bsg_cdev = {
1036 1013 .kobj = {.name = "bsg", },
1037 1014 .owner = THIS_MODULE,
1038 1015  
... ... @@ -1069,16 +1046,9 @@
1069 1046 if (ret)
1070 1047 goto unregister_chrdev;
1071 1048  
1072   - ret = scsi_register_interface(&bsg_intf);
1073   - if (ret)
1074   - goto remove_cdev;
1075   -
1076 1049 printk(KERN_INFO BSG_DESCRIPTION " version " BSG_VERSION
1077 1050 " loaded (major %d)\n", bsg_major);
1078 1051 return 0;
1079   -remove_cdev:
1080   - printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret);
1081   - cdev_del(&bsg_cdev);
1082 1052 unregister_chrdev:
1083 1053 unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS);
1084 1054 destroy_bsg_class:
drivers/scsi/scsi_sysfs.c
... ... @@ -715,6 +715,7 @@
715 715 int scsi_sysfs_add_sdev(struct scsi_device *sdev)
716 716 {
717 717 int error, i;
  718 + struct request_queue *rq = sdev->request_queue;
718 719  
719 720 if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0)
720 721 return error;
... ... @@ -734,6 +735,17 @@
734 735 /* take a reference for the sdev_classdev; this is
735 736 * released by the sdev_class .release */
736 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 749 if (sdev->host->hostt->sdev_attrs) {
738 750 for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) {
739 751 error = attr_add(&sdev->sdev_gendev,
... ... @@ -780,6 +792,7 @@
780 792 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
781 793 return;
782 794  
  795 + bsg_unregister_queue(sdev->request_queue);
783 796 class_device_unregister(&sdev->sdev_classdev);
784 797 transport_remove_device(dev);
785 798 device_del(dev);