Merge ../ntfs-2.6-devel
[powerpc.git] / drivers / mtd / chips / cfi_cmdset_0001.c
index e3a5c5d..ded2c33 100644 (file)
@@ -4,7 +4,7 @@
  *
  * (C) 2000 Red Hat. GPL'd
  *
- * $Id: cfi_cmdset_0001.c,v 1.185 2005/11/07 11:14:22 gleixner Exp $
+ * $Id: cfi_cmdset_0001.c,v 1.186 2005/11/23 22:07:52 nico Exp $
  *
  *
  * 10/10/2000  Nicolas Pitre <nico@cam.org>
@@ -484,8 +484,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
 
  setup_err:
        if(mtd) {
-               if(mtd->eraseregions)
-                       kfree(mtd->eraseregions);
+               kfree(mtd->eraseregions);
                kfree(mtd);
        }
        kfree(cfi->cmdset_priv);
@@ -645,9 +644,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
                 *
                 * - contension arbitration is handled in the owner's context.
                 *
-                * The 'shared' struct can be read when its lock is taken.
-                * However any writes to it can only be made when the current
-                * owner's lock is also held.
+                * The 'shared' struct can be read and/or written only when
+                * its lock is taken.
                 */
                struct flchip_shared *shared = chip->priv;
                struct flchip *contender;
@@ -676,14 +674,13 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
                        }
                        timeo = jiffies + HZ;
                        spin_lock(&shared->lock);
+                       spin_unlock(contender->mutex);
                }
 
                /* We now own it */
                shared->writing = chip;
                if (mode == FL_ERASING)
                        shared->erasing = chip;
-               if (contender && contender != chip)
-                       spin_unlock(contender->mutex);
                spin_unlock(&shared->lock);
        }
 
@@ -1022,8 +1019,8 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
 #define XIP_INVAL_CACHED_RANGE(map, from, size)  \
        INVALIDATE_CACHED_RANGE(map, from, size)
 
-#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec)  \
-       UDELAY(map, chip, adr, usec)
+#define INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, adr, len, usec)  \
+       UDELAY(map, chip, cmd_adr, usec)
 
 /*
  * Extra notes:
@@ -1055,7 +1052,7 @@ do {  \
        spin_lock(chip->mutex);  \
 } while (0)
 
-#define INVALIDATE_CACHE_UDELAY(map, chip, adr, len, usec)  \
+#define INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, adr, len, usec)  \
 do {  \
        spin_unlock(chip->mutex);  \
        INVALIDATE_CACHED_RANGE(map, adr, len);  \
@@ -1287,7 +1284,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
        map_write(map, datum, adr);
        chip->state = mode;
 
-       INVALIDATE_CACHE_UDELAY(map, chip,
+       INVALIDATE_CACHE_UDELAY(map, chip, adr,
                                adr, map_bankwidth(map),
                                chip->word_write_time);
 
@@ -1575,8 +1572,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
        map_write(map, CMD(0xd0), cmd_adr);
        chip->state = FL_WRITING;
 
-       INVALIDATE_CACHE_UDELAY(map, chip,
-                               cmd_adr, len,
+       INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr,
+                               adr, len,
                                chip->buffer_write_time);
 
        timeo = jiffies + (HZ/2);
@@ -1747,7 +1744,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
        chip->state = FL_ERASING;
        chip->erase_suspended = 0;
 
-       INVALIDATE_CACHE_UDELAY(map, chip,
+       INVALIDATE_CACHE_UDELAY(map, chip, adr,
                                adr, len,
                                chip->erase_time*1000/2);