Re: [PATCH 3/4] mtd: Factor out OF partition support from the NOR driver.

2008-01-08 Thread David Woodhouse
Please adjust for commit 4edaf56e0f8a6f71e3361bf74e3dc835811761e6 and
resend.

-- 
dwmw2

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 3/4] mtd: Factor out OF partition support from the NOR driver.

2008-01-07 Thread Stefan Roese
On Thursday 13 December 2007, Scott Wood wrote:
> Signed-off-by: Scott Wood <[EMAIL PROTECTED]>

Acked-by: Stefan Roese <[EMAIL PROTECTED]>

Best regards,
Stefan
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 3/4] mtd: Factor out OF partition support from the NOR driver.

2007-12-13 Thread Scott Wood
Signed-off-by: Scott Wood <[EMAIL PROTECTED]>
---
 drivers/mtd/Kconfig|8 
 drivers/mtd/Makefile   |1 +
 drivers/mtd/maps/physmap_of.c  |   88 ---
 drivers/mtd/ofpart.c   |   68 +++
 include/linux/mtd/partitions.h |9 -
 5 files changed, 112 insertions(+), 62 deletions(-)
 create mode 100644 drivers/mtd/ofpart.c

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 8848e8a..b729410 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -150,6 +150,14 @@ config MTD_AFS_PARTS
  for your particular device. It won't happen automatically. The
  'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example.
 
+config MTD_OF_PARTS
+   tristate "Flash partition map based on OF description"
+   depends on PPC_OF && MTD_PARTITIONS
+   help
+ This provides a partition parsing function which derives
+ the partition map from the children of the flash node,
+ as described in Documentation/powerpc/booting-without-of.txt.
+
 comment "User Modules And Translation Layers"
 
 config MTD_CHAR
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 7f0b04b..538e33d 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_MTD_CONCAT)  += mtdconcat.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
 obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
 obj-$(CONFIG_MTD_AFS_PARTS)+= afs.o
+obj-$(CONFIG_MTD_OF_PARTS)  += ofpart.o
 
 # 'Users' - code which presents functionality to userspace.
 obj-$(CONFIG_MTD_CHAR) += mtdchar.o
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index aeed9ea..49acd41 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -80,64 +80,6 @@ static int parse_obsolete_partitions(struct of_device *dev,
 
return nr_parts;
 }
-
-static int __devinit parse_partitions(struct of_flash *info,
- struct of_device *dev)
-{
-   const char *partname;
-   static const char *part_probe_types[]
-   = { "cmdlinepart", "RedBoot", NULL };
-   struct device_node *dp = dev->node, *pp;
-   int nr_parts, i;
-
-   /* First look for RedBoot table or partitions on the command
-* line, these take precedence over device tree information */
-   nr_parts = parse_mtd_partitions(info->mtd, part_probe_types,
-   &info->parts, 0);
-   if (nr_parts > 0) {
-   add_mtd_partitions(info->mtd, info->parts, nr_parts);
-   return 0;
-   }
-
-   /* First count the subnodes */
-   nr_parts = 0;
-   for (pp = dp->child; pp; pp = pp->sibling)
-   nr_parts++;
-
-   if (nr_parts == 0)
-   return parse_obsolete_partitions(dev, info, dp);
-
-   info->parts = kzalloc(nr_parts * sizeof(*info->parts),
- GFP_KERNEL);
-   if (!info->parts)
-   return -ENOMEM;
-
-   for (pp = dp->child, i = 0; pp; pp = pp->sibling, i++) {
-   const u32 *reg;
-   int len;
-
-   reg = of_get_property(pp, "reg", &len);
-   if (!reg || (len != 2*sizeof(u32))) {
-   dev_err(&dev->dev, "Invalid 'reg' on %s\n",
-   dp->full_name);
-   kfree(info->parts);
-   info->parts = NULL;
-   return -EINVAL;
-   }
-   info->parts[i].offset = reg[0];
-   info->parts[i].size = reg[1];
-
-   partname = of_get_property(pp, "label", &len);
-   if (!partname)
-   partname = of_get_property(pp, "name", &len);
-   info->parts[i].name = (char *)partname;
-
-   if (of_get_property(pp, "read-only", &len))
-   info->parts[i].mask_flags = MTD_WRITEABLE;
-   }
-
-   return nr_parts;
-}
 #else /* MTD_PARTITIONS */
 #defineOF_FLASH_PARTS(info)(0)
 #define parse_partitions(info, dev)(0)
@@ -212,6 +154,10 @@ static struct mtd_info * __devinit obsolete_probe(struct 
of_device *dev,
 static int __devinit of_flash_probe(struct of_device *dev,
const struct of_device_id *match)
 {
+#ifdef CONFIG_MTD_PARTITIONS
+   static const char *part_probe_types[]
+   = { "cmdlinepart", "RedBoot", NULL };
+#endif
struct device_node *dp = dev->node;
struct resource res;
struct of_flash *info;
@@ -274,13 +220,33 @@ static int __devinit of_flash_probe(struct of_device *dev,
}
info->mtd->owner = THIS_MODULE;
 
-   err = parse_partitions(info, dev);
+#ifdef CONFIG_MTD_PARTITIONS
+   /* First look for RedBoot table or partitions on the command
+* line, these take precedence over device tree info