mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
[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 <[email protected]> Signed-off-by: James Bottomley <[email protected]>
This commit is contained in:
parent
0e78d158b6
commit
39dca558a5
4 changed files with 38 additions and 21 deletions
21
block/bsg.c
21
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue