mtd: nand: Get rid of needless 'goto'
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Sat Oct 8 21:59:02 PDT 2016
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=fc6b4d12bc394aa9b5c22aa3a2f5128ad6c84a72
Commit: fc6b4d12bc394aa9b5c22aa3a2f5128ad6c84a72
Parent: 76fe334f71dd20f7eadd4c624441ec7d1fb92f33
Author: Andrey Smirnov <andrew.smirnov at gmail.com>
AuthorDate: Thu Jul 21 14:59:21 2016 -0700
Committer: Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Fri Sep 23 09:35:16 2016 +0200
mtd: nand: Get rid of needless 'goto'
Using "goto" and "switch" statement only makes it harder to follow
control flow and doesn't bring any advantages. Rewrite the code to avoid
using "goto".
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
drivers/mtd/nand/nand_base.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7f742c9..108adef 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2162,7 +2162,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
static int nand_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
{
- int ret = -ENOTSUPP;
+ int ret;
ops->retlen = 0;
@@ -2173,24 +2173,18 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
return -EINVAL;
}
- nand_get_device(mtd, FL_READING);
-
- switch (ops->mode) {
- case MTD_OPS_PLACE_OOB:
- case MTD_OPS_AUTO_OOB:
- case MTD_OPS_RAW:
- break;
+ if (ops->mode != MTD_OPS_PLACE_OOB &&
+ ops->mode != MTD_OPS_AUTO_OOB &&
+ ops->mode != MTD_OPS_RAW)
+ return -ENOTSUPP;
- default:
- goto out;
- }
+ nand_get_device(mtd, FL_READING);
if (!ops->datbuf)
ret = nand_do_read_oob(mtd, from, ops);
else
ret = nand_do_read_ops(mtd, from, ops);
-out:
nand_release_device(mtd);
return ret;
}
More information about the linux-mtd-cvs
mailing list