diff options
author | Paul Parsons <lost.distance@yahoo.com> | 2012-03-07 09:13:41 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-03-26 19:52:56 -0400 |
commit | 7c8d206f219fe52966d970f791246a542718e5ba (patch) | |
tree | 1b9c6e0630aed4df9efb911fccd276c978dd1b23 /drivers/mtd | |
parent | 5fbabf3f45a15c2b39170980cee01368138f4d79 (diff) |
mtd: maps: pcmciamtd: 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 pcmciamtd_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')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index e8e9fec23553..7d5cf369f0ad 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -295,13 +295,24 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f | |||
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | static DEFINE_SPINLOCK(pcmcia_vpp_lock); | ||
299 | static int pcmcia_vpp_refcnt; | ||
298 | static void pcmciamtd_set_vpp(struct map_info *map, int on) | 300 | static void pcmciamtd_set_vpp(struct map_info *map, int on) |
299 | { | 301 | { |
300 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; | 302 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
301 | struct pcmcia_device *link = dev->p_dev; | 303 | struct pcmcia_device *link = dev->p_dev; |
304 | unsigned long flags; | ||
302 | 305 | ||
303 | pr_debug("dev = %p on = %d vpp = %d\n\n", dev, on, dev->vpp); | 306 | pr_debug("dev = %p on = %d vpp = %d\n\n", dev, on, dev->vpp); |
304 | pcmcia_fixup_vpp(link, on ? dev->vpp : 0); | 307 | spin_lock_irqsave(&pcmcia_vpp_lock, flags); |
308 | if (on) { | ||
309 | if (++pcmcia_vpp_refcnt == 1) /* first nested 'on' */ | ||
310 | pcmcia_fixup_vpp(link, dev->vpp); | ||
311 | } else { | ||
312 | if (--pcmcia_vpp_refcnt == 0) /* last nested 'off' */ | ||
313 | pcmcia_fixup_vpp(link, 0); | ||
314 | } | ||
315 | spin_unlock_irqrestore(&pcmcia_vpp_lock, flags); | ||
305 | } | 316 | } |
306 | 317 | ||
307 | 318 | ||