Automatic nest count for ENABLE_VPP

Todd Poynor tpoynor at mvista.com
Wed Jan 12 22:34:55 EST 2005


Comments in map.h indicate the .set_vpp routine must handle nested
enable calls, which doesn't seem to be the case for several map drivers.
And those that do keep a nest count may run into problems due to extra
DISABLE_VPP calls (by, for example, cfi_cmdset_0001 put_chip).

The map drivers can be modified to check for nesting underflow, but this
might best be implemented once in the enable/disable macros (and made a
property of the map, whereas most counts today are one per map driver).

It would also be possible to modify routines such as put_chip to check
whether to call DISABLE_VPP via the count (assuming the count should be
zero at get_chip time and put_chip time).

Any opinion on the way to do this?  Thanks -- Todd

Index: linux-2.6.10/include/linux/mtd/map.h
===================================================================
--- linux-2.6.10.orig/include/linux/mtd/map.h	2004-12-24 21:34:31.000000000 +0000
+++ linux-2.6.10/include/linux/mtd/map.h	2005-01-13 02:10:28.000000000 +0000
@@ -219,6 +219,7 @@
 	unsigned long map_priv_2;
 	void *fldrv_priv;
 	struct mtd_chip_driver *fldrv;
+	int vpp_count;
 };
 
 struct mtd_chip_driver {
@@ -235,8 +236,8 @@
 struct mtd_info *do_map_probe(const char *name, struct map_info *map);
 void map_destroy(struct mtd_info *mtd);
 
-#define ENABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 1); } while(0)
-#define DISABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 0); } while(0)
+#define ENABLE_VPP(map) do { if(map->set_vpp && (map->vpp_count++ == 0)) map->set_vpp(map, 1); } while(0)
+#define DISABLE_VPP(map) do { if(map->set_vpp && map->vpp_count && (--map->vpp_count == 0)) map->set_vpp(map, 0); } while(0)
 
 #define INVALIDATE_CACHED_RANGE(map, from, size) \
 	do { if(map->inval_cache) map->inval_cache(map, from, size); } while(0)




More information about the linux-mtd mailing list