diff options
Diffstat (limited to 'block/bsg.c')
-rw-r--r-- | block/bsg.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/block/bsg.c b/block/bsg.c index ff64ae3bacee..420a5a9f1b23 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -800,11 +800,10 @@ static struct bsg_device *bsg_add_device(struct inode *inode, | |||
800 | static struct bsg_device *__bsg_get_device(int minor, struct request_queue *q) | 800 | static struct bsg_device *__bsg_get_device(int minor, struct request_queue *q) |
801 | { | 801 | { |
802 | struct bsg_device *bd; | 802 | struct bsg_device *bd; |
803 | struct hlist_node *entry; | ||
804 | 803 | ||
805 | mutex_lock(&bsg_mutex); | 804 | mutex_lock(&bsg_mutex); |
806 | 805 | ||
807 | hlist_for_each_entry(bd, entry, bsg_dev_idx_hash(minor), dev_list) { | 806 | hlist_for_each_entry(bd, bsg_dev_idx_hash(minor), dev_list) { |
808 | if (bd->queue == q) { | 807 | if (bd->queue == q) { |
809 | atomic_inc(&bd->ref_count); | 808 | atomic_inc(&bd->ref_count); |
810 | goto found; | 809 | goto found; |
@@ -997,7 +996,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, | |||
997 | { | 996 | { |
998 | struct bsg_class_device *bcd; | 997 | struct bsg_class_device *bcd; |
999 | dev_t dev; | 998 | dev_t dev; |
1000 | int ret, minor; | 999 | int ret; |
1001 | struct device *class_dev = NULL; | 1000 | struct device *class_dev = NULL; |
1002 | const char *devname; | 1001 | const char *devname; |
1003 | 1002 | ||
@@ -1017,23 +1016,16 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, | |||
1017 | 1016 | ||
1018 | mutex_lock(&bsg_mutex); | 1017 | mutex_lock(&bsg_mutex); |
1019 | 1018 | ||
1020 | ret = idr_pre_get(&bsg_minor_idr, GFP_KERNEL); | 1019 | ret = idr_alloc(&bsg_minor_idr, bcd, 0, BSG_MAX_DEVS, GFP_KERNEL); |
1021 | if (!ret) { | 1020 | if (ret < 0) { |
1022 | ret = -ENOMEM; | 1021 | if (ret == -ENOSPC) { |
1023 | goto unlock; | 1022 | printk(KERN_ERR "bsg: too many bsg devices\n"); |
1024 | } | 1023 | ret = -EINVAL; |
1025 | 1024 | } | |
1026 | ret = idr_get_new(&bsg_minor_idr, bcd, &minor); | ||
1027 | if (ret < 0) | ||
1028 | goto unlock; | 1025 | goto unlock; |
1029 | |||
1030 | if (minor >= BSG_MAX_DEVS) { | ||
1031 | printk(KERN_ERR "bsg: too many bsg devices\n"); | ||
1032 | ret = -EINVAL; | ||
1033 | goto remove_idr; | ||
1034 | } | 1026 | } |
1035 | 1027 | ||
1036 | bcd->minor = minor; | 1028 | bcd->minor = ret; |
1037 | bcd->queue = q; | 1029 | bcd->queue = q; |
1038 | bcd->parent = get_device(parent); | 1030 | bcd->parent = get_device(parent); |
1039 | bcd->release = release; | 1031 | bcd->release = release; |
@@ -1059,8 +1051,7 @@ unregister_class_dev: | |||
1059 | device_unregister(class_dev); | 1051 | device_unregister(class_dev); |
1060 | put_dev: | 1052 | put_dev: |
1061 | put_device(parent); | 1053 | put_device(parent); |
1062 | remove_idr: | 1054 | idr_remove(&bsg_minor_idr, bcd->minor); |
1063 | idr_remove(&bsg_minor_idr, minor); | ||
1064 | unlock: | 1055 | unlock: |
1065 | mutex_unlock(&bsg_mutex); | 1056 | mutex_unlock(&bsg_mutex); |
1066 | return ret; | 1057 | return ret; |