Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 89775
b: refs/heads/master
c: d45ac4f
h: refs/heads/master
i:
  89773: 641a721
  89771: 7549a94
  89767: adb7f9b
  89759: 7c0b573
v: v3
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Apr 18, 2008
1 parent 47a5b96 commit c205206
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0e4ff797d7f2f2bb860b8f31dc5d1f2273b2f05a
refs/heads/master: d45ac4fa8f277e1ec5acfb67ce5d6406555760cf
19 changes: 13 additions & 6 deletions trunk/block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ static struct bsg_device *bsg_alloc_device(void)
static int bsg_put_device(struct bsg_device *bd)
{
int ret = 0;
struct device *dev = bd->queue->bsg_dev.dev;

mutex_lock(&bsg_mutex);

Expand All @@ -730,6 +731,7 @@ static int bsg_put_device(struct bsg_device *bd)
kfree(bd);
out:
mutex_unlock(&bsg_mutex);
put_device(dev);
return ret;
}

Expand Down Expand Up @@ -789,21 +791,27 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
struct bsg_device *bd;
struct bsg_class_device *bcd;

bd = __bsg_get_device(iminor(inode));
if (bd)
return bd;

/*
* find the class device
*/
mutex_lock(&bsg_mutex);
bcd = idr_find(&bsg_minor_idr, iminor(inode));
if (bcd)
get_device(bcd->dev);
mutex_unlock(&bsg_mutex);

if (!bcd)
return ERR_PTR(-ENODEV);

return bsg_add_device(inode, bcd->queue, file);
bd = __bsg_get_device(iminor(inode));
if (bd)
return bd;

bd = bsg_add_device(inode, bcd->queue, file);
if (IS_ERR(bd))
put_device(bcd->dev);

return bd;
}

static int bsg_open(struct inode *inode, struct file *file)
Expand Down Expand Up @@ -942,7 +950,6 @@ void bsg_unregister_queue(struct request_queue *q)
class_device_unregister(bcd->class_dev);
put_device(bcd->dev);
bcd->class_dev = NULL;
bcd->dev = NULL;
mutex_unlock(&bsg_mutex);
}
EXPORT_SYMBOL_GPL(bsg_unregister_queue);
Expand Down

0 comments on commit c205206

Please sign in to comment.