aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@steeleye.com>2007-07-20 19:22:17 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-07-21 09:58:23 -0400
commit39dca558a5b52b63e49bc234a7e887be092aa690 (patch)
tree31c3c412458e657fdbedc73f50b7de26c7ed0c4a /block
parent0e78d158b67fba3977f577f293c323359d80dd0e (diff)
[SCSI] bsg: make class backlinks
Currently, bsg doesn't make class backlinks (a process whereby you'd get a link to bsg in the device directory in the same way you get one for sg). This is because the bsg device is uninitialised, so the class device has nothing it can attach to. The fix is to make the bsg device point to the cdevice of the entity creating the bsg, necessitating changing the bsg_register_queue() prototype into a form that takes the generic device. Acked-by: FUJITA Tomonori <tomof@acm.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'block')
-rw-r--r--block/bsg.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/block/bsg.c b/block/bsg.c
index 0e3d5d490d20..4eebcd5c7311 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -936,20 +936,29 @@ void bsg_unregister_queue(struct request_queue *q)
936 936
937 mutex_lock(&bsg_mutex); 937 mutex_lock(&bsg_mutex);
938 sysfs_remove_link(&q->kobj, "bsg"); 938 sysfs_remove_link(&q->kobj, "bsg");
939 class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor)); 939 class_device_unregister(bcd->class_dev);
940 put_device(bcd->dev);
940 bcd->class_dev = NULL; 941 bcd->class_dev = NULL;
942 bcd->dev = NULL;
941 list_del_init(&bcd->list); 943 list_del_init(&bcd->list);
942 bsg_device_nr--; 944 bsg_device_nr--;
943 mutex_unlock(&bsg_mutex); 945 mutex_unlock(&bsg_mutex);
944} 946}
945EXPORT_SYMBOL_GPL(bsg_unregister_queue); 947EXPORT_SYMBOL_GPL(bsg_unregister_queue);
946 948
947int bsg_register_queue(struct request_queue *q, const char *name) 949int bsg_register_queue(struct request_queue *q, struct device *gdev,
950 const char *name)
948{ 951{
949 struct bsg_class_device *bcd, *__bcd; 952 struct bsg_class_device *bcd, *__bcd;
950 dev_t dev; 953 dev_t dev;
951 int ret = -EMFILE; 954 int ret = -EMFILE;
952 struct class_device *class_dev = NULL; 955 struct class_device *class_dev = NULL;
956 const char *devname;
957
958 if (name)
959 devname = name;
960 else
961 devname = gdev->bus_id;
953 962
954 /* 963 /*
955 * we need a proper transport to send commands, not a stacked device 964 * we need a proper transport to send commands, not a stacked device
@@ -982,11 +991,13 @@ retry:
982 bsg_minor_idx = 0; 991 bsg_minor_idx = 0;
983 992
984 bcd->queue = q; 993 bcd->queue = q;
994 bcd->dev = get_device(gdev);
985 dev = MKDEV(bsg_major, bcd->minor); 995 dev = MKDEV(bsg_major, bcd->minor);
986 class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", name); 996 class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s",
997 devname);
987 if (IS_ERR(class_dev)) { 998 if (IS_ERR(class_dev)) {
988 ret = PTR_ERR(class_dev); 999 ret = PTR_ERR(class_dev);
989 goto err; 1000 goto err_put;
990 } 1001 }
991 bcd->class_dev = class_dev; 1002 bcd->class_dev = class_dev;
992 1003
@@ -1004,6 +1015,8 @@ retry:
1004 1015
1005err_unregister: 1016err_unregister:
1006 class_device_unregister(class_dev); 1017 class_device_unregister(class_dev);
1018err_put:
1019 put_device(gdev);
1007err: 1020err:
1008 mutex_unlock(&bsg_mutex); 1021 mutex_unlock(&bsg_mutex);
1009 return ret; 1022 return ret;