Commit 7c8d206f authored by Paul Parsons's avatar Paul Parsons Committed by David Woodhouse

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: default avatarPaul Parsons <lost.distance@yahoo.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 5fbabf3f
...@@ -295,13 +295,24 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f ...@@ -295,13 +295,24 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
} }
static DEFINE_SPINLOCK(pcmcia_vpp_lock);
static int pcmcia_vpp_refcnt;
static void pcmciamtd_set_vpp(struct map_info *map, int on) static void pcmciamtd_set_vpp(struct map_info *map, int on)
{ {
struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
struct pcmcia_device *link = dev->p_dev; struct pcmcia_device *link = dev->p_dev;
unsigned long flags;
pr_debug("dev = %p on = %d vpp = %d\n\n", dev, on, dev->vpp); pr_debug("dev = %p on = %d vpp = %d\n\n", dev, on, dev->vpp);
pcmcia_fixup_vpp(link, on ? dev->vpp : 0); spin_lock_irqsave(&pcmcia_vpp_lock, flags);
if (on) {
if (++pcmcia_vpp_refcnt == 1) /* first nested 'on' */
pcmcia_fixup_vpp(link, dev->vpp);
} else {
if (--pcmcia_vpp_refcnt == 0) /* last nested 'off' */
pcmcia_fixup_vpp(link, 0);
}
spin_unlock_irqrestore(&pcmcia_vpp_lock, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment