public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 08/12] mtd: dataflash: Minor cleanups
Date: Fri, 12 Feb 2016 14:06:13 +0530	[thread overview]
Message-ID: <1455266174-3240-9-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1455266174-3240-1-git-send-email-jteki@openedev.com>

- rename spi_dataflash to mtd_dataflash
- 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: Bin Meng <bmeng.cn@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: York Sun <york.sun@nxp.com>
Cc: Haikun Wang <haikun.wang@freescale.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
 drivers/mtd/spi-nor/sf_dataflash.c | 51 ++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c b/drivers/mtd/spi-nor/sf_dataflash.c
index 9943560..2a5f5ae 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -1,5 +1,4 @@
 /*
- *
  * Atmel DataFlash probing
  *
  * Copyright (C) 2016 Jagan Teki <jteki@openedev.com>
@@ -7,8 +6,10 @@
  * 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>
@@ -67,7 +68,6 @@
 #define OP_WRITE_SECURITY_REVC	0x9A
 #define OP_WRITE_SECURITY	0x9B	/* revision D */
 
-
 struct dataflash {
 	uint8_t			command[16];
 
@@ -77,9 +77,7 @@ struct dataflash {
 	struct spi_slave	*spi;
 };
 
-/*
- * 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;
@@ -118,9 +116,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 dataflash	*priv = mtd->priv;
@@ -145,7 +141,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;
 	}
 
@@ -231,7 +227,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;
 	}
 
@@ -290,7 +286,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;
 	}
 
@@ -387,7 +383,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;
@@ -551,7 +547,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;
 				}
@@ -573,10 +569,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);
 }
 
 /*
@@ -593,7 +587,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 spi_slave	*spi = dev_get_parent_priv(dev);
 	struct flash_info	*info;
@@ -621,19 +615,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.
@@ -663,8 +657,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;
 	}
@@ -678,16 +671,16 @@ 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", },
 	{ }
 };
 
-U_BOOT_DRIVER(spi_dataflash) = {
-	.name		= "spi_dataflash",
+U_BOOT_DRIVER(mtd_dataflash) = {
+	.name		= "mtd_dataflash",
 	.id		= UCLASS_MTD,
-	.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

  parent reply	other threads:[~2016-02-12  8:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12  8:36 [U-Boot] [PATCH 00/12] mtd: dataflash: Add UCLASS_MTD Jagan Teki
2016-02-12  8:36 ` [U-Boot] [PATCH 01/12] mtd: spi-nor: Copy sf_dataflash Jagan Teki
2016-02-12 16:55   ` york sun
2016-02-12 17:51     ` Jagan Teki
2016-02-12 19:12       ` york sun
2016-02-12 19:28     ` Simon Glass
2016-02-12 19:31     ` Simon Glass
2016-02-12  8:36 ` [U-Boot] [PATCH 02/12] mtd: dataflash: Remove unneeded spi data Jagan Teki
2016-02-12  8:36 ` [U-Boot] [PATCH 03/12] mtd: dataflash: Move flash id detection into jedec_probe Jagan Teki
2016-02-12  8:36 ` [U-Boot] [PATCH 04/12] mtd: dataflash: Fix add_dataflash return logic Jagan Teki
2016-02-12  8:36 ` [U-Boot] [PATCH 05/12] mtd: dataflash: Add UCLASS_MTD support Jagan Teki
2016-02-12  8:36 ` [U-Boot] [PATCH 06/12] mtd: dataflash: Use spi_write_then_read Jagan Teki
2016-02-12  8:36 ` [U-Boot] [PATCH 07/12] mtd: dataflash: Drop sf_internal.h Jagan Teki
2016-02-12  8:36 ` Jagan Teki [this message]
2016-02-12  8:36 ` [U-Boot] [PATCH 09/12] mtd: Rename sf_dataflash.c to mtd_dataflash.c Jagan Teki

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=1455266174-3240-9-git-send-email-jteki@openedev.com \
    --to=jteki@openedev.com \
    --cc=u-boot@lists.denx.de \
    /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