MTD: Fix wrong check register_blkdev return value
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Sat Oct 30 07:59:01 EDT 2010
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=6fe4c590313133ebd5dadb769031489ff178ece1
Commit: 6fe4c590313133ebd5dadb769031489ff178ece1
Parent: 6411bf6cdfe9b444bc3aa0c23f8cf35460d69432
Author: Frank Li <Frank.Li at freescale.com>
AuthorDate: Tue Oct 26 11:02:19 2010 +0800
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sat Oct 30 12:30:50 2010 +0100
MTD: Fix wrong check register_blkdev return value
register_blkdev return 1..255 when major = 0.
if (ret ) {
printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
tr->name, tr->major, ret);
mutex_unlock(&mtd_table_mutex);
return ret;
}
Above code will return fail when register_blkdev return allocated major number.
Signed-off-by: Frank Li <Frank.Li at freescale.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/mtd_blkdevs.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index a919587..63790e9 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -502,13 +502,16 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
mutex_lock(&mtd_table_mutex);
ret = register_blkdev(tr->major, tr->name);
- if (ret) {
+ if (ret < 0) {
printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
tr->name, tr->major, ret);
mutex_unlock(&mtd_table_mutex);
return ret;
}
+ if (ret)
+ tr->major = ret;
+
tr->blkshift = ffs(tr->blksize) - 1;
INIT_LIST_HEAD(&tr->devs);
More information about the linux-mtd-cvs
mailing list