Skip to content

Commit 41c9c66

Browse files
ndreyscomputersforpeace
authored andcommitted
mtd: dataflash: Improve coding style in jedec_probe()
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: [email protected] Cc: David Woodhouse <[email protected]> Cc: Brian Norris <[email protected]> Cc: Boris Brezillon <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Cyrille Pitchen <[email protected]> Cc: Marek Vasut <[email protected]> Cc: [email protected] Acked-by: Marek Vasut <[email protected]> Tested-by: Chris Healy <[email protected]> Signed-off-by: Andrey Smirnov <[email protected]> Signed-off-by: Brian Norris <[email protected]>
1 parent c41e43c commit 41c9c66

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

drivers/mtd/devices/mtd_dataflash.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#define OP_WRITE_SECURITY_REVC 0x9A
8383
#define OP_WRITE_SECURITY 0x9B /* revision D */
8484

85+
#define CFI_MFR_ATMEL 0x1F
8586

8687
struct dataflash {
8788
u8 command[4];
@@ -738,28 +739,30 @@ static struct flash_info dataflash_data[] = {
738739

739740
static struct flash_info *jedec_probe(struct spi_device *spi)
740741
{
741-
int tmp;
742-
u8 code = OP_READ_ID;
743-
u8 id[3];
744-
u32 jedec;
745-
struct flash_info *info;
742+
int ret, i;
743+
u8 code = OP_READ_ID;
744+
u8 id[3];
745+
u32 jedec;
746+
struct flash_info *info;
746747
int status;
747748

748-
/* JEDEC also defines an optional "extended device information"
749+
/*
750+
* JEDEC also defines an optional "extended device information"
749751
* string for after vendor-specific data, after the three bytes
750752
* we use here. Supporting some chips might require using it.
751753
*
752754
* If the vendor ID isn't Atmel's (0x1f), assume this call failed.
753755
* That's not an error; only rev C and newer chips handle it, and
754756
* only Atmel sells these chips.
755757
*/
756-
tmp = spi_write_then_read(spi, &code, 1, id, 3);
757-
if (tmp < 0) {
758+
ret = spi_write_then_read(spi, &code, 1, id, 3);
759+
if (ret < 0) {
758760
pr_debug("%s: error %d reading JEDEC ID\n",
759-
dev_name(&spi->dev), tmp);
760-
return ERR_PTR(tmp);
761+
dev_name(&spi->dev), ret);
762+
return ERR_PTR(ret);
761763
}
762-
if (id[0] != 0x1f)
764+
765+
if (id[0] != CFI_MFR_ATMEL)
763766
return NULL;
764767

765768
jedec = id[0];
@@ -768,9 +771,9 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
768771
jedec = jedec << 8;
769772
jedec |= id[2];
770773

771-
for (tmp = 0, info = dataflash_data;
772-
tmp < ARRAY_SIZE(dataflash_data);
773-
tmp++, info++) {
774+
for (i = 0, info = dataflash_data;
775+
i < ARRAY_SIZE(dataflash_data);
776+
i++, info++) {
774777
if (info->jedec_id == jedec) {
775778
pr_debug("%s: OTP, sector protect%s\n",
776779
dev_name(&spi->dev),

0 commit comments

Comments
 (0)