summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2001-03-09 20:33:35 +0000
committerRalf Baechle <ralf@linux-mips.org>2001-03-09 20:33:35 +0000
commit116674acc97ba75a720329996877077d988443a2 (patch)
tree6a3f2ff0b612ae2ee8a3f3509370c9e6333a53b3 /drivers/mtd
parent71118c319fcae4a138f16e35b4f7e0a6d53ce2ca (diff)
Merge with Linux 2.4.2.
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/cfi_cmdset_0001.c4
-rw-r--r--drivers/mtd/cfi_cmdset_0002.c4
-rw-r--r--drivers/mtd/cfi_probe.c2
-rw-r--r--drivers/mtd/doc1000.c2
-rw-r--r--drivers/mtd/doc2000.c2
-rw-r--r--drivers/mtd/doc2001.c2
-rw-r--r--drivers/mtd/docecc.c2
-rw-r--r--drivers/mtd/docprobe.c2
-rw-r--r--drivers/mtd/ftl.c4
-rw-r--r--drivers/mtd/map_ram.c2
-rw-r--r--drivers/mtd/map_rom.c2
-rw-r--r--drivers/mtd/mapped.c673
-rw-r--r--drivers/mtd/mixmem.c2
-rw-r--r--drivers/mtd/mtdblock.c2
-rw-r--r--drivers/mtd/mtdchar.c9
-rw-r--r--drivers/mtd/mtdcore.c2
-rw-r--r--drivers/mtd/mtdpart.c2
-rw-r--r--drivers/mtd/mtdram.c2
-rw-r--r--drivers/mtd/nftl.c2
-rw-r--r--drivers/mtd/nftlmount.c6
-rw-r--r--drivers/mtd/octagon-5066.c6
-rw-r--r--drivers/mtd/pmc551.c7
-rw-r--r--drivers/mtd/rpxlite.c1
-rw-r--r--drivers/mtd/slram.c3
-rw-r--r--drivers/mtd/vmax301.c6
25 files changed, 39 insertions, 712 deletions
diff --git a/drivers/mtd/cfi_cmdset_0001.c b/drivers/mtd/cfi_cmdset_0001.c
index e765d91fc..56e5a394a 100644
--- a/drivers/mtd/cfi_cmdset_0001.c
+++ b/drivers/mtd/cfi_cmdset_0001.c
@@ -15,7 +15,7 @@
#include <asm/byteorder.h>
#include <linux/errno.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/mtd/map.h>
#include <linux/mtd/cfi.h>
@@ -816,13 +816,13 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
* as the whole point is that nobody can do anything
* with the chip now anyway.
*/
- spin_unlock_bh(chip->mutex);
break;
default:
ret = -EAGAIN;
break;
}
+ spin_unlock_bh(chip->mutex);
}
/* Unlock the chips again */
diff --git a/drivers/mtd/cfi_cmdset_0002.c b/drivers/mtd/cfi_cmdset_0002.c
index 6cb0de4e9..3b0d9b7af 100644
--- a/drivers/mtd/cfi_cmdset_0002.c
+++ b/drivers/mtd/cfi_cmdset_0002.c
@@ -18,7 +18,7 @@
#include <asm/byteorder.h>
#include <linux/errno.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/mtd/map.h>
#include <linux/mtd/cfi.h>
@@ -552,13 +552,13 @@ static int cfi_amdext_suspend(struct mtd_info *mtd)
* as the whole point is that nobody can do anything
* with the chip now anyway.
*/
- spin_unlock_bh(chip->mutex);
break;
default:
ret = -EAGAIN;
break;
}
+ spin_unlock_bh(chip->mutex);
}
/* Unlock the chips again */
diff --git a/drivers/mtd/cfi_probe.c b/drivers/mtd/cfi_probe.c
index e46d26f56..f44ba5817 100644
--- a/drivers/mtd/cfi_probe.c
+++ b/drivers/mtd/cfi_probe.c
@@ -11,7 +11,7 @@
#include <asm/io.h>
#include <asm/byteorder.h>
#include <linux/errno.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/mtd/map.h>
#include <linux/mtd/cfi.h>
diff --git a/drivers/mtd/doc1000.c b/drivers/mtd/doc1000.c
index 584745359..a681652c0 100644
--- a/drivers/mtd/doc1000.c
+++ b/drivers/mtd/doc1000.c
@@ -12,7 +12,7 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/ptrace.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
diff --git a/drivers/mtd/doc2000.c b/drivers/mtd/doc2000.c
index 22ef68e62..4957fcd66 100644
--- a/drivers/mtd/doc2000.c
+++ b/drivers/mtd/doc2000.c
@@ -15,7 +15,7 @@
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/delay.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/types.h>
diff --git a/drivers/mtd/doc2001.c b/drivers/mtd/doc2001.c
index 79aa3630d..d80143783 100644
--- a/drivers/mtd/doc2001.c
+++ b/drivers/mtd/doc2001.c
@@ -15,7 +15,7 @@
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/delay.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/types.h>
diff --git a/drivers/mtd/docecc.c b/drivers/mtd/docecc.c
index cddc968c0..c10ff2b88 100644
--- a/drivers/mtd/docecc.c
+++ b/drivers/mtd/docecc.c
@@ -31,7 +31,7 @@
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/delay.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/types.h>
diff --git a/drivers/mtd/docprobe.c b/drivers/mtd/docprobe.c
index 37fec2a0c..9f5ba083b 100644
--- a/drivers/mtd/docprobe.c
+++ b/drivers/mtd/docprobe.c
@@ -50,7 +50,7 @@
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/delay.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/types.h>
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 21ed0cecd..aaa948b64 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -30,7 +30,7 @@
are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
Alternatively, the contents of this file may be used under the
- terms of the GNU Public License version 2 (the "GPL"), in which
+ terms of the GNU General Public License version 2 (the "GPL"), in which
case the provisions of the GPL are applicable instead of the
above. If you wish to allow the use of your version of this file
only under the terms of the GPL and not to allow others to use
@@ -68,7 +68,7 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/ptrace.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
diff --git a/drivers/mtd/map_ram.c b/drivers/mtd/map_ram.c
index 00c009d7f..1a4e5a06a 100644
--- a/drivers/mtd/map_ram.c
+++ b/drivers/mtd/map_ram.c
@@ -10,7 +10,7 @@
#include <asm/io.h>
#include <asm/byteorder.h>
#include <linux/errno.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/mtd/map.h>
diff --git a/drivers/mtd/map_rom.c b/drivers/mtd/map_rom.c
index c976c7ecf..455cb99fd 100644
--- a/drivers/mtd/map_rom.c
+++ b/drivers/mtd/map_rom.c
@@ -10,7 +10,7 @@
#include <asm/io.h>
#include <asm/byteorder.h>
#include <linux/errno.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/mtd/map.h>
diff --git a/drivers/mtd/mapped.c b/drivers/mtd/mapped.c
deleted file mode 100644
index 45db9e442..000000000
--- a/drivers/mtd/mapped.c
+++ /dev/null
@@ -1,673 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/
-// $Id: mapped.c,v 1.8 2000/03/31 14:40:42 dwmw2 Exp $
-/* ######################################################################
-
- Flash MTD Routines
-
- These routine support IDing and manipulating flash. Currently the
- older JEDEC ID mechanism and a table is used for determining the
- flash characterisitics, but it is trivial to add support for the
- CFI specification:
- http://www.pentium.com/design/flash/ in the technote section.
-
- ##################################################################### */
- /*}}}*/
-#include <linux/mtd/mapped.h>
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <asm/io.h>
-
-struct JEDECTable mtd_JEDEC_table[] =
- {{0x01AD,"AMD Am29F016",2*1024*1024,64*1024,MTD_CAP_NORFLASH},
- {0x01D5,"AMD Am29F080",1*1024*1024,64*1024,MTD_CAP_NORFLASH},
- {}};
-
-// flash_setup - Setup the mapped_mtd_info structure for normal flash /*{{{*/
-// ---------------------------------------------------------------------
-/* There is a set of commands that flash manufactures follow for getting the
- JEDEC id, erasing and writing. So long as your flash device supports
- getting the JEDEC ID in this (standard?) way it will be supported as flash,
- otherwise it is converted to ROM. Upon completion the structure is
- registered with the MTD layer */
-int mtd_mapped_setup(struct mapped_mtd_info *map)
-{
- DEBUG(1, "\n");
- // Must define a page function to use the defaults!
- if (map->page == 0)
- return -1;
-
- if (map->jedec_sense == 0)
- map->jedec_sense = flash_jedec;
-
- if (map->jedec_sense(map) != 0)
- return -1;
-
- if (map->mtd.erase == 0 && map->mtd.type == MTD_NORFLASH)
- map->mtd.erase = flash_erase;
- if (map->mtd.write == 0)
- {
- if (map->mtd.type == MTD_NORFLASH)
- map->mtd.write = flash_write;
- if (map->mtd.type == MTD_RAM)
- map->mtd.write = ram_write;
- }
- if (map->mtd.read == 0)
- map->mtd.read = rom_read;
-
- return add_mtd_device(&map->mtd);
-}
- /*}}}*/
-// flash_remove - Remove the flash device from the MTD layer /*{{{*/
-// ---------------------------------------------------------------------
-/* Free any memory allocated for the device here */
-int mtd_mapped_remove(struct mapped_mtd_info *map)
-{
- return del_mtd_device(&map->mtd);
-}
- /*}}}*/
-
-// checkparity - Checks a number for odd parity /*{{{*/
-// ---------------------------------------------------------------------
-/* Helper for the JEDEC function, JEDEC numbers all have odd parity */
-static int checkparity(u_char C)
-{
- u_char parity = 0;
- while (C != 0)
- {
- parity ^= C & 1;
- C >>= 1;
- }
-
- return parity == 1;
-}
- /*}}}*/
-// SetJedec - Set the jedec information for a chip /*{{{*/
-// ---------------------------------------------------------------------
-/* We track the configuration of each chip separately in the chip list,
- each chip can have a different type and configuration to allow for
- maximum flexability. */
-void set_jedec(struct mapped_mtd_info *map,unsigned chip,unsigned char mfr,
- unsigned char id)
-{
- unsigned long longID = (mfr << 8) + id;
- unsigned int I;
-
- map->mtd.type = MTD_NORFLASH;
- map->mfr = mfr;
- map->id = id;
-
- // Locate the chip in the jedec table
- for (I = 0; mtd_JEDEC_table[I].jedec != 0; I++)
- {
- if (mtd_JEDEC_table[I].jedec == longID)
- break;
- }
-
- if (mtd_JEDEC_table[I].jedec != longID || longID == 0)
- {
- printk("Unknown JEDEC number %x-%x, treating as ROM\n",map->mfr,
- map->id);
- map->mtd.type = MTD_ROM;
- return;
- }
-
- // Setup the MTD from the JEDEC information
-// map->mtd.size = mtd_JEDEC_table[I].size;
-// map->mtd.erasesize = mtd_JEDEC_table[I].sectorsize;
-// map->mtd.capabilities = mtd_JEDEC_table[I].capabilities;
-// strncpy(map->mtd.part,mtd_JEDEC_table[I].name,sizeof(map->mtd.part)-1);
-
- map->chips[chip].jedec = longID;
- map->chips[chip].size = mtd_JEDEC_table[I].size;
- map->chips[chip].sectorsize = mtd_JEDEC_table[I].sectorsize;
- map->chips[chip].capabilities = mtd_JEDEC_table[I].capabilities;
- map->chips[chip].base = 0;
-}
- /*}}}*/
-// isjedec - Check if reading from the memory location gives jedec #s /*{{{*/
-// ---------------------------------------------------------------------
-/* This is ment to be called on the flash window once it is in jedec mode */
-int isjedec(unsigned long base)
-{
- // Test #1, JEDEC numbers are readable from 0x??00/0x??01
- if (readb(base + 0) != readb(base + 0x100) ||
- readb(base + 1) != readb(base + 0x101))
- return 0;
-
- // Test #2 JEDEC numbers exhibit odd parity
- if (checkparity(readb(base + 0)) == 0 || checkparity(readb(base + 1)) == 0)
- return 0;
- return 1;
-}
- /*}}}*/
-// flash_jedec - JEDEC ID sensor /*{{{*/
-// ---------------------------------------------------------------------
-/* The mysterious jedec flash probe sequence writes a specific pattern of
- bytes to the flash. This should be general enough to work with any MTD
- structure that may contain a flash chip, but note that it will corrupt
- address 0x5555 on SRAM cards if the machine dies between the two
- critical operations. */
-int flash_jedec(struct mapped_mtd_info *map)
-{
- unsigned I;
- u_char OldVal;
- unsigned long base;
- unsigned long baseaddr = 0;
- unsigned chip = 0;
- unsigned count;
-
- // Who has a page size this small? :>
- if (map->pagesize < 0x555)
- return 1;
-
- base = map->page(map,0);
-
- // Wait for any write/erase operation to settle
- OldVal = readb(base);
- for (I = 0; OldVal != readb(base) && I < 10000; I++)
- OldVal = readb(base);
-
- /* Check for sram by writing to it, the write also happens to be part
- of the flash reset sequence.. */
- OldVal = readb(base + 0x555);
- writeb(OldVal,base + 0x555);
- writeb(0xF0,base + 0x555);
- if (OldVal != readb(base + 0x555))
- {
- udelay(100);
-
- // Set it back and make sure..
- writeb(OldVal,base + 0x555);
- if (OldVal == readb(base + 0x555))
- {
- map->mtd.type = MTD_RAM;
- return 0;
- }
-
- writeb(0xF0,base + 0x555);
- }
-
- // Probe for chips
- while (chip < sizeof(map->chips)/sizeof(map->chips[0]))
- {
- // Already in jedec mode, we might be doing some address wrap around
- if (chip != 0 && isjedec(base) != 0)
- {
- /* Try to reset this page and check if that resets the first page
- to confirm */
- writeb(0xF0,base + 0x555);
- if (isjedec(base) != 0)
- break;
- base = map->page(map,0);
- if (isjedec(base) == 0)
- break;
- base = map->page(map,baseaddr/map->pagesize);
- }
-
- // Send the sequence
- writeb(0xAA,base + 0x555);
- writeb(0x55,base + 0x2AA);
- writeb(0x90,base + 0x555);
-
- // Check the jedec number
- if (isjedec(base) == 0)
- {
- /* If this is the first chip it must be rom, otherwise it is the
- end of the flash region */
- if (chip == 0)
- {
- map->mtd.type = MTD_ROM;
- return 0;
- }
- break;
- }
-
- // Store the jdec info
- set_jedec(map,chip,readb(base + 0),readb(base + 1));
- map->chips[chip].base = baseaddr;
-
- // Jump to the next chip
- baseaddr += map->chips[chip].size;
- if (baseaddr/map->pagesize > map->maxsize)
- break;
- base = map->page(map,baseaddr/map->pagesize);
- if (base == 0)
- return -EIO;
-
- chip++;
- }
-
- // Reset all of the chips
- map->mtd.size = 0;
- baseaddr = 0;
- map->mtd.flags = 0xFFFF;
- for (I = 0; map->chips[I].jedec != 0; I++)
- {
- // Fill in the various MTD structures
- map->mtd.size += map->chips[I].size;
- if (map->mtd.erasesize < map->chips[I].sectorsize)
- map->mtd.erasesize = map->chips[I].sectorsize;
- map->mtd.flags &= map->chips[I].capabilities;
-
- base = map->page(map,baseaddr/map->pagesize);
- baseaddr += map->chips[chip].size;
- writeb(0xF0,base + 0); // Reset
- }
-
- /* Generate a part name that includes the number of different chips and
- other configuration information */
- count = 1;
- map->part[0] = 0;
- for (I = 0; map->chips[I].jedec != 0; I++)
- {
- unsigned J;
- if (map->chips[I+1].jedec == map->chips[I].jedec)
- {
- count++;
- continue;
- }
-
- // Locate the chip in the jedec table
- for (J = 0; mtd_JEDEC_table[J].jedec != 0; J++)
- {
- if (mtd_JEDEC_table[J].jedec == map->chips[I].jedec)
- break;
- }
-
- if (map->part[0] != 0)
- strcat(map->part,",");
-
- if (count != 1)
- sprintf(map->part+strlen(map->part),"%u*[%s]",count,
- mtd_JEDEC_table[J].name);
- else
- sprintf(map->part+strlen(map->part),"%s",
- mtd_JEDEC_table[J].name);
- count = 1;
- }
- return 0;
-}
- /*}}}*/
-
-// flash_failed - Print a console message about why the failure /*{{{*/
-// ---------------------------------------------------------------------
-/* Pass the flags value that the flash return before it re-entered read
- mode. */
-static void flash_failed(unsigned char code)
-{
- /* Bit 5 being high indicates that there was an internal device
- failure, erasure time limits exceeded or something */
- if ((code & (1 << 5)) != 0)
- {
- printk("mtd: Internal Flash failure\n");
- return;
- }
- printk("mtd: Programming didn't take\n");
-}
- /*}}}*/
-// flash_erase - Generic erase function /*{{{*/
-// ---------------------------------------------------------------------
-/* This uses the erasure function described in the AMD Flash Handbook,
- it will work for flashes with a fixed sector size only. Flashes with
- a selection of sector sizes (ie the AMD Am29F800B) will need a different
- routine. This routine tries to parallize erasing multiple chips/sectors
- where possible */
-int flash_erase(struct mtd_info *mtd, struct erase_info *instr)
-{
- unsigned long Time = 0;
- unsigned long NoTime = 0;
- unsigned long start = instr->addr, len = instr->len;
- unsigned int I;
- struct mapped_mtd_info *map = (struct mapped_mtd_info *)mtd;
-
- // Verify the arguments..
- if (start + len > map->mtd.size ||
- (start % map->mtd.erasesize) != 0 ||
- (len % map->mtd.erasesize) != 0 ||
- (len/map->mtd.erasesize) == 0)
- return -EINVAL;
-
- flash_chip_scan(map,start,len);
-
- // Start the erase sequence on each chip
- for (I = 0; map->chips[I].jedec != 0; I++)
- {
- unsigned long off;
- struct flash_chip *chip = map->chips + I;
- unsigned long base;
- unsigned long flags;
-
- if (chip->length == 0)
- continue;
-
- if (page_jump(map,chip->base + chip->start,0x555,&base,0) != 0)
- return -EIO;
-
- // Send the erase setup code
- writeb(0xF0,base + 0x555);
- writeb(0xAA,base + 0x555);
- writeb(0x55,base + 0x2AA);
- writeb(0x80,base + 0x555);
- writeb(0xAA,base + 0x555);
- writeb(0x55,base + 0x2AA);
-
- // Use chip erase if possible
- if (chip->start == 0 && chip->length == chip->size)
- {
- writeb(0x10,base+0x555);
- continue;
- }
-
- /* Once we start selecting the erase sectors the delay between each
- command must not exceed 50us or it will immediately start erasing
- and ignore the other sectors */
- save_flags(flags);
- cli();
- for (off = 0; off < chip->length; off += chip->sectorsize)
- {
- if (page_jump(map,chip->base + chip->start + off,1,&base,0) != 0)
- return -EIO;
-
- // Check to make sure we didn't timeout
- writeb(0x30,base);
- if ((readb(base) & (1 << 3)) != 0)
- {
- printk("mtd: Ack! We timed out the erase timer!\n");
- return -EIO;
- }
- }
- restore_flags(flags);
- }
-
- /* We could split this into a timer routine and return early, performing
- background erasure.. Maybe later if the need warrents */
-
- /* Poll the flash for erasure completion, specs say this can take as long
- as 480 seconds to do all the sectors (for a 2 meg flash).
- Erasure time is dependant on chip age, temp and wear.. */
- Time = 0;
- NoTime = 0;
- for (I = 0; map->chips[I].jedec != 0; I++)
- {
- struct flash_chip *chip = map->chips + I;
- unsigned long base;
- unsigned long off = 0;
- if (chip->length == 0)
- continue;
-
- if (page_jump(map,chip->base + chip->start,1,&base,0) != 0)
- return -EIO;
-
- while (1)
- {
- unsigned char Last[4];
- unsigned long Count = 0;
-
- /* During erase bit 7 is held low and bit 6 toggles, we watch this,
- should it stop toggling or go high then the erase is completed,
- or this is not really flash ;> */
- Last[0] = readb(base);
- Last[1] = readb(base);
- Last[2] = readb(base);
- for (Count = 3; (Last[(Count - 1) % 4] & (1 << 7)) == 0 &&
- Last[(Count - 1) % 4] != Last[(Count - 2) % 4]; Count++)
- {
- if (NoTime == 0)
- Time += HZ/10 - schedule_timeout(HZ/10);
- NoTime = 0;
-
- Last[Count % 4] = readb(base);
-
- // Count time, max of 15s per sector (according to AMD)
- if (Time > 15*len/mtd->erasesize*HZ)
- {
- printk("mtd: Flash Erase Timed out\n");
- return -EIO;
- }
- }
-
- if (Last[(Count - 1) % 4] == Last[(Count - 2) % 4])
- {
- flash_failed(Last[(Count - 3) % 4]);
- return -EIO;
- }
-
- // Skip to the next chip if we used chip erase
- if (chip->length == chip->size)
- off = chip->size;
- else
- off += chip->sectorsize;
-
- if (off >= chip->length)
- break;
- if (page_jump(map,chip->base + chip->start + off,1,&base,0) != 0)
- return -EIO;
- NoTime = 1;
- }
- }
-
- // Paranoid verify of erasure
- {
- unsigned long base;
- unsigned long buflen;
- while (len > 0)
- {
- unsigned long step;
-
- if (page_jump(map,start,len,&base,&buflen) != 0)
- return -EIO;
- start += buflen;
- len -= buflen;
- step = buflen/128;
- for (;buflen != 0; buflen -= step)
- {
- if (readb(base+buflen-1) != 0xFF)
- {
- printk("mtd: Flash Erase didn't take %lu %lu %lu\n",buflen,len,start);
- return -EIO;
- }
- }
- }
- }
-
- return 0;
-}
-#if 1
- /*}}}*/
-// flash_write - Generic writing function /*{{{*/
-// ---------------------------------------------------------------------
-/* This could do parallel writes on multiple chips but doesnt, memory
- constraints make that infeasable. This should work with any sort of
- linear flash that is not interleved */
-extern int flash_write(struct mtd_info *mtd, loff_t start, size_t len,
- size_t *retlen, const u_char *buf)
-{
- struct mapped_mtd_info *map = (struct mapped_mtd_info *)mtd;
- unsigned long base;
- unsigned long off;
- DEBUG(1,"\n");
- if (start + len > mtd->size)
- return -EIO;
-
- while (len != 0)
- {
- // Compute the page offset and reposition
- base = map->page(map,(u_long)start/map->pagesize);
- off = (u_long)start % map->pagesize;
-
- // Loop over this page
- for (; off != map->pagesize && len != 0; start++, len--, off++,buf++)
- {
- unsigned char oldbyte = readb(base+off);
- unsigned char Last[4];
- unsigned long Count = 0;
-
- if (oldbyte == *buf)
- continue;
- if (((~oldbyte) & *buf) != 0)
- printk("mtd: warn: Trying to set a 0 to a 1\n");
-
- // Write
- writeb(0xAA,base + 0x555);
- writeb(0x55,base + 0x2AA);
- writeb(0xA0,base + 0x555);
- writeb(*buf,base + off);
- Last[0] = readb(base + off);
- Last[1] = readb(base + off);
- Last[2] = readb(base + off);
-
- /* Wait for the flash to finish the operation. We store the last 4
- status bytes that have been retrieved so we can determine why
- it failed. The toggle bits keep toggling when there is a
- failure */
- for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] &&
- Count < 10000; Count++)
- Last[Count % 4] = readb(base + off);
- if (Last[(Count - 1) % 4] != *buf)
- {
- flash_failed(Last[(Count - 3) % 4]);
- return -EIO;
- }
- }
- }
- *retlen = len;
- return 0;
-}
-#endif
-
-// ram_write - Generic writing function for ram /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-extern int ram_write(struct mtd_info *mtd, loff_t start, size_t len,
- size_t *retlen, const u_char *buf)
-{
- struct mapped_mtd_info *map = (struct mapped_mtd_info *)mtd;
- unsigned long base;
- size_t origlen = len;
- unsigned long buflen;
- DEBUG(1,"\n");
- if (start + len > mtd->size)
- return -EIO;
-
- while (len != 0)
- {
- // Reposition..
- if (page_jump(map,start,len,&base,&buflen) != 0)
- return -EIO;
-
- // Copy
- memcpy_toio(base,buf,buflen);
- len -= buflen;
- start += buflen;
- }
- *retlen = origlen;
- return 0;
-}
-
-// rom_read - Read handler for any sort of device /*{{{*/
-// ---------------------------------------------------------------------
-/* This is a generic read function that should work with any device in the
- mapped region. */
-extern int rom_read(struct mtd_info *mtd, loff_t start, size_t len,
- size_t *retlen, u_char *buf)
-{
- struct mapped_mtd_info *map = (struct mapped_mtd_info *)mtd;
- size_t origlen = len;
- unsigned long base;
- unsigned long buflen;
-
- printk("Rom_Read\n");
- if (start + len > mtd->size)
- return -EIO;
-
- while (len != 0)
- {
- // Reposition..
- if (page_jump(map,start,len,&base,&buflen) != 0)
- return -EIO;
-
- // Copy
- memcpy_fromio(buf,base,buflen);
- len -= buflen;
- start += buflen;
- }
- *retlen = origlen;
- return 0;
-}
-
-// page_jump - Move the window and return the buffer /*{{{*/
-// ---------------------------------------------------------------------
-/* Unlike the page function this returns a buffer and length adjusted for
- the page dimensions and the reading offset into the page, simplifies
- many of the other routines */
-int page_jump(struct mapped_mtd_info *map,unsigned long start,
- unsigned long len,unsigned long *base,
- unsigned long *retlen)
-{
- DEBUG(1,"Page Jump\n");
- if (start > map->mtd.size || start + len > map->mtd.size)
- return -EINVAL;
-
- *base = map->page(map,start/map->pagesize);
- if (*base == 0)
- return -EIO;
-
- *base += start % map->pagesize;
-
- // If retlen is 0 that mean the caller requires len bytes, no quibbling.
- if (retlen == 0)
- {
- if (len > map->pagesize - (start % map->pagesize))
- return -EIO;
- return 0;
- }
-
- // Compute the buffer paramaters and return
- if (len > map->pagesize - (start % map->pagesize))
- *retlen = map->pagesize - (start % map->pagesize);
- else
- *retlen = len;
- return 0;
-}
- /*}}}*/
-// flash_chip_scan - Intersect a region with the flash chip structure /*{{{*/
-// ---------------------------------------------------------------------
-/* This is used to enhance the speed of the erase routine,
- when things are being done to multiple chips it is possible to
- parallize the operations, particularly full memory erases of multi
- chip memories benifit */
-
-void flash_chip_scan(struct mapped_mtd_info *map,unsigned long start,
- unsigned long len)
-{
- unsigned int I = 0;
-
- DEBUG(1,"\n");
- // Zero the records
- for (I = 0; map->chips[I].jedec != 0; I++)
- map->chips[I].start = map->chips[I].length = 0;
-
- // Intesect our region with the chip structures
- for (I = 0; map->chips[I].jedec != 0 && len != 0; I++)
- {
- // Havent found the start yet
- if (start >= map->chips[I].base + map->chips[I].size)
- continue;
-
- // Store the portion of this chip that is being effected
- map->chips[I].start = start - map->chips[I].base;
- if (len <= map->chips[I].size - map->chips[I].start)
- map->chips[I].length = len;
- else
- map->chips[I].length = map->chips[I].size - map->chips[I].start;
- len -= map->chips[I].length;
- start = map->chips[I].base + map->chips[I].size;
- }
-}
- /*}}}*/
-
diff --git a/drivers/mtd/mixmem.c b/drivers/mtd/mixmem.c
index 8326f864b..18fc4e2d7 100644
--- a/drivers/mtd/mixmem.c
+++ b/drivers/mtd/mixmem.c
@@ -11,7 +11,7 @@
*/
#include <linux/module.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/ioport.h>
#include <asm/io.h>
#include <linux/init.h>
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index d1344468b..5ab6437c1 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -10,7 +10,7 @@
#include <linux/types.h>
#include <linux/module.h>
#include <linux/kernel.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/mtd/mtd.h>
#define MAJOR_NR MTD_BLOCK_MAJOR
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 9b2b65bfb..8a866f28d 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,6 +1,5 @@
/*
- * Almost: $Id: mtdchar.c,v 1.21 2000/12/09 21:15:12 dwmw2 Exp $
- * (With some of the compatibility for previous kernels taken out)
+ * $Id: mtdchar.c,v 1.21.2.3 2001/01/09 00:18:31 dwmw2 Exp $
*
* Character-device access to raw MTD devices.
*
@@ -13,7 +12,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#ifdef CONFIG_DEVFS_FS
#include <linux/devfs_fs_kernel.h>
@@ -447,10 +446,6 @@ static void mtd_notify_remove(struct mtd_info* mtd)
mod_init_t init_mtdchar(void)
{
#ifdef CONFIG_DEVFS_FS
- int i;
- char name[8];
- struct mtd_info* mtd;
-
if (devfs_register_chrdev(MTD_CHAR_MAJOR, "mtd", &mtd_fops))
{
printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n",
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 8c30838ba..df58ba446 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -11,7 +11,7 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/ptrace.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 0135be39e..7101f7b2b 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -11,7 +11,7 @@
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/list.h>
#include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/mtdram.c b/drivers/mtd/mtdram.c
index bac119919..d3a33495d 100644
--- a/drivers/mtd/mtdram.c
+++ b/drivers/mtd/mtdram.c
@@ -12,7 +12,7 @@
#include <linux/config.h>
#include <linux/module.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/mtd/compatmac.h>
#include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nftl.c b/drivers/mtd/nftl.c
index d7e2aeaad..be82bfd91 100644
--- a/drivers/mtd/nftl.c
+++ b/drivers/mtd/nftl.c
@@ -63,7 +63,7 @@
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/delay.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/blkpg.h>
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 0e6252855..72f734d98 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -28,7 +28,7 @@
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/delay.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/mtd/mtd.h>
@@ -118,7 +118,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
break;
}
}
- ReplUnitTable:
+ ReplUnitTable:;
}
if (boot_record_count == 0) {
@@ -652,7 +652,7 @@ int NFTL_mount(struct NFTLrecord *s)
}
}
}
- examine_ReplUnitTable:
+ examine_ReplUnitTable:;
}
/* second pass to format unreferenced blocks and init free block count */
diff --git a/drivers/mtd/octagon-5066.c b/drivers/mtd/octagon-5066.c
index 70e78d7e9..9561e1b0a 100644
--- a/drivers/mtd/octagon-5066.c
+++ b/drivers/mtd/octagon-5066.c
@@ -1,4 +1,4 @@
-// $Id: octagon-5066.c,v 1.12 2000/11/27 08:50:22 dwmw2 Exp $
+// $Id: octagon-5066.c,v 1.12.2.1 2001/02/15 10:12:48 dwmw2 Exp $
/* ######################################################################
Octagon 5066 MTD Driver.
@@ -25,7 +25,7 @@
##################################################################### */
#include <linux/module.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <asm/io.h>
@@ -273,7 +273,7 @@ int __init init_oct5066(void)
}
}
- if (!oct5066_mtd[1] && !oct5066_mtd[2]) {
+ if (!oct5066_mtd[0] && !oct5066_mtd[1]) {
cleanup_oct5066();
return -ENXIO;
}
diff --git a/drivers/mtd/pmc551.c b/drivers/mtd/pmc551.c
index ab9049356..383204ff6 100644
--- a/drivers/mtd/pmc551.c
+++ b/drivers/mtd/pmc551.c
@@ -78,7 +78,7 @@
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/ptrace.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
@@ -483,7 +483,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
pci_write_config_word( dev, PMC551_SDRAM_CMD, 0x00bf );
/*
- * Wait untill command has gone through
+ * Wait until command has gone through
* FIXME: register spinning issue
*/
do { pci_read_config_word( dev, PMC551_SDRAM_CMD, &cmd );
@@ -709,7 +709,7 @@ int __init init_pmc551(void)
PCI_Device->irq);
/*
- * The PMC551 device acts VERY wierd if you don't init it
+ * The PMC551 device acts VERY weird if you don't init it
* first. i.e. it will not correctly report devsel. If for
* some reason the sdram is in a wrote-protected state the
* device will DEVSEL when it is written to causing problems
@@ -804,6 +804,7 @@ int __init init_pmc551(void)
if (add_mtd_device(mtd)) {
printk(KERN_NOTICE "pmc551: Failed to register new device\n");
+ iounmap(priv->start);
kfree(mtd->priv);
kfree(mtd);
break;
diff --git a/drivers/mtd/rpxlite.c b/drivers/mtd/rpxlite.c
index 51bcaf8a9..3c19cfb2d 100644
--- a/drivers/mtd/rpxlite.c
+++ b/drivers/mtd/rpxlite.c
@@ -94,6 +94,7 @@ int __init init_rpxlite(void)
return 0;
}
+ iounmap((void *)rpxlite_map.map_priv_1);
return -ENXIO;
}
diff --git a/drivers/mtd/slram.c b/drivers/mtd/slram.c
index 48067c814..d2e4f8ed2 100644
--- a/drivers/mtd/slram.c
+++ b/drivers/mtd/slram.c
@@ -11,7 +11,7 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/ptrace.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
@@ -200,6 +200,7 @@ int init_slram(void)
if (add_mtd_device(mymtd))
{
printk("Failed to register new device\n");
+ iounmap(((struct mypriv *)mymtd->priv)->start);
kfree(mymtd->priv);
kfree(mymtd);
return -EAGAIN;
diff --git a/drivers/mtd/vmax301.c b/drivers/mtd/vmax301.c
index e694604e7..cab69b451 100644
--- a/drivers/mtd/vmax301.c
+++ b/drivers/mtd/vmax301.c
@@ -17,7 +17,7 @@
##################################################################### */
#include <linux/module.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <asm/spinlock.h>
@@ -228,8 +228,10 @@ int __init init_vmax301(void)
}
}
- if (!vmax_mtd[1] && !vmax_mtd[2])
+ if (!vmax_mtd[1] && !vmax_mtd[2]) {
+ iounmap(iomapadr);
return -ENXIO;
+ }
return 0;
}