diff mbox

[1/6] physmap: make map_info customizable

Message ID 200812012223.mB1MNbjl014522@imap1.linux-foundation.org
State New, archived
Headers show

Commit Message

Andrew Morton Dec. 1, 2008, 10:23 p.m. UTC
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

Add a hook to physmap_flash_data for map_info initialization.  This makes
platform code can customize map operations.

Background: I wrote this patch to support RBTX4939 board, which requires
custom map->{read,write,copy_from} function.  I think extending the
physmap driver is better than adding a new map driver.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/mtd/maps/physmap.c  |    5 ++++-
 include/linux/mtd/physmap.h |    1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

David Woodhouse Dec. 10, 2008, 4:14 p.m. UTC | #1
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> Add a hook to physmap_flash_data for map_info initialization.  This makes
> platform code can customize map operations.
> 
> Background: I wrote this patch to support RBTX4939 board, which requires
> custom map->{read,write,copy_from} function.  I think extending the
> physmap driver is better than adding a new map driver.

Hm. I'm unconvinced -- surely you're calling into a function which does
everything that a 'new map driver' would have to do anyway?

Would you advocate that we remove _all_ the dedicated map drivers and
replace them with this method?

Can't you enable physmap without CONFIG_MTD_COMPLEX_MAPPINGS being set
anyway? The 'special' functions can't be used in that config, and we
just assume that direct access works.
diff mbox

Patch

diff -puN drivers/mtd/maps/physmap.c~physmap-make-map_info-customizable drivers/mtd/maps/physmap.c
--- a/drivers/mtd/maps/physmap.c~physmap-make-map_info-customizable
+++ a/drivers/mtd/maps/physmap.c
@@ -128,7 +128,10 @@  static int physmap_flash_probe(struct pl
 			goto err_out;
 		}
 
-		simple_map_init(&info->map[i]);
+		if (physmap_data->map_init)
+			(*physmap_data->map_init)(&info->map[i]);
+		else
+			simple_map_init(&info->map[i]);
 
 		probe_type = rom_probe_types;
 		for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++)
diff -puN include/linux/mtd/physmap.h~physmap-make-map_info-customizable include/linux/mtd/physmap.h
--- a/include/linux/mtd/physmap.h~physmap-make-map_info-customizable
+++ a/include/linux/mtd/physmap.h
@@ -25,6 +25,7 @@  struct physmap_flash_data {
 	void			(*set_vpp)(struct map_info *, int);
 	unsigned int		nr_parts;
 	struct mtd_partition	*parts;
+	void			(*map_init)(struct map_info *map);
 };
 
 /*