[PATCH] CORE: Allow kernel access to struct mtd_part and PART() for axfs

Jared Hulbert jaredeh at gmail.com
Fri Aug 18 05:23:51 EDT 2006


In order to mount to mtd partitions axfs (axfs.sf.net) needs the
physical address
found by using the mtd_part structure.  This patch simply moves the
definition of struct mtd_part and PART() from drivers/mtd/mtdpart.c to
include/linux/mtd/partitions.h where other parts of the kernel, such as
axfs, can use it.

This is actually in my brand new shiny users/jehulber/mtd-intel.git
all ready to be pulled.  If everyone is okay with it that is.

This is best way we could figure out to get access to the physical
address of a given partition.  We _need_ the physical address to use
remap_pfn_range().

<AXFSCODE>
	part = PART(mtd);
	map = part->master->priv;
	fsi->virtaddr = (void *)virtaddr;
	fsi->clean_up_callback = axfs_mtd_cleanup;
	fsi->callback_data = (u32) mtdnr;
	fsi->physaddr = (void *)(map->phys + part->offset);
</AXFSCODE>


<PATCH>
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -24,23 +24,6 @@
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
-/* Our partition node structure */
-struct mtd_part {
- struct mtd_info mtd;
- struct mtd_info *master;
- u_int32_t offset;
- int index;
- struct list_head list;
- int registered;
-};
-
-/*
- * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
- * the pointer to that structure with this macro.
- */
-#define PART(x) ((struct mtd_part *)(x))
-
-
/*
* MTD methods which simply translate the effective address and pass through
* to the _real_ device.
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -45,6 +45,22 @@ struct mtd_partition {
struct mtd_info **mtdp; /* pointer to store the MTD object */
};
+/* Our partition node structure */
+struct mtd_part {
+ struct mtd_info mtd;
+ struct mtd_info *master;
+ u_int32_t offset;
+ int index;
+ struct list_head list;
+ int registered;
+};
+
+/*
+ * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
+ * the pointer to that structure with this macro.
+ */
+#define PART(x) ((struct mtd_part *)(x))
+
#define MTDPART_OFS_NXTBLK (-2)
#define MTDPART_OFS_APPEND (-1)
#define MTDPART_SIZ_FULL (0)
</PATCH>




More information about the linux-mtd mailing list