linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: linux-mtd@lists.infradead.org
Cc: "Vignesh Raghavendra" <vigneshr@ti.com>,
	"Tudor Ambarus" <tudor.ambarus@microchip.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	linux-kernel@vger.kernel.org,
	"Miquel Raynal" <miquel.raynal@bootlin.com>
Subject: [PATCH] mtd: spi-nor: Simplify loop in spi_nor_read_id()
Date: Tue, 18 Feb 2020 16:10:34 +0100	[thread overview]
Message-ID: <20200218151034.24744-1-j.neuschaefer@gmx.net> (raw)

- Don't use `tmp` for two purposes (return value, loop counter)
- Name the loop counter `i`, as is convention
- Return the pointer variable that the if conditions leading up to the
  return statement already operate on, rather than a different
  expression that evaluates to the same pointer

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 drivers/mtd/spi-nor/spi-nor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 4fc632ec18fe..c491572d5267 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2711,7 +2711,7 @@ static const struct flash_info spi_nor_ids[] = {

 static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
 {
-	int			tmp;
+	int			tmp, i;
 	u8			*id = nor->bouncebuf;
 	const struct flash_info	*info;

@@ -2732,11 +2732,11 @@ static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
 		return ERR_PTR(tmp);
 	}

-	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
-		info = &spi_nor_ids[tmp];
+	for (i = 0; i < ARRAY_SIZE(spi_nor_ids) - 1; i++) {
+		info = &spi_nor_ids[i];
 		if (info->id_len) {
 			if (!memcmp(info->id, id, info->id_len))
-				return &spi_nor_ids[tmp];
+				return info;
 		}
 	}
 	dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n",
--
2.20.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

             reply	other threads:[~2020-02-18 15:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 15:10 Jonathan Neuschäfer [this message]
2020-02-19  8:06 ` [PATCH] mtd: spi-nor: Simplify loop in spi_nor_read_id() Tudor.Ambarus
2020-02-21 16:22   ` Jonathan Neuschäfer
2020-02-21 16:50     ` Tudor.Ambarus
2020-02-22 21:51       ` Jonathan Neuschäfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200218151034.24744-1-j.neuschaefer@gmx.net \
    --to=j.neuschaefer@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@microchip.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).