[U-Boot] [PATCH v7 34/34] mtd: dataflash: Minor cleanups

Jagan Teki jteki at openedev.com
Thu Nov 26 13:04:18 CET 2015


- fix single line comments
- remove unneeded spaces
- ascending order of include files
- rename spi_dataflash_* to dataflash_*
- rename SPI DATAFLASH to dataflash
- rename SPI DataFlash to dataflash
- return NULL replaced with error code

Cc: Haikun Wang <haikun.wang at freescale.com>
Signed-off-by: Jagan Teki <jteki at openedev.com>
---
 drivers/mtd/spi/mtd_dataflash.c | 50 +++++++++++++++++------------------------
 1 file changed, 21 insertions(+), 29 deletions(-)

diff --git a/drivers/mtd/spi/mtd_dataflash.c b/drivers/mtd/spi/mtd_dataflash.c
index bdface2..65ac5e9 100644
--- a/drivers/mtd/spi/mtd_dataflash.c
+++ b/drivers/mtd/spi/mtd_dataflash.c
@@ -1,5 +1,4 @@
 /*
- *
  * Atmel DataFlash probing
  *
  * Copyright (C) 2015 Jagan Teki <jteki at openedev.com>
@@ -7,14 +6,15 @@
  * Haikun Wang (haikun.wang at freescale.com)
  *
  * SPDX-License-Identifier:	GPL-2.0+
-*/
+ */
+
 #include <common.h>
+#include <div64.h>
 #include <dm.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <spi.h>
 #include <spi_flash.h>
-#include <div64.h>
 #include <linux/err.h>
 #include <linux/math64.h>
 #include <linux/mtd/mtd.h>
@@ -69,7 +69,6 @@
 #define OP_WRITE_SECURITY_REVC	0x9A
 #define OP_WRITE_SECURITY	0x9B	/* revision D */
 
-
 struct dataflash {
 	uint8_t			command[16];
 
@@ -79,9 +78,7 @@ struct dataflash {
 	struct mtd_info		mtd;
 };
 
-/*
- * Return the status of the DataFlash device.
- */
+/* Return the status of the DataFlash device */
 static inline int dataflash_status(struct spi_slave *spi)
 {
 	int ret;
@@ -120,9 +117,7 @@ static int dataflash_waitready(struct spi_slave *spi)
 	return -ETIME;
 }
 
-/*
- * Erase pages of flash.
- */
+/* Erase pages of flash */
 static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
 	struct spi_flash	*flash = mtd->priv;
@@ -148,7 +143,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 
 	status = spi_claim_bus(spi);
 	if (status) {
-		debug("SPI DATAFLASH: unable to claim SPI bus\n");
+		debug("dataflash: unable to claim SPI bus\n");
 		return status;
 	}
 
@@ -235,7 +230,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
 
 	status = spi_claim_bus(spi);
 	if (status) {
-		debug("SPI DATAFLASH: unable to claim SPI bus\n");
+		debug("dataflash: unable to claim SPI bus\n");
 		return status;
 	}
 
@@ -295,7 +290,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 	status = spi_claim_bus(spi);
 	if (status) {
-		debug("SPI DATAFLASH: unable to claim SPI bus\n");
+		debug("dataflash: unable to claim SPI bus\n");
 		return status;
 	}
 
@@ -392,7 +387,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 		/* Check result of the compare operation */
 		if (status & (1 << 6)) {
-			printf("SPI DataFlash: write compare page %u, err %d\n",
+			printf("dataflash: write compare page %u, err %d\n",
 			       pageaddr, status);
 			remaining = 0;
 			status = -EIO;
@@ -440,7 +435,7 @@ static int add_dataflash(struct spi_flash *flash, char *name, int nr_pages,
 	mtd->_write = dataflash_write;
 
 #ifndef CONFIG_SPL_BUILD
-	printf("SPI DataFlash: Detected %s with page size ", flash->name);
+	printf("DATAFLASH: Detected %s with page size ", flash->name);
 	print_size(priv->page_size, ", erase size ");
 	print_size(mtd->erasesize, ", total ");
 	print_size(mtd->size, "");
@@ -553,7 +548,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
 			if (info->flags & SUP_POW2PS) {
 				status = dataflash_status(spi);
 				if (status < 0) {
-					debug("SPI DataFlash: status error %d\n",
+					debug("dataflash: status error %d\n",
 					      status);
 					return NULL;
 				}
@@ -575,10 +570,8 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
 	 * size (it might be binary) even when we can tell which density
 	 * class is involved (legacy chip id scheme).
 	 */
-	printf("SPI DataFlash: Unsupported flash IDs: ");
-	printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
-	       id[0], jedec, id[3] << 8 | id[4]);
-	return NULL;
+	printf("dataflash: JEDEC id %06x not handled\n", jedec);
+	return ERR_PTR(-ENODEV);
 }
 
 /*
@@ -595,7 +588,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
  *   AT45DB0642  64Mbit  (8M)    xx111xxx (0x3c)   8192   1056     11
  *   AT45DB1282  128Mbit (16M)   xx0100xx (0x10)  16384   1056     11
  */
-static int spi_dataflash_probe(struct udevice *dev)
+static int dataflash_probe(struct udevice *dev)
 {
 	struct dataflash	*priv = dev_get_priv(dev);
 	struct spi_slave	*spi = dev_get_parent_priv(dev);
@@ -633,19 +626,19 @@ static int spi_dataflash_probe(struct udevice *dev)
 			goto err_status;
 	}
 
-	/*
+       /*
 	* Older chips support only legacy commands, identifing
 	* capacity using bits in the status byte.
 	*/
 	status = dataflash_status(spi);
 	if (status <= 0 || status == 0xff) {
-		printf("SPI DataFlash: read status error %d\n", status);
+		printf("dataflash: read status error %d\n", status);
 		if (status == 0 || status == 0xff)
 			status = -ENODEV;
 		goto err_jedec_probe;
 	}
 
-	/*
+       /*
 	* if there's a device there, assume it's dataflash.
 	* board setup should have set spi->max_speed_max to
 	* match f(car) for continuous reads, mode 0 or 3.
@@ -675,8 +668,7 @@ static int spi_dataflash_probe(struct udevice *dev)
 		break;
 	/* obsolete AT45DB1282 not (yet?) supported */
 	default:
-		dev_info(&spi->dev, "unsupported device (%x)\n",
-			 status & 0x3c);
+		printf("dataflash: unsupported device (%x)\n", status & 0x3c);
 		status = -ENODEV;
 		goto err_status;
 	}
@@ -690,7 +682,7 @@ err_jedec_probe:
 	return status;
 }
 
-static const struct udevice_id spi_dataflash_ids[] = {
+static const struct udevice_id dataflash_ids[] = {
 	{ .compatible = "atmel,at45", },
 	{ .compatible = "atmel,dataflash", },
 	{ }
@@ -699,7 +691,7 @@ static const struct udevice_id spi_dataflash_ids[] = {
 U_BOOT_DRIVER(spi_dataflash) = {
 	.name		= "spi_dataflash",
 	.id		= UCLASS_SPI_FLASH,
-	.of_match	= spi_dataflash_ids,
-	.probe		= spi_dataflash_probe,
+	.of_match	= dataflash_ids,
+	.probe		= dataflash_probe,
 	.priv_auto_alloc_size = sizeof(struct dataflash),
 };
-- 
1.9.1



More information about the U-Boot mailing list