提交 fc6b4d12 编写于 作者: A Andrey Smirnov 提交者: Boris Brezillon

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: NBrian Norris <computersforpeace@gmail.com>
Signed-off-by: NAndrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com>
上级 76fe334f
...@@ -2162,7 +2162,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -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, static int nand_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops) struct mtd_oob_ops *ops)
{ {
int ret = -ENOTSUPP; int ret;
ops->retlen = 0; ops->retlen = 0;
...@@ -2173,24 +2173,18 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -2173,24 +2173,18 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
return -EINVAL; return -EINVAL;
} }
nand_get_device(mtd, FL_READING); if (ops->mode != MTD_OPS_PLACE_OOB &&
ops->mode != MTD_OPS_AUTO_OOB &&
switch (ops->mode) { ops->mode != MTD_OPS_RAW)
case MTD_OPS_PLACE_OOB: return -ENOTSUPP;
case MTD_OPS_AUTO_OOB:
case MTD_OPS_RAW:
break;
default: nand_get_device(mtd, FL_READING);
goto out;
}
if (!ops->datbuf) if (!ops->datbuf)
ret = nand_do_read_oob(mtd, from, ops); ret = nand_do_read_oob(mtd, from, ops);
else else
ret = nand_do_read_ops(mtd, from, ops); ret = nand_do_read_ops(mtd, from, ops);
out:
nand_release_device(mtd); nand_release_device(mtd);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册