Skip to contentSkip to conversation

mtd: spi: sf_dataflash: Add print message while erase error

PATCH New Wenyou Yang 3 participants 3 messages Jul 21, 2017 – Aug 8, 2017 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: spi: sf_dataflash: Add print message while erase error

Add the print message to tell us why the erase operation doesn't work.

---

 drivers/mtd/spi/sf_dataflash.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/mtd/spi/sf_dataflash.c +8 -2
index b2166ad4e5..a1a79a4d02 100644
@@ -131,11 +131,17 @@ static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len)
 	debug("%s: erase addr=0x%x len 0x%x\n", dev->name, offset, len);
 
 	div_u64_rem(len, spi_flash->page_size, &rem);
-	if (rem)
+	if (rem) {
+		printf("%s: len(0x%x) isn't the multiple of page size(0x%x)\n",
+		       dev->name, len, spi_flash->page_size);
 		return -EINVAL;
+	}
 	div_u64_rem(offset, spi_flash->page_size, &rem);
-	if (rem)
+	if (rem) {
+		printf("%s: offset(0x%x) isn't the multiple of page size(0x%x)\n",
+		       dev->name, offset, spi_flash->page_size);
 		return -EINVAL;
+	}
 
 	status = spi_claim_bus(spi);
 	if (status) {
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/1 mtd: spi: sf_dataflash: Add print message while erase error

Quoted 7 lines · Wenyou Yang

Add the print message to tell us why the erase operation doesn't work.

---

 drivers/mtd/spi/sf_dataflash.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

In general I think it is bad to print messages in drivers. But we don't really have a logging mechanism which we could use instead.

#2 lore raw

PATCH 1/1 mtd: spi: sf_dataflash: Add print message while erase error

Quoted 10 lines · Simon Glass
Quoted 7 lines · Wenyou Yang

Add the print message to tell us why the erase operation doesn't work.

---

 drivers/mtd/spi/sf_dataflash.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Applied to u-boot-spi/master

thanks!

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.