Skip to content

Commit

Permalink
mtd: maps: l440gx: Add reference counter to set_vpp()
Browse files Browse the repository at this point in the history
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 l440gx_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>
  • Loading branch information
Paul Parsons authored and David Woodhouse committed Mar 26, 2012
1 parent 876fe76 commit 5fbabf3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/mtd/maps/l440gx.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ static struct mtd_info *mymtd;


/* Is this really the vpp port? */
static DEFINE_SPINLOCK(l440gx_vpp_lock);
static int l440gx_vpp_refcnt;
static void l440gx_set_vpp(struct map_info *map, int vpp)
{
unsigned long l;
unsigned long flags;

l = inl(VPP_PORT);
spin_lock_irqsave(&l440gx_vpp_lock, flags);
if (vpp) {
l |= 1;
if (++l440gx_vpp_refcnt == 1) /* first nested 'on' */
outl(inl(VPP_PORT) | 1, VPP_PORT);
} else {
l &= ~1;
if (--l440gx_vpp_refcnt == 0) /* last nested 'off' */
outl(inl(VPP_PORT) & ~1, VPP_PORT);
}
outl(l, VPP_PORT);
spin_unlock_irqrestore(&l440gx_vpp_lock, flags);
}

static struct map_info l440gx_map = {
Expand Down

0 comments on commit 5fbabf3

Please sign in to comment.