diff mbox series

[-next] mtd: rawnand: macronix: Use match_string() helper to simplify the code

Message ID 20191230025217.30812-1-yuehaibing@huawei.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series [-next] mtd: rawnand: macronix: Use match_string() helper to simplify the code | expand

Commit Message

Yue Haibing Dec. 30, 2019, 2:52 a.m. UTC
match_string() returns the array index of a matching string.
Use it instead of the open-coded implementation.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/mtd/nand/raw/nand_macronix.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

kernel test robot Dec. 30, 2019, 12:37 p.m. UTC | #1
Hi YueHaibing,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20191220]
[also build test WARNING on linus/master v5.5-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/YueHaibing/mtd-rawnand-macronix-Use-match_string-helper-to-simplify-the-code/20191230-111849
base:    7ddd09fc4b745fb1d8942f95389583e08412e0cd

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

smatch warnings:
drivers/mtd/nand/raw/nand_macronix.c:85 macronix_nand_fix_broken_get_timings() warn: unsigned 'i' is never less than zero.

vim +/i +85 drivers/mtd/nand/raw/nand_macronix.c

    54	
    55	/*
    56	 * Macronix AC series does not support using SET/GET_FEATURES to change
    57	 * the timings unlike what is declared in the parameter page. Unflag
    58	 * this feature to avoid unnecessary downturns.
    59	 */
    60	static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
    61	{
    62		unsigned int i;
    63		static const char * const broken_get_timings[] = {
    64			"MX30LF1G18AC",
    65			"MX30LF1G28AC",
    66			"MX30LF2G18AC",
    67			"MX30LF2G28AC",
    68			"MX30LF4G18AC",
    69			"MX30LF4G28AC",
    70			"MX60LF8G18AC",
    71			"MX30UF1G18AC",
    72			"MX30UF1G16AC",
    73			"MX30UF2G18AC",
    74			"MX30UF2G16AC",
    75			"MX30UF4G18AC",
    76			"MX30UF4G16AC",
    77			"MX30UF4G28AC",
    78		};
    79	
    80		if (!chip->parameters.supports_set_get_features)
    81			return;
    82	
    83		i = match_string(broken_get_timings, ARRAY_SIZE(broken_get_timings),
    84				 chip->parameters.model);
  > 85		if (i < 0)
    86			return;
    87	
    88		bitmap_clear(chip->parameters.get_feature_list,
    89			     ONFI_FEATURE_ADDR_TIMING_MODE, 1);
    90		bitmap_clear(chip->parameters.set_feature_list,
    91			     ONFI_FEATURE_ADDR_TIMING_MODE, 1);
    92	}
    93	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
index 58511ae..5619289 100644
--- a/drivers/mtd/nand/raw/nand_macronix.c
+++ b/drivers/mtd/nand/raw/nand_macronix.c
@@ -80,12 +80,9 @@  static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
 	if (!chip->parameters.supports_set_get_features)
 		return;
 
-	for (i = 0; i < ARRAY_SIZE(broken_get_timings); i++) {
-		if (!strcmp(broken_get_timings[i], chip->parameters.model))
-			break;
-	}
-
-	if (i == ARRAY_SIZE(broken_get_timings))
+	i = match_string(broken_get_timings, ARRAY_SIZE(broken_get_timings),
+			 chip->parameters.model);
+	if (i < 0)
 		return;
 
 	bitmap_clear(chip->parameters.get_feature_list,