aboutsummaryrefslogtreecommitdiffstats
path: root/block/bsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/bsg.c')
-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;