Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1625364

[PATCH v2 2/3] mtd: dataflash: Improve coding style in jedec_probe()

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Andrey Smirnov <andrew.smirnov@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/3] mtd: dataflash: Improve coding style in jedec_probe()
Date Tue, 18 Apr 2017 16:30:03 +0200
Message-ID <txCiL-7dQ-29@gated-at.bofh.it> (permalink)
References <txCiK-7dQ-15@gated-at.bofh.it>
X-Original-To linux-mtd@lists.infradead.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JgxFwnGgh7C4SKnOon0eVwawXAbLUXPK8zB1WyVw4fc=; b=aP34NKVRGUTZGJc6k8JYnCazvpdxz6e35SevgxQXKdC3sB5UaU587hbwqElnmICyV6 RhbBs1MdbzRwL/e8ExYXbqFr6+6vYfP8Uac/Q6e55LbkUhM4ai7P+wN4kmoYmYq64wv6 jsRStVy+0PcWidNNLzlOPtHzneS6fF0kGqnozEiiQYYGCALQy/0jN/HTWE8TgrLOpTgp kKe3IHk9nCeJysutB4KYj3uEJ6pek/iStyIpukTjQo8R2nmeJ3dbbvIiKUA794R08t0Q NdOBioxab62QdGBpMAZ5bX2GtDYayCU3Q7gi1pkHKfnSQwqndOYT+ngMEuslyb8a05qW Y6fg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JgxFwnGgh7C4SKnOon0eVwawXAbLUXPK8zB1WyVw4fc=; b=Fyv/vwJz6XLHMYOdxOv3ibNnxZXN1XcVgIifYdtgpQcLumexRnrok1SCR1yI5kObvE 1YlKFUJb5KYG1Ct/MmKT+z3b8arf5nlEbJbLETlCE1tLkKJIr/g0LkvP5Myp6i90V6gh ryc7Gb3hSltliwYKpfEQYTeMfBdyK32Ii9UNkWYmII7j9WNnK6MHD8SXZeoskRT6As/W fHOQh3XxWbTKvgJwufammxiZ4sATycelWw2ovIWpGFq1EojsFBMyj6pmulpC3LiRMhLW uBw8evSvKD/efjjk4ehLm+yiK5ceyJC8Neb8jBcZazWVW46QhuraAcnSttqzMgNo7Uo0 5Wng==
X-Gm-Message-State AN3rC/6MiK0sNKlkT/Ay47AtOQYUpF1caZvEotYuVrhAIYvLStWh++ry CWTis40LZrebXw==
X-Received by 10.84.209.174 with SMTP id y43mr14502509plh.132.1492525309747; Tue, 18 Apr 2017 07:21:49 -0700 (PDT)
X-Mailer git-send-email 2.9.3
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 95
Organization linux.* mail to news gateway
X-Original-Cc Andrey Smirnov <andrew.smirnov@gmail.com>, cphealy@gmail.com, David Woodhouse <dwmw2@infradead.org>, Brian Norris <computersforpeace@gmail.com>, Boris Brezillon <boris.brezillon@free-electrons.com>, Marek Vasut <marek.vasut@gmail.com>, Richard Weinberger <richard@nod.at>, Cyrille Pitchen <cyrille.pitchen@atmel.com>, linux-kernel@vger.kernel.org
X-Original-Date Tue, 18 Apr 2017 07:21:26 -0700
X-Original-Message-ID <20170418142127.23301-2-andrew.smirnov@gmail.com>
X-Original-References <20170418142127.23301-1-andrew.smirnov@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1625364

Show key headers only | View raw


As per request from Marek Vasut, change the following:

   - Replace indentation between type and name of local variable from
     tabs to spaces

   - Replace magic number 0x1F with CFI_MFR_ATMEL macro

   - Replace variable 'tmp' with 'ret' and 'i' where appropriate

   - Reformat multi-line comments and add newlines where appropriate

No functional change intended.

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
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mtd/devices/mtd_dataflash.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index a566231..5b7a8c3 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -82,6 +82,7 @@
 #define OP_WRITE_SECURITY_REVC	0x9A
 #define OP_WRITE_SECURITY	0x9B	/* revision D */
 
+#define CFI_MFR_ATMEL		0x1F
 
 struct dataflash {
 	u8			command[4];
@@ -738,14 +739,15 @@ static struct flash_info dataflash_data[] = {
 
 static struct flash_info *jedec_probe(struct spi_device *spi)
 {
-	int			tmp;
-	u8			code = OP_READ_ID;
-	u8			id[3];
-	u32			jedec;
-	struct flash_info	*info;
+	int ret, i;
+	u8 code = OP_READ_ID;
+	u8 id[3];
+	u32 jedec;
+	struct flash_info *info;
 	int status;
 
-	/* JEDEC also defines an optional "extended device information"
+	/*
+	 * JEDEC also defines an optional "extended device information"
 	 * string for after vendor-specific data, after the three bytes
 	 * we use here.  Supporting some chips might require using it.
 	 *
@@ -753,13 +755,14 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
 	 * That's not an error; only rev C and newer chips handle it, and
 	 * only Atmel sells these chips.
 	 */
-	tmp = spi_write_then_read(spi, &code, 1, id, 3);
-	if (tmp < 0) {
+	ret = spi_write_then_read(spi, &code, 1, id, 3);
+	if (ret < 0) {
 		pr_debug("%s: error %d reading JEDEC ID\n",
-			dev_name(&spi->dev), tmp);
-		return ERR_PTR(tmp);
+			dev_name(&spi->dev), ret);
+		return ERR_PTR(ret);
 	}
-	if (id[0] != 0x1f)
+
+	if (id[0] != CFI_MFR_ATMEL)
 		return NULL;
 
 	jedec = id[0];
@@ -768,9 +771,9 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
 	jedec = jedec << 8;
 	jedec |= id[2];
 
-	for (tmp = 0, info = dataflash_data;
-			tmp < ARRAY_SIZE(dataflash_data);
-			tmp++, info++) {
+	for (i = 0, info = dataflash_data;
+			i < ARRAY_SIZE(dataflash_data);
+			i++, info++) {
 		if (info->jedec_id == jedec) {
 			pr_debug("%s: OTP, sector protect%s\n",
 				dev_name(&spi->dev),
-- 
2.9.3

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/3] mtd: dataflash: Replace C99 type with their kernel counterparts Andrey Smirnov <andrew.smirnov@gmail.com> - 2017-04-18 16:30 +0200
  [PATCH v2 2/3] mtd: dataflash: Improve coding style in jedec_probe() Andrey Smirnov <andrew.smirnov@gmail.com> - 2017-04-18 16:30 +0200
    Re: [PATCH v2 2/3] mtd: dataflash: Improve coding style in  jedec_probe() Marek Vasut <marek.vasut@gmail.com> - 2017-04-18 21:10 +0200
      Re: [PATCH v2 2/3] mtd: dataflash: Improve coding style in  jedec_probe() Marek Vasut <marek.vasut@gmail.com> - 2017-04-19 00:40 +0200
      Re: [PATCH v2 2/3] mtd: dataflash: Improve coding style in  jedec_probe() Joe Perches <joe@perches.com> - 2017-04-19 00:40 +0200
  [PATCH v2 3/3] mtd: dataflash: Make use of "extened device information" Andrey Smirnov <andrew.smirnov@gmail.com> - 2017-04-18 16:30 +0200
    Re: [PATCH v2 3/3] mtd: dataflash: Make use of "extened device  information" Marek Vasut <marek.vasut@gmail.com> - 2017-04-18 21:10 +0200
      Re: [PATCH v2 3/3] mtd: dataflash: Make use of "extened device information" Andrey Smirnov <andrew.smirnov@gmail.com> - 2017-04-19 05:00 +0200
        Re: [PATCH v2 3/3] mtd: dataflash: Make use of "extened device  information" Marek Vasut <marek.vasut@gmail.com> - 2017-04-19 10:50 +0200
          Re: [PATCH v2 3/3] mtd: dataflash: Make use of "extened device information" Andrey Smirnov <andrew.smirnov@gmail.com> - 2017-04-19 17:10 +0200
            Re: [PATCH v2 3/3] mtd: dataflash: Make use of "extened device  information" Marek Vasut <marek.vasut@gmail.com> - 2017-04-19 17:40 +0200
  Re: [PATCH v2 1/3] mtd: dataflash: Replace C99 type with their kernel  counterparts Marek Vasut <marek.vasut@gmail.com> - 2017-04-18 21:10 +0200

csiph-web