summaryrefslogtreecommitdiffstats
path: root/linux-2.4.x/drivers/mtd/chips/amd_flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux-2.4.x/drivers/mtd/chips/amd_flash.c')
-rw-r--r--linux-2.4.x/drivers/mtd/chips/amd_flash.c483
1 files changed, 240 insertions, 243 deletions
diff --git a/linux-2.4.x/drivers/mtd/chips/amd_flash.c b/linux-2.4.x/drivers/mtd/chips/amd_flash.c
index 860b8a0..d3d2e13 100644
--- a/linux-2.4.x/drivers/mtd/chips/amd_flash.c
+++ b/linux-2.4.x/drivers/mtd/chips/amd_flash.c
@@ -3,7 +3,7 @@
*
* Author: Jonas Holmberg <jonas.holmberg@axis.com>
*
- * $Id: amd_flash.c,v 1.17 2002/03/05 17:00:37 jonashg Exp $
+ * $Id: amd_flash.c,v 1.29 2006/03/29 08:31:10 dwmw2 Exp $
*
* Copyright (c) 2001 Axis Communications AB
*
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/init.h>
#include <linux/mtd/map.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/flashchip.h>
@@ -66,7 +67,6 @@
#define AM29LV160DT 0x22C4
#define AM29LV160DB 0x2249
#define AM29BDS323D 0x22D1
-#define AM29BDS643D 0x227E
/* Atmel */
#define AT49xV16x 0x00C0
@@ -75,6 +75,7 @@
/* Fujitsu */
#define MBM29LV160TE 0x22C4
#define MBM29LV160BE 0x2249
+#define MBM29LV800BB 0x225B
/* ST - www.st.com */
#define M29W800T 0x00D7
@@ -92,9 +93,9 @@
#define D6_MASK 0x40
struct amd_flash_private {
- int device_type;
- int interleave;
- int numchips;
+ int device_type;
+ int interleave;
+ int numchips;
unsigned long chipshift;
// const char *im_name;
struct flchip chips[0];
@@ -124,10 +125,10 @@ static struct mtd_info *amd_flash_probe(struct map_info *map);
static struct mtd_chip_driver amd_flash_chipdrv = {
- probe: amd_flash_probe,
- destroy: amd_flash_destroy,
- name: "amd_flash",
- module: THIS_MODULE
+ .probe = amd_flash_probe,
+ .destroy = amd_flash_destroy,
+ .name = "amd_flash",
+ .module = THIS_MODULE
};
@@ -139,11 +140,11 @@ static const char im_name[] = "amd_flash";
static inline __u32 wide_read(struct map_info *map, __u32 addr)
{
if (map->buswidth == 1) {
- return map->read8(map, addr);
+ return map_read8(map, addr);
} else if (map->buswidth == 2) {
- return map->read16(map, addr);
+ return map_read16(map, addr);
} else if (map->buswidth == 4) {
- return map->read32(map, addr);
+ return map_read32(map, addr);
}
return 0;
@@ -152,11 +153,11 @@ static inline __u32 wide_read(struct map_info *map, __u32 addr)
static inline void wide_write(struct map_info *map, __u32 val, __u32 addr)
{
if (map->buswidth == 1) {
- map->write8(map, val, addr);
+ map_write8(map, val, addr);
} else if (map->buswidth == 2) {
- map->write16(map, val, addr);
+ map_write16(map, val, addr);
} else if (map->buswidth == 4) {
- map->write32(map, val, addr);
+ map_write32(map, val, addr);
}
}
@@ -252,7 +253,7 @@ static int amd_flash_do_unlock(struct mtd_info *mtd, loff_t ofs, size_t len,
int i;
int retval = 0;
int lock_status;
-
+
map = mtd->priv;
/* Pass the whole chip through sector by sector and check for each
@@ -272,7 +273,7 @@ static int amd_flash_do_unlock(struct mtd_info *mtd, loff_t ofs, size_t len,
unlock_sector(map, eraseoffset, is_unlock);
lock_status = is_sector_locked(map, eraseoffset);
-
+
if (is_unlock && lock_status) {
printk("Cannot unlock sector at address %x length %xx\n",
eraseoffset, merip->erasesize);
@@ -304,7 +305,7 @@ static int amd_flash_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
/*
* Reads JEDEC manufacturer ID and device ID and returns the index of the first
* matching table entry (-1 if not found or alias for already found chip).
- */
+ */
static int probe_new_chip(struct mtd_info *mtd, __u32 base,
struct flchip *chips,
struct amd_flash_private *private,
@@ -423,221 +424,219 @@ static int probe_new_chip(struct mtd_info *mtd, __u32 base,
static struct mtd_info *amd_flash_probe(struct map_info *map)
{
- /* Keep this table on the stack so that it gets deallocated after the
- * probe is done.
- */
- const struct amd_flash_info table[] = {
+ static const struct amd_flash_info table[] = {
{
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29LV160DT,
- name: "AMD AM29LV160DT",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 31 },
- { offset: 0x1F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x1F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x1FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29LV160DT,
+ .name = "AMD AM29LV160DT",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 },
+ { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29LV160DB,
- name: "AMD AM29LV160DB",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
- { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29LV160DB,
+ .name = "AMD AM29LV160DB",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 }
}
}, {
- mfr_id: MANUFACTURER_TOSHIBA,
- dev_id: TC58FVT160,
- name: "Toshiba TC58FVT160",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 31 },
- { offset: 0x1F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x1F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x1FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_TOSHIBA,
+ .dev_id = TC58FVT160,
+ .name = "Toshiba TC58FVT160",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 },
+ { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_FUJITSU,
- dev_id: MBM29LV160TE,
- name: "Fujitsu MBM29LV160TE",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 31 },
- { offset: 0x1F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x1F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x1FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_FUJITSU,
+ .dev_id = MBM29LV160TE,
+ .name = "Fujitsu MBM29LV160TE",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 },
+ { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_TOSHIBA,
- dev_id: TC58FVB160,
- name: "Toshiba TC58FVB160",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
- { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
+ .mfr_id = MANUFACTURER_TOSHIBA,
+ .dev_id = TC58FVB160,
+ .name = "Toshiba TC58FVB160",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 }
}
}, {
- mfr_id: MANUFACTURER_FUJITSU,
- dev_id: MBM29LV160BE,
- name: "Fujitsu MBM29LV160BE",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
- { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
+ .mfr_id = MANUFACTURER_FUJITSU,
+ .dev_id = MBM29LV160BE,
+ .name = "Fujitsu MBM29LV160BE",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29LV800BB,
- name: "AMD AM29LV800BB",
- size: 0x00100000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
- { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 15 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29LV800BB,
+ .name = "AMD AM29LV800BB",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29F800BB,
- name: "AMD AM29F800BB",
- size: 0x00100000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
- { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 15 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29F800BB,
+ .name = "AMD AM29F800BB",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29LV800BT,
- name: "AMD AM29LV800BT",
- size: 0x00100000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 15 },
- { offset: 0x0F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x0F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x0FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29LV800BT,
+ .name = "AMD AM29LV800BT",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 },
+ { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29F800BT,
- name: "AMD AM29F800BT",
- size: 0x00100000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 15 },
- { offset: 0x0F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x0F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x0FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29F800BT,
+ .name = "AMD AM29F800BT",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 },
+ { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29LV800BB,
- name: "AMD AM29LV800BB",
- size: 0x00100000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 15 },
- { offset: 0x0F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x0F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x0FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29LV800BB,
+ .name = "AMD AM29LV800BB",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 },
+ { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_ST,
- dev_id: M29W800T,
- name: "ST M29W800T",
- size: 0x00100000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 15 },
- { offset: 0x0F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x0F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x0FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_FUJITSU,
+ .dev_id = MBM29LV800BB,
+ .name = "Fujitsu MBM29LV800BB",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 }
}
}, {
- mfr_id: MANUFACTURER_ST,
- dev_id: M29W160DT,
- name: "ST M29W160DT",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 31 },
- { offset: 0x1F0000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x1F8000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x1FC000, erasesize: 0x04000, numblocks: 1 }
+ .mfr_id = MANUFACTURER_ST,
+ .dev_id = M29W800T,
+ .name = "ST M29W800T",
+ .size = 0x00100000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 },
+ { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_ST,
- dev_id: M29W160DB,
- name: "ST M29W160DB",
- size: 0x00200000,
- numeraseregions: 4,
- regions: {
- { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
- { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
- { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
+ .mfr_id = MANUFACTURER_ST,
+ .dev_id = M29W160DT,
+ .name = "ST M29W160DT",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 },
+ { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29BDS323D,
- name: "AMD AM29BDS323D",
- size: 0x00400000,
- numeraseregions: 3,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 48 },
- { offset: 0x300000, erasesize: 0x10000, numblocks: 15 },
- { offset: 0x3f0000, erasesize: 0x02000, numblocks: 8 },
+ .mfr_id = MANUFACTURER_ST,
+ .dev_id = M29W160DB,
+ .name = "ST M29W160DB",
+ .size = 0x00200000,
+ .numeraseregions = 4,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 },
+ { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 },
+ { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 }
}
}, {
- mfr_id: MANUFACTURER_AMD,
- dev_id: AM29BDS643D,
- name: "AMD AM29BDS643D",
- size: 0x00800000,
- numeraseregions: 3,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 96 },
- { offset: 0x600000, erasesize: 0x10000, numblocks: 31 },
- { offset: 0x7f0000, erasesize: 0x02000, numblocks: 8 },
+ .mfr_id = MANUFACTURER_AMD,
+ .dev_id = AM29BDS323D,
+ .name = "AMD AM29BDS323D",
+ .size = 0x00400000,
+ .numeraseregions = 3,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 48 },
+ { .offset = 0x300000, .erasesize = 0x10000, .numblocks = 15 },
+ { .offset = 0x3f0000, .erasesize = 0x02000, .numblocks = 8 },
}
}, {
- mfr_id: MANUFACTURER_ATMEL,
- dev_id: AT49xV16x,
- name: "Atmel AT49xV16x",
- size: 0x00200000,
- numeraseregions: 2,
- regions: {
- { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
- { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
+ .mfr_id = MANUFACTURER_ATMEL,
+ .dev_id = AT49xV16x,
+ .name = "Atmel AT49xV16x",
+ .size = 0x00200000,
+ .numeraseregions = 2,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x02000, .numblocks = 8 },
+ { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 }
}
}, {
- mfr_id: MANUFACTURER_ATMEL,
- dev_id: AT49xV16xT,
- name: "Atmel AT49xV16xT",
- size: 0x00200000,
- numeraseregions: 2,
- regions: {
- { offset: 0x000000, erasesize: 0x10000, numblocks: 31 },
- { offset: 0x1F0000, erasesize: 0x02000, numblocks: 8 }
+ .mfr_id = MANUFACTURER_ATMEL,
+ .dev_id = AT49xV16xT,
+ .name = "Atmel AT49xV16xT",
+ .size = 0x00200000,
+ .numeraseregions = 2,
+ .regions = {
+ { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 },
+ { .offset = 0x1F0000, .erasesize = 0x02000, .numblocks = 8 }
}
- }
+ }
};
struct mtd_info *mtd;
@@ -665,7 +664,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
printk("%s: Probing for AMD compatible flash...\n", map->name);
if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table,
- sizeof(table)/sizeof(table[0])))
+ ARRAY_SIZE(table)))
== -1) {
printk(KERN_WARNING
"%s: Found no AMD compatible device at location zero\n",
@@ -697,17 +696,17 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
base += (1 << temp.chipshift)) {
int numchips = temp.numchips;
table_pos[numchips] = probe_new_chip(mtd, base, chips,
- &temp, table, sizeof(table)/sizeof(table[0]));
+ &temp, table, ARRAY_SIZE(table));
}
mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) *
mtd->numeraseregions, GFP_KERNEL);
- if (!mtd->eraseregions) {
+ if (!mtd->eraseregions) {
printk(KERN_WARNING "%s: Failed to allocate "
"memory for MTD erase region info\n", map->name);
kfree(mtd);
map->fldrv_priv = NULL;
- return 0;
+ return NULL;
}
reg_idx = 0;
@@ -740,12 +739,12 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
mtd->type = MTD_NORFLASH;
mtd->flags = MTD_CAP_NORFLASH;
mtd->name = map->name;
- mtd->erase = amd_flash_erase;
- mtd->read = amd_flash_read;
- mtd->write = amd_flash_write;
- mtd->sync = amd_flash_sync;
- mtd->suspend = amd_flash_suspend;
- mtd->resume = amd_flash_resume;
+ mtd->erase = amd_flash_erase;
+ mtd->read = amd_flash_read;
+ mtd->write = amd_flash_write;
+ mtd->sync = amd_flash_sync;
+ mtd->suspend = amd_flash_suspend;
+ mtd->resume = amd_flash_resume;
mtd->lock = amd_flash_lock;
mtd->unlock = amd_flash_unlock;
@@ -769,8 +768,8 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
map->fldrv_priv = private;
map->fldrv = &amd_flash_chipdrv;
- MOD_INC_USE_COUNT;
+ __module_get(THIS_MODULE);
return mtd;
}
@@ -790,7 +789,7 @@ retry:
map->name, chip->state);
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
-
+
spin_unlock_bh(chip->mutex);
schedule();
@@ -803,13 +802,13 @@ retry:
timeo = jiffies + HZ;
goto retry;
- }
+ }
adr += chip->start;
chip->state = FL_READY;
- map->copy_from(map, buf, adr, len);
+ map_copy_from(map, buf, adr, len);
wake_up(&chip->wq);
spin_unlock_bh(chip->mutex);
@@ -890,7 +889,7 @@ retry:
map->name, chip->state);
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
-
+
spin_unlock_bh(chip->mutex);
schedule();
@@ -902,7 +901,7 @@ retry:
timeo = jiffies + HZ;
goto retry;
- }
+ }
chip->state = FL_WRITING;
@@ -912,8 +911,8 @@ retry:
wide_write(map, datum, adr);
times_left = 500000;
- while (times_left-- && flash_is_busy(map, adr, private->interleave)) {
- if (current->need_resched) {
+ while (times_left-- && flash_is_busy(map, adr, private->interleave)) {
+ if (need_resched()) {
spin_unlock_bh(chip->mutex);
schedule();
spin_lock_bh(chip->mutex);
@@ -971,7 +970,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
u_char tmp_buf[4];
__u32 datum;
- map->copy_from(map, tmp_buf,
+ map_copy_from(map, tmp_buf,
bus_ofs + private->chips[chipnum].start,
map->buswidth);
while (len && i < map->buswidth)
@@ -990,7 +989,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
if (ret) {
return ret;
}
-
+
ofs += n;
buf += n;
(*retlen) += n;
@@ -1003,7 +1002,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
}
}
}
-
+
/* We are now aligned, write as much as possible. */
while(len >= map->buswidth) {
__u32 datum;
@@ -1044,7 +1043,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
u_char tmp_buf[2];
__u32 datum;
- map->copy_from(map, tmp_buf,
+ map_copy_from(map, tmp_buf,
ofs + private->chips[chipnum].start,
map->buswidth);
while (len--) {
@@ -1064,7 +1063,7 @@ static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len,
if (ret) {
return ret;
}
-
+
(*retlen) += n;
}
@@ -1086,7 +1085,7 @@ retry:
if (chip->state != FL_READY){
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
-
+
spin_unlock_bh(chip->mutex);
schedule();
@@ -1099,7 +1098,7 @@ retry:
timeo = jiffies + HZ;
goto retry;
- }
+ }
chip->state = FL_ERASING;
@@ -1107,30 +1106,30 @@ retry:
ENABLE_VPP(map);
send_cmd(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA);
send_cmd_to_addr(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA_2, adr);
-
+
timeo = jiffies + (HZ * 20);
spin_unlock_bh(chip->mutex);
- schedule_timeout(HZ);
+ msleep(1000);
spin_lock_bh(chip->mutex);
-
+
while (flash_is_busy(map, adr, private->interleave)) {
if (chip->state != FL_ERASING) {
/* Someone's suspended the erase. Sleep */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
-
+
spin_unlock_bh(chip->mutex);
printk(KERN_INFO "%s: erase suspended. Sleeping\n",
map->name);
schedule();
remove_wait_queue(&chip->wq, &wait);
-
+
if (signal_pending(current)) {
return -EINTR;
}
-
+
timeo = jiffies + (HZ*2); /* FIXME */
spin_lock_bh(chip->mutex);
continue;
@@ -1146,15 +1145,15 @@ retry:
return -EIO;
}
-
+
/* Latency issues. Drop the lock, wait a while and retry */
spin_unlock_bh(chip->mutex);
- if (current->need_resched)
+ if (need_resched())
schedule();
else
udelay(1);
-
+
spin_lock_bh(chip->mutex);
}
@@ -1165,7 +1164,7 @@ retry:
__u8 verify;
for (address = adr; address < (adr + size); address++) {
- if ((verify = map->read8(map, address)) != 0xFF) {
+ if ((verify = map_read8(map, address)) != 0xFF) {
error = 1;
break;
}
@@ -1181,7 +1180,7 @@ retry:
return -EIO;
}
}
-
+
DISABLE_VPP(map);
chip->state = FL_READY;
wake_up(&chip->wq);
@@ -1247,7 +1246,7 @@ static int amd_flash_erase(struct mtd_info *mtd, struct erase_info *instr)
* with the erase region at that address.
*/
- while ((i < mtd->numeraseregions) &&
+ while ((i < mtd->numeraseregions) &&
((instr->addr + instr->len) >= regions[i].offset)) {
i++;
}
@@ -1294,12 +1293,10 @@ static int amd_flash_erase(struct mtd_info *mtd, struct erase_info *instr)
}
}
}
-
+
instr->state = MTD_ERASE_DONE;
- if (instr->callback) {
- instr->callback(instr);
- }
-
+ mtd_erase_callback(instr);
+
return 0;
}
@@ -1327,7 +1324,7 @@ static void amd_flash_sync(struct mtd_info *mtd)
case FL_JEDEC_QUERY:
chip->oldstate = chip->state;
chip->state = FL_SYNCING;
- /* No need to wake_up() on this state change -
+ /* No need to wake_up() on this state change -
* as the whole point is that nobody can do anything
* with the chip now anyway.
*/
@@ -1338,13 +1335,13 @@ static void amd_flash_sync(struct mtd_info *mtd)
default:
/* Not an idle state */
add_wait_queue(&chip->wq, &wait);
-
+
spin_unlock_bh(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
-
+
goto retry;
}
}
@@ -1354,7 +1351,7 @@ static void amd_flash_sync(struct mtd_info *mtd)
chip = &private->chips[i];
spin_lock_bh(chip->mutex);
-
+
if (chip->state == FL_SYNCING) {
chip->state = chip->oldstate;
wake_up(&chip->wq);