mtd: dataflash: Get rid of loop counter in jedec_probe()
authorAndrey Smirnov <andrew.smirnov@gmail.com>
Fri, 21 Apr 2017 16:30:24 +0000 (09:30 -0700)
committerBrian Norris <computersforpeace@gmail.com>
Thu, 11 May 2017 17:04:39 +0000 (10:04 -0700)
"For" loop in jedec_probe can be simplified to not need counter
'i'. Convert the code and get rid of the variable.

Cc: cphealy@gmail.com
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Tested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/devices/mtd_dataflash.c

index ccd1e024d343baff31cc3d7194145909c923b917..2d3e4034b591474b0345175f14f2356bba5f9d96 100644 (file)
@@ -736,7 +736,7 @@ static struct flash_info dataflash_data[] = {
 
 static struct flash_info *jedec_probe(struct spi_device *spi)
 {
-       int ret, i;
+       int ret;
        u8 code = OP_READ_ID;
        u8 id[3];
        u32 jedec;
@@ -767,9 +767,9 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
        jedec = jedec << 8;
        jedec |= id[2];
 
-       for (i = 0, info = dataflash_data;
-                       i < ARRAY_SIZE(dataflash_data);
-                       i++, info++) {
+       for (info = dataflash_data;
+            info < dataflash_data + ARRAY_SIZE(dataflash_data);
+            info++) {
                if (info->jedec_id == jedec) {
                        dev_dbg(&spi->dev, "OTP, sector protect%s\n",
                                (info->flags & SUP_POW2PS) ?