diff options
author | James Bottomley <James.Bottomley@steeleye.com> | 2007-07-20 18:22:17 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-07-21 08:58:23 -0500 |
commit | 39dca558a5b52b63e49bc234a7e887be092aa690 (patch) | |
tree | 31c3c412458e657fdbedc73f50b7de26c7ed0c4a /block | |
parent | 0e78d158b67fba3977f577f293c323359d80dd0e (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.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/block/bsg.c b/block/bsg.c index 0e3d5d490d2..4eebcd5c731 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -936,20 +936,29 @@ void bsg_unregister_queue(struct request_queue *q) mutex_lock(&bsg_mutex); sysfs_remove_link(&q->kobj, "bsg"); - class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor)); + class_device_unregister(bcd->class_dev); + put_device(bcd->dev); bcd->class_dev = NULL; + bcd->dev = NULL; list_del_init(&bcd->list); bsg_device_nr--; mutex_unlock(&bsg_mutex); } EXPORT_SYMBOL_GPL(bsg_unregister_queue); -int bsg_register_queue(struct request_queue *q, const char *name) +int bsg_register_queue(struct request_queue *q, struct device *gdev, + const char *name) { struct bsg_class_device *bcd, *__bcd; dev_t dev; int ret = -EMFILE; struct class_device *class_dev = NULL; + const char *devname; + + if (name) + devname = name; + else + devname = gdev->bus_id; /* * we need a proper transport to send commands, not a stacked device @@ -982,11 +991,13 @@ retry: bsg_minor_idx = 0; bcd->queue = q; + bcd->dev = get_device(gdev); dev = MKDEV(bsg_major, bcd->minor); - class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", name); + class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s", + devname); if (IS_ERR(class_dev)) { ret = PTR_ERR(class_dev); - goto err; + goto err_put; } bcd->class_dev = class_dev; @@ -1004,6 +1015,8 @@ retry: err_unregister: class_device_unregister(class_dev); +err_put: + put_device(gdev); err: mutex_unlock(&bsg_mutex); return ret; |