diff options
author | Paul Parsons <lost.distance@yahoo.com> | 2012-03-07 09:14:31 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-03-26 19:53:02 -0400 |
commit | ee478af8b675908b217198a75cf759d422a81ccb (patch) | |
tree | 3f9b3bdb6967607cf7e13579469f0ceaeb0e3bfe /drivers/mtd/maps/sa1100-flash.c | |
parent | 7c8d206f219fe52966d970f791246a542718e5ba (diff) |
mtd: maps: sa1100-flash: Add reference counter to set_vpp()
This patch is part of a set which fixes unnecessary flash erase and write errors
resulting from the MTD CFI driver turning off vpp while an erase is in progress.
This patch allows sa1100_set_vpp() calls to be nested by adding a reference
counter.
Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/maps/sa1100-flash.c')
-rw-r--r-- | drivers/mtd/maps/sa1100-flash.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index cbc3b7867910..1eaf7b6c35e5 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
@@ -36,10 +36,22 @@ struct sa_info { | |||
36 | struct sa_subdev_info subdev[0]; | 36 | struct sa_subdev_info subdev[0]; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static DEFINE_SPINLOCK(sa1100_vpp_lock); | ||
40 | static int sa1100_vpp_refcnt; | ||
39 | static void sa1100_set_vpp(struct map_info *map, int on) | 41 | static void sa1100_set_vpp(struct map_info *map, int on) |
40 | { | 42 | { |
41 | struct sa_subdev_info *subdev = container_of(map, struct sa_subdev_info, map); | 43 | struct sa_subdev_info *subdev = container_of(map, struct sa_subdev_info, map); |
42 | subdev->plat->set_vpp(on); | 44 | unsigned long flags; |
45 | |||
46 | spin_lock_irqsave(&sa1100_vpp_lock, flags); | ||
47 | if (on) { | ||
48 | if (++sa1100_vpp_refcnt == 1) /* first nested 'on' */ | ||
49 | subdev->plat->set_vpp(1); | ||
50 | } else { | ||
51 | if (--sa1100_vpp_refcnt == 0) /* last nested 'off' */ | ||
52 | subdev->plat->set_vpp(0); | ||
53 | } | ||
54 | spin_unlock_irqrestore(&sa1100_vpp_lock, flags); | ||
43 | } | 55 | } |
44 | 56 | ||
45 | static void sa1100_destroy_subdev(struct sa_subdev_info *subdev) | 57 | static void sa1100_destroy_subdev(struct sa_subdev_info *subdev) |