All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [MTD] cs553x_nand.c: support partitions, cs553x_cleanup() fix (take 2)
@ 2007-01-04 17:41 Indrek Kruusa
  2007-02-09 14:14 ` David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: Indrek Kruusa @ 2007-01-04 17:41 UTC (permalink / raw)
  To: linux-mtd

Hi!

Take 2. Basic (and maybe too simple ;)) naming added for chip selects.

Patch for drivers/mtd/nand/cs553x_nand.c:
- support partitions
- cs553x_cleanup(): try the cleanup for all chip selects

Signed-off-by: Indrek Kruusa <indrek.kruusa@artecdesign.ee>


dmesg:

Probing CS553x NAND controller CS#1 at MMIO 0x20000000
NAND device: Manufacturer ID: 0x98, Chip ID: 0x76 (Toshiba NAND 64MiB 3,3V 8-bit)
2 cmdlinepart partitions found on MTD device cs553x_nand_cs1
Using command line partition definition
Creating 2 MTD partitions on "cs553x_nand_cs1":
0x00000000-0x00600000 : "kernel"
0x00800000-0x03e00000 : "root"





--- mtd-2.6/drivers/mtd/nand/cs553x_nand.c	2007-01-04 17:43:44.000000000 +0200
+++ ik-2.6/drivers/mtd/nand/cs553x_nand.c	2007-01-04 19:21:29.000000000 +0200
@@ -13,6 +13,9 @@
  *  Overview:
  *   This is a device driver for the NAND flash controller found on
  *   the AMD CS5535/CS5536 companion chipsets for the Geode processor.
+ *   Partition table can be defined on command line as follows:
+ *          mtdparts=cs553x_nand_cs1:6m@0m(kernel),54m@8m(root)
+ *   , where cs553x_nand_cs[0-3] reflects the chip select for NAND
  *
  */
 
@@ -186,6 +189,7 @@
 	int err = 0;
 	struct nand_chip *this;
 	struct mtd_info *new_mtd;
+	char mtd_name[16] = "cs553x_nand_csX\0";
 
 	printk(KERN_NOTICE "Probing CS553x NAND controller CS#%d at %sIO 0x%08lx\n", cs, mmio?"MM":"P", adr);
 
@@ -245,6 +249,9 @@
 		goto out_ior;
 	}
 
+	mtd_name[14] = (char)(48 + cs);
+	new_mtd->name = (char*)mtd_name;
+
 	cs553x_mtd[cs] = new_mtd;
 	goto out;
 
@@ -273,12 +280,21 @@
 	return 0;
 }
 
+
+#ifdef CONFIG_MTD_PARTITIONS
+const char *part_probes[] = { "cmdlinepart", NULL };
+#endif
+
+
 static int __init cs553x_init(void)
 {
 	int err = -ENXIO;
 	int i;
 	uint64_t val;
 
+	int mtd_parts_nb = 0;
+	struct mtd_partition *mtd_parts = NULL;
+
 	/* If the CPU isn't a Geode GX or LX, abort */
 	if (!is_geode())
 		return -ENXIO;
@@ -307,9 +323,19 @@
 	   do mtdconcat etc. if we want to. */
 	for (i = 0; i < NR_CS553X_CONTROLLERS; i++) {
 		if (cs553x_mtd[i]) {
-			add_mtd_device(cs553x_mtd[i]);
 
 			/* If any devices registered, return success. Else the last error. */
+#ifdef CONFIG_MTD_PARTITIONS
+			mtd_parts_nb = parse_mtd_partitions(cs553x_mtd[i], part_probes, &mtd_parts, 0);
+			if (mtd_parts_nb > 0) {
+				printk(KERN_NOTICE "Using command line partition definition\n");
+				add_mtd_partitions(cs553x_mtd[i], mtd_parts, mtd_parts_nb);
+			} else {
+				add_mtd_device(cs553x_mtd[i]);
+			}
+#else
+			add_mtd_device(cs553x_mtd[i]);
+#endif
 			err = 0;
 		}
 	}
@@ -329,7 +355,7 @@
 		void __iomem *mmio_base;
 
 		if (!mtd)
-			break;
+			continue;
 
 		this = cs553x_mtd[i]->priv;
 		mmio_base = this->IO_ADDR_R;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [MTD] cs553x_nand.c: support partitions, cs553x_cleanup() fix (take 2)
  2007-01-04 17:41 [PATCH] [MTD] cs553x_nand.c: support partitions, cs553x_cleanup() fix (take 2) Indrek Kruusa
@ 2007-02-09 14:14 ` David Woodhouse
  0 siblings, 0 replies; 2+ messages in thread
From: David Woodhouse @ 2007-02-09 14:14 UTC (permalink / raw)
  To: Indrek Kruusa; +Cc: linux-mtd

On Thu, 2007-01-04 at 19:41 +0200, Indrek Kruusa wrote:
> @@ -186,6 +189,7 @@
>         int err = 0;
>         struct nand_chip *this;
>         struct mtd_info *new_mtd;
> +       char mtd_name[16] = "cs553x_nand_csX\0";
>  
>         printk(KERN_NOTICE "Probing CS553x NAND controller CS#%d at %sIO 0x%08lx\n", cs, mmio?"MM":"P", adr);
>  
> @@ -245,6 +249,9 @@
>                 goto out_ior;
>         }
>  
> +       mtd_name[14] = (char)(48 + cs);
> +       new_mtd->name = (char*)mtd_name;
> +
>         cs553x_mtd[cs] = new_mtd;
>         goto out;
>  
> @@ -273,12 +280,21 @@ 

Then they just end up all pointing to the same original memory. Don't
you need to allocate and strcpy?

-- 
dwmw2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-09 14:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-04 17:41 [PATCH] [MTD] cs553x_nand.c: support partitions, cs553x_cleanup() fix (take 2) Indrek Kruusa
2007-02-09 14:14 ` David Woodhouse

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.