Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

authored by

Andrey Smirnov and committed by
Boris Brezillon
fc6b4d12 76fe334f

+6 -12
+6 -12
drivers/mtd/nand/nand_base.c
··· 2162 2162 static int nand_read_oob(struct mtd_info *mtd, loff_t from, 2163 2163 struct mtd_oob_ops *ops) 2164 2164 { 2165 - int ret = -ENOTSUPP; 2165 + int ret; 2166 2166 2167 2167 ops->retlen = 0; 2168 2168 ··· 2173 2173 return -EINVAL; 2174 2174 } 2175 2175 2176 + if (ops->mode != MTD_OPS_PLACE_OOB && 2177 + ops->mode != MTD_OPS_AUTO_OOB && 2178 + ops->mode != MTD_OPS_RAW) 2179 + return -ENOTSUPP; 2180 + 2176 2181 nand_get_device(mtd, FL_READING); 2177 - 2178 - switch (ops->mode) { 2179 - case MTD_OPS_PLACE_OOB: 2180 - case MTD_OPS_AUTO_OOB: 2181 - case MTD_OPS_RAW: 2182 - break; 2183 - 2184 - default: 2185 - goto out; 2186 - } 2187 2182 2188 2183 if (!ops->datbuf) 2189 2184 ret = nand_do_read_oob(mtd, from, ops); 2190 2185 else 2191 2186 ret = nand_do_read_ops(mtd, from, ops); 2192 2187 2193 - out: 2194 2188 nand_release_device(mtd); 2195 2189 return ret; 2196 2190 }