aboutsummaryrefslogtreecommitdiffstats
path: root/block/bsg.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 23:58:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 23:58:09 -0500
commit2a7d2b96d5cba7568139d9ab157a0e97ab32440f (patch)
treead029d8cc7b7068b7250e914360ec6315fdfa114 /block/bsg.c
parente3c4877de8b9d93bd47b6ee88eb594b1c1e10da5 (diff)
parentb67bfe0d42cac56c512dd5da4b1b347a23f4b70a (diff)
Merge branch 'akpm' (final batch from Andrew)
Merge third patch-bumb from Andrew Morton: "This wraps me up for -rc1. - Lots of misc stuff and things which were deferred/missed from patchbombings 1 & 2. - ocfs2 things - lib/scatterlist - hfsplus - fatfs - documentation - signals - procfs - lockdep - coredump - seqfile core - kexec - Tejun's large IDR tree reworkings - ipmi - partitions - nbd - random() things - kfifo - tools/testing/selftests updates - Sasha's large and pointless hlist cleanup" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (163 commits) hlist: drop the node parameter from iterators kcmp: make it depend on CHECKPOINT_RESTORE selftests: add a simple doc tools/testing/selftests/Makefile: rearrange targets selftests/efivarfs: add create-read test selftests/efivarfs: add empty file creation test selftests: add tests for efivarfs kfifo: fix kfifo_alloc() and kfifo_init() kfifo: move kfifo.c from kernel/ to lib/ arch Kconfig: centralise CONFIG_ARCH_NO_VIRT_TO_BUS w1: add support for DS2413 Dual Channel Addressable Switch memstick: move the dereference below the NULL test drivers/pps/clients/pps-gpio.c: use devm_kzalloc Documentation/DMA-API-HOWTO.txt: fix typo include/linux/eventfd.h: fix incorrect filename is a comment mtd: mtd_stresstest: use prandom_bytes() mtd: mtd_subpagetest: convert to use prandom library mtd: mtd_speedtest: use prandom_bytes mtd: mtd_pagetest: convert to use prandom library mtd: mtd_oobtest: convert to use prandom library ...
Diffstat (limited to 'block/bsg.c')
-rw-r--r--block/bsg.c29
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,
800static struct bsg_device *__bsg_get_device(int minor, struct request_queue *q) 800static 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);
1060put_dev: 1052put_dev:
1061 put_device(parent); 1053 put_device(parent);
1062remove_idr: 1054 idr_remove(&bsg_minor_idr, bcd->minor);
1063 idr_remove(&bsg_minor_idr, minor);
1064unlock: 1055unlock:
1065 mutex_unlock(&bsg_mutex); 1056 mutex_unlock(&bsg_mutex);
1066 return ret; 1057 return ret;