All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fathi BOUDRA <fabo@debian.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Fill in remaining MTD driver data for OneNAND (take #2)
Date: Wed, 6 Aug 2008 10:06:20 +0200	[thread overview]
Message-ID: <200808061006.21706.fabo@debian.org> (raw)

Fill in remaining MTD driver data for OneNAND.
Review onenand_print_device_info():
 - Return device info to fill mtd device name.
 - Remove verbose parameter as it become useless.

Since last comments:
 - Include malloc.h
 - Initialize dev_info pointer.

Signed-off-by: Fathi Boudra <fabo@debian.org>
---
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index ce99a38..c9a0627 100644
--- a/common/cmd_onenand.c
+++ b/common/cmd_onenand.c
@@ -38,7 +38,7 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char 
*argv[])
 			onenand_init();
 			return 0;
 		}
-		onenand_print_device_info(onenand_chip.device_id, 1);
+		printf("%s\n", onenand_mtd.name);
 		return 0;
 
 	default:
diff --git a/drivers/mtd/onenand/onenand_base.c 
b/drivers/mtd/onenand/onenand_base.c
index d32e382..8d76724 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -19,6 +19,7 @@
 
 #include <asm/io.h>
 #include <asm/errno.h>
+#include <malloc.h>
 
 /* It should access 16-bit instead of 8-bit */
 static inline void *memcpy_16(void *dst, const void *src, unsigned int len)
@@ -1112,21 +1113,21 @@ int onenand_unlock(struct mtd_info *mtd, loff_t ofs, 
size_t len)
  *
  * Print device ID
  */
-void onenand_print_device_info(int device, int verbose)
+char * onenand_print_device_info(int device)
 {
 	int vcc, demuxed, ddp, density;
-
-	if (!verbose)
-		return;
+	char *dev_info = (char *)malloc(80);
 
 	vcc = device & ONENAND_DEVICE_VCC_MASK;
 	demuxed = device & ONENAND_DEVICE_IS_DEMUX;
 	ddp = device & ONENAND_DEVICE_IS_DDP;
 	density = device >> ONENAND_DEVICE_DENSITY_SHIFT;
-	printk(KERN_INFO "%sOneNAND%s %dMB %sV 16-bit (0x%02x)\n",
+	sprintf(dev_info, "%sOneNAND%s %dMB %sV 16-bit (0x%02x)",
 	       demuxed ? "" : "Muxed ",
 	       ddp ? "(DDP)" : "",
 	       (16 << density), vcc ? "2.65/3.3" : "1.8", device);
+
+	return dev_info;
 }
 
 static const struct onenand_manufacturers onenand_manuf_ids[] = {
@@ -1205,7 +1206,7 @@ static int onenand_probe(struct mtd_info *mtd)
 	}
 
 	/* Flash device information */
-	onenand_print_device_info(dev_id, 0);
+	mtd->name = onenand_print_device_info(dev_id);
 	this->device_id = dev_id;
 
 	density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT;
@@ -1241,6 +1242,18 @@ static int onenand_probe(struct mtd_info *mtd)
 		this->options |= ONENAND_CONT_LOCK;
 	}
 
+	/* Fill in remaining MTD driver data */
+	mtd->erase = onenand_erase;
+	mtd->read = onenand_read;
+	mtd->write = onenand_write;
+	mtd->read_ecc = onenand_read_ecc;
+	mtd->write_ecc = onenand_write_ecc;
+	mtd->read_oob = onenand_read_oob;
+	mtd->write_oob = onenand_write_oob;
+	mtd->sync = onenand_sync;
+	mtd->block_isbad = onenand_block_isbad;
+	mtd->block_markbad = onenand_block_markbad;
+
 	return 0;
 }
 
diff --git a/include/onenand_uboot.h b/include/onenand_uboot.h
index 4449f98..cb7914d 100644
--- a/include/onenand_uboot.h
+++ b/include/onenand_uboot.h
@@ -39,6 +39,6 @@ extern int onenand_erase(struct mtd_info *mtd, struct 
erase_info *instr);
 
 extern int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len);
 
-extern void onenand_print_device_info(int device, int verbose);
+extern char * onenand_print_device_info(int device);
 
 #endif /* __UBOOT_ONENAND_H */

             reply	other threads:[~2008-08-06  8:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06  8:06 Fathi BOUDRA [this message]
2008-08-06 16:09 ` [U-Boot-Users] [PATCH] Fill in remaining MTD driver data for OneNAND (take #2) Scott Wood
2008-08-06 16:18   ` Wolfgang Denk
2008-08-11 20:48 ` [U-Boot] " Scott Wood
  -- strict thread matches above, loose matches on Subject: below --
2008-08-06 16:32 [U-Boot-Users] " Fathi BOUDRA
2008-08-06 16:37 ` Scott Wood

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=200808061006.21706.fabo@debian.org \
    --to=fabo@debian.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.