aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2008-04-21 09:51:06 +0200
committerJens Axboe <jens.axboe@oracle.com>2008-04-21 09:51:06 +0200
commitfb199746303a6bfd6121834ec9e810471185c530 (patch)
treec50ed0dd313e7fcffddd021639473f001fcf8b05 /block
parent2472892a3ce17b177cc0d8099a6391949c75abf2 (diff)
downloadkernel_samsung_smdk4412-fb199746303a6bfd6121834ec9e810471185c530.zip
kernel_samsung_smdk4412-fb199746303a6bfd6121834ec9e810471185c530.tar.gz
kernel_samsung_smdk4412-fb199746303a6bfd6121834ec9e810471185c530.tar.bz2
block: fix blk_register_queue() return value
blk_register_queue() returns -ENXIO when queue->request_fn is NULL. But there are some block drivers that call blk_register_queue() via add_disk() with queue->request_fn == NULL. (For example, brd, loop) Although no one checks return value of blk_register_queue(), this patch makes it return 0 instead of -ENXIO when queue->request_fn is NULL, Also this patch adds warning when blk_register_queue() and blk_unregister_queue() are called with queue == NULL rather than ignore invalid usage silently. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-sysfs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 54d0db1..fc41d83 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -276,9 +276,12 @@ int blk_register_queue(struct gendisk *disk)
struct request_queue *q = disk->queue;
- if (!q || !q->request_fn)
+ if (WARN_ON(!q))
return -ENXIO;
+ if (!q->request_fn)
+ return 0;
+
ret = kobject_add(&q->kobj, kobject_get(&disk->dev.kobj),
"%s", "queue");
if (ret < 0)
@@ -300,7 +303,10 @@ void blk_unregister_queue(struct gendisk *disk)
{
struct request_queue *q = disk->queue;
- if (q && q->request_fn) {
+ if (WARN_ON(!q))
+ return;
+
+ if (q->request_fn) {
elv_unregister_queue(q);
kobject_uevent(&q->kobj, KOBJ_REMOVE);