[PATCH][MTD] mtdpart.c: allow other drivers to get physical address of partition

Jared Hulbert jaredeh at gmail.com
Thu Jul 26 20:04:56 EDT 2007


This is necessary to XIP applications because vm_insert_pfn() requires
a physical address.  Allows AXFS to get the physical address on the
flash of it's partition.  Second try, see
(www.infradead.org/pipermail/linux-mtd/2006-August/016342.html)

Signed-off-by: Jared Hulbert <jaredeh at gmail.com>


diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 9c62368..af0c1ff 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -20,6 +20,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/compatmac.h>
+#include <linux/mtd/map.h>

 /* Our partition linked list */
 static LIST_HEAD(mtd_partitions);
@@ -40,6 +41,17 @@ struct mtd_part {
  */
 #define PART(x)  ((struct mtd_part *)(x))

+/*
+ * Allow other modules to get the physical address of a given partition
+ */
+void *mtd_get_partition_physaddr(struct mtd_info *mtd)
+{
+	struct mtd_part *part = PART(mtd);
+	struct map_info *map = part->master->priv;
+	
+	return (void *)(map->phys + part->offset);
+}
+EXPORT_SYMBOL_GPL(mtd_get_partition_physaddr);

 /*
  * MTD methods which simply translate the effective address and pass through
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index da6b3d6..3e9ff2c 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -52,6 +52,7 @@ struct mtd_partition {

 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
 int del_mtd_partitions(struct mtd_info *);
+void *mtd_get_partition_physaddr(struct mtd_info *);

 /*
  * Functions dealing with the various ways of partitioning the space



More information about the linux-mtd mailing list