diff options
Diffstat (limited to 'drivers/mtd')
65 files changed, 758 insertions, 468 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index c93a8be5d5f1..f5ab6fa1057b 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -58,8 +58,8 @@ static int cfi_intelext_write_buffers(struct mtd_info *, loff_t, size_t, size_t | |||
58 | static int cfi_intelext_writev(struct mtd_info *, const struct kvec *, unsigned long, loff_t, size_t *); | 58 | static int cfi_intelext_writev(struct mtd_info *, const struct kvec *, unsigned long, loff_t, size_t *); |
59 | static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *); | 59 | static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *); |
60 | static void cfi_intelext_sync (struct mtd_info *); | 60 | static void cfi_intelext_sync (struct mtd_info *); |
61 | static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len); | 61 | static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
62 | static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); | 62 | static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
63 | #ifdef CONFIG_MTD_OTP | 63 | #ifdef CONFIG_MTD_OTP |
64 | static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 64 | static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
65 | static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 65 | static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
@@ -558,8 +558,8 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd) | |||
558 | } | 558 | } |
559 | 559 | ||
560 | for (i=0; i<mtd->numeraseregions;i++){ | 560 | for (i=0; i<mtd->numeraseregions;i++){ |
561 | printk(KERN_DEBUG "erase region %d: offset=0x%x,size=0x%x,blocks=%d\n", | 561 | printk(KERN_DEBUG "erase region %d: offset=0x%llx,size=0x%x,blocks=%d\n", |
562 | i,mtd->eraseregions[i].offset, | 562 | i,(unsigned long long)mtd->eraseregions[i].offset, |
563 | mtd->eraseregions[i].erasesize, | 563 | mtd->eraseregions[i].erasesize, |
564 | mtd->eraseregions[i].numblocks); | 564 | mtd->eraseregions[i].numblocks); |
565 | } | 565 | } |
@@ -2058,7 +2058,7 @@ out: put_chip(map, chip, adr); | |||
2058 | return ret; | 2058 | return ret; |
2059 | } | 2059 | } |
2060 | 2060 | ||
2061 | static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 2061 | static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
2062 | { | 2062 | { |
2063 | int ret; | 2063 | int ret; |
2064 | 2064 | ||
@@ -2082,7 +2082,7 @@ static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
2082 | return ret; | 2082 | return ret; |
2083 | } | 2083 | } |
2084 | 2084 | ||
2085 | static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 2085 | static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
2086 | { | 2086 | { |
2087 | int ret; | 2087 | int ret; |
2088 | 2088 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index d74ec46aa032..f9c435a42670 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -71,8 +71,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr | |||
71 | static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); | 71 | static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); |
72 | #include "fwh_lock.h" | 72 | #include "fwh_lock.h" |
73 | 73 | ||
74 | static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, size_t len); | 74 | static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
75 | static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); | 75 | static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
76 | 76 | ||
77 | static struct mtd_chip_driver cfi_amdstd_chipdrv = { | 77 | static struct mtd_chip_driver cfi_amdstd_chipdrv = { |
78 | .probe = NULL, /* Not usable directly */ | 78 | .probe = NULL, /* Not usable directly */ |
@@ -1774,12 +1774,12 @@ out_unlock: | |||
1774 | return ret; | 1774 | return ret; |
1775 | } | 1775 | } |
1776 | 1776 | ||
1777 | static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 1777 | static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
1778 | { | 1778 | { |
1779 | return cfi_varsize_frob(mtd, do_atmel_lock, ofs, len, NULL); | 1779 | return cfi_varsize_frob(mtd, do_atmel_lock, ofs, len, NULL); |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 1782 | static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
1783 | { | 1783 | { |
1784 | return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL); | 1784 | return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL); |
1785 | } | 1785 | } |
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index d4714dd9f7ab..6c740f346f91 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c | |||
@@ -42,8 +42,8 @@ static int cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
42 | unsigned long count, loff_t to, size_t *retlen); | 42 | unsigned long count, loff_t to, size_t *retlen); |
43 | static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_info *); | 43 | static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_info *); |
44 | static void cfi_staa_sync (struct mtd_info *); | 44 | static void cfi_staa_sync (struct mtd_info *); |
45 | static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len); | 45 | static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
46 | static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); | 46 | static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
47 | static int cfi_staa_suspend (struct mtd_info *); | 47 | static int cfi_staa_suspend (struct mtd_info *); |
48 | static void cfi_staa_resume (struct mtd_info *); | 48 | static void cfi_staa_resume (struct mtd_info *); |
49 | 49 | ||
@@ -221,8 +221,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
221 | } | 221 | } |
222 | 222 | ||
223 | for (i=0; i<mtd->numeraseregions;i++){ | 223 | for (i=0; i<mtd->numeraseregions;i++){ |
224 | printk(KERN_DEBUG "%d: offset=0x%x,size=0x%x,blocks=%d\n", | 224 | printk(KERN_DEBUG "%d: offset=0x%llx,size=0x%x,blocks=%d\n", |
225 | i,mtd->eraseregions[i].offset, | 225 | i, (unsigned long long)mtd->eraseregions[i].offset, |
226 | mtd->eraseregions[i].erasesize, | 226 | mtd->eraseregions[i].erasesize, |
227 | mtd->eraseregions[i].numblocks); | 227 | mtd->eraseregions[i].numblocks); |
228 | } | 228 | } |
@@ -964,7 +964,7 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd, | |||
964 | adr += regions[i].erasesize; | 964 | adr += regions[i].erasesize; |
965 | len -= regions[i].erasesize; | 965 | len -= regions[i].erasesize; |
966 | 966 | ||
967 | if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift))) | 967 | if (adr % (1<< cfi->chipshift) == (((unsigned long)regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift))) |
968 | i++; | 968 | i++; |
969 | 969 | ||
970 | if (adr >> cfi->chipshift) { | 970 | if (adr >> cfi->chipshift) { |
@@ -1135,7 +1135,7 @@ retry: | |||
1135 | spin_unlock_bh(chip->mutex); | 1135 | spin_unlock_bh(chip->mutex); |
1136 | return 0; | 1136 | return 0; |
1137 | } | 1137 | } |
1138 | static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 1138 | static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
1139 | { | 1139 | { |
1140 | struct map_info *map = mtd->priv; | 1140 | struct map_info *map = mtd->priv; |
1141 | struct cfi_private *cfi = map->fldrv_priv; | 1141 | struct cfi_private *cfi = map->fldrv_priv; |
@@ -1284,7 +1284,7 @@ retry: | |||
1284 | spin_unlock_bh(chip->mutex); | 1284 | spin_unlock_bh(chip->mutex); |
1285 | return 0; | 1285 | return 0; |
1286 | } | 1286 | } |
1287 | static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 1287 | static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
1288 | { | 1288 | { |
1289 | struct map_info *map = mtd->priv; | 1289 | struct map_info *map = mtd->priv; |
1290 | struct cfi_private *cfi = map->fldrv_priv; | 1290 | struct cfi_private *cfi = map->fldrv_priv; |
diff --git a/drivers/mtd/chips/fwh_lock.h b/drivers/mtd/chips/fwh_lock.h index ab44f2b996f8..57e0e4e921f9 100644 --- a/drivers/mtd/chips/fwh_lock.h +++ b/drivers/mtd/chips/fwh_lock.h | |||
@@ -77,7 +77,7 @@ static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip, | |||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len) | 80 | static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
81 | { | 81 | { |
82 | int ret; | 82 | int ret; |
83 | 83 | ||
@@ -88,7 +88,7 @@ static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len) | 91 | static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
92 | { | 92 | { |
93 | int ret; | 93 | int ret; |
94 | 94 | ||
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c index f4bda4cee495..578de1c67bfe 100644 --- a/drivers/mtd/devices/lart.c +++ b/drivers/mtd/devices/lart.c | |||
@@ -619,7 +619,7 @@ static struct mtd_partition lart_partitions[] = { | |||
619 | }; | 619 | }; |
620 | #endif | 620 | #endif |
621 | 621 | ||
622 | int __init lart_flash_init (void) | 622 | static int __init lart_flash_init (void) |
623 | { | 623 | { |
624 | int result; | 624 | int result; |
625 | memset (&mtd,0,sizeof (mtd)); | 625 | memset (&mtd,0,sizeof (mtd)); |
@@ -690,7 +690,7 @@ int __init lart_flash_init (void) | |||
690 | return (result); | 690 | return (result); |
691 | } | 691 | } |
692 | 692 | ||
693 | void __exit lart_flash_exit (void) | 693 | static void __exit lart_flash_exit (void) |
694 | { | 694 | { |
695 | #ifndef HAVE_PARTITIONS | 695 | #ifndef HAVE_PARTITIONS |
696 | del_mtd_device (&mtd); | 696 | del_mtd_device (&mtd); |
@@ -705,5 +705,3 @@ module_exit (lart_flash_exit); | |||
705 | MODULE_LICENSE("GPL"); | 705 | MODULE_LICENSE("GPL"); |
706 | MODULE_AUTHOR("Abraham vd Merwe <abraham@2d3d.co.za>"); | 706 | MODULE_AUTHOR("Abraham vd Merwe <abraham@2d3d.co.za>"); |
707 | MODULE_DESCRIPTION("MTD driver for Intel 28F160F3 on LART board"); | 707 | MODULE_DESCRIPTION("MTD driver for Intel 28F160F3 on LART board"); |
708 | |||
709 | |||
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 6659b2275c0c..7c3fc766dcf1 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/mutex.h> | 22 | #include <linux/mutex.h> |
23 | #include <linux/math64.h> | ||
23 | 24 | ||
24 | #include <linux/mtd/mtd.h> | 25 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
@@ -169,9 +170,9 @@ static int wait_till_ready(struct m25p *flash) | |||
169 | */ | 170 | */ |
170 | static int erase_chip(struct m25p *flash) | 171 | static int erase_chip(struct m25p *flash) |
171 | { | 172 | { |
172 | DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n", | 173 | DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %lldKiB\n", |
173 | flash->spi->dev.bus_id, __func__, | 174 | dev_name(&flash->spi->dev), __func__, |
174 | flash->mtd.size / 1024); | 175 | (long long)(flash->mtd.size >> 10)); |
175 | 176 | ||
176 | /* Wait until finished previous write command. */ | 177 | /* Wait until finished previous write command. */ |
177 | if (wait_till_ready(flash)) | 178 | if (wait_till_ready(flash)) |
@@ -197,7 +198,7 @@ static int erase_chip(struct m25p *flash) | |||
197 | static int erase_sector(struct m25p *flash, u32 offset) | 198 | static int erase_sector(struct m25p *flash, u32 offset) |
198 | { | 199 | { |
199 | DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB at 0x%08x\n", | 200 | DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB at 0x%08x\n", |
200 | flash->spi->dev.bus_id, __func__, | 201 | dev_name(&flash->spi->dev), __func__, |
201 | flash->mtd.erasesize / 1024, offset); | 202 | flash->mtd.erasesize / 1024, offset); |
202 | 203 | ||
203 | /* Wait until finished previous write command. */ | 204 | /* Wait until finished previous write command. */ |
@@ -232,18 +233,18 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
232 | { | 233 | { |
233 | struct m25p *flash = mtd_to_m25p(mtd); | 234 | struct m25p *flash = mtd_to_m25p(mtd); |
234 | u32 addr,len; | 235 | u32 addr,len; |
236 | uint32_t rem; | ||
235 | 237 | ||
236 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %d\n", | 238 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%llx, len %lld\n", |
237 | flash->spi->dev.bus_id, __func__, "at", | 239 | dev_name(&flash->spi->dev), __func__, "at", |
238 | (u32)instr->addr, instr->len); | 240 | (long long)instr->addr, (long long)instr->len); |
239 | 241 | ||
240 | /* sanity checks */ | 242 | /* sanity checks */ |
241 | if (instr->addr + instr->len > flash->mtd.size) | 243 | if (instr->addr + instr->len > flash->mtd.size) |
242 | return -EINVAL; | 244 | return -EINVAL; |
243 | if ((instr->addr % mtd->erasesize) != 0 | 245 | div_u64_rem(instr->len, mtd->erasesize, &rem); |
244 | || (instr->len % mtd->erasesize) != 0) { | 246 | if (rem) |
245 | return -EINVAL; | 247 | return -EINVAL; |
246 | } | ||
247 | 248 | ||
248 | addr = instr->addr; | 249 | addr = instr->addr; |
249 | len = instr->len; | 250 | len = instr->len; |
@@ -295,7 +296,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
295 | struct spi_message m; | 296 | struct spi_message m; |
296 | 297 | ||
297 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", | 298 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", |
298 | flash->spi->dev.bus_id, __func__, "from", | 299 | dev_name(&flash->spi->dev), __func__, "from", |
299 | (u32)from, len); | 300 | (u32)from, len); |
300 | 301 | ||
301 | /* sanity checks */ | 302 | /* sanity checks */ |
@@ -367,7 +368,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
367 | struct spi_message m; | 368 | struct spi_message m; |
368 | 369 | ||
369 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", | 370 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", |
370 | flash->spi->dev.bus_id, __func__, "to", | 371 | dev_name(&flash->spi->dev), __func__, "to", |
371 | (u32)to, len); | 372 | (u32)to, len); |
372 | 373 | ||
373 | if (retlen) | 374 | if (retlen) |
@@ -563,7 +564,7 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi) | |||
563 | tmp = spi_write_then_read(spi, &code, 1, id, 5); | 564 | tmp = spi_write_then_read(spi, &code, 1, id, 5); |
564 | if (tmp < 0) { | 565 | if (tmp < 0) { |
565 | DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", | 566 | DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", |
566 | spi->dev.bus_id, tmp); | 567 | dev_name(&spi->dev), tmp); |
567 | return NULL; | 568 | return NULL; |
568 | } | 569 | } |
569 | jedec = id[0]; | 570 | jedec = id[0]; |
@@ -617,7 +618,7 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
617 | /* unrecognized chip? */ | 618 | /* unrecognized chip? */ |
618 | if (i == ARRAY_SIZE(m25p_data)) { | 619 | if (i == ARRAY_SIZE(m25p_data)) { |
619 | DEBUG(MTD_DEBUG_LEVEL0, "%s: unrecognized id %s\n", | 620 | DEBUG(MTD_DEBUG_LEVEL0, "%s: unrecognized id %s\n", |
620 | spi->dev.bus_id, data->type); | 621 | dev_name(&spi->dev), data->type); |
621 | info = NULL; | 622 | info = NULL; |
622 | 623 | ||
623 | /* recognized; is that chip really what's there? */ | 624 | /* recognized; is that chip really what's there? */ |
@@ -658,7 +659,7 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
658 | if (data && data->name) | 659 | if (data && data->name) |
659 | flash->mtd.name = data->name; | 660 | flash->mtd.name = data->name; |
660 | else | 661 | else |
661 | flash->mtd.name = spi->dev.bus_id; | 662 | flash->mtd.name = dev_name(&spi->dev); |
662 | 663 | ||
663 | flash->mtd.type = MTD_NORFLASH; | 664 | flash->mtd.type = MTD_NORFLASH; |
664 | flash->mtd.writesize = 1; | 665 | flash->mtd.writesize = 1; |
@@ -677,24 +678,24 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
677 | flash->mtd.erasesize = info->sector_size; | 678 | flash->mtd.erasesize = info->sector_size; |
678 | } | 679 | } |
679 | 680 | ||
680 | dev_info(&spi->dev, "%s (%d Kbytes)\n", info->name, | 681 | dev_info(&spi->dev, "%s (%lld Kbytes)\n", info->name, |
681 | flash->mtd.size / 1024); | 682 | (long long)flash->mtd.size >> 10); |
682 | 683 | ||
683 | DEBUG(MTD_DEBUG_LEVEL2, | 684 | DEBUG(MTD_DEBUG_LEVEL2, |
684 | "mtd .name = %s, .size = 0x%.8x (%uMiB) " | 685 | "mtd .name = %s, .size = 0x%llx (%lldMiB) " |
685 | ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n", | 686 | ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n", |
686 | flash->mtd.name, | 687 | flash->mtd.name, |
687 | flash->mtd.size, flash->mtd.size / (1024*1024), | 688 | (long long)flash->mtd.size, (long long)(flash->mtd.size >> 20), |
688 | flash->mtd.erasesize, flash->mtd.erasesize / 1024, | 689 | flash->mtd.erasesize, flash->mtd.erasesize / 1024, |
689 | flash->mtd.numeraseregions); | 690 | flash->mtd.numeraseregions); |
690 | 691 | ||
691 | if (flash->mtd.numeraseregions) | 692 | if (flash->mtd.numeraseregions) |
692 | for (i = 0; i < flash->mtd.numeraseregions; i++) | 693 | for (i = 0; i < flash->mtd.numeraseregions; i++) |
693 | DEBUG(MTD_DEBUG_LEVEL2, | 694 | DEBUG(MTD_DEBUG_LEVEL2, |
694 | "mtd.eraseregions[%d] = { .offset = 0x%.8x, " | 695 | "mtd.eraseregions[%d] = { .offset = 0x%llx, " |
695 | ".erasesize = 0x%.8x (%uKiB), " | 696 | ".erasesize = 0x%.8x (%uKiB), " |
696 | ".numblocks = %d }\n", | 697 | ".numblocks = %d }\n", |
697 | i, flash->mtd.eraseregions[i].offset, | 698 | i, (long long)flash->mtd.eraseregions[i].offset, |
698 | flash->mtd.eraseregions[i].erasesize, | 699 | flash->mtd.eraseregions[i].erasesize, |
699 | flash->mtd.eraseregions[i].erasesize / 1024, | 700 | flash->mtd.eraseregions[i].erasesize / 1024, |
700 | flash->mtd.eraseregions[i].numblocks); | 701 | flash->mtd.eraseregions[i].numblocks); |
@@ -722,12 +723,12 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
722 | if (nr_parts > 0) { | 723 | if (nr_parts > 0) { |
723 | for (i = 0; i < nr_parts; i++) { | 724 | for (i = 0; i < nr_parts; i++) { |
724 | DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " | 725 | DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " |
725 | "{.name = %s, .offset = 0x%.8x, " | 726 | "{.name = %s, .offset = 0x%llx, " |
726 | ".size = 0x%.8x (%uKiB) }\n", | 727 | ".size = 0x%llx (%lldKiB) }\n", |
727 | i, parts[i].name, | 728 | i, parts[i].name, |
728 | parts[i].offset, | 729 | (long long)parts[i].offset, |
729 | parts[i].size, | 730 | (long long)parts[i].size, |
730 | parts[i].size / 1024); | 731 | (long long)(parts[i].size >> 10)); |
731 | } | 732 | } |
732 | flash->partitioned = 1; | 733 | flash->partitioned = 1; |
733 | return add_mtd_partitions(&flash->mtd, parts, nr_parts); | 734 | return add_mtd_partitions(&flash->mtd, parts, nr_parts); |
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index 6dd9aff8bb2d..d44f741ae229 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <linux/math64.h> | ||
19 | 20 | ||
20 | #include <linux/spi/spi.h> | 21 | #include <linux/spi/spi.h> |
21 | #include <linux/spi/flash.h> | 22 | #include <linux/spi/flash.h> |
@@ -128,7 +129,7 @@ static int dataflash_waitready(struct spi_device *spi) | |||
128 | status = dataflash_status(spi); | 129 | status = dataflash_status(spi); |
129 | if (status < 0) { | 130 | if (status < 0) { |
130 | DEBUG(MTD_DEBUG_LEVEL1, "%s: status %d?\n", | 131 | DEBUG(MTD_DEBUG_LEVEL1, "%s: status %d?\n", |
131 | spi->dev.bus_id, status); | 132 | dev_name(&spi->dev), status); |
132 | status = 0; | 133 | status = 0; |
133 | } | 134 | } |
134 | 135 | ||
@@ -152,15 +153,20 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
152 | struct spi_message msg; | 153 | struct spi_message msg; |
153 | unsigned blocksize = priv->page_size << 3; | 154 | unsigned blocksize = priv->page_size << 3; |
154 | uint8_t *command; | 155 | uint8_t *command; |
156 | uint32_t rem; | ||
155 | 157 | ||
156 | DEBUG(MTD_DEBUG_LEVEL2, "%s: erase addr=0x%x len 0x%x\n", | 158 | DEBUG(MTD_DEBUG_LEVEL2, "%s: erase addr=0x%llx len 0x%llx\n", |
157 | spi->dev.bus_id, | 159 | dev_name(&spi->dev), (long long)instr->addr, |
158 | instr->addr, instr->len); | 160 | (long long)instr->len); |
159 | 161 | ||
160 | /* Sanity checks */ | 162 | /* Sanity checks */ |
161 | if ((instr->addr + instr->len) > mtd->size | 163 | if (instr->addr + instr->len > mtd->size) |
162 | || (instr->len % priv->page_size) != 0 | 164 | return -EINVAL; |
163 | || (instr->addr % priv->page_size) != 0) | 165 | div_u64_rem(instr->len, priv->page_size, &rem); |
166 | if (rem) | ||
167 | return -EINVAL; | ||
168 | div_u64_rem(instr->addr, priv->page_size, &rem); | ||
169 | if (rem) | ||
164 | return -EINVAL; | 170 | return -EINVAL; |
165 | 171 | ||
166 | spi_message_init(&msg); | 172 | spi_message_init(&msg); |
@@ -178,7 +184,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
178 | /* Calculate flash page address; use block erase (for speed) if | 184 | /* Calculate flash page address; use block erase (for speed) if |
179 | * we're at a block boundary and need to erase the whole block. | 185 | * we're at a block boundary and need to erase the whole block. |
180 | */ | 186 | */ |
181 | pageaddr = instr->addr / priv->page_size; | 187 | pageaddr = div_u64(instr->len, priv->page_size); |
182 | do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize; | 188 | do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize; |
183 | pageaddr = pageaddr << priv->page_offset; | 189 | pageaddr = pageaddr << priv->page_offset; |
184 | 190 | ||
@@ -197,7 +203,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
197 | 203 | ||
198 | if (status < 0) { | 204 | if (status < 0) { |
199 | printk(KERN_ERR "%s: erase %x, err %d\n", | 205 | printk(KERN_ERR "%s: erase %x, err %d\n", |
200 | spi->dev.bus_id, pageaddr, status); | 206 | dev_name(&spi->dev), pageaddr, status); |
201 | /* REVISIT: can retry instr->retries times; or | 207 | /* REVISIT: can retry instr->retries times; or |
202 | * giveup and instr->fail_addr = instr->addr; | 208 | * giveup and instr->fail_addr = instr->addr; |
203 | */ | 209 | */ |
@@ -239,7 +245,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
239 | int status; | 245 | int status; |
240 | 246 | ||
241 | DEBUG(MTD_DEBUG_LEVEL2, "%s: read 0x%x..0x%x\n", | 247 | DEBUG(MTD_DEBUG_LEVEL2, "%s: read 0x%x..0x%x\n", |
242 | priv->spi->dev.bus_id, (unsigned)from, (unsigned)(from + len)); | 248 | dev_name(&priv->spi->dev), (unsigned)from, (unsigned)(from + len)); |
243 | 249 | ||
244 | *retlen = 0; | 250 | *retlen = 0; |
245 | 251 | ||
@@ -288,7 +294,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
288 | status = 0; | 294 | status = 0; |
289 | } else | 295 | } else |
290 | DEBUG(MTD_DEBUG_LEVEL1, "%s: read %x..%x --> %d\n", | 296 | DEBUG(MTD_DEBUG_LEVEL1, "%s: read %x..%x --> %d\n", |
291 | priv->spi->dev.bus_id, | 297 | dev_name(&priv->spi->dev), |
292 | (unsigned)from, (unsigned)(from + len), | 298 | (unsigned)from, (unsigned)(from + len), |
293 | status); | 299 | status); |
294 | return status; | 300 | return status; |
@@ -315,7 +321,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
315 | uint8_t *command; | 321 | uint8_t *command; |
316 | 322 | ||
317 | DEBUG(MTD_DEBUG_LEVEL2, "%s: write 0x%x..0x%x\n", | 323 | DEBUG(MTD_DEBUG_LEVEL2, "%s: write 0x%x..0x%x\n", |
318 | spi->dev.bus_id, (unsigned)to, (unsigned)(to + len)); | 324 | dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len)); |
319 | 325 | ||
320 | *retlen = 0; | 326 | *retlen = 0; |
321 | 327 | ||
@@ -374,7 +380,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
374 | status = spi_sync(spi, &msg); | 380 | status = spi_sync(spi, &msg); |
375 | if (status < 0) | 381 | if (status < 0) |
376 | DEBUG(MTD_DEBUG_LEVEL1, "%s: xfer %u -> %d \n", | 382 | DEBUG(MTD_DEBUG_LEVEL1, "%s: xfer %u -> %d \n", |
377 | spi->dev.bus_id, addr, status); | 383 | dev_name(&spi->dev), addr, status); |
378 | 384 | ||
379 | (void) dataflash_waitready(priv->spi); | 385 | (void) dataflash_waitready(priv->spi); |
380 | } | 386 | } |
@@ -396,7 +402,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
396 | spi_transfer_del(x + 1); | 402 | spi_transfer_del(x + 1); |
397 | if (status < 0) | 403 | if (status < 0) |
398 | DEBUG(MTD_DEBUG_LEVEL1, "%s: pgm %u/%u -> %d \n", | 404 | DEBUG(MTD_DEBUG_LEVEL1, "%s: pgm %u/%u -> %d \n", |
399 | spi->dev.bus_id, addr, writelen, status); | 405 | dev_name(&spi->dev), addr, writelen, status); |
400 | 406 | ||
401 | (void) dataflash_waitready(priv->spi); | 407 | (void) dataflash_waitready(priv->spi); |
402 | 408 | ||
@@ -416,14 +422,14 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
416 | status = spi_sync(spi, &msg); | 422 | status = spi_sync(spi, &msg); |
417 | if (status < 0) | 423 | if (status < 0) |
418 | DEBUG(MTD_DEBUG_LEVEL1, "%s: compare %u -> %d \n", | 424 | DEBUG(MTD_DEBUG_LEVEL1, "%s: compare %u -> %d \n", |
419 | spi->dev.bus_id, addr, status); | 425 | dev_name(&spi->dev), addr, status); |
420 | 426 | ||
421 | status = dataflash_waitready(priv->spi); | 427 | status = dataflash_waitready(priv->spi); |
422 | 428 | ||
423 | /* Check result of the compare operation */ | 429 | /* Check result of the compare operation */ |
424 | if (status & (1 << 6)) { | 430 | if (status & (1 << 6)) { |
425 | printk(KERN_ERR "%s: compare page %u, err %d\n", | 431 | printk(KERN_ERR "%s: compare page %u, err %d\n", |
426 | spi->dev.bus_id, pageaddr, status); | 432 | dev_name(&spi->dev), pageaddr, status); |
427 | remaining = 0; | 433 | remaining = 0; |
428 | status = -EIO; | 434 | status = -EIO; |
429 | break; | 435 | break; |
@@ -667,8 +673,8 @@ add_dataflash_otp(struct spi_device *spi, char *name, | |||
667 | if (revision >= 'c') | 673 | if (revision >= 'c') |
668 | otp_tag = otp_setup(device, revision); | 674 | otp_tag = otp_setup(device, revision); |
669 | 675 | ||
670 | dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes%s\n", | 676 | dev_info(&spi->dev, "%s (%lld KBytes) pagesize %d bytes%s\n", |
671 | name, DIV_ROUND_UP(device->size, 1024), | 677 | name, (long long)((device->size + 1023) >> 10), |
672 | pagesize, otp_tag); | 678 | pagesize, otp_tag); |
673 | dev_set_drvdata(&spi->dev, priv); | 679 | dev_set_drvdata(&spi->dev, priv); |
674 | 680 | ||
@@ -779,7 +785,7 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi) | |||
779 | tmp = spi_write_then_read(spi, &code, 1, id, 3); | 785 | tmp = spi_write_then_read(spi, &code, 1, id, 3); |
780 | if (tmp < 0) { | 786 | if (tmp < 0) { |
781 | DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", | 787 | DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", |
782 | spi->dev.bus_id, tmp); | 788 | dev_name(&spi->dev), tmp); |
783 | return ERR_PTR(tmp); | 789 | return ERR_PTR(tmp); |
784 | } | 790 | } |
785 | if (id[0] != 0x1f) | 791 | if (id[0] != 0x1f) |
@@ -869,7 +875,7 @@ static int __devinit dataflash_probe(struct spi_device *spi) | |||
869 | status = dataflash_status(spi); | 875 | status = dataflash_status(spi); |
870 | if (status <= 0 || status == 0xff) { | 876 | if (status <= 0 || status == 0xff) { |
871 | DEBUG(MTD_DEBUG_LEVEL1, "%s: status error %d\n", | 877 | DEBUG(MTD_DEBUG_LEVEL1, "%s: status error %d\n", |
872 | spi->dev.bus_id, status); | 878 | dev_name(&spi->dev), status); |
873 | if (status == 0 || status == 0xff) | 879 | if (status == 0 || status == 0xff) |
874 | status = -ENODEV; | 880 | status = -ENODEV; |
875 | return status; | 881 | return status; |
@@ -905,13 +911,13 @@ static int __devinit dataflash_probe(struct spi_device *spi) | |||
905 | /* obsolete AT45DB1282 not (yet?) supported */ | 911 | /* obsolete AT45DB1282 not (yet?) supported */ |
906 | default: | 912 | default: |
907 | DEBUG(MTD_DEBUG_LEVEL1, "%s: unsupported device (%x)\n", | 913 | DEBUG(MTD_DEBUG_LEVEL1, "%s: unsupported device (%x)\n", |
908 | spi->dev.bus_id, status & 0x3c); | 914 | dev_name(&spi->dev), status & 0x3c); |
909 | status = -ENODEV; | 915 | status = -ENODEV; |
910 | } | 916 | } |
911 | 917 | ||
912 | if (status < 0) | 918 | if (status < 0) |
913 | DEBUG(MTD_DEBUG_LEVEL1, "%s: add_dataflash --> %d\n", | 919 | DEBUG(MTD_DEBUG_LEVEL1, "%s: add_dataflash --> %d\n", |
914 | spi->dev.bus_id, status); | 920 | dev_name(&spi->dev), status); |
915 | 921 | ||
916 | return status; | 922 | return status; |
917 | } | 923 | } |
@@ -921,7 +927,7 @@ static int __devexit dataflash_remove(struct spi_device *spi) | |||
921 | struct dataflash *flash = dev_get_drvdata(&spi->dev); | 927 | struct dataflash *flash = dev_get_drvdata(&spi->dev); |
922 | int status; | 928 | int status; |
923 | 929 | ||
924 | DEBUG(MTD_DEBUG_LEVEL1, "%s: remove\n", spi->dev.bus_id); | 930 | DEBUG(MTD_DEBUG_LEVEL1, "%s: remove\n", dev_name(&spi->dev)); |
925 | 931 | ||
926 | if (mtd_has_partitions() && flash->partitioned) | 932 | if (mtd_has_partitions() && flash->partitioned) |
927 | status = del_mtd_partitions(&flash->mtd); | 933 | status = del_mtd_partitions(&flash->mtd); |
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index 9bf581c4f740..a790c062af1f 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
@@ -109,25 +109,25 @@ module_param(shuffle_freq, int, 0); | |||
109 | /* Each memory region corresponds to a minor device */ | 109 | /* Each memory region corresponds to a minor device */ |
110 | typedef struct partition_t { | 110 | typedef struct partition_t { |
111 | struct mtd_blktrans_dev mbd; | 111 | struct mtd_blktrans_dev mbd; |
112 | u_int32_t state; | 112 | uint32_t state; |
113 | u_int32_t *VirtualBlockMap; | 113 | uint32_t *VirtualBlockMap; |
114 | u_int32_t *VirtualPageMap; | 114 | uint32_t *VirtualPageMap; |
115 | u_int32_t FreeTotal; | 115 | uint32_t FreeTotal; |
116 | struct eun_info_t { | 116 | struct eun_info_t { |
117 | u_int32_t Offset; | 117 | uint32_t Offset; |
118 | u_int32_t EraseCount; | 118 | uint32_t EraseCount; |
119 | u_int32_t Free; | 119 | uint32_t Free; |
120 | u_int32_t Deleted; | 120 | uint32_t Deleted; |
121 | } *EUNInfo; | 121 | } *EUNInfo; |
122 | struct xfer_info_t { | 122 | struct xfer_info_t { |
123 | u_int32_t Offset; | 123 | uint32_t Offset; |
124 | u_int32_t EraseCount; | 124 | uint32_t EraseCount; |
125 | u_int16_t state; | 125 | uint16_t state; |
126 | } *XferInfo; | 126 | } *XferInfo; |
127 | u_int16_t bam_index; | 127 | uint16_t bam_index; |
128 | u_int32_t *bam_cache; | 128 | uint32_t *bam_cache; |
129 | u_int16_t DataUnits; | 129 | uint16_t DataUnits; |
130 | u_int32_t BlocksPerUnit; | 130 | uint32_t BlocksPerUnit; |
131 | erase_unit_header_t header; | 131 | erase_unit_header_t header; |
132 | } partition_t; | 132 | } partition_t; |
133 | 133 | ||
@@ -199,8 +199,8 @@ static int scan_header(partition_t *part) | |||
199 | static int build_maps(partition_t *part) | 199 | static int build_maps(partition_t *part) |
200 | { | 200 | { |
201 | erase_unit_header_t header; | 201 | erase_unit_header_t header; |
202 | u_int16_t xvalid, xtrans, i; | 202 | uint16_t xvalid, xtrans, i; |
203 | u_int blocks, j; | 203 | unsigned blocks, j; |
204 | int hdr_ok, ret = -1; | 204 | int hdr_ok, ret = -1; |
205 | ssize_t retval; | 205 | ssize_t retval; |
206 | loff_t offset; | 206 | loff_t offset; |
@@ -269,14 +269,14 @@ static int build_maps(partition_t *part) | |||
269 | 269 | ||
270 | /* Set up virtual page map */ | 270 | /* Set up virtual page map */ |
271 | blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; | 271 | blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; |
272 | part->VirtualBlockMap = vmalloc(blocks * sizeof(u_int32_t)); | 272 | part->VirtualBlockMap = vmalloc(blocks * sizeof(uint32_t)); |
273 | if (!part->VirtualBlockMap) | 273 | if (!part->VirtualBlockMap) |
274 | goto out_XferInfo; | 274 | goto out_XferInfo; |
275 | 275 | ||
276 | memset(part->VirtualBlockMap, 0xff, blocks * sizeof(u_int32_t)); | 276 | memset(part->VirtualBlockMap, 0xff, blocks * sizeof(uint32_t)); |
277 | part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize; | 277 | part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize; |
278 | 278 | ||
279 | part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(u_int32_t), | 279 | part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(uint32_t), |
280 | GFP_KERNEL); | 280 | GFP_KERNEL); |
281 | if (!part->bam_cache) | 281 | if (!part->bam_cache) |
282 | goto out_VirtualBlockMap; | 282 | goto out_VirtualBlockMap; |
@@ -290,7 +290,7 @@ static int build_maps(partition_t *part) | |||
290 | offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset); | 290 | offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset); |
291 | 291 | ||
292 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, | 292 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, |
293 | part->BlocksPerUnit * sizeof(u_int32_t), &retval, | 293 | part->BlocksPerUnit * sizeof(uint32_t), &retval, |
294 | (unsigned char *)part->bam_cache); | 294 | (unsigned char *)part->bam_cache); |
295 | 295 | ||
296 | if (ret) | 296 | if (ret) |
@@ -332,7 +332,7 @@ out: | |||
332 | ======================================================================*/ | 332 | ======================================================================*/ |
333 | 333 | ||
334 | static int erase_xfer(partition_t *part, | 334 | static int erase_xfer(partition_t *part, |
335 | u_int16_t xfernum) | 335 | uint16_t xfernum) |
336 | { | 336 | { |
337 | int ret; | 337 | int ret; |
338 | struct xfer_info_t *xfer; | 338 | struct xfer_info_t *xfer; |
@@ -408,7 +408,7 @@ static int prepare_xfer(partition_t *part, int i) | |||
408 | erase_unit_header_t header; | 408 | erase_unit_header_t header; |
409 | struct xfer_info_t *xfer; | 409 | struct xfer_info_t *xfer; |
410 | int nbam, ret; | 410 | int nbam, ret; |
411 | u_int32_t ctl; | 411 | uint32_t ctl; |
412 | ssize_t retlen; | 412 | ssize_t retlen; |
413 | loff_t offset; | 413 | loff_t offset; |
414 | 414 | ||
@@ -430,15 +430,15 @@ static int prepare_xfer(partition_t *part, int i) | |||
430 | } | 430 | } |
431 | 431 | ||
432 | /* Write the BAM stub */ | 432 | /* Write the BAM stub */ |
433 | nbam = (part->BlocksPerUnit * sizeof(u_int32_t) + | 433 | nbam = (part->BlocksPerUnit * sizeof(uint32_t) + |
434 | le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE; | 434 | le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE; |
435 | 435 | ||
436 | offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset); | 436 | offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset); |
437 | ctl = cpu_to_le32(BLOCK_CONTROL); | 437 | ctl = cpu_to_le32(BLOCK_CONTROL); |
438 | 438 | ||
439 | for (i = 0; i < nbam; i++, offset += sizeof(u_int32_t)) { | 439 | for (i = 0; i < nbam; i++, offset += sizeof(uint32_t)) { |
440 | 440 | ||
441 | ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t), | 441 | ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t), |
442 | &retlen, (u_char *)&ctl); | 442 | &retlen, (u_char *)&ctl); |
443 | 443 | ||
444 | if (ret) | 444 | if (ret) |
@@ -461,18 +461,18 @@ static int prepare_xfer(partition_t *part, int i) | |||
461 | 461 | ||
462 | ======================================================================*/ | 462 | ======================================================================*/ |
463 | 463 | ||
464 | static int copy_erase_unit(partition_t *part, u_int16_t srcunit, | 464 | static int copy_erase_unit(partition_t *part, uint16_t srcunit, |
465 | u_int16_t xferunit) | 465 | uint16_t xferunit) |
466 | { | 466 | { |
467 | u_char buf[SECTOR_SIZE]; | 467 | u_char buf[SECTOR_SIZE]; |
468 | struct eun_info_t *eun; | 468 | struct eun_info_t *eun; |
469 | struct xfer_info_t *xfer; | 469 | struct xfer_info_t *xfer; |
470 | u_int32_t src, dest, free, i; | 470 | uint32_t src, dest, free, i; |
471 | u_int16_t unit; | 471 | uint16_t unit; |
472 | int ret; | 472 | int ret; |
473 | ssize_t retlen; | 473 | ssize_t retlen; |
474 | loff_t offset; | 474 | loff_t offset; |
475 | u_int16_t srcunitswap = cpu_to_le16(srcunit); | 475 | uint16_t srcunitswap = cpu_to_le16(srcunit); |
476 | 476 | ||
477 | eun = &part->EUNInfo[srcunit]; | 477 | eun = &part->EUNInfo[srcunit]; |
478 | xfer = &part->XferInfo[xferunit]; | 478 | xfer = &part->XferInfo[xferunit]; |
@@ -486,7 +486,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit, | |||
486 | offset = eun->Offset + le32_to_cpu(part->header.BAMOffset); | 486 | offset = eun->Offset + le32_to_cpu(part->header.BAMOffset); |
487 | 487 | ||
488 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, | 488 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, |
489 | part->BlocksPerUnit * sizeof(u_int32_t), | 489 | part->BlocksPerUnit * sizeof(uint32_t), |
490 | &retlen, (u_char *) (part->bam_cache)); | 490 | &retlen, (u_char *) (part->bam_cache)); |
491 | 491 | ||
492 | /* mark the cache bad, in case we get an error later */ | 492 | /* mark the cache bad, in case we get an error later */ |
@@ -503,7 +503,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit, | |||
503 | offset = xfer->Offset + 20; /* Bad! */ | 503 | offset = xfer->Offset + 20; /* Bad! */ |
504 | unit = cpu_to_le16(0x7fff); | 504 | unit = cpu_to_le16(0x7fff); |
505 | 505 | ||
506 | ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int16_t), | 506 | ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint16_t), |
507 | &retlen, (u_char *) &unit); | 507 | &retlen, (u_char *) &unit); |
508 | 508 | ||
509 | if (ret) { | 509 | if (ret) { |
@@ -560,7 +560,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit, | |||
560 | 560 | ||
561 | 561 | ||
562 | /* All clear? Then update the LogicalEUN again */ | 562 | /* All clear? Then update the LogicalEUN again */ |
563 | ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(u_int16_t), | 563 | ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(uint16_t), |
564 | &retlen, (u_char *)&srcunitswap); | 564 | &retlen, (u_char *)&srcunitswap); |
565 | 565 | ||
566 | if (ret) { | 566 | if (ret) { |
@@ -605,8 +605,8 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit, | |||
605 | 605 | ||
606 | static int reclaim_block(partition_t *part) | 606 | static int reclaim_block(partition_t *part) |
607 | { | 607 | { |
608 | u_int16_t i, eun, xfer; | 608 | uint16_t i, eun, xfer; |
609 | u_int32_t best; | 609 | uint32_t best; |
610 | int queued, ret; | 610 | int queued, ret; |
611 | 611 | ||
612 | DEBUG(0, "ftl_cs: reclaiming space...\n"); | 612 | DEBUG(0, "ftl_cs: reclaiming space...\n"); |
@@ -723,10 +723,10 @@ static void dump_lists(partition_t *part) | |||
723 | } | 723 | } |
724 | #endif | 724 | #endif |
725 | 725 | ||
726 | static u_int32_t find_free(partition_t *part) | 726 | static uint32_t find_free(partition_t *part) |
727 | { | 727 | { |
728 | u_int16_t stop, eun; | 728 | uint16_t stop, eun; |
729 | u_int32_t blk; | 729 | uint32_t blk; |
730 | size_t retlen; | 730 | size_t retlen; |
731 | int ret; | 731 | int ret; |
732 | 732 | ||
@@ -749,7 +749,7 @@ static u_int32_t find_free(partition_t *part) | |||
749 | 749 | ||
750 | ret = part->mbd.mtd->read(part->mbd.mtd, | 750 | ret = part->mbd.mtd->read(part->mbd.mtd, |
751 | part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset), | 751 | part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset), |
752 | part->BlocksPerUnit * sizeof(u_int32_t), | 752 | part->BlocksPerUnit * sizeof(uint32_t), |
753 | &retlen, (u_char *) (part->bam_cache)); | 753 | &retlen, (u_char *) (part->bam_cache)); |
754 | 754 | ||
755 | if (ret) { | 755 | if (ret) { |
@@ -786,7 +786,7 @@ static u_int32_t find_free(partition_t *part) | |||
786 | static int ftl_read(partition_t *part, caddr_t buffer, | 786 | static int ftl_read(partition_t *part, caddr_t buffer, |
787 | u_long sector, u_long nblocks) | 787 | u_long sector, u_long nblocks) |
788 | { | 788 | { |
789 | u_int32_t log_addr, bsize; | 789 | uint32_t log_addr, bsize; |
790 | u_long i; | 790 | u_long i; |
791 | int ret; | 791 | int ret; |
792 | size_t offset, retlen; | 792 | size_t offset, retlen; |
@@ -829,14 +829,14 @@ static int ftl_read(partition_t *part, caddr_t buffer, | |||
829 | 829 | ||
830 | ======================================================================*/ | 830 | ======================================================================*/ |
831 | 831 | ||
832 | static int set_bam_entry(partition_t *part, u_int32_t log_addr, | 832 | static int set_bam_entry(partition_t *part, uint32_t log_addr, |
833 | u_int32_t virt_addr) | 833 | uint32_t virt_addr) |
834 | { | 834 | { |
835 | u_int32_t bsize, blk, le_virt_addr; | 835 | uint32_t bsize, blk, le_virt_addr; |
836 | #ifdef PSYCHO_DEBUG | 836 | #ifdef PSYCHO_DEBUG |
837 | u_int32_t old_addr; | 837 | uint32_t old_addr; |
838 | #endif | 838 | #endif |
839 | u_int16_t eun; | 839 | uint16_t eun; |
840 | int ret; | 840 | int ret; |
841 | size_t retlen, offset; | 841 | size_t retlen, offset; |
842 | 842 | ||
@@ -845,11 +845,11 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr, | |||
845 | bsize = 1 << part->header.EraseUnitSize; | 845 | bsize = 1 << part->header.EraseUnitSize; |
846 | eun = log_addr / bsize; | 846 | eun = log_addr / bsize; |
847 | blk = (log_addr % bsize) / SECTOR_SIZE; | 847 | blk = (log_addr % bsize) / SECTOR_SIZE; |
848 | offset = (part->EUNInfo[eun].Offset + blk * sizeof(u_int32_t) + | 848 | offset = (part->EUNInfo[eun].Offset + blk * sizeof(uint32_t) + |
849 | le32_to_cpu(part->header.BAMOffset)); | 849 | le32_to_cpu(part->header.BAMOffset)); |
850 | 850 | ||
851 | #ifdef PSYCHO_DEBUG | 851 | #ifdef PSYCHO_DEBUG |
852 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(u_int32_t), | 852 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(uint32_t), |
853 | &retlen, (u_char *)&old_addr); | 853 | &retlen, (u_char *)&old_addr); |
854 | if (ret) { | 854 | if (ret) { |
855 | printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret); | 855 | printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret); |
@@ -886,7 +886,7 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr, | |||
886 | #endif | 886 | #endif |
887 | part->bam_cache[blk] = le_virt_addr; | 887 | part->bam_cache[blk] = le_virt_addr; |
888 | } | 888 | } |
889 | ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t), | 889 | ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t), |
890 | &retlen, (u_char *)&le_virt_addr); | 890 | &retlen, (u_char *)&le_virt_addr); |
891 | 891 | ||
892 | if (ret) { | 892 | if (ret) { |
@@ -900,7 +900,7 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr, | |||
900 | static int ftl_write(partition_t *part, caddr_t buffer, | 900 | static int ftl_write(partition_t *part, caddr_t buffer, |
901 | u_long sector, u_long nblocks) | 901 | u_long sector, u_long nblocks) |
902 | { | 902 | { |
903 | u_int32_t bsize, log_addr, virt_addr, old_addr, blk; | 903 | uint32_t bsize, log_addr, virt_addr, old_addr, blk; |
904 | u_long i; | 904 | u_long i; |
905 | int ret; | 905 | int ret; |
906 | size_t retlen, offset; | 906 | size_t retlen, offset; |
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index 50ce13887f63..73f05227dc8c 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -50,7 +50,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
50 | struct INFTLrecord *inftl; | 50 | struct INFTLrecord *inftl; |
51 | unsigned long temp; | 51 | unsigned long temp; |
52 | 52 | ||
53 | if (mtd->type != MTD_NANDFLASH) | 53 | if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) |
54 | return; | 54 | return; |
55 | /* OK, this is moderately ugly. But probably safe. Alternatives? */ | 55 | /* OK, this is moderately ugly. But probably safe. Alternatives? */ |
56 | if (memcmp(mtd->name, "DiskOnChip", 10)) | 56 | if (memcmp(mtd->name, "DiskOnChip", 10)) |
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index 9113628ed1ef..f751dd97c549 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c | |||
@@ -63,7 +63,7 @@ static int find_boot_record(struct INFTLrecord *inftl) | |||
63 | * otherwise. | 63 | * otherwise. |
64 | */ | 64 | */ |
65 | inftl->EraseSize = inftl->mbd.mtd->erasesize; | 65 | inftl->EraseSize = inftl->mbd.mtd->erasesize; |
66 | inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize; | 66 | inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize; |
67 | 67 | ||
68 | inftl->MediaUnit = BLOCK_NIL; | 68 | inftl->MediaUnit = BLOCK_NIL; |
69 | 69 | ||
@@ -187,7 +187,7 @@ static int find_boot_record(struct INFTLrecord *inftl) | |||
187 | mh->BlockMultiplierBits); | 187 | mh->BlockMultiplierBits); |
188 | inftl->EraseSize = inftl->mbd.mtd->erasesize << | 188 | inftl->EraseSize = inftl->mbd.mtd->erasesize << |
189 | mh->BlockMultiplierBits; | 189 | mh->BlockMultiplierBits; |
190 | inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize; | 190 | inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize; |
191 | block >>= mh->BlockMultiplierBits; | 191 | block >>= mh->BlockMultiplierBits; |
192 | } | 192 | } |
193 | 193 | ||
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 5ea169362164..3788a548336c 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
@@ -23,9 +23,20 @@ config MTD_PHYSMAP | |||
23 | To compile this driver as a module, choose M here: the | 23 | To compile this driver as a module, choose M here: the |
24 | module will be called physmap. | 24 | module will be called physmap. |
25 | 25 | ||
26 | config MTD_PHYSMAP_COMPAT | ||
27 | bool "Physmap compat support" | ||
28 | depends on MTD_PHYSMAP | ||
29 | default n | ||
30 | help | ||
31 | Setup a simple mapping via the Kconfig options. Normally the | ||
32 | physmap configuration options are done via your board's | ||
33 | resource file. | ||
34 | |||
35 | If unsure, say N here. | ||
36 | |||
26 | config MTD_PHYSMAP_START | 37 | config MTD_PHYSMAP_START |
27 | hex "Physical start address of flash mapping" | 38 | hex "Physical start address of flash mapping" |
28 | depends on MTD_PHYSMAP | 39 | depends on MTD_PHYSMAP_COMPAT |
29 | default "0x8000000" | 40 | default "0x8000000" |
30 | help | 41 | help |
31 | This is the physical memory location at which the flash chips | 42 | This is the physical memory location at which the flash chips |
@@ -37,7 +48,7 @@ config MTD_PHYSMAP_START | |||
37 | 48 | ||
38 | config MTD_PHYSMAP_LEN | 49 | config MTD_PHYSMAP_LEN |
39 | hex "Physical length of flash mapping" | 50 | hex "Physical length of flash mapping" |
40 | depends on MTD_PHYSMAP | 51 | depends on MTD_PHYSMAP_COMPAT |
41 | default "0" | 52 | default "0" |
42 | help | 53 | help |
43 | This is the total length of the mapping of the flash chips on | 54 | This is the total length of the mapping of the flash chips on |
@@ -51,7 +62,7 @@ config MTD_PHYSMAP_LEN | |||
51 | 62 | ||
52 | config MTD_PHYSMAP_BANKWIDTH | 63 | config MTD_PHYSMAP_BANKWIDTH |
53 | int "Bank width in octets" | 64 | int "Bank width in octets" |
54 | depends on MTD_PHYSMAP | 65 | depends on MTD_PHYSMAP_COMPAT |
55 | default "2" | 66 | default "2" |
56 | help | 67 | help |
57 | This is the total width of the data bus of the flash devices | 68 | This is the total width of the data bus of the flash devices |
diff --git a/drivers/mtd/maps/alchemy-flash.c b/drivers/mtd/maps/alchemy-flash.c index 82811bcb0436..845ad4f2a542 100644 --- a/drivers/mtd/maps/alchemy-flash.c +++ b/drivers/mtd/maps/alchemy-flash.c | |||
@@ -111,7 +111,7 @@ static struct mtd_partition alchemy_partitions[] = { | |||
111 | 111 | ||
112 | static struct mtd_info *mymtd; | 112 | static struct mtd_info *mymtd; |
113 | 113 | ||
114 | int __init alchemy_mtd_init(void) | 114 | static int __init alchemy_mtd_init(void) |
115 | { | 115 | { |
116 | struct mtd_partition *parts; | 116 | struct mtd_partition *parts; |
117 | int nb_parts = 0; | 117 | int nb_parts = 0; |
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c index d1eec7d3243f..237733d094c4 100644 --- a/drivers/mtd/maps/amd76xrom.c +++ b/drivers/mtd/maps/amd76xrom.c | |||
@@ -232,8 +232,8 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev, | |||
232 | /* Trim the size if we are larger than the map */ | 232 | /* Trim the size if we are larger than the map */ |
233 | if (map->mtd->size > map->map.size) { | 233 | if (map->mtd->size > map->map.size) { |
234 | printk(KERN_WARNING MOD_NAME | 234 | printk(KERN_WARNING MOD_NAME |
235 | " rom(%u) larger than window(%lu). fixing...\n", | 235 | " rom(%llu) larger than window(%lu). fixing...\n", |
236 | map->mtd->size, map->map.size); | 236 | (unsigned long long)map->mtd->size, map->map.size); |
237 | map->mtd->size = map->map.size; | 237 | map->mtd->size = map->map.size; |
238 | } | 238 | } |
239 | if (window->rsrc.parent) { | 239 | if (window->rsrc.parent) { |
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c index 0ecc3f6d735b..b4ed81611918 100644 --- a/drivers/mtd/maps/cfi_flagadm.c +++ b/drivers/mtd/maps/cfi_flagadm.c | |||
@@ -88,7 +88,7 @@ struct mtd_partition flagadm_parts[] = { | |||
88 | 88 | ||
89 | static struct mtd_info *mymtd; | 89 | static struct mtd_info *mymtd; |
90 | 90 | ||
91 | int __init init_flagadm(void) | 91 | static int __init init_flagadm(void) |
92 | { | 92 | { |
93 | printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n", | 93 | printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n", |
94 | FLASH_SIZE, FLASH_PHYS_ADDR); | 94 | FLASH_SIZE, FLASH_PHYS_ADDR); |
diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c index 1a6feb4474de..5f7a245ed132 100644 --- a/drivers/mtd/maps/ck804xrom.c +++ b/drivers/mtd/maps/ck804xrom.c | |||
@@ -263,8 +263,8 @@ static int __devinit ck804xrom_init_one (struct pci_dev *pdev, | |||
263 | /* Trim the size if we are larger than the map */ | 263 | /* Trim the size if we are larger than the map */ |
264 | if (map->mtd->size > map->map.size) { | 264 | if (map->mtd->size > map->map.size) { |
265 | printk(KERN_WARNING MOD_NAME | 265 | printk(KERN_WARNING MOD_NAME |
266 | " rom(%u) larger than window(%lu). fixing...\n", | 266 | " rom(%llu) larger than window(%lu). fixing...\n", |
267 | map->mtd->size, map->map.size); | 267 | (unsigned long long)map->mtd->size, map->map.size); |
268 | map->mtd->size = map->map.size; | 268 | map->mtd->size = map->map.size; |
269 | } | 269 | } |
270 | if (window->rsrc.parent) { | 270 | if (window->rsrc.parent) { |
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c index e115667bf1d0..cfacfa6f45dd 100644 --- a/drivers/mtd/maps/dbox2-flash.c +++ b/drivers/mtd/maps/dbox2-flash.c | |||
@@ -69,7 +69,7 @@ struct map_info dbox2_flash_map = { | |||
69 | .phys = WINDOW_ADDR, | 69 | .phys = WINDOW_ADDR, |
70 | }; | 70 | }; |
71 | 71 | ||
72 | int __init init_dbox2_flash(void) | 72 | static int __init init_dbox2_flash(void) |
73 | { | 73 | { |
74 | printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR); | 74 | printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR); |
75 | dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); | 75 | dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); |
diff --git a/drivers/mtd/maps/edb7312.c b/drivers/mtd/maps/edb7312.c index 9433738c1664..be9e90b44587 100644 --- a/drivers/mtd/maps/edb7312.c +++ b/drivers/mtd/maps/edb7312.c | |||
@@ -71,7 +71,7 @@ static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; | |||
71 | static int mtd_parts_nb = 0; | 71 | static int mtd_parts_nb = 0; |
72 | static struct mtd_partition *mtd_parts = 0; | 72 | static struct mtd_partition *mtd_parts = 0; |
73 | 73 | ||
74 | int __init init_edb7312nor(void) | 74 | static int __init init_edb7312nor(void) |
75 | { | 75 | { |
76 | static const char *rom_probe_types[] = PROBETYPES; | 76 | static const char *rom_probe_types[] = PROBETYPES; |
77 | const char **type; | 77 | const char **type; |
diff --git a/drivers/mtd/maps/esb2rom.c b/drivers/mtd/maps/esb2rom.c index bbbcdd4c8d13..11a2f57df9cf 100644 --- a/drivers/mtd/maps/esb2rom.c +++ b/drivers/mtd/maps/esb2rom.c | |||
@@ -324,8 +324,8 @@ static int __devinit esb2rom_init_one(struct pci_dev *pdev, | |||
324 | /* Trim the size if we are larger than the map */ | 324 | /* Trim the size if we are larger than the map */ |
325 | if (map->mtd->size > map->map.size) { | 325 | if (map->mtd->size > map->map.size) { |
326 | printk(KERN_WARNING MOD_NAME | 326 | printk(KERN_WARNING MOD_NAME |
327 | " rom(%u) larger than window(%lu). fixing...\n", | 327 | " rom(%llu) larger than window(%lu). fixing...\n", |
328 | map->mtd->size, map->map.size); | 328 | (unsigned long long)map->mtd->size, map->map.size); |
329 | map->mtd->size = map->map.size; | 329 | map->mtd->size = map->map.size; |
330 | } | 330 | } |
331 | if (window->rsrc.parent) { | 331 | if (window->rsrc.parent) { |
diff --git a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c index a8e3fde4cbd5..1e43124d498b 100644 --- a/drivers/mtd/maps/fortunet.c +++ b/drivers/mtd/maps/fortunet.c | |||
@@ -181,7 +181,7 @@ __setup("MTD_Partition=", MTD_New_Partition); | |||
181 | /* Backwards-spelling-compatibility */ | 181 | /* Backwards-spelling-compatibility */ |
182 | __setup("MTD_Partion=", MTD_New_Partition); | 182 | __setup("MTD_Partion=", MTD_New_Partition); |
183 | 183 | ||
184 | int __init init_fortunet(void) | 184 | static int __init init_fortunet(void) |
185 | { | 185 | { |
186 | int ix,iy; | 186 | int ix,iy; |
187 | for(iy=ix=0;ix<MAX_NUM_REGIONS;ix++) | 187 | for(iy=ix=0;ix<MAX_NUM_REGIONS;ix++) |
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c index 3b959fad1c4e..72c724fa8c27 100644 --- a/drivers/mtd/maps/h720x-flash.c +++ b/drivers/mtd/maps/h720x-flash.c | |||
@@ -65,7 +65,7 @@ static const char *probes[] = { "cmdlinepart", NULL }; | |||
65 | /* | 65 | /* |
66 | * Initialize FLASH support | 66 | * Initialize FLASH support |
67 | */ | 67 | */ |
68 | int __init h720x_mtd_init(void) | 68 | static int __init h720x_mtd_init(void) |
69 | { | 69 | { |
70 | 70 | ||
71 | char *part_type = NULL; | 71 | char *part_type = NULL; |
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c index aeb6c916e23f..c32bc28920b3 100644 --- a/drivers/mtd/maps/ichxrom.c +++ b/drivers/mtd/maps/ichxrom.c | |||
@@ -258,8 +258,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev, | |||
258 | /* Trim the size if we are larger than the map */ | 258 | /* Trim the size if we are larger than the map */ |
259 | if (map->mtd->size > map->map.size) { | 259 | if (map->mtd->size > map->map.size) { |
260 | printk(KERN_WARNING MOD_NAME | 260 | printk(KERN_WARNING MOD_NAME |
261 | " rom(%u) larger than window(%lu). fixing...\n", | 261 | " rom(%llu) larger than window(%lu). fixing...\n", |
262 | map->mtd->size, map->map.size); | 262 | (unsigned long long)map->mtd->size, map->map.size); |
263 | map->mtd->size = map->map.size; | 263 | map->mtd->size = map->map.size; |
264 | } | 264 | } |
265 | if (window->rsrc.parent) { | 265 | if (window->rsrc.parent) { |
diff --git a/drivers/mtd/maps/impa7.c b/drivers/mtd/maps/impa7.c index 2682ab51a367..998a27da97f3 100644 --- a/drivers/mtd/maps/impa7.c +++ b/drivers/mtd/maps/impa7.c | |||
@@ -70,7 +70,7 @@ static struct mtd_partition *mtd_parts[NUM_FLASHBANKS]; | |||
70 | 70 | ||
71 | static const char *probes[] = { "cmdlinepart", NULL }; | 71 | static const char *probes[] = { "cmdlinepart", NULL }; |
72 | 72 | ||
73 | int __init init_impa7(void) | 73 | static int __init init_impa7(void) |
74 | { | 74 | { |
75 | static const char *rom_probe_types[] = PROBETYPES; | 75 | static const char *rom_probe_types[] = PROBETYPES; |
76 | const char **type; | 76 | const char **type; |
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c index 7100ee3c7b01..d2ec262666c7 100644 --- a/drivers/mtd/maps/integrator-flash.c +++ b/drivers/mtd/maps/integrator-flash.c | |||
@@ -105,7 +105,7 @@ static int armflash_probe(struct platform_device *dev) | |||
105 | info->map.bankwidth = plat->width; | 105 | info->map.bankwidth = plat->width; |
106 | info->map.phys = res->start; | 106 | info->map.phys = res->start; |
107 | info->map.virt = base; | 107 | info->map.virt = base; |
108 | info->map.name = dev->dev.bus_id; | 108 | info->map.name = dev_name(&dev->dev); |
109 | info->map.set_vpp = armflash_set_vpp; | 109 | info->map.set_vpp = armflash_set_vpp; |
110 | 110 | ||
111 | simple_map_init(&info->map); | 111 | simple_map_init(&info->map); |
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c index ed58f6a77bd9..748c85f635f1 100644 --- a/drivers/mtd/maps/ipaq-flash.c +++ b/drivers/mtd/maps/ipaq-flash.c | |||
@@ -202,7 +202,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; | |||
202 | 202 | ||
203 | static int __init h1900_special_case(void); | 203 | static int __init h1900_special_case(void); |
204 | 204 | ||
205 | int __init ipaq_mtd_init(void) | 205 | static int __init ipaq_mtd_init(void) |
206 | { | 206 | { |
207 | struct mtd_partition *parts = NULL; | 207 | struct mtd_partition *parts = NULL; |
208 | int nb_parts = 0; | 208 | int nb_parts = 0; |
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c index 3ea1de9be720..d4fb9a3ab4df 100644 --- a/drivers/mtd/maps/ixp2000.c +++ b/drivers/mtd/maps/ixp2000.c | |||
@@ -188,7 +188,7 @@ static int ixp2000_flash_probe(struct platform_device *dev) | |||
188 | */ | 188 | */ |
189 | info->map.map_priv_2 = (unsigned long) ixp_data->bank_setup; | 189 | info->map.map_priv_2 = (unsigned long) ixp_data->bank_setup; |
190 | 190 | ||
191 | info->map.name = dev->dev.bus_id; | 191 | info->map.name = dev_name(&dev->dev); |
192 | info->map.read = ixp2000_flash_read8; | 192 | info->map.read = ixp2000_flash_read8; |
193 | info->map.write = ixp2000_flash_write8; | 193 | info->map.write = ixp2000_flash_write8; |
194 | info->map.copy_from = ixp2000_flash_copy_from; | 194 | info->map.copy_from = ixp2000_flash_copy_from; |
@@ -196,7 +196,7 @@ static int ixp2000_flash_probe(struct platform_device *dev) | |||
196 | 196 | ||
197 | info->res = request_mem_region(dev->resource->start, | 197 | info->res = request_mem_region(dev->resource->start, |
198 | dev->resource->end - dev->resource->start + 1, | 198 | dev->resource->end - dev->resource->start + 1, |
199 | dev->dev.bus_id); | 199 | dev_name(&dev->dev)); |
200 | if (!info->res) { | 200 | if (!info->res) { |
201 | dev_err(&dev->dev, "Could not reserve memory region\n"); | 201 | dev_err(&dev->dev, "Could not reserve memory region\n"); |
202 | err = -ENOMEM; | 202 | err = -ENOMEM; |
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index 16555cbeaea4..7214b876feba 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c | |||
@@ -218,7 +218,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev) | |||
218 | * handle that. | 218 | * handle that. |
219 | */ | 219 | */ |
220 | info->map.bankwidth = 2; | 220 | info->map.bankwidth = 2; |
221 | info->map.name = dev->dev.bus_id; | 221 | info->map.name = dev_name(&dev->dev); |
222 | info->map.read = ixp4xx_read16, | 222 | info->map.read = ixp4xx_read16, |
223 | info->map.write = ixp4xx_probe_write16, | 223 | info->map.write = ixp4xx_probe_write16, |
224 | info->map.copy_from = ixp4xx_copy_from, | 224 | info->map.copy_from = ixp4xx_copy_from, |
diff --git a/drivers/mtd/maps/mbx860.c b/drivers/mtd/maps/mbx860.c index 706f67394b07..0eb5a7c85380 100644 --- a/drivers/mtd/maps/mbx860.c +++ b/drivers/mtd/maps/mbx860.c | |||
@@ -55,7 +55,7 @@ struct map_info mbx_map = { | |||
55 | .bankwidth = 4, | 55 | .bankwidth = 4, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | int __init init_mbx(void) | 58 | static int __init init_mbx(void) |
59 | { | 59 | { |
60 | printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR); | 60 | printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR); |
61 | mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); | 61 | mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); |
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index 965e6c6d6ab0..df682667604a 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c | |||
@@ -226,7 +226,7 @@ static int __init nettel_init(void) | |||
226 | 226 | ||
227 | if ((amd_mtd = do_map_probe("jedec_probe", &nettel_amd_map))) { | 227 | if ((amd_mtd = do_map_probe("jedec_probe", &nettel_amd_map))) { |
228 | printk(KERN_NOTICE "SNAPGEAR: AMD flash device size = %dK\n", | 228 | printk(KERN_NOTICE "SNAPGEAR: AMD flash device size = %dK\n", |
229 | amd_mtd->size>>10); | 229 | (int)(amd_mtd->size>>10)); |
230 | 230 | ||
231 | amd_mtd->owner = THIS_MODULE; | 231 | amd_mtd->owner = THIS_MODULE; |
232 | 232 | ||
@@ -362,8 +362,7 @@ static int __init nettel_init(void) | |||
362 | 362 | ||
363 | intel_mtd->owner = THIS_MODULE; | 363 | intel_mtd->owner = THIS_MODULE; |
364 | 364 | ||
365 | num_intel_partitions = sizeof(nettel_intel_partitions) / | 365 | num_intel_partitions = ARRAY_SIZE(nettel_intel_partitions); |
366 | sizeof(nettel_intel_partitions[0]); | ||
367 | 366 | ||
368 | if (intelboot) { | 367 | if (intelboot) { |
369 | /* | 368 | /* |
diff --git a/drivers/mtd/maps/octagon-5066.c b/drivers/mtd/maps/octagon-5066.c index 43e04c1d22a9..2b2e45093218 100644 --- a/drivers/mtd/maps/octagon-5066.c +++ b/drivers/mtd/maps/octagon-5066.c | |||
@@ -184,7 +184,7 @@ void cleanup_oct5066(void) | |||
184 | release_region(PAGE_IO, 1); | 184 | release_region(PAGE_IO, 1); |
185 | } | 185 | } |
186 | 186 | ||
187 | int __init init_oct5066(void) | 187 | static int __init init_oct5066(void) |
188 | { | 188 | { |
189 | int i; | 189 | int i; |
190 | int ret = 0; | 190 | int ret = 0; |
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c index 05f276af15da..7e50e9b1b781 100644 --- a/drivers/mtd/maps/omap_nor.c +++ b/drivers/mtd/maps/omap_nor.c | |||
@@ -101,7 +101,7 @@ static int __init omapflash_probe(struct platform_device *pdev) | |||
101 | err = -ENOMEM; | 101 | err = -ENOMEM; |
102 | goto out_release_mem_region; | 102 | goto out_release_mem_region; |
103 | } | 103 | } |
104 | info->map.name = pdev->dev.bus_id; | 104 | info->map.name = dev_name(&pdev->dev); |
105 | info->map.phys = res->start; | 105 | info->map.phys = res->start; |
106 | info->map.size = size; | 106 | info->map.size = size; |
107 | info->map.bankwidth = pdata->width; | 107 | info->map.bankwidth = pdata->width; |
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index dfbf3f270cea..d3a2acc7e9be 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
@@ -29,7 +29,6 @@ struct physmap_flash_info { | |||
29 | struct map_info map[MAX_RESOURCES]; | 29 | struct map_info map[MAX_RESOURCES]; |
30 | #ifdef CONFIG_MTD_PARTITIONS | 30 | #ifdef CONFIG_MTD_PARTITIONS |
31 | int nr_parts; | 31 | int nr_parts; |
32 | struct mtd_partition *parts; | ||
33 | #endif | 32 | #endif |
34 | }; | 33 | }; |
35 | 34 | ||
@@ -56,14 +55,10 @@ static int physmap_flash_remove(struct platform_device *dev) | |||
56 | for (i = 0; i < MAX_RESOURCES; i++) { | 55 | for (i = 0; i < MAX_RESOURCES; i++) { |
57 | if (info->mtd[i] != NULL) { | 56 | if (info->mtd[i] != NULL) { |
58 | #ifdef CONFIG_MTD_PARTITIONS | 57 | #ifdef CONFIG_MTD_PARTITIONS |
59 | if (info->nr_parts) { | 58 | if (info->nr_parts || physmap_data->nr_parts) |
60 | del_mtd_partitions(info->mtd[i]); | 59 | del_mtd_partitions(info->mtd[i]); |
61 | kfree(info->parts); | 60 | else |
62 | } else if (physmap_data->nr_parts) { | ||
63 | del_mtd_partitions(info->mtd[i]); | ||
64 | } else { | ||
65 | del_mtd_device(info->mtd[i]); | 61 | del_mtd_device(info->mtd[i]); |
66 | } | ||
67 | #else | 62 | #else |
68 | del_mtd_device(info->mtd[i]); | 63 | del_mtd_device(info->mtd[i]); |
69 | #endif | 64 | #endif |
@@ -86,6 +81,9 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
86 | int err = 0; | 81 | int err = 0; |
87 | int i; | 82 | int i; |
88 | int devices_found = 0; | 83 | int devices_found = 0; |
84 | #ifdef CONFIG_MTD_PARTITIONS | ||
85 | struct mtd_partition *parts; | ||
86 | #endif | ||
89 | 87 | ||
90 | physmap_data = dev->dev.platform_data; | 88 | physmap_data = dev->dev.platform_data; |
91 | if (physmap_data == NULL) | 89 | if (physmap_data == NULL) |
@@ -108,13 +106,13 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
108 | if (!devm_request_mem_region(&dev->dev, | 106 | if (!devm_request_mem_region(&dev->dev, |
109 | dev->resource[i].start, | 107 | dev->resource[i].start, |
110 | dev->resource[i].end - dev->resource[i].start + 1, | 108 | dev->resource[i].end - dev->resource[i].start + 1, |
111 | dev->dev.bus_id)) { | 109 | dev_name(&dev->dev))) { |
112 | dev_err(&dev->dev, "Could not reserve memory region\n"); | 110 | dev_err(&dev->dev, "Could not reserve memory region\n"); |
113 | err = -ENOMEM; | 111 | err = -ENOMEM; |
114 | goto err_out; | 112 | goto err_out; |
115 | } | 113 | } |
116 | 114 | ||
117 | info->map[i].name = dev->dev.bus_id; | 115 | info->map[i].name = dev_name(&dev->dev); |
118 | info->map[i].phys = dev->resource[i].start; | 116 | info->map[i].phys = dev->resource[i].start; |
119 | info->map[i].size = dev->resource[i].end - dev->resource[i].start + 1; | 117 | info->map[i].size = dev->resource[i].end - dev->resource[i].start + 1; |
120 | info->map[i].bankwidth = physmap_data->width; | 118 | info->map[i].bankwidth = physmap_data->width; |
@@ -150,7 +148,7 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
150 | * We detected multiple devices. Concatenate them together. | 148 | * We detected multiple devices. Concatenate them together. |
151 | */ | 149 | */ |
152 | #ifdef CONFIG_MTD_CONCAT | 150 | #ifdef CONFIG_MTD_CONCAT |
153 | info->cmtd = mtd_concat_create(info->mtd, devices_found, dev->dev.bus_id); | 151 | info->cmtd = mtd_concat_create(info->mtd, devices_found, dev_name(&dev->dev)); |
154 | if (info->cmtd == NULL) | 152 | if (info->cmtd == NULL) |
155 | err = -ENXIO; | 153 | err = -ENXIO; |
156 | #else | 154 | #else |
@@ -163,9 +161,10 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
163 | goto err_out; | 161 | goto err_out; |
164 | 162 | ||
165 | #ifdef CONFIG_MTD_PARTITIONS | 163 | #ifdef CONFIG_MTD_PARTITIONS |
166 | err = parse_mtd_partitions(info->cmtd, part_probe_types, &info->parts, 0); | 164 | err = parse_mtd_partitions(info->cmtd, part_probe_types, &parts, 0); |
167 | if (err > 0) { | 165 | if (err > 0) { |
168 | add_mtd_partitions(info->cmtd, info->parts, err); | 166 | add_mtd_partitions(info->cmtd, parts, err); |
167 | kfree(parts); | ||
169 | return 0; | 168 | return 0; |
170 | } | 169 | } |
171 | 170 | ||
@@ -251,14 +250,7 @@ static struct platform_driver physmap_flash_driver = { | |||
251 | }; | 250 | }; |
252 | 251 | ||
253 | 252 | ||
254 | #ifdef CONFIG_MTD_PHYSMAP_LEN | 253 | #ifdef CONFIG_MTD_PHYSMAP_COMPAT |
255 | #if CONFIG_MTD_PHYSMAP_LEN != 0 | ||
256 | #warning using PHYSMAP compat code | ||
257 | #define PHYSMAP_COMPAT | ||
258 | #endif | ||
259 | #endif | ||
260 | |||
261 | #ifdef PHYSMAP_COMPAT | ||
262 | static struct physmap_flash_data physmap_flash_data = { | 254 | static struct physmap_flash_data physmap_flash_data = { |
263 | .width = CONFIG_MTD_PHYSMAP_BANKWIDTH, | 255 | .width = CONFIG_MTD_PHYSMAP_BANKWIDTH, |
264 | }; | 256 | }; |
@@ -302,7 +294,7 @@ static int __init physmap_init(void) | |||
302 | int err; | 294 | int err; |
303 | 295 | ||
304 | err = platform_driver_register(&physmap_flash_driver); | 296 | err = platform_driver_register(&physmap_flash_driver); |
305 | #ifdef PHYSMAP_COMPAT | 297 | #ifdef CONFIG_MTD_PHYSMAP_COMPAT |
306 | if (err == 0) | 298 | if (err == 0) |
307 | platform_device_register(&physmap_flash); | 299 | platform_device_register(&physmap_flash); |
308 | #endif | 300 | #endif |
@@ -312,7 +304,7 @@ static int __init physmap_init(void) | |||
312 | 304 | ||
313 | static void __exit physmap_exit(void) | 305 | static void __exit physmap_exit(void) |
314 | { | 306 | { |
315 | #ifdef PHYSMAP_COMPAT | 307 | #ifdef CONFIG_MTD_PHYSMAP_COMPAT |
316 | platform_device_unregister(&physmap_flash); | 308 | platform_device_unregister(&physmap_flash); |
317 | #endif | 309 | #endif |
318 | platform_driver_unregister(&physmap_flash_driver); | 310 | platform_driver_unregister(&physmap_flash_driver); |
@@ -326,8 +318,7 @@ MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); | |||
326 | MODULE_DESCRIPTION("Generic configurable MTD map driver"); | 318 | MODULE_DESCRIPTION("Generic configurable MTD map driver"); |
327 | 319 | ||
328 | /* legacy platform drivers can't hotplug or coldplg */ | 320 | /* legacy platform drivers can't hotplug or coldplg */ |
329 | #ifndef PHYSMAP_COMPAT | 321 | #ifndef CONFIG_MTD_PHYSMAP_COMPAT |
330 | /* work with hotplug and coldplug */ | 322 | /* work with hotplug and coldplug */ |
331 | MODULE_ALIAS("platform:physmap-flash"); | 323 | MODULE_ALIAS("platform:physmap-flash"); |
332 | #endif | 324 | #endif |
333 | |||
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 5fcfec034a94..fbf0ca939d72 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c | |||
@@ -183,7 +183,7 @@ static int __devinit of_flash_probe(struct of_device *dev, | |||
183 | 183 | ||
184 | err = -EBUSY; | 184 | err = -EBUSY; |
185 | info->res = request_mem_region(res.start, res.end - res.start + 1, | 185 | info->res = request_mem_region(res.start, res.end - res.start + 1, |
186 | dev->dev.bus_id); | 186 | dev_name(&dev->dev)); |
187 | if (!info->res) | 187 | if (!info->res) |
188 | goto err_out; | 188 | goto err_out; |
189 | 189 | ||
@@ -194,7 +194,7 @@ static int __devinit of_flash_probe(struct of_device *dev, | |||
194 | goto err_out; | 194 | goto err_out; |
195 | } | 195 | } |
196 | 196 | ||
197 | info->map.name = dev->dev.bus_id; | 197 | info->map.name = dev_name(&dev->dev); |
198 | info->map.phys = res.start; | 198 | info->map.phys = res.start; |
199 | info->map.size = res.end - res.start + 1; | 199 | info->map.size = res.end - res.start + 1; |
200 | info->map.bankwidth = *width; | 200 | info->map.bankwidth = *width; |
diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c index f43ba2815cbb..4768bd5459d6 100644 --- a/drivers/mtd/maps/pmcmsp-flash.c +++ b/drivers/mtd/maps/pmcmsp-flash.c | |||
@@ -48,7 +48,7 @@ static int fcnt; | |||
48 | 48 | ||
49 | #define DEBUG_MARKER printk(KERN_NOTICE "%s[%d]\n", __func__, __LINE__) | 49 | #define DEBUG_MARKER printk(KERN_NOTICE "%s[%d]\n", __func__, __LINE__) |
50 | 50 | ||
51 | int __init init_msp_flash(void) | 51 | static int __init init_msp_flash(void) |
52 | { | 52 | { |
53 | int i, j; | 53 | int i, j; |
54 | int offset, coff; | 54 | int offset, coff; |
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c index de002eb1a7fe..933c0b63b016 100644 --- a/drivers/mtd/maps/redwood.c +++ b/drivers/mtd/maps/redwood.c | |||
@@ -122,7 +122,7 @@ struct map_info redwood_flash_map = { | |||
122 | 122 | ||
123 | static struct mtd_info *redwood_mtd; | 123 | static struct mtd_info *redwood_mtd; |
124 | 124 | ||
125 | int __init init_redwood_flash(void) | 125 | static int __init init_redwood_flash(void) |
126 | { | 126 | { |
127 | int err; | 127 | int err; |
128 | 128 | ||
diff --git a/drivers/mtd/maps/rpxlite.c b/drivers/mtd/maps/rpxlite.c index 14d90edb4430..3e3ef53d4fd4 100644 --- a/drivers/mtd/maps/rpxlite.c +++ b/drivers/mtd/maps/rpxlite.c | |||
@@ -23,7 +23,7 @@ static struct map_info rpxlite_map = { | |||
23 | .phys = WINDOW_ADDR, | 23 | .phys = WINDOW_ADDR, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | int __init init_rpxlite(void) | 26 | static int __init init_rpxlite(void) |
27 | { | 27 | { |
28 | printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR); | 28 | printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR); |
29 | rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); | 29 | rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); |
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c index 6e1e99cd2b59..d5374cdcb163 100644 --- a/drivers/mtd/maps/sbc8240.c +++ b/drivers/mtd/maps/sbc8240.c | |||
@@ -136,7 +136,7 @@ static struct mtd_part_def sbc8240_part_banks[NUM_FLASH_BANKS]; | |||
136 | #endif /* CONFIG_MTD_PARTITIONS */ | 136 | #endif /* CONFIG_MTD_PARTITIONS */ |
137 | 137 | ||
138 | 138 | ||
139 | int __init init_sbc8240_mtd (void) | 139 | static int __init init_sbc8240_mtd (void) |
140 | { | 140 | { |
141 | static struct _cjs { | 141 | static struct _cjs { |
142 | u_long addr; | 142 | u_long addr; |
diff --git a/drivers/mtd/maps/scb2_flash.c b/drivers/mtd/maps/scb2_flash.c index 21169e6d646c..7e329f09a548 100644 --- a/drivers/mtd/maps/scb2_flash.c +++ b/drivers/mtd/maps/scb2_flash.c | |||
@@ -118,7 +118,8 @@ scb2_fixup_mtd(struct mtd_info *mtd) | |||
118 | struct mtd_erase_region_info *region = &mtd->eraseregions[i]; | 118 | struct mtd_erase_region_info *region = &mtd->eraseregions[i]; |
119 | 119 | ||
120 | if (region->numblocks * region->erasesize > mtd->size) { | 120 | if (region->numblocks * region->erasesize > mtd->size) { |
121 | region->numblocks = (mtd->size / region->erasesize); | 121 | region->numblocks = ((unsigned long)mtd->size / |
122 | region->erasesize); | ||
122 | done = 1; | 123 | done = 1; |
123 | } else { | 124 | } else { |
124 | region->numblocks = 0; | 125 | region->numblocks = 0; |
@@ -187,8 +188,9 @@ scb2_flash_probe(struct pci_dev *dev, const struct pci_device_id *ent) | |||
187 | return -ENODEV; | 188 | return -ENODEV; |
188 | } | 189 | } |
189 | 190 | ||
190 | printk(KERN_NOTICE MODNAME ": chip size 0x%x at offset 0x%x\n", | 191 | printk(KERN_NOTICE MODNAME ": chip size 0x%llx at offset 0x%llx\n", |
191 | scb2_mtd->size, SCB2_WINDOW - scb2_mtd->size); | 192 | (unsigned long long)scb2_mtd->size, |
193 | (unsigned long long)(SCB2_WINDOW - scb2_mtd->size)); | ||
192 | 194 | ||
193 | add_mtd_device(scb2_mtd); | 195 | add_mtd_device(scb2_mtd); |
194 | 196 | ||
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c index 026eab028189..b392f096c706 100644 --- a/drivers/mtd/maps/sharpsl-flash.c +++ b/drivers/mtd/maps/sharpsl-flash.c | |||
@@ -47,7 +47,7 @@ static struct mtd_partition sharpsl_partitions[1] = { | |||
47 | } | 47 | } |
48 | }; | 48 | }; |
49 | 49 | ||
50 | int __init init_sharpsl(void) | 50 | static int __init init_sharpsl(void) |
51 | { | 51 | { |
52 | struct mtd_partition *parts; | 52 | struct mtd_partition *parts; |
53 | int nb_parts = 0; | 53 | int nb_parts = 0; |
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c index a5d3d8531faa..60146984f4be 100644 --- a/drivers/mtd/maps/tqm8xxl.c +++ b/drivers/mtd/maps/tqm8xxl.c | |||
@@ -109,7 +109,7 @@ static struct mtd_partition tqm8xxl_fs_partitions[] = { | |||
109 | }; | 109 | }; |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | int __init init_tqm_mtd(void) | 112 | static int __init init_tqm_mtd(void) |
113 | { | 113 | { |
114 | int idx = 0, ret = 0; | 114 | int idx = 0, ret = 0; |
115 | unsigned long flash_addr, flash_size, mtd_size = 0; | 115 | unsigned long flash_addr, flash_size, mtd_size = 0; |
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c index 0dc645f8152f..81756e397711 100644 --- a/drivers/mtd/maps/uclinux.c +++ b/drivers/mtd/maps/uclinux.c | |||
@@ -51,7 +51,7 @@ int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
51 | 51 | ||
52 | /****************************************************************************/ | 52 | /****************************************************************************/ |
53 | 53 | ||
54 | int __init uclinux_mtd_init(void) | 54 | static int __init uclinux_mtd_init(void) |
55 | { | 55 | { |
56 | struct mtd_info *mtd; | 56 | struct mtd_info *mtd; |
57 | struct map_info *mapp; | 57 | struct map_info *mapp; |
@@ -94,7 +94,7 @@ int __init uclinux_mtd_init(void) | |||
94 | 94 | ||
95 | /****************************************************************************/ | 95 | /****************************************************************************/ |
96 | 96 | ||
97 | void __exit uclinux_mtd_cleanup(void) | 97 | static void __exit uclinux_mtd_cleanup(void) |
98 | { | 98 | { |
99 | if (uclinux_ram_mtdinfo) { | 99 | if (uclinux_ram_mtdinfo) { |
100 | del_mtd_partitions(uclinux_ram_mtdinfo); | 100 | del_mtd_partitions(uclinux_ram_mtdinfo); |
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c index 5a0c9a353b0f..6d452dcdfe34 100644 --- a/drivers/mtd/maps/vmax301.c +++ b/drivers/mtd/maps/vmax301.c | |||
@@ -146,7 +146,7 @@ static void __exit cleanup_vmax301(void) | |||
146 | iounmap((void *)vmax_map[0].map_priv_1 - WINDOW_START); | 146 | iounmap((void *)vmax_map[0].map_priv_1 - WINDOW_START); |
147 | } | 147 | } |
148 | 148 | ||
149 | int __init init_vmax301(void) | 149 | static int __init init_vmax301(void) |
150 | { | 150 | { |
151 | int i; | 151 | int i; |
152 | unsigned long iomapadr; | 152 | unsigned long iomapadr; |
diff --git a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c index 413b0cf9bbd2..933a2b6598b4 100644 --- a/drivers/mtd/maps/wr_sbc82xx_flash.c +++ b/drivers/mtd/maps/wr_sbc82xx_flash.c | |||
@@ -74,7 +74,7 @@ do { \ | |||
74 | } \ | 74 | } \ |
75 | } while (0); | 75 | } while (0); |
76 | 76 | ||
77 | int __init init_sbc82xx_flash(void) | 77 | static int __init init_sbc82xx_flash(void) |
78 | { | 78 | { |
79 | volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl; | 79 | volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl; |
80 | int bigflash; | 80 | int bigflash; |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index bcffeda2df3d..e9ec59e9a566 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -450,16 +450,20 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
450 | if (!erase) | 450 | if (!erase) |
451 | ret = -ENOMEM; | 451 | ret = -ENOMEM; |
452 | else { | 452 | else { |
453 | struct erase_info_user einfo; | ||
454 | |||
453 | wait_queue_head_t waitq; | 455 | wait_queue_head_t waitq; |
454 | DECLARE_WAITQUEUE(wait, current); | 456 | DECLARE_WAITQUEUE(wait, current); |
455 | 457 | ||
456 | init_waitqueue_head(&waitq); | 458 | init_waitqueue_head(&waitq); |
457 | 459 | ||
458 | if (copy_from_user(&erase->addr, argp, | 460 | if (copy_from_user(&einfo, argp, |
459 | sizeof(struct erase_info_user))) { | 461 | sizeof(struct erase_info_user))) { |
460 | kfree(erase); | 462 | kfree(erase); |
461 | return -EFAULT; | 463 | return -EFAULT; |
462 | } | 464 | } |
465 | erase->addr = einfo.start; | ||
466 | erase->len = einfo.length; | ||
463 | erase->mtd = mtd; | 467 | erase->mtd = mtd; |
464 | erase->callback = mtdchar_erase_callback; | 468 | erase->callback = mtdchar_erase_callback; |
465 | erase->priv = (unsigned long)&waitq; | 469 | erase->priv = (unsigned long)&waitq; |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 789842d0e6f2..3dbb1b38db66 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -197,7 +197,7 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
197 | continue; | 197 | continue; |
198 | } | 198 | } |
199 | 199 | ||
200 | size = min(total_len, (size_t)(subdev->size - to)); | 200 | size = min_t(uint64_t, total_len, subdev->size - to); |
201 | wsize = size; /* store for future use */ | 201 | wsize = size; /* store for future use */ |
202 | 202 | ||
203 | entry_high = entry_low; | 203 | entry_high = entry_low; |
@@ -385,7 +385,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
385 | struct mtd_concat *concat = CONCAT(mtd); | 385 | struct mtd_concat *concat = CONCAT(mtd); |
386 | struct mtd_info *subdev; | 386 | struct mtd_info *subdev; |
387 | int i, err; | 387 | int i, err; |
388 | u_int32_t length, offset = 0; | 388 | uint64_t length, offset = 0; |
389 | struct erase_info *erase; | 389 | struct erase_info *erase; |
390 | 390 | ||
391 | if (!(mtd->flags & MTD_WRITEABLE)) | 391 | if (!(mtd->flags & MTD_WRITEABLE)) |
@@ -518,7 +518,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
518 | return 0; | 518 | return 0; |
519 | } | 519 | } |
520 | 520 | ||
521 | static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 521 | static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
522 | { | 522 | { |
523 | struct mtd_concat *concat = CONCAT(mtd); | 523 | struct mtd_concat *concat = CONCAT(mtd); |
524 | int i, err = -EINVAL; | 524 | int i, err = -EINVAL; |
@@ -528,7 +528,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
528 | 528 | ||
529 | for (i = 0; i < concat->num_subdev; i++) { | 529 | for (i = 0; i < concat->num_subdev; i++) { |
530 | struct mtd_info *subdev = concat->subdev[i]; | 530 | struct mtd_info *subdev = concat->subdev[i]; |
531 | size_t size; | 531 | uint64_t size; |
532 | 532 | ||
533 | if (ofs >= subdev->size) { | 533 | if (ofs >= subdev->size) { |
534 | size = 0; | 534 | size = 0; |
@@ -556,7 +556,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
556 | return err; | 556 | return err; |
557 | } | 557 | } |
558 | 558 | ||
559 | static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 559 | static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
560 | { | 560 | { |
561 | struct mtd_concat *concat = CONCAT(mtd); | 561 | struct mtd_concat *concat = CONCAT(mtd); |
562 | int i, err = 0; | 562 | int i, err = 0; |
@@ -566,7 +566,7 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
566 | 566 | ||
567 | for (i = 0; i < concat->num_subdev; i++) { | 567 | for (i = 0; i < concat->num_subdev; i++) { |
568 | struct mtd_info *subdev = concat->subdev[i]; | 568 | struct mtd_info *subdev = concat->subdev[i]; |
569 | size_t size; | 569 | uint64_t size; |
570 | 570 | ||
571 | if (ofs >= subdev->size) { | 571 | if (ofs >= subdev->size) { |
572 | size = 0; | 572 | size = 0; |
@@ -691,12 +691,12 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
691 | */ | 691 | */ |
692 | struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to concatenate */ | 692 | struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to concatenate */ |
693 | int num_devs, /* number of subdevices */ | 693 | int num_devs, /* number of subdevices */ |
694 | char *name) | 694 | const char *name) |
695 | { /* name for the new device */ | 695 | { /* name for the new device */ |
696 | int i; | 696 | int i; |
697 | size_t size; | 697 | size_t size; |
698 | struct mtd_concat *concat; | 698 | struct mtd_concat *concat; |
699 | u_int32_t max_erasesize, curr_erasesize; | 699 | uint32_t max_erasesize, curr_erasesize; |
700 | int num_erase_region; | 700 | int num_erase_region; |
701 | 701 | ||
702 | printk(KERN_NOTICE "Concatenating MTD devices:\n"); | 702 | printk(KERN_NOTICE "Concatenating MTD devices:\n"); |
@@ -842,12 +842,14 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
842 | concat->mtd.erasesize = curr_erasesize; | 842 | concat->mtd.erasesize = curr_erasesize; |
843 | concat->mtd.numeraseregions = 0; | 843 | concat->mtd.numeraseregions = 0; |
844 | } else { | 844 | } else { |
845 | uint64_t tmp64; | ||
846 | |||
845 | /* | 847 | /* |
846 | * erase block size varies across the subdevices: allocate | 848 | * erase block size varies across the subdevices: allocate |
847 | * space to store the data describing the variable erase regions | 849 | * space to store the data describing the variable erase regions |
848 | */ | 850 | */ |
849 | struct mtd_erase_region_info *erase_region_p; | 851 | struct mtd_erase_region_info *erase_region_p; |
850 | u_int32_t begin, position; | 852 | uint64_t begin, position; |
851 | 853 | ||
852 | concat->mtd.erasesize = max_erasesize; | 854 | concat->mtd.erasesize = max_erasesize; |
853 | concat->mtd.numeraseregions = num_erase_region; | 855 | concat->mtd.numeraseregions = num_erase_region; |
@@ -879,8 +881,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
879 | erase_region_p->offset = begin; | 881 | erase_region_p->offset = begin; |
880 | erase_region_p->erasesize = | 882 | erase_region_p->erasesize = |
881 | curr_erasesize; | 883 | curr_erasesize; |
882 | erase_region_p->numblocks = | 884 | tmp64 = position - begin; |
883 | (position - begin) / curr_erasesize; | 885 | do_div(tmp64, curr_erasesize); |
886 | erase_region_p->numblocks = tmp64; | ||
884 | begin = position; | 887 | begin = position; |
885 | 888 | ||
886 | curr_erasesize = subdev[i]->erasesize; | 889 | curr_erasesize = subdev[i]->erasesize; |
@@ -897,9 +900,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
897 | erase_region_p->offset = begin; | 900 | erase_region_p->offset = begin; |
898 | erase_region_p->erasesize = | 901 | erase_region_p->erasesize = |
899 | curr_erasesize; | 902 | curr_erasesize; |
900 | erase_region_p->numblocks = | 903 | tmp64 = position - begin; |
901 | (position - | 904 | do_div(tmp64, curr_erasesize); |
902 | begin) / curr_erasesize; | 905 | erase_region_p->numblocks = tmp64; |
903 | begin = position; | 906 | begin = position; |
904 | 907 | ||
905 | curr_erasesize = | 908 | curr_erasesize = |
@@ -909,14 +912,16 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
909 | } | 912 | } |
910 | position += | 913 | position += |
911 | subdev[i]->eraseregions[j]. | 914 | subdev[i]->eraseregions[j]. |
912 | numblocks * curr_erasesize; | 915 | numblocks * (uint64_t)curr_erasesize; |
913 | } | 916 | } |
914 | } | 917 | } |
915 | } | 918 | } |
916 | /* Now write the final entry */ | 919 | /* Now write the final entry */ |
917 | erase_region_p->offset = begin; | 920 | erase_region_p->offset = begin; |
918 | erase_region_p->erasesize = curr_erasesize; | 921 | erase_region_p->erasesize = curr_erasesize; |
919 | erase_region_p->numblocks = (position - begin) / curr_erasesize; | 922 | tmp64 = position - begin; |
923 | do_div(tmp64, curr_erasesize); | ||
924 | erase_region_p->numblocks = tmp64; | ||
920 | } | 925 | } |
921 | 926 | ||
922 | return &concat->mtd; | 927 | return &concat->mtd; |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index a9d246949820..76fe0a1e7a5e 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -57,6 +57,19 @@ int add_mtd_device(struct mtd_info *mtd) | |||
57 | mtd->index = i; | 57 | mtd->index = i; |
58 | mtd->usecount = 0; | 58 | mtd->usecount = 0; |
59 | 59 | ||
60 | if (is_power_of_2(mtd->erasesize)) | ||
61 | mtd->erasesize_shift = ffs(mtd->erasesize) - 1; | ||
62 | else | ||
63 | mtd->erasesize_shift = 0; | ||
64 | |||
65 | if (is_power_of_2(mtd->writesize)) | ||
66 | mtd->writesize_shift = ffs(mtd->writesize) - 1; | ||
67 | else | ||
68 | mtd->writesize_shift = 0; | ||
69 | |||
70 | mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1; | ||
71 | mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; | ||
72 | |||
60 | /* Some chips always power up locked. Unlock them now */ | 73 | /* Some chips always power up locked. Unlock them now */ |
61 | if ((mtd->flags & MTD_WRITEABLE) | 74 | if ((mtd->flags & MTD_WRITEABLE) |
62 | && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) { | 75 | && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) { |
@@ -344,7 +357,8 @@ static inline int mtd_proc_info (char *buf, int i) | |||
344 | if (!this) | 357 | if (!this) |
345 | return 0; | 358 | return 0; |
346 | 359 | ||
347 | return sprintf(buf, "mtd%d: %8.8x %8.8x \"%s\"\n", i, this->size, | 360 | return sprintf(buf, "mtd%d: %8.8llx %8.8x \"%s\"\n", i, |
361 | (unsigned long long)this->size, | ||
348 | this->erasesize, this->name); | 362 | this->erasesize, this->name); |
349 | } | 363 | } |
350 | 364 | ||
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index aebb3b27edbd..1a6b3beabe8d 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
@@ -80,9 +80,9 @@ static int mtdoops_erase_block(struct mtd_info *mtd, int offset) | |||
80 | if (ret) { | 80 | if (ret) { |
81 | set_current_state(TASK_RUNNING); | 81 | set_current_state(TASK_RUNNING); |
82 | remove_wait_queue(&wait_q, &wait); | 82 | remove_wait_queue(&wait_q, &wait); |
83 | printk (KERN_WARNING "mtdoops: erase of region [0x%x, 0x%x] " | 83 | printk (KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] " |
84 | "on \"%s\" failed\n", | 84 | "on \"%s\" failed\n", |
85 | erase.addr, erase.len, mtd->name); | 85 | (unsigned long long)erase.addr, (unsigned long long)erase.len, mtd->name); |
86 | return ret; | 86 | return ret; |
87 | } | 87 | } |
88 | 88 | ||
@@ -289,7 +289,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd) | |||
289 | } | 289 | } |
290 | 290 | ||
291 | cxt->mtd = mtd; | 291 | cxt->mtd = mtd; |
292 | cxt->oops_pages = mtd->size / OOPS_PAGE_SIZE; | 292 | if (mtd->size > INT_MAX) |
293 | cxt->oops_pages = INT_MAX / OOPS_PAGE_SIZE; | ||
294 | else | ||
295 | cxt->oops_pages = (int)mtd->size / OOPS_PAGE_SIZE; | ||
293 | 296 | ||
294 | find_next_position(cxt); | 297 | find_next_position(cxt); |
295 | 298 | ||
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 3728913fa5fa..144e6b613a77 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -26,7 +26,7 @@ static LIST_HEAD(mtd_partitions); | |||
26 | struct mtd_part { | 26 | struct mtd_part { |
27 | struct mtd_info mtd; | 27 | struct mtd_info mtd; |
28 | struct mtd_info *master; | 28 | struct mtd_info *master; |
29 | u_int32_t offset; | 29 | uint64_t offset; |
30 | int index; | 30 | int index; |
31 | struct list_head list; | 31 | struct list_head list; |
32 | int registered; | 32 | int registered; |
@@ -235,7 +235,7 @@ void mtd_erase_callback(struct erase_info *instr) | |||
235 | } | 235 | } |
236 | EXPORT_SYMBOL_GPL(mtd_erase_callback); | 236 | EXPORT_SYMBOL_GPL(mtd_erase_callback); |
237 | 237 | ||
238 | static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 238 | static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
239 | { | 239 | { |
240 | struct mtd_part *part = PART(mtd); | 240 | struct mtd_part *part = PART(mtd); |
241 | if ((len + ofs) > mtd->size) | 241 | if ((len + ofs) > mtd->size) |
@@ -243,7 +243,7 @@ static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
243 | return part->master->lock(part->master, ofs + part->offset, len); | 243 | return part->master->lock(part->master, ofs + part->offset, len); |
244 | } | 244 | } |
245 | 245 | ||
246 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 246 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
247 | { | 247 | { |
248 | struct mtd_part *part = PART(mtd); | 248 | struct mtd_part *part = PART(mtd); |
249 | if ((len + ofs) > mtd->size) | 249 | if ((len + ofs) > mtd->size) |
@@ -317,7 +317,7 @@ EXPORT_SYMBOL(del_mtd_partitions); | |||
317 | 317 | ||
318 | static struct mtd_part *add_one_partition(struct mtd_info *master, | 318 | static struct mtd_part *add_one_partition(struct mtd_info *master, |
319 | const struct mtd_partition *part, int partno, | 319 | const struct mtd_partition *part, int partno, |
320 | u_int32_t cur_offset) | 320 | uint64_t cur_offset) |
321 | { | 321 | { |
322 | struct mtd_part *slave; | 322 | struct mtd_part *slave; |
323 | 323 | ||
@@ -395,19 +395,19 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
395 | slave->offset = cur_offset; | 395 | slave->offset = cur_offset; |
396 | if (slave->offset == MTDPART_OFS_NXTBLK) { | 396 | if (slave->offset == MTDPART_OFS_NXTBLK) { |
397 | slave->offset = cur_offset; | 397 | slave->offset = cur_offset; |
398 | if ((cur_offset % master->erasesize) != 0) { | 398 | if (mtd_mod_by_eb(cur_offset, master) != 0) { |
399 | /* Round up to next erasesize */ | 399 | /* Round up to next erasesize */ |
400 | slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize; | 400 | slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize; |
401 | printk(KERN_NOTICE "Moving partition %d: " | 401 | printk(KERN_NOTICE "Moving partition %d: " |
402 | "0x%08x -> 0x%08x\n", partno, | 402 | "0x%012llx -> 0x%012llx\n", partno, |
403 | cur_offset, slave->offset); | 403 | (unsigned long long)cur_offset, (unsigned long long)slave->offset); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | if (slave->mtd.size == MTDPART_SIZ_FULL) | 406 | if (slave->mtd.size == MTDPART_SIZ_FULL) |
407 | slave->mtd.size = master->size - slave->offset; | 407 | slave->mtd.size = master->size - slave->offset; |
408 | 408 | ||
409 | printk(KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset, | 409 | printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n", (unsigned long long)slave->offset, |
410 | slave->offset + slave->mtd.size, slave->mtd.name); | 410 | (unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name); |
411 | 411 | ||
412 | /* let's do some sanity checks */ | 412 | /* let's do some sanity checks */ |
413 | if (slave->offset >= master->size) { | 413 | if (slave->offset >= master->size) { |
@@ -420,13 +420,13 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
420 | } | 420 | } |
421 | if (slave->offset + slave->mtd.size > master->size) { | 421 | if (slave->offset + slave->mtd.size > master->size) { |
422 | slave->mtd.size = master->size - slave->offset; | 422 | slave->mtd.size = master->size - slave->offset; |
423 | printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n", | 423 | printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n", |
424 | part->name, master->name, slave->mtd.size); | 424 | part->name, master->name, (unsigned long long)slave->mtd.size); |
425 | } | 425 | } |
426 | if (master->numeraseregions > 1) { | 426 | if (master->numeraseregions > 1) { |
427 | /* Deal with variable erase size stuff */ | 427 | /* Deal with variable erase size stuff */ |
428 | int i, max = master->numeraseregions; | 428 | int i, max = master->numeraseregions; |
429 | u32 end = slave->offset + slave->mtd.size; | 429 | u64 end = slave->offset + slave->mtd.size; |
430 | struct mtd_erase_region_info *regions = master->eraseregions; | 430 | struct mtd_erase_region_info *regions = master->eraseregions; |
431 | 431 | ||
432 | /* Find the first erase regions which is part of this | 432 | /* Find the first erase regions which is part of this |
@@ -449,7 +449,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
449 | } | 449 | } |
450 | 450 | ||
451 | if ((slave->mtd.flags & MTD_WRITEABLE) && | 451 | if ((slave->mtd.flags & MTD_WRITEABLE) && |
452 | (slave->offset % slave->mtd.erasesize)) { | 452 | mtd_mod_by_eb(slave->offset, &slave->mtd)) { |
453 | /* Doesn't start on a boundary of major erase size */ | 453 | /* Doesn't start on a boundary of major erase size */ |
454 | /* FIXME: Let it be writable if it is on a boundary of | 454 | /* FIXME: Let it be writable if it is on a boundary of |
455 | * _minor_ erase size though */ | 455 | * _minor_ erase size though */ |
@@ -458,7 +458,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
458 | part->name); | 458 | part->name); |
459 | } | 459 | } |
460 | if ((slave->mtd.flags & MTD_WRITEABLE) && | 460 | if ((slave->mtd.flags & MTD_WRITEABLE) && |
461 | (slave->mtd.size % slave->mtd.erasesize)) { | 461 | mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) { |
462 | slave->mtd.flags &= ~MTD_WRITEABLE; | 462 | slave->mtd.flags &= ~MTD_WRITEABLE; |
463 | printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", | 463 | printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", |
464 | part->name); | 464 | part->name); |
@@ -466,7 +466,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
466 | 466 | ||
467 | slave->mtd.ecclayout = master->ecclayout; | 467 | slave->mtd.ecclayout = master->ecclayout; |
468 | if (master->block_isbad) { | 468 | if (master->block_isbad) { |
469 | uint32_t offs = 0; | 469 | uint64_t offs = 0; |
470 | 470 | ||
471 | while (offs < slave->mtd.size) { | 471 | while (offs < slave->mtd.size) { |
472 | if (master->block_isbad(master, | 472 | if (master->block_isbad(master, |
@@ -501,7 +501,7 @@ int add_mtd_partitions(struct mtd_info *master, | |||
501 | int nbparts) | 501 | int nbparts) |
502 | { | 502 | { |
503 | struct mtd_part *slave; | 503 | struct mtd_part *slave; |
504 | u_int32_t cur_offset = 0; | 504 | uint64_t cur_offset = 0; |
505 | int i; | 505 | int i; |
506 | 506 | ||
507 | printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); | 507 | printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); |
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c index 4aa5bd6158da..65929db29446 100644 --- a/drivers/mtd/nand/fsl_elbc_nand.c +++ b/drivers/mtd/nand/fsl_elbc_nand.c | |||
@@ -777,7 +777,9 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv) | |||
777 | /* Fill in fsl_elbc_mtd structure */ | 777 | /* Fill in fsl_elbc_mtd structure */ |
778 | priv->mtd.priv = chip; | 778 | priv->mtd.priv = chip; |
779 | priv->mtd.owner = THIS_MODULE; | 779 | priv->mtd.owner = THIS_MODULE; |
780 | priv->fmr = 0; /* rest filled in later */ | 780 | |
781 | /* Set the ECCM according to the settings in bootloader.*/ | ||
782 | priv->fmr = in_be32(&lbc->fmr) & FMR_ECCM; | ||
781 | 783 | ||
782 | /* fill in nand_chip structure */ | 784 | /* fill in nand_chip structure */ |
783 | /* set up function call table */ | 785 | /* set up function call table */ |
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c index a83192f80eba..7815a404a632 100644 --- a/drivers/mtd/nand/fsl_upm.c +++ b/drivers/mtd/nand/fsl_upm.c | |||
@@ -222,7 +222,7 @@ static int __devinit fun_probe(struct of_device *ofdev, | |||
222 | 222 | ||
223 | fun->rnb_gpio = of_get_gpio(ofdev->node, 0); | 223 | fun->rnb_gpio = of_get_gpio(ofdev->node, 0); |
224 | if (fun->rnb_gpio >= 0) { | 224 | if (fun->rnb_gpio >= 0) { |
225 | ret = gpio_request(fun->rnb_gpio, ofdev->dev.bus_id); | 225 | ret = gpio_request(fun->rnb_gpio, dev_name(&ofdev->dev)); |
226 | if (ret) { | 226 | if (ret) { |
227 | dev_err(&ofdev->dev, "can't request RNB gpio\n"); | 227 | dev_err(&ofdev->dev, "can't request RNB gpio\n"); |
228 | goto err2; | 228 | goto err2; |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 0a9c9cd33f96..0c3afccde8a2 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -2014,13 +2014,14 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
2014 | int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | 2014 | int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, |
2015 | int allowbbt) | 2015 | int allowbbt) |
2016 | { | 2016 | { |
2017 | int page, len, status, pages_per_block, ret, chipnr; | 2017 | int page, status, pages_per_block, ret, chipnr; |
2018 | struct nand_chip *chip = mtd->priv; | 2018 | struct nand_chip *chip = mtd->priv; |
2019 | int rewrite_bbt[NAND_MAX_CHIPS]={0}; | 2019 | loff_t rewrite_bbt[NAND_MAX_CHIPS]={0}; |
2020 | unsigned int bbt_masked_page = 0xffffffff; | 2020 | unsigned int bbt_masked_page = 0xffffffff; |
2021 | loff_t len; | ||
2021 | 2022 | ||
2022 | DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n", | 2023 | DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%012llx, len = %llu\n", |
2023 | (unsigned int)instr->addr, (unsigned int)instr->len); | 2024 | (unsigned long long)instr->addr, (unsigned long long)instr->len); |
2024 | 2025 | ||
2025 | /* Start address must align on block boundary */ | 2026 | /* Start address must align on block boundary */ |
2026 | if (instr->addr & ((1 << chip->phys_erase_shift) - 1)) { | 2027 | if (instr->addr & ((1 << chip->phys_erase_shift) - 1)) { |
@@ -2116,7 +2117,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2116 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " | 2117 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " |
2117 | "Failed erase, page 0x%08x\n", page); | 2118 | "Failed erase, page 0x%08x\n", page); |
2118 | instr->state = MTD_ERASE_FAILED; | 2119 | instr->state = MTD_ERASE_FAILED; |
2119 | instr->fail_addr = (page << chip->page_shift); | 2120 | instr->fail_addr = |
2121 | ((loff_t)page << chip->page_shift); | ||
2120 | goto erase_exit; | 2122 | goto erase_exit; |
2121 | } | 2123 | } |
2122 | 2124 | ||
@@ -2126,7 +2128,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2126 | */ | 2128 | */ |
2127 | if (bbt_masked_page != 0xffffffff && | 2129 | if (bbt_masked_page != 0xffffffff && |
2128 | (page & BBT_PAGE_MASK) == bbt_masked_page) | 2130 | (page & BBT_PAGE_MASK) == bbt_masked_page) |
2129 | rewrite_bbt[chipnr] = (page << chip->page_shift); | 2131 | rewrite_bbt[chipnr] = |
2132 | ((loff_t)page << chip->page_shift); | ||
2130 | 2133 | ||
2131 | /* Increment page address and decrement length */ | 2134 | /* Increment page address and decrement length */ |
2132 | len -= (1 << chip->phys_erase_shift); | 2135 | len -= (1 << chip->phys_erase_shift); |
@@ -2173,7 +2176,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2173 | continue; | 2176 | continue; |
2174 | /* update the BBT for chip */ | 2177 | /* update the BBT for chip */ |
2175 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt " | 2178 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt " |
2176 | "(%d:0x%0x 0x%0x)\n", chipnr, rewrite_bbt[chipnr], | 2179 | "(%d:0x%0llx 0x%0x)\n", chipnr, rewrite_bbt[chipnr], |
2177 | chip->bbt_td->pages[chipnr]); | 2180 | chip->bbt_td->pages[chipnr]); |
2178 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); | 2181 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); |
2179 | } | 2182 | } |
@@ -2365,7 +2368,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2365 | if (!mtd->name) | 2368 | if (!mtd->name) |
2366 | mtd->name = type->name; | 2369 | mtd->name = type->name; |
2367 | 2370 | ||
2368 | chip->chipsize = type->chipsize << 20; | 2371 | chip->chipsize = (uint64_t)type->chipsize << 20; |
2369 | 2372 | ||
2370 | /* Newer devices have all the information in additional id bytes */ | 2373 | /* Newer devices have all the information in additional id bytes */ |
2371 | if (!type->pagesize) { | 2374 | if (!type->pagesize) { |
@@ -2423,7 +2426,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2423 | 2426 | ||
2424 | chip->bbt_erase_shift = chip->phys_erase_shift = | 2427 | chip->bbt_erase_shift = chip->phys_erase_shift = |
2425 | ffs(mtd->erasesize) - 1; | 2428 | ffs(mtd->erasesize) - 1; |
2426 | chip->chip_shift = ffs(chip->chipsize) - 1; | 2429 | if (chip->chipsize & 0xffffffff) |
2430 | chip->chip_shift = ffs((unsigned)chip->chipsize) - 1; | ||
2431 | else | ||
2432 | chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32)) + 32 - 1; | ||
2427 | 2433 | ||
2428 | /* Set the bad block position */ | 2434 | /* Set the bad block position */ |
2429 | chip->badblockpos = mtd->writesize > 512 ? | 2435 | chip->badblockpos = mtd->writesize > 512 ? |
@@ -2517,7 +2523,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips) | |||
2517 | /** | 2523 | /** |
2518 | * nand_scan_tail - [NAND Interface] Scan for the NAND device | 2524 | * nand_scan_tail - [NAND Interface] Scan for the NAND device |
2519 | * @mtd: MTD device structure | 2525 | * @mtd: MTD device structure |
2520 | * @maxchips: Number of chips to scan for | ||
2521 | * | 2526 | * |
2522 | * This is the second phase of the normal nand_scan() function. It | 2527 | * This is the second phase of the normal nand_scan() function. It |
2523 | * fills out all the uninitialized function pointers with the defaults | 2528 | * fills out all the uninitialized function pointers with the defaults |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 0b1c48595f12..55c23e5cd210 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -171,16 +171,16 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
171 | if (tmp == msk) | 171 | if (tmp == msk) |
172 | continue; | 172 | continue; |
173 | if (reserved_block_code && (tmp == reserved_block_code)) { | 173 | if (reserved_block_code && (tmp == reserved_block_code)) { |
174 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", | 174 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%012llx\n", |
175 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 175 | (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
176 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); | 176 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); |
177 | mtd->ecc_stats.bbtblocks++; | 177 | mtd->ecc_stats.bbtblocks++; |
178 | continue; | 178 | continue; |
179 | } | 179 | } |
180 | /* Leave it for now, if its matured we can move this | 180 | /* Leave it for now, if its matured we can move this |
181 | * message to MTD_DEBUG_LEVEL0 */ | 181 | * message to MTD_DEBUG_LEVEL0 */ |
182 | printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", | 182 | printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%012llx\n", |
183 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 183 | (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
184 | /* Factory marked bad or worn out ? */ | 184 | /* Factory marked bad or worn out ? */ |
185 | if (tmp == 0) | 185 | if (tmp == 0) |
186 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); | 186 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); |
@@ -284,7 +284,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, | |||
284 | 284 | ||
285 | /* Read the primary version, if available */ | 285 | /* Read the primary version, if available */ |
286 | if (td->options & NAND_BBT_VERSION) { | 286 | if (td->options & NAND_BBT_VERSION) { |
287 | scan_read_raw(mtd, buf, td->pages[0] << this->page_shift, | 287 | scan_read_raw(mtd, buf, (loff_t)td->pages[0] << this->page_shift, |
288 | mtd->writesize); | 288 | mtd->writesize); |
289 | td->version[0] = buf[mtd->writesize + td->veroffs]; | 289 | td->version[0] = buf[mtd->writesize + td->veroffs]; |
290 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", | 290 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", |
@@ -293,7 +293,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, | |||
293 | 293 | ||
294 | /* Read the mirror version, if available */ | 294 | /* Read the mirror version, if available */ |
295 | if (md && (md->options & NAND_BBT_VERSION)) { | 295 | if (md && (md->options & NAND_BBT_VERSION)) { |
296 | scan_read_raw(mtd, buf, md->pages[0] << this->page_shift, | 296 | scan_read_raw(mtd, buf, (loff_t)md->pages[0] << this->page_shift, |
297 | mtd->writesize); | 297 | mtd->writesize); |
298 | md->version[0] = buf[mtd->writesize + md->veroffs]; | 298 | md->version[0] = buf[mtd->writesize + md->veroffs]; |
299 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", | 299 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", |
@@ -411,7 +411,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
411 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); | 411 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); |
412 | startblock = chip * numblocks; | 412 | startblock = chip * numblocks; |
413 | numblocks += startblock; | 413 | numblocks += startblock; |
414 | from = startblock << (this->bbt_erase_shift - 1); | 414 | from = (loff_t)startblock << (this->bbt_erase_shift - 1); |
415 | } | 415 | } |
416 | 416 | ||
417 | for (i = startblock; i < numblocks;) { | 417 | for (i = startblock; i < numblocks;) { |
@@ -428,8 +428,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
428 | 428 | ||
429 | if (ret) { | 429 | if (ret) { |
430 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 430 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
431 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 431 | printk(KERN_WARNING "Bad eraseblock %d at 0x%012llx\n", |
432 | i >> 1, (unsigned int)from); | 432 | i >> 1, (unsigned long long)from); |
433 | mtd->ecc_stats.badblocks++; | 433 | mtd->ecc_stats.badblocks++; |
434 | } | 434 | } |
435 | 435 | ||
@@ -495,7 +495,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
495 | for (block = 0; block < td->maxblocks; block++) { | 495 | for (block = 0; block < td->maxblocks; block++) { |
496 | 496 | ||
497 | int actblock = startblock + dir * block; | 497 | int actblock = startblock + dir * block; |
498 | loff_t offs = actblock << this->bbt_erase_shift; | 498 | loff_t offs = (loff_t)actblock << this->bbt_erase_shift; |
499 | 499 | ||
500 | /* Read first page */ | 500 | /* Read first page */ |
501 | scan_read_raw(mtd, buf, offs, mtd->writesize); | 501 | scan_read_raw(mtd, buf, offs, mtd->writesize); |
@@ -719,7 +719,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
719 | 719 | ||
720 | memset(&einfo, 0, sizeof(einfo)); | 720 | memset(&einfo, 0, sizeof(einfo)); |
721 | einfo.mtd = mtd; | 721 | einfo.mtd = mtd; |
722 | einfo.addr = (unsigned long)to; | 722 | einfo.addr = to; |
723 | einfo.len = 1 << this->bbt_erase_shift; | 723 | einfo.len = 1 << this->bbt_erase_shift; |
724 | res = nand_erase_nand(mtd, &einfo, 1); | 724 | res = nand_erase_nand(mtd, &einfo, 1); |
725 | if (res < 0) | 725 | if (res < 0) |
@@ -729,8 +729,8 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
729 | if (res < 0) | 729 | if (res < 0) |
730 | goto outerr; | 730 | goto outerr; |
731 | 731 | ||
732 | printk(KERN_DEBUG "Bad block table written to 0x%08x, version " | 732 | printk(KERN_DEBUG "Bad block table written to 0x%012llx, version " |
733 | "0x%02X\n", (unsigned int)to, td->version[chip]); | 733 | "0x%02X\n", (unsigned long long)to, td->version[chip]); |
734 | 734 | ||
735 | /* Mark it as used */ | 735 | /* Mark it as used */ |
736 | td->pages[chip] = page; | 736 | td->pages[chip] = page; |
@@ -910,7 +910,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
910 | newval = oldval | (0x2 << (block & 0x06)); | 910 | newval = oldval | (0x2 << (block & 0x06)); |
911 | this->bbt[(block >> 3)] = newval; | 911 | this->bbt[(block >> 3)] = newval; |
912 | if ((oldval != newval) && td->reserved_block_code) | 912 | if ((oldval != newval) && td->reserved_block_code) |
913 | nand_update_bbt(mtd, block << (this->bbt_erase_shift - 1)); | 913 | nand_update_bbt(mtd, (loff_t)block << (this->bbt_erase_shift - 1)); |
914 | continue; | 914 | continue; |
915 | } | 915 | } |
916 | update = 0; | 916 | update = 0; |
@@ -931,7 +931,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
931 | new ones have been marked, then we need to update the stored | 931 | new ones have been marked, then we need to update the stored |
932 | bbts. This should only happen once. */ | 932 | bbts. This should only happen once. */ |
933 | if (update && td->reserved_block_code) | 933 | if (update && td->reserved_block_code) |
934 | nand_update_bbt(mtd, (block - 2) << (this->bbt_erase_shift - 1)); | 934 | nand_update_bbt(mtd, (loff_t)(block - 2) << (this->bbt_erase_shift - 1)); |
935 | } | 935 | } |
936 | } | 936 | } |
937 | 937 | ||
@@ -1027,7 +1027,6 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs) | |||
1027 | if (!this->bbt || !td) | 1027 | if (!this->bbt || !td) |
1028 | return -EINVAL; | 1028 | return -EINVAL; |
1029 | 1029 | ||
1030 | len = mtd->size >> (this->bbt_erase_shift + 2); | ||
1031 | /* Allocate a temporary buffer for one eraseblock incl. oob */ | 1030 | /* Allocate a temporary buffer for one eraseblock incl. oob */ |
1032 | len = (1 << this->bbt_erase_shift); | 1031 | len = (1 << this->bbt_erase_shift); |
1033 | len += (len >> this->page_shift) * mtd->oobsize; | 1032 | len += (len >> this->page_shift) * mtd->oobsize; |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index ae7c57781a68..23b53fc405f5 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -38,6 +38,8 @@ | |||
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/list.h> | 39 | #include <linux/list.h> |
40 | #include <linux/random.h> | 40 | #include <linux/random.h> |
41 | #include <linux/fs.h> | ||
42 | #include <linux/pagemap.h> | ||
41 | 43 | ||
42 | /* Default simulator parameters values */ | 44 | /* Default simulator parameters values */ |
43 | #if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE) || \ | 45 | #if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE) || \ |
@@ -100,6 +102,7 @@ static unsigned int bitflips = 0; | |||
100 | static char *gravepages = NULL; | 102 | static char *gravepages = NULL; |
101 | static unsigned int rptwear = 0; | 103 | static unsigned int rptwear = 0; |
102 | static unsigned int overridesize = 0; | 104 | static unsigned int overridesize = 0; |
105 | static char *cache_file = NULL; | ||
103 | 106 | ||
104 | module_param(first_id_byte, uint, 0400); | 107 | module_param(first_id_byte, uint, 0400); |
105 | module_param(second_id_byte, uint, 0400); | 108 | module_param(second_id_byte, uint, 0400); |
@@ -122,12 +125,13 @@ module_param(bitflips, uint, 0400); | |||
122 | module_param(gravepages, charp, 0400); | 125 | module_param(gravepages, charp, 0400); |
123 | module_param(rptwear, uint, 0400); | 126 | module_param(rptwear, uint, 0400); |
124 | module_param(overridesize, uint, 0400); | 127 | module_param(overridesize, uint, 0400); |
128 | module_param(cache_file, charp, 0400); | ||
125 | 129 | ||
126 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); | 130 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); |
127 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); | 131 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); |
128 | MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); | 132 | MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); |
129 | MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); | 133 | MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); |
130 | MODULE_PARM_DESC(access_delay, "Initial page access delay (microiseconds)"); | 134 | MODULE_PARM_DESC(access_delay, "Initial page access delay (microseconds)"); |
131 | MODULE_PARM_DESC(programm_delay, "Page programm delay (microseconds"); | 135 | MODULE_PARM_DESC(programm_delay, "Page programm delay (microseconds"); |
132 | MODULE_PARM_DESC(erase_delay, "Sector erase delay (milliseconds)"); | 136 | MODULE_PARM_DESC(erase_delay, "Sector erase delay (milliseconds)"); |
133 | MODULE_PARM_DESC(output_cycle, "Word output (from flash) time (nanodeconds)"); | 137 | MODULE_PARM_DESC(output_cycle, "Word output (from flash) time (nanodeconds)"); |
@@ -153,6 +157,7 @@ MODULE_PARM_DESC(rptwear, "Number of erases inbetween reporting wear, if | |||
153 | MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the ID bytes. " | 157 | MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the ID bytes. " |
154 | "The size is specified in erase blocks and as the exponent of a power of two" | 158 | "The size is specified in erase blocks and as the exponent of a power of two" |
155 | " e.g. 5 means a size of 32 erase blocks"); | 159 | " e.g. 5 means a size of 32 erase blocks"); |
160 | MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory"); | ||
156 | 161 | ||
157 | /* The largest possible page size */ | 162 | /* The largest possible page size */ |
158 | #define NS_LARGEST_PAGE_SIZE 2048 | 163 | #define NS_LARGEST_PAGE_SIZE 2048 |
@@ -266,6 +271,9 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I | |||
266 | */ | 271 | */ |
267 | #define NS_MAX_PREVSTATES 1 | 272 | #define NS_MAX_PREVSTATES 1 |
268 | 273 | ||
274 | /* Maximum page cache pages needed to read or write a NAND page to the cache_file */ | ||
275 | #define NS_MAX_HELD_PAGES 16 | ||
276 | |||
269 | /* | 277 | /* |
270 | * A union to represent flash memory contents and flash buffer. | 278 | * A union to represent flash memory contents and flash buffer. |
271 | */ | 279 | */ |
@@ -295,6 +303,9 @@ struct nandsim { | |||
295 | /* The simulated NAND flash pages array */ | 303 | /* The simulated NAND flash pages array */ |
296 | union ns_mem *pages; | 304 | union ns_mem *pages; |
297 | 305 | ||
306 | /* Slab allocator for nand pages */ | ||
307 | struct kmem_cache *nand_pages_slab; | ||
308 | |||
298 | /* Internal buffer of page + OOB size bytes */ | 309 | /* Internal buffer of page + OOB size bytes */ |
299 | union ns_mem buf; | 310 | union ns_mem buf; |
300 | 311 | ||
@@ -335,6 +346,13 @@ struct nandsim { | |||
335 | int ale; /* address Latch Enable */ | 346 | int ale; /* address Latch Enable */ |
336 | int wp; /* write Protect */ | 347 | int wp; /* write Protect */ |
337 | } lines; | 348 | } lines; |
349 | |||
350 | /* Fields needed when using a cache file */ | ||
351 | struct file *cfile; /* Open file */ | ||
352 | unsigned char *pages_written; /* Which pages have been written */ | ||
353 | void *file_buf; | ||
354 | struct page *held_pages[NS_MAX_HELD_PAGES]; | ||
355 | int held_cnt; | ||
338 | }; | 356 | }; |
339 | 357 | ||
340 | /* | 358 | /* |
@@ -420,25 +438,69 @@ static struct mtd_info *nsmtd; | |||
420 | static u_char ns_verify_buf[NS_LARGEST_PAGE_SIZE]; | 438 | static u_char ns_verify_buf[NS_LARGEST_PAGE_SIZE]; |
421 | 439 | ||
422 | /* | 440 | /* |
423 | * Allocate array of page pointers and initialize the array to NULL | 441 | * Allocate array of page pointers, create slab allocation for an array |
424 | * pointers. | 442 | * and initialize the array by NULL pointers. |
425 | * | 443 | * |
426 | * RETURNS: 0 if success, -ENOMEM if memory alloc fails. | 444 | * RETURNS: 0 if success, -ENOMEM if memory alloc fails. |
427 | */ | 445 | */ |
428 | static int alloc_device(struct nandsim *ns) | 446 | static int alloc_device(struct nandsim *ns) |
429 | { | 447 | { |
430 | int i; | 448 | struct file *cfile; |
449 | int i, err; | ||
450 | |||
451 | if (cache_file) { | ||
452 | cfile = filp_open(cache_file, O_CREAT | O_RDWR | O_LARGEFILE, 0600); | ||
453 | if (IS_ERR(cfile)) | ||
454 | return PTR_ERR(cfile); | ||
455 | if (!cfile->f_op || (!cfile->f_op->read && !cfile->f_op->aio_read)) { | ||
456 | NS_ERR("alloc_device: cache file not readable\n"); | ||
457 | err = -EINVAL; | ||
458 | goto err_close; | ||
459 | } | ||
460 | if (!cfile->f_op->write && !cfile->f_op->aio_write) { | ||
461 | NS_ERR("alloc_device: cache file not writeable\n"); | ||
462 | err = -EINVAL; | ||
463 | goto err_close; | ||
464 | } | ||
465 | ns->pages_written = vmalloc(ns->geom.pgnum); | ||
466 | if (!ns->pages_written) { | ||
467 | NS_ERR("alloc_device: unable to allocate pages written array\n"); | ||
468 | err = -ENOMEM; | ||
469 | goto err_close; | ||
470 | } | ||
471 | ns->file_buf = kmalloc(ns->geom.pgszoob, GFP_KERNEL); | ||
472 | if (!ns->file_buf) { | ||
473 | NS_ERR("alloc_device: unable to allocate file buf\n"); | ||
474 | err = -ENOMEM; | ||
475 | goto err_free; | ||
476 | } | ||
477 | ns->cfile = cfile; | ||
478 | memset(ns->pages_written, 0, ns->geom.pgnum); | ||
479 | return 0; | ||
480 | } | ||
431 | 481 | ||
432 | ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem)); | 482 | ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem)); |
433 | if (!ns->pages) { | 483 | if (!ns->pages) { |
434 | NS_ERR("alloc_map: unable to allocate page array\n"); | 484 | NS_ERR("alloc_device: unable to allocate page array\n"); |
435 | return -ENOMEM; | 485 | return -ENOMEM; |
436 | } | 486 | } |
437 | for (i = 0; i < ns->geom.pgnum; i++) { | 487 | for (i = 0; i < ns->geom.pgnum; i++) { |
438 | ns->pages[i].byte = NULL; | 488 | ns->pages[i].byte = NULL; |
439 | } | 489 | } |
490 | ns->nand_pages_slab = kmem_cache_create("nandsim", | ||
491 | ns->geom.pgszoob, 0, 0, NULL); | ||
492 | if (!ns->nand_pages_slab) { | ||
493 | NS_ERR("cache_create: unable to create kmem_cache\n"); | ||
494 | return -ENOMEM; | ||
495 | } | ||
440 | 496 | ||
441 | return 0; | 497 | return 0; |
498 | |||
499 | err_free: | ||
500 | vfree(ns->pages_written); | ||
501 | err_close: | ||
502 | filp_close(cfile, NULL); | ||
503 | return err; | ||
442 | } | 504 | } |
443 | 505 | ||
444 | /* | 506 | /* |
@@ -448,11 +510,20 @@ static void free_device(struct nandsim *ns) | |||
448 | { | 510 | { |
449 | int i; | 511 | int i; |
450 | 512 | ||
513 | if (ns->cfile) { | ||
514 | kfree(ns->file_buf); | ||
515 | vfree(ns->pages_written); | ||
516 | filp_close(ns->cfile, NULL); | ||
517 | return; | ||
518 | } | ||
519 | |||
451 | if (ns->pages) { | 520 | if (ns->pages) { |
452 | for (i = 0; i < ns->geom.pgnum; i++) { | 521 | for (i = 0; i < ns->geom.pgnum; i++) { |
453 | if (ns->pages[i].byte) | 522 | if (ns->pages[i].byte) |
454 | kfree(ns->pages[i].byte); | 523 | kmem_cache_free(ns->nand_pages_slab, |
524 | ns->pages[i].byte); | ||
455 | } | 525 | } |
526 | kmem_cache_destroy(ns->nand_pages_slab); | ||
456 | vfree(ns->pages); | 527 | vfree(ns->pages); |
457 | } | 528 | } |
458 | } | 529 | } |
@@ -464,7 +535,7 @@ static char *get_partition_name(int i) | |||
464 | return kstrdup(buf, GFP_KERNEL); | 535 | return kstrdup(buf, GFP_KERNEL); |
465 | } | 536 | } |
466 | 537 | ||
467 | static u_int64_t divide(u_int64_t n, u_int32_t d) | 538 | static uint64_t divide(uint64_t n, uint32_t d) |
468 | { | 539 | { |
469 | do_div(n, d); | 540 | do_div(n, d); |
470 | return n; | 541 | return n; |
@@ -480,8 +551,8 @@ static int init_nandsim(struct mtd_info *mtd) | |||
480 | struct nand_chip *chip = (struct nand_chip *)mtd->priv; | 551 | struct nand_chip *chip = (struct nand_chip *)mtd->priv; |
481 | struct nandsim *ns = (struct nandsim *)(chip->priv); | 552 | struct nandsim *ns = (struct nandsim *)(chip->priv); |
482 | int i, ret = 0; | 553 | int i, ret = 0; |
483 | u_int64_t remains; | 554 | uint64_t remains; |
484 | u_int64_t next_offset; | 555 | uint64_t next_offset; |
485 | 556 | ||
486 | if (NS_IS_INITIALIZED(ns)) { | 557 | if (NS_IS_INITIALIZED(ns)) { |
487 | NS_ERR("init_nandsim: nandsim is already initialized\n"); | 558 | NS_ERR("init_nandsim: nandsim is already initialized\n"); |
@@ -548,7 +619,7 @@ static int init_nandsim(struct mtd_info *mtd) | |||
548 | remains = ns->geom.totsz; | 619 | remains = ns->geom.totsz; |
549 | next_offset = 0; | 620 | next_offset = 0; |
550 | for (i = 0; i < parts_num; ++i) { | 621 | for (i = 0; i < parts_num; ++i) { |
551 | u_int64_t part_sz = (u_int64_t)parts[i] * ns->geom.secsz; | 622 | uint64_t part_sz = (uint64_t)parts[i] * ns->geom.secsz; |
552 | 623 | ||
553 | if (!part_sz || part_sz > remains) { | 624 | if (!part_sz || part_sz > remains) { |
554 | NS_ERR("bad partition size.\n"); | 625 | NS_ERR("bad partition size.\n"); |
@@ -1211,6 +1282,97 @@ static int find_operation(struct nandsim *ns, uint32_t flag) | |||
1211 | return -1; | 1282 | return -1; |
1212 | } | 1283 | } |
1213 | 1284 | ||
1285 | static void put_pages(struct nandsim *ns) | ||
1286 | { | ||
1287 | int i; | ||
1288 | |||
1289 | for (i = 0; i < ns->held_cnt; i++) | ||
1290 | page_cache_release(ns->held_pages[i]); | ||
1291 | } | ||
1292 | |||
1293 | /* Get page cache pages in advance to provide NOFS memory allocation */ | ||
1294 | static int get_pages(struct nandsim *ns, struct file *file, size_t count, loff_t pos) | ||
1295 | { | ||
1296 | pgoff_t index, start_index, end_index; | ||
1297 | struct page *page; | ||
1298 | struct address_space *mapping = file->f_mapping; | ||
1299 | |||
1300 | start_index = pos >> PAGE_CACHE_SHIFT; | ||
1301 | end_index = (pos + count - 1) >> PAGE_CACHE_SHIFT; | ||
1302 | if (end_index - start_index + 1 > NS_MAX_HELD_PAGES) | ||
1303 | return -EINVAL; | ||
1304 | ns->held_cnt = 0; | ||
1305 | for (index = start_index; index <= end_index; index++) { | ||
1306 | page = find_get_page(mapping, index); | ||
1307 | if (page == NULL) { | ||
1308 | page = find_or_create_page(mapping, index, GFP_NOFS); | ||
1309 | if (page == NULL) { | ||
1310 | write_inode_now(mapping->host, 1); | ||
1311 | page = find_or_create_page(mapping, index, GFP_NOFS); | ||
1312 | } | ||
1313 | if (page == NULL) { | ||
1314 | put_pages(ns); | ||
1315 | return -ENOMEM; | ||
1316 | } | ||
1317 | unlock_page(page); | ||
1318 | } | ||
1319 | ns->held_pages[ns->held_cnt++] = page; | ||
1320 | } | ||
1321 | return 0; | ||
1322 | } | ||
1323 | |||
1324 | static int set_memalloc(void) | ||
1325 | { | ||
1326 | if (current->flags & PF_MEMALLOC) | ||
1327 | return 0; | ||
1328 | current->flags |= PF_MEMALLOC; | ||
1329 | return 1; | ||
1330 | } | ||
1331 | |||
1332 | static void clear_memalloc(int memalloc) | ||
1333 | { | ||
1334 | if (memalloc) | ||
1335 | current->flags &= ~PF_MEMALLOC; | ||
1336 | } | ||
1337 | |||
1338 | static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos) | ||
1339 | { | ||
1340 | mm_segment_t old_fs; | ||
1341 | ssize_t tx; | ||
1342 | int err, memalloc; | ||
1343 | |||
1344 | err = get_pages(ns, file, count, *pos); | ||
1345 | if (err) | ||
1346 | return err; | ||
1347 | old_fs = get_fs(); | ||
1348 | set_fs(get_ds()); | ||
1349 | memalloc = set_memalloc(); | ||
1350 | tx = vfs_read(file, (char __user *)buf, count, pos); | ||
1351 | clear_memalloc(memalloc); | ||
1352 | set_fs(old_fs); | ||
1353 | put_pages(ns); | ||
1354 | return tx; | ||
1355 | } | ||
1356 | |||
1357 | static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos) | ||
1358 | { | ||
1359 | mm_segment_t old_fs; | ||
1360 | ssize_t tx; | ||
1361 | int err, memalloc; | ||
1362 | |||
1363 | err = get_pages(ns, file, count, *pos); | ||
1364 | if (err) | ||
1365 | return err; | ||
1366 | old_fs = get_fs(); | ||
1367 | set_fs(get_ds()); | ||
1368 | memalloc = set_memalloc(); | ||
1369 | tx = vfs_write(file, (char __user *)buf, count, pos); | ||
1370 | clear_memalloc(memalloc); | ||
1371 | set_fs(old_fs); | ||
1372 | put_pages(ns); | ||
1373 | return tx; | ||
1374 | } | ||
1375 | |||
1214 | /* | 1376 | /* |
1215 | * Returns a pointer to the current page. | 1377 | * Returns a pointer to the current page. |
1216 | */ | 1378 | */ |
@@ -1227,6 +1389,38 @@ static inline u_char *NS_PAGE_BYTE_OFF(struct nandsim *ns) | |||
1227 | return NS_GET_PAGE(ns)->byte + ns->regs.column + ns->regs.off; | 1389 | return NS_GET_PAGE(ns)->byte + ns->regs.column + ns->regs.off; |
1228 | } | 1390 | } |
1229 | 1391 | ||
1392 | int do_read_error(struct nandsim *ns, int num) | ||
1393 | { | ||
1394 | unsigned int page_no = ns->regs.row; | ||
1395 | |||
1396 | if (read_error(page_no)) { | ||
1397 | int i; | ||
1398 | memset(ns->buf.byte, 0xFF, num); | ||
1399 | for (i = 0; i < num; ++i) | ||
1400 | ns->buf.byte[i] = random32(); | ||
1401 | NS_WARN("simulating read error in page %u\n", page_no); | ||
1402 | return 1; | ||
1403 | } | ||
1404 | return 0; | ||
1405 | } | ||
1406 | |||
1407 | void do_bit_flips(struct nandsim *ns, int num) | ||
1408 | { | ||
1409 | if (bitflips && random32() < (1 << 22)) { | ||
1410 | int flips = 1; | ||
1411 | if (bitflips > 1) | ||
1412 | flips = (random32() % (int) bitflips) + 1; | ||
1413 | while (flips--) { | ||
1414 | int pos = random32() % (num * 8); | ||
1415 | ns->buf.byte[pos / 8] ^= (1 << (pos % 8)); | ||
1416 | NS_WARN("read_page: flipping bit %d in page %d " | ||
1417 | "reading from %d ecc: corrected=%u failed=%u\n", | ||
1418 | pos, ns->regs.row, ns->regs.column + ns->regs.off, | ||
1419 | nsmtd->ecc_stats.corrected, nsmtd->ecc_stats.failed); | ||
1420 | } | ||
1421 | } | ||
1422 | } | ||
1423 | |||
1230 | /* | 1424 | /* |
1231 | * Fill the NAND buffer with data read from the specified page. | 1425 | * Fill the NAND buffer with data read from the specified page. |
1232 | */ | 1426 | */ |
@@ -1234,36 +1428,40 @@ static void read_page(struct nandsim *ns, int num) | |||
1234 | { | 1428 | { |
1235 | union ns_mem *mypage; | 1429 | union ns_mem *mypage; |
1236 | 1430 | ||
1431 | if (ns->cfile) { | ||
1432 | if (!ns->pages_written[ns->regs.row]) { | ||
1433 | NS_DBG("read_page: page %d not written\n", ns->regs.row); | ||
1434 | memset(ns->buf.byte, 0xFF, num); | ||
1435 | } else { | ||
1436 | loff_t pos; | ||
1437 | ssize_t tx; | ||
1438 | |||
1439 | NS_DBG("read_page: page %d written, reading from %d\n", | ||
1440 | ns->regs.row, ns->regs.column + ns->regs.off); | ||
1441 | if (do_read_error(ns, num)) | ||
1442 | return; | ||
1443 | pos = (loff_t)ns->regs.row * ns->geom.pgszoob + ns->regs.column + ns->regs.off; | ||
1444 | tx = read_file(ns, ns->cfile, ns->buf.byte, num, &pos); | ||
1445 | if (tx != num) { | ||
1446 | NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); | ||
1447 | return; | ||
1448 | } | ||
1449 | do_bit_flips(ns, num); | ||
1450 | } | ||
1451 | return; | ||
1452 | } | ||
1453 | |||
1237 | mypage = NS_GET_PAGE(ns); | 1454 | mypage = NS_GET_PAGE(ns); |
1238 | if (mypage->byte == NULL) { | 1455 | if (mypage->byte == NULL) { |
1239 | NS_DBG("read_page: page %d not allocated\n", ns->regs.row); | 1456 | NS_DBG("read_page: page %d not allocated\n", ns->regs.row); |
1240 | memset(ns->buf.byte, 0xFF, num); | 1457 | memset(ns->buf.byte, 0xFF, num); |
1241 | } else { | 1458 | } else { |
1242 | unsigned int page_no = ns->regs.row; | ||
1243 | NS_DBG("read_page: page %d allocated, reading from %d\n", | 1459 | NS_DBG("read_page: page %d allocated, reading from %d\n", |
1244 | ns->regs.row, ns->regs.column + ns->regs.off); | 1460 | ns->regs.row, ns->regs.column + ns->regs.off); |
1245 | if (read_error(page_no)) { | 1461 | if (do_read_error(ns, num)) |
1246 | int i; | ||
1247 | memset(ns->buf.byte, 0xFF, num); | ||
1248 | for (i = 0; i < num; ++i) | ||
1249 | ns->buf.byte[i] = random32(); | ||
1250 | NS_WARN("simulating read error in page %u\n", page_no); | ||
1251 | return; | 1462 | return; |
1252 | } | ||
1253 | memcpy(ns->buf.byte, NS_PAGE_BYTE_OFF(ns), num); | 1463 | memcpy(ns->buf.byte, NS_PAGE_BYTE_OFF(ns), num); |
1254 | if (bitflips && random32() < (1 << 22)) { | 1464 | do_bit_flips(ns, num); |
1255 | int flips = 1; | ||
1256 | if (bitflips > 1) | ||
1257 | flips = (random32() % (int) bitflips) + 1; | ||
1258 | while (flips--) { | ||
1259 | int pos = random32() % (num * 8); | ||
1260 | ns->buf.byte[pos / 8] ^= (1 << (pos % 8)); | ||
1261 | NS_WARN("read_page: flipping bit %d in page %d " | ||
1262 | "reading from %d ecc: corrected=%u failed=%u\n", | ||
1263 | pos, ns->regs.row, ns->regs.column + ns->regs.off, | ||
1264 | nsmtd->ecc_stats.corrected, nsmtd->ecc_stats.failed); | ||
1265 | } | ||
1266 | } | ||
1267 | } | 1465 | } |
1268 | } | 1466 | } |
1269 | 1467 | ||
@@ -1275,11 +1473,20 @@ static void erase_sector(struct nandsim *ns) | |||
1275 | union ns_mem *mypage; | 1473 | union ns_mem *mypage; |
1276 | int i; | 1474 | int i; |
1277 | 1475 | ||
1476 | if (ns->cfile) { | ||
1477 | for (i = 0; i < ns->geom.pgsec; i++) | ||
1478 | if (ns->pages_written[ns->regs.row + i]) { | ||
1479 | NS_DBG("erase_sector: freeing page %d\n", ns->regs.row + i); | ||
1480 | ns->pages_written[ns->regs.row + i] = 0; | ||
1481 | } | ||
1482 | return; | ||
1483 | } | ||
1484 | |||
1278 | mypage = NS_GET_PAGE(ns); | 1485 | mypage = NS_GET_PAGE(ns); |
1279 | for (i = 0; i < ns->geom.pgsec; i++) { | 1486 | for (i = 0; i < ns->geom.pgsec; i++) { |
1280 | if (mypage->byte != NULL) { | 1487 | if (mypage->byte != NULL) { |
1281 | NS_DBG("erase_sector: freeing page %d\n", ns->regs.row+i); | 1488 | NS_DBG("erase_sector: freeing page %d\n", ns->regs.row+i); |
1282 | kfree(mypage->byte); | 1489 | kmem_cache_free(ns->nand_pages_slab, mypage->byte); |
1283 | mypage->byte = NULL; | 1490 | mypage->byte = NULL; |
1284 | } | 1491 | } |
1285 | mypage++; | 1492 | mypage++; |
@@ -1295,16 +1502,57 @@ static int prog_page(struct nandsim *ns, int num) | |||
1295 | union ns_mem *mypage; | 1502 | union ns_mem *mypage; |
1296 | u_char *pg_off; | 1503 | u_char *pg_off; |
1297 | 1504 | ||
1505 | if (ns->cfile) { | ||
1506 | loff_t off, pos; | ||
1507 | ssize_t tx; | ||
1508 | int all; | ||
1509 | |||
1510 | NS_DBG("prog_page: writing page %d\n", ns->regs.row); | ||
1511 | pg_off = ns->file_buf + ns->regs.column + ns->regs.off; | ||
1512 | off = (loff_t)ns->regs.row * ns->geom.pgszoob + ns->regs.column + ns->regs.off; | ||
1513 | if (!ns->pages_written[ns->regs.row]) { | ||
1514 | all = 1; | ||
1515 | memset(ns->file_buf, 0xff, ns->geom.pgszoob); | ||
1516 | } else { | ||
1517 | all = 0; | ||
1518 | pos = off; | ||
1519 | tx = read_file(ns, ns->cfile, pg_off, num, &pos); | ||
1520 | if (tx != num) { | ||
1521 | NS_ERR("prog_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx); | ||
1522 | return -1; | ||
1523 | } | ||
1524 | } | ||
1525 | for (i = 0; i < num; i++) | ||
1526 | pg_off[i] &= ns->buf.byte[i]; | ||
1527 | if (all) { | ||
1528 | pos = (loff_t)ns->regs.row * ns->geom.pgszoob; | ||
1529 | tx = write_file(ns, ns->cfile, ns->file_buf, ns->geom.pgszoob, &pos); | ||
1530 | if (tx != ns->geom.pgszoob) { | ||
1531 | NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); | ||
1532 | return -1; | ||
1533 | } | ||
1534 | ns->pages_written[ns->regs.row] = 1; | ||
1535 | } else { | ||
1536 | pos = off; | ||
1537 | tx = write_file(ns, ns->cfile, pg_off, num, &pos); | ||
1538 | if (tx != num) { | ||
1539 | NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx); | ||
1540 | return -1; | ||
1541 | } | ||
1542 | } | ||
1543 | return 0; | ||
1544 | } | ||
1545 | |||
1298 | mypage = NS_GET_PAGE(ns); | 1546 | mypage = NS_GET_PAGE(ns); |
1299 | if (mypage->byte == NULL) { | 1547 | if (mypage->byte == NULL) { |
1300 | NS_DBG("prog_page: allocating page %d\n", ns->regs.row); | 1548 | NS_DBG("prog_page: allocating page %d\n", ns->regs.row); |
1301 | /* | 1549 | /* |
1302 | * We allocate memory with GFP_NOFS because a flash FS may | 1550 | * We allocate memory with GFP_NOFS because a flash FS may |
1303 | * utilize this. If it is holding an FS lock, then gets here, | 1551 | * utilize this. If it is holding an FS lock, then gets here, |
1304 | * then kmalloc runs writeback which goes to the FS again | 1552 | * then kernel memory alloc runs writeback which goes to the FS |
1305 | * and deadlocks. This was seen in practice. | 1553 | * again and deadlocks. This was seen in practice. |
1306 | */ | 1554 | */ |
1307 | mypage->byte = kmalloc(ns->geom.pgszoob, GFP_NOFS); | 1555 | mypage->byte = kmem_cache_alloc(ns->nand_pages_slab, GFP_NOFS); |
1308 | if (mypage->byte == NULL) { | 1556 | if (mypage->byte == NULL) { |
1309 | NS_ERR("prog_page: error allocating memory for page %d\n", ns->regs.row); | 1557 | NS_ERR("prog_page: error allocating memory for page %d\n", ns->regs.row); |
1310 | return -1; | 1558 | return -1; |
@@ -1736,13 +1984,17 @@ static void ns_nand_write_byte(struct mtd_info *mtd, u_char byte) | |||
1736 | 1984 | ||
1737 | /* Check if chip is expecting command */ | 1985 | /* Check if chip is expecting command */ |
1738 | if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) { | 1986 | if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) { |
1739 | /* | 1987 | /* Do not warn if only 2 id bytes are read */ |
1740 | * We are in situation when something else (not command) | 1988 | if (!(ns->regs.command == NAND_CMD_READID && |
1741 | * was expected but command was input. In this case ignore | 1989 | NS_STATE(ns->state) == STATE_DATAOUT_ID && ns->regs.count == 2)) { |
1742 | * previous command(s)/state(s) and accept the last one. | 1990 | /* |
1743 | */ | 1991 | * We are in situation when something else (not command) |
1744 | NS_WARN("write_byte: command (%#x) wasn't expected, expected state is %s, " | 1992 | * was expected but command was input. In this case ignore |
1745 | "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate)); | 1993 | * previous command(s)/state(s) and accept the last one. |
1994 | */ | ||
1995 | NS_WARN("write_byte: command (%#x) wasn't expected, expected state is %s, " | ||
1996 | "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate)); | ||
1997 | } | ||
1746 | switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); | 1998 | switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); |
1747 | } | 1999 | } |
1748 | 2000 | ||
@@ -2044,7 +2296,7 @@ static int __init ns_init_module(void) | |||
2044 | } | 2296 | } |
2045 | 2297 | ||
2046 | if (overridesize) { | 2298 | if (overridesize) { |
2047 | u_int64_t new_size = (u_int64_t)nsmtd->erasesize << overridesize; | 2299 | uint64_t new_size = (uint64_t)nsmtd->erasesize << overridesize; |
2048 | if (new_size >> overridesize != nsmtd->erasesize) { | 2300 | if (new_size >> overridesize != nsmtd->erasesize) { |
2049 | NS_ERR("overridesize is too big\n"); | 2301 | NS_ERR("overridesize is too big\n"); |
2050 | goto err_exit; | 2302 | goto err_exit; |
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c index f674c5427b17..75f9f4874ecf 100644 --- a/drivers/mtd/nand/plat_nand.c +++ b/drivers/mtd/nand/plat_nand.c | |||
@@ -54,7 +54,7 @@ static int __init plat_nand_probe(struct platform_device *pdev) | |||
54 | data->chip.priv = &data; | 54 | data->chip.priv = &data; |
55 | data->mtd.priv = &data->chip; | 55 | data->mtd.priv = &data->chip; |
56 | data->mtd.owner = THIS_MODULE; | 56 | data->mtd.owner = THIS_MODULE; |
57 | data->mtd.name = pdev->dev.bus_id; | 57 | data->mtd.name = dev_name(&pdev->dev); |
58 | 58 | ||
59 | data->chip.IO_ADDR_R = data->io_base; | 59 | data->chip.IO_ADDR_R = data->io_base; |
60 | data->chip.IO_ADDR_W = data->io_base; | 60 | data->chip.IO_ADDR_W = data->io_base; |
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 30a518e211bd..54ec7542a7b7 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * drivers/mtd/nand/sharpsl.c | 2 | * drivers/mtd/nand/sharpsl.c |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Richard Purdie | 4 | * Copyright (C) 2004 Richard Purdie |
5 | * Copyright (C) 2008 Dmitry Baryshkov | ||
5 | * | 6 | * |
6 | * Based on Sharp's NAND driver sharp_sl.c | 7 | * Based on Sharp's NAND driver sharp_sl.c |
7 | * | 8 | * |
@@ -19,22 +20,31 @@ | |||
19 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/nand.h> |
20 | #include <linux/mtd/nand_ecc.h> | 21 | #include <linux/mtd/nand_ecc.h> |
21 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/mtd/sharpsl.h> | ||
22 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/platform_device.h> | ||
26 | |||
23 | #include <asm/io.h> | 27 | #include <asm/io.h> |
24 | #include <mach/hardware.h> | 28 | #include <mach/hardware.h> |
25 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
26 | 30 | ||
27 | static void __iomem *sharpsl_io_base; | 31 | struct sharpsl_nand { |
28 | static int sharpsl_phys_base = 0x0C000000; | 32 | struct mtd_info mtd; |
33 | struct nand_chip chip; | ||
34 | |||
35 | void __iomem *io; | ||
36 | }; | ||
37 | |||
38 | #define mtd_to_sharpsl(_mtd) container_of(_mtd, struct sharpsl_nand, mtd) | ||
29 | 39 | ||
30 | /* register offset */ | 40 | /* register offset */ |
31 | #define ECCLPLB sharpsl_io_base+0x00 /* line parity 7 - 0 bit */ | 41 | #define ECCLPLB 0x00 /* line parity 7 - 0 bit */ |
32 | #define ECCLPUB sharpsl_io_base+0x04 /* line parity 15 - 8 bit */ | 42 | #define ECCLPUB 0x04 /* line parity 15 - 8 bit */ |
33 | #define ECCCP sharpsl_io_base+0x08 /* column parity 5 - 0 bit */ | 43 | #define ECCCP 0x08 /* column parity 5 - 0 bit */ |
34 | #define ECCCNTR sharpsl_io_base+0x0C /* ECC byte counter */ | 44 | #define ECCCNTR 0x0C /* ECC byte counter */ |
35 | #define ECCCLRR sharpsl_io_base+0x10 /* cleare ECC */ | 45 | #define ECCCLRR 0x10 /* cleare ECC */ |
36 | #define FLASHIO sharpsl_io_base+0x14 /* Flash I/O */ | 46 | #define FLASHIO 0x14 /* Flash I/O */ |
37 | #define FLASHCTL sharpsl_io_base+0x18 /* Flash Control */ | 47 | #define FLASHCTL 0x18 /* Flash Control */ |
38 | 48 | ||
39 | /* Flash control bit */ | 49 | /* Flash control bit */ |
40 | #define FLRYBY (1 << 5) | 50 | #define FLRYBY (1 << 5) |
@@ -45,35 +55,6 @@ static int sharpsl_phys_base = 0x0C000000; | |||
45 | #define FLCE0 (1 << 0) | 55 | #define FLCE0 (1 << 0) |
46 | 56 | ||
47 | /* | 57 | /* |
48 | * MTD structure for SharpSL | ||
49 | */ | ||
50 | static struct mtd_info *sharpsl_mtd = NULL; | ||
51 | |||
52 | /* | ||
53 | * Define partitions for flash device | ||
54 | */ | ||
55 | #define DEFAULT_NUM_PARTITIONS 3 | ||
56 | |||
57 | static int nr_partitions; | ||
58 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { | ||
59 | { | ||
60 | .name = "System Area", | ||
61 | .offset = 0, | ||
62 | .size = 7 * 1024 * 1024, | ||
63 | }, | ||
64 | { | ||
65 | .name = "Root Filesystem", | ||
66 | .offset = 7 * 1024 * 1024, | ||
67 | .size = 30 * 1024 * 1024, | ||
68 | }, | ||
69 | { | ||
70 | .name = "Home Filesystem", | ||
71 | .offset = MTDPART_OFS_APPEND, | ||
72 | .size = MTDPART_SIZ_FULL, | ||
73 | }, | ||
74 | }; | ||
75 | |||
76 | /* | ||
77 | * hardware specific access to control-lines | 58 | * hardware specific access to control-lines |
78 | * ctrl: | 59 | * ctrl: |
79 | * NAND_CNE: bit 0 -> ! bit 0 & 4 | 60 | * NAND_CNE: bit 0 -> ! bit 0 & 4 |
@@ -84,6 +65,7 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = { | |||
84 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd, | 65 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd, |
85 | unsigned int ctrl) | 66 | unsigned int ctrl) |
86 | { | 67 | { |
68 | struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); | ||
87 | struct nand_chip *chip = mtd->priv; | 69 | struct nand_chip *chip = mtd->priv; |
88 | 70 | ||
89 | if (ctrl & NAND_CTRL_CHANGE) { | 71 | if (ctrl & NAND_CTRL_CHANGE) { |
@@ -93,103 +75,97 @@ static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd, | |||
93 | 75 | ||
94 | bits ^= 0x11; | 76 | bits ^= 0x11; |
95 | 77 | ||
96 | writeb((readb(FLASHCTL) & ~0x17) | bits, FLASHCTL); | 78 | writeb((readb(sharpsl->io + FLASHCTL) & ~0x17) | bits, sharpsl->io + FLASHCTL); |
97 | } | 79 | } |
98 | 80 | ||
99 | if (cmd != NAND_CMD_NONE) | 81 | if (cmd != NAND_CMD_NONE) |
100 | writeb(cmd, chip->IO_ADDR_W); | 82 | writeb(cmd, chip->IO_ADDR_W); |
101 | } | 83 | } |
102 | 84 | ||
103 | static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; | ||
104 | |||
105 | static struct nand_bbt_descr sharpsl_bbt = { | ||
106 | .options = 0, | ||
107 | .offs = 4, | ||
108 | .len = 2, | ||
109 | .pattern = scan_ff_pattern | ||
110 | }; | ||
111 | |||
112 | static struct nand_bbt_descr sharpsl_akita_bbt = { | ||
113 | .options = 0, | ||
114 | .offs = 4, | ||
115 | .len = 1, | ||
116 | .pattern = scan_ff_pattern | ||
117 | }; | ||
118 | |||
119 | static struct nand_ecclayout akita_oobinfo = { | ||
120 | .eccbytes = 24, | ||
121 | .eccpos = { | ||
122 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, | ||
123 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, | ||
124 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, | ||
125 | .oobfree = {{0x08, 0x09}} | ||
126 | }; | ||
127 | |||
128 | static int sharpsl_nand_dev_ready(struct mtd_info *mtd) | 85 | static int sharpsl_nand_dev_ready(struct mtd_info *mtd) |
129 | { | 86 | { |
130 | return !((readb(FLASHCTL) & FLRYBY) == 0); | 87 | struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); |
88 | return !((readb(sharpsl->io + FLASHCTL) & FLRYBY) == 0); | ||
131 | } | 89 | } |
132 | 90 | ||
133 | static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) | 91 | static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) |
134 | { | 92 | { |
135 | writeb(0, ECCCLRR); | 93 | struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); |
94 | writeb(0, sharpsl->io + ECCCLRR); | ||
136 | } | 95 | } |
137 | 96 | ||
138 | static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) | 97 | static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) |
139 | { | 98 | { |
140 | ecc_code[0] = ~readb(ECCLPUB); | 99 | struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); |
141 | ecc_code[1] = ~readb(ECCLPLB); | 100 | ecc_code[0] = ~readb(sharpsl->io + ECCLPUB); |
142 | ecc_code[2] = (~readb(ECCCP) << 2) | 0x03; | 101 | ecc_code[1] = ~readb(sharpsl->io + ECCLPLB); |
143 | return readb(ECCCNTR) != 0; | 102 | ecc_code[2] = (~readb(sharpsl->io + ECCCP) << 2) | 0x03; |
103 | return readb(sharpsl->io + ECCCNTR) != 0; | ||
144 | } | 104 | } |
145 | 105 | ||
146 | #ifdef CONFIG_MTD_PARTITIONS | 106 | #ifdef CONFIG_MTD_PARTITIONS |
147 | const char *part_probes[] = { "cmdlinepart", NULL }; | 107 | static const char *part_probes[] = { "cmdlinepart", NULL }; |
148 | #endif | 108 | #endif |
149 | 109 | ||
150 | /* | 110 | /* |
151 | * Main initialization routine | 111 | * Main initialization routine |
152 | */ | 112 | */ |
153 | static int __init sharpsl_nand_init(void) | 113 | static int __devinit sharpsl_nand_probe(struct platform_device *pdev) |
154 | { | 114 | { |
155 | struct nand_chip *this; | 115 | struct nand_chip *this; |
116 | #ifdef CONFIG_MTD_PARTITIONS | ||
156 | struct mtd_partition *sharpsl_partition_info; | 117 | struct mtd_partition *sharpsl_partition_info; |
118 | int nr_partitions; | ||
119 | #endif | ||
120 | struct resource *r; | ||
157 | int err = 0; | 121 | int err = 0; |
122 | struct sharpsl_nand *sharpsl; | ||
123 | struct sharpsl_nand_platform_data *data = pdev->dev.platform_data; | ||
124 | |||
125 | if (!data) { | ||
126 | dev_err(&pdev->dev, "no platform data!\n"); | ||
127 | return -EINVAL; | ||
128 | } | ||
158 | 129 | ||
159 | /* Allocate memory for MTD device structure and private data */ | 130 | /* Allocate memory for MTD device structure and private data */ |
160 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); | 131 | sharpsl = kzalloc(sizeof(struct sharpsl_nand), GFP_KERNEL); |
161 | if (!sharpsl_mtd) { | 132 | if (!sharpsl) { |
162 | printk("Unable to allocate SharpSL NAND MTD device structure.\n"); | 133 | printk("Unable to allocate SharpSL NAND MTD device structure.\n"); |
163 | return -ENOMEM; | 134 | return -ENOMEM; |
164 | } | 135 | } |
165 | 136 | ||
137 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
138 | if (!r) { | ||
139 | dev_err(&pdev->dev, "no io memory resource defined!\n"); | ||
140 | err = -ENODEV; | ||
141 | goto err_get_res; | ||
142 | } | ||
143 | |||
166 | /* map physical address */ | 144 | /* map physical address */ |
167 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); | 145 | sharpsl->io = ioremap(r->start, resource_size(r)); |
168 | if (!sharpsl_io_base) { | 146 | if (!sharpsl->io) { |
169 | printk("ioremap to access Sharp SL NAND chip failed\n"); | 147 | printk("ioremap to access Sharp SL NAND chip failed\n"); |
170 | kfree(sharpsl_mtd); | 148 | err = -EIO; |
171 | return -EIO; | 149 | goto err_ioremap; |
172 | } | 150 | } |
173 | 151 | ||
174 | /* Get pointer to private data */ | 152 | /* Get pointer to private data */ |
175 | this = (struct nand_chip *)(&sharpsl_mtd[1]); | 153 | this = (struct nand_chip *)(&sharpsl->chip); |
176 | |||
177 | /* Initialize structures */ | ||
178 | memset(sharpsl_mtd, 0, sizeof(struct mtd_info)); | ||
179 | memset(this, 0, sizeof(struct nand_chip)); | ||
180 | 154 | ||
181 | /* Link the private data with the MTD structure */ | 155 | /* Link the private data with the MTD structure */ |
182 | sharpsl_mtd->priv = this; | 156 | sharpsl->mtd.priv = this; |
183 | sharpsl_mtd->owner = THIS_MODULE; | 157 | sharpsl->mtd.owner = THIS_MODULE; |
158 | |||
159 | platform_set_drvdata(pdev, sharpsl); | ||
184 | 160 | ||
185 | /* | 161 | /* |
186 | * PXA initialize | 162 | * PXA initialize |
187 | */ | 163 | */ |
188 | writeb(readb(FLASHCTL) | FLWP, FLASHCTL); | 164 | writeb(readb(sharpsl->io + FLASHCTL) | FLWP, sharpsl->io + FLASHCTL); |
189 | 165 | ||
190 | /* Set address of NAND IO lines */ | 166 | /* Set address of NAND IO lines */ |
191 | this->IO_ADDR_R = FLASHIO; | 167 | this->IO_ADDR_R = sharpsl->io + FLASHIO; |
192 | this->IO_ADDR_W = FLASHIO; | 168 | this->IO_ADDR_W = sharpsl->io + FLASHIO; |
193 | /* Set address of hardware control function */ | 169 | /* Set address of hardware control function */ |
194 | this->cmd_ctrl = sharpsl_nand_hwcontrol; | 170 | this->cmd_ctrl = sharpsl_nand_hwcontrol; |
195 | this->dev_ready = sharpsl_nand_dev_ready; | 171 | this->dev_ready = sharpsl_nand_dev_ready; |
@@ -199,68 +175,89 @@ static int __init sharpsl_nand_init(void) | |||
199 | this->ecc.mode = NAND_ECC_HW; | 175 | this->ecc.mode = NAND_ECC_HW; |
200 | this->ecc.size = 256; | 176 | this->ecc.size = 256; |
201 | this->ecc.bytes = 3; | 177 | this->ecc.bytes = 3; |
202 | this->badblock_pattern = &sharpsl_bbt; | 178 | this->badblock_pattern = data->badblock_pattern; |
203 | if (machine_is_akita() || machine_is_borzoi()) { | 179 | this->ecc.layout = data->ecc_layout; |
204 | this->badblock_pattern = &sharpsl_akita_bbt; | ||
205 | this->ecc.layout = &akita_oobinfo; | ||
206 | } | ||
207 | this->ecc.hwctl = sharpsl_nand_enable_hwecc; | 180 | this->ecc.hwctl = sharpsl_nand_enable_hwecc; |
208 | this->ecc.calculate = sharpsl_nand_calculate_ecc; | 181 | this->ecc.calculate = sharpsl_nand_calculate_ecc; |
209 | this->ecc.correct = nand_correct_data; | 182 | this->ecc.correct = nand_correct_data; |
210 | 183 | ||
211 | /* Scan to find existence of the device */ | 184 | /* Scan to find existence of the device */ |
212 | err = nand_scan(sharpsl_mtd, 1); | 185 | err = nand_scan(&sharpsl->mtd, 1); |
213 | if (err) { | 186 | if (err) |
214 | iounmap(sharpsl_io_base); | 187 | goto err_scan; |
215 | kfree(sharpsl_mtd); | ||
216 | return err; | ||
217 | } | ||
218 | 188 | ||
219 | /* Register the partitions */ | 189 | /* Register the partitions */ |
220 | sharpsl_mtd->name = "sharpsl-nand"; | 190 | sharpsl->mtd.name = "sharpsl-nand"; |
221 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0); | 191 | #ifdef CONFIG_MTD_PARTITIONS |
222 | 192 | nr_partitions = parse_mtd_partitions(&sharpsl->mtd, part_probes, &sharpsl_partition_info, 0); | |
223 | if (nr_partitions <= 0) { | 193 | if (nr_partitions <= 0) { |
224 | nr_partitions = DEFAULT_NUM_PARTITIONS; | 194 | nr_partitions = data->nr_partitions; |
225 | sharpsl_partition_info = sharpsl_nand_default_partition_info; | 195 | sharpsl_partition_info = data->partitions; |
226 | if (machine_is_poodle()) { | ||
227 | sharpsl_partition_info[1].size = 22 * 1024 * 1024; | ||
228 | } else if (machine_is_corgi() || machine_is_shepherd()) { | ||
229 | sharpsl_partition_info[1].size = 25 * 1024 * 1024; | ||
230 | } else if (machine_is_husky()) { | ||
231 | sharpsl_partition_info[1].size = 53 * 1024 * 1024; | ||
232 | } else if (machine_is_spitz()) { | ||
233 | sharpsl_partition_info[1].size = 5 * 1024 * 1024; | ||
234 | } else if (machine_is_akita()) { | ||
235 | sharpsl_partition_info[1].size = 58 * 1024 * 1024; | ||
236 | } else if (machine_is_borzoi()) { | ||
237 | sharpsl_partition_info[1].size = 32 * 1024 * 1024; | ||
238 | } | ||
239 | } | 196 | } |
240 | 197 | ||
241 | add_mtd_partitions(sharpsl_mtd, sharpsl_partition_info, nr_partitions); | 198 | if (nr_partitions > 0) |
199 | err = add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions); | ||
200 | else | ||
201 | #endif | ||
202 | err = add_mtd_device(&sharpsl->mtd); | ||
203 | if (err) | ||
204 | goto err_add; | ||
242 | 205 | ||
243 | /* Return happy */ | 206 | /* Return happy */ |
244 | return 0; | 207 | return 0; |
245 | } | ||
246 | 208 | ||
247 | module_init(sharpsl_nand_init); | 209 | err_add: |
210 | nand_release(&sharpsl->mtd); | ||
211 | |||
212 | err_scan: | ||
213 | platform_set_drvdata(pdev, NULL); | ||
214 | iounmap(sharpsl->io); | ||
215 | err_ioremap: | ||
216 | err_get_res: | ||
217 | kfree(sharpsl); | ||
218 | return err; | ||
219 | } | ||
248 | 220 | ||
249 | /* | 221 | /* |
250 | * Clean up routine | 222 | * Clean up routine |
251 | */ | 223 | */ |
252 | static void __exit sharpsl_nand_cleanup(void) | 224 | static int __devexit sharpsl_nand_remove(struct platform_device *pdev) |
253 | { | 225 | { |
226 | struct sharpsl_nand *sharpsl = platform_get_drvdata(pdev); | ||
227 | |||
254 | /* Release resources, unregister device */ | 228 | /* Release resources, unregister device */ |
255 | nand_release(sharpsl_mtd); | 229 | nand_release(&sharpsl->mtd); |
256 | 230 | ||
257 | iounmap(sharpsl_io_base); | 231 | platform_set_drvdata(pdev, NULL); |
232 | |||
233 | iounmap(sharpsl->io); | ||
258 | 234 | ||
259 | /* Free the MTD device structure */ | 235 | /* Free the MTD device structure */ |
260 | kfree(sharpsl_mtd); | 236 | kfree(sharpsl); |
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static struct platform_driver sharpsl_nand_driver = { | ||
242 | .driver = { | ||
243 | .name = "sharpsl-nand", | ||
244 | .owner = THIS_MODULE, | ||
245 | }, | ||
246 | .probe = sharpsl_nand_probe, | ||
247 | .remove = __devexit_p(sharpsl_nand_remove), | ||
248 | }; | ||
249 | |||
250 | static int __init sharpsl_nand_init(void) | ||
251 | { | ||
252 | return platform_driver_register(&sharpsl_nand_driver); | ||
261 | } | 253 | } |
254 | module_init(sharpsl_nand_init); | ||
262 | 255 | ||
263 | module_exit(sharpsl_nand_cleanup); | 256 | static void __exit sharpsl_nand_exit(void) |
257 | { | ||
258 | platform_driver_unregister(&sharpsl_nand_driver); | ||
259 | } | ||
260 | module_exit(sharpsl_nand_exit); | ||
264 | 261 | ||
265 | MODULE_LICENSE("GPL"); | 262 | MODULE_LICENSE("GPL"); |
266 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | 263 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); |
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c index edb1e322113d..daa6a4c3b8ce 100644 --- a/drivers/mtd/nand/tmio_nand.c +++ b/drivers/mtd/nand/tmio_nand.c | |||
@@ -433,7 +433,7 @@ static int tmio_probe(struct platform_device *dev) | |||
433 | nand_chip->chip_delay = 15; | 433 | nand_chip->chip_delay = 15; |
434 | 434 | ||
435 | retval = request_irq(irq, &tmio_irq, | 435 | retval = request_irq(irq, &tmio_irq, |
436 | IRQF_DISABLED, dev->dev.bus_id, tmio); | 436 | IRQF_DISABLED, dev_name(&dev->dev), tmio); |
437 | if (retval) { | 437 | if (retval) { |
438 | dev_err(&dev->dev, "request_irq error %d\n", retval); | 438 | dev_err(&dev->dev, "request_irq error %d\n", retval); |
439 | goto err_irq; | 439 | goto err_irq; |
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index 320b929abe79..d1c4546513f7 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -39,7 +39,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
39 | struct NFTLrecord *nftl; | 39 | struct NFTLrecord *nftl; |
40 | unsigned long temp; | 40 | unsigned long temp; |
41 | 41 | ||
42 | if (mtd->type != MTD_NANDFLASH) | 42 | if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) |
43 | return; | 43 | return; |
44 | /* OK, this is moderately ugly. But probably safe. Alternatives? */ | 44 | /* OK, this is moderately ugly. But probably safe. Alternatives? */ |
45 | if (memcmp(mtd->name, "DiskOnChip", 10)) | 45 | if (memcmp(mtd->name, "DiskOnChip", 10)) |
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c index ccc4f209fbb5..8b22b1836e9f 100644 --- a/drivers/mtd/nftlmount.c +++ b/drivers/mtd/nftlmount.c | |||
@@ -51,7 +51,7 @@ static int find_boot_record(struct NFTLrecord *nftl) | |||
51 | the mtd device accordingly. We could even get rid of | 51 | the mtd device accordingly. We could even get rid of |
52 | nftl->EraseSize if there were any point in doing so. */ | 52 | nftl->EraseSize if there were any point in doing so. */ |
53 | nftl->EraseSize = nftl->mbd.mtd->erasesize; | 53 | nftl->EraseSize = nftl->mbd.mtd->erasesize; |
54 | nftl->nb_blocks = nftl->mbd.mtd->size / nftl->EraseSize; | 54 | nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; |
55 | 55 | ||
56 | nftl->MediaUnit = BLOCK_NIL; | 56 | nftl->MediaUnit = BLOCK_NIL; |
57 | nftl->SpareMediaUnit = BLOCK_NIL; | 57 | nftl->SpareMediaUnit = BLOCK_NIL; |
@@ -168,7 +168,7 @@ device is already correct. | |||
168 | printk(KERN_NOTICE "WARNING: Support for NFTL with UnitSizeFactor 0x%02x is experimental\n", | 168 | printk(KERN_NOTICE "WARNING: Support for NFTL with UnitSizeFactor 0x%02x is experimental\n", |
169 | mh->UnitSizeFactor); | 169 | mh->UnitSizeFactor); |
170 | nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor); | 170 | nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor); |
171 | nftl->nb_blocks = nftl->mbd.mtd->size / nftl->EraseSize; | 171 | nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; |
172 | } | 172 | } |
173 | #endif | 173 | #endif |
174 | nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); | 174 | nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); |
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c index ad81ab8e95e2..5b69e7773c6c 100644 --- a/drivers/mtd/onenand/generic.c +++ b/drivers/mtd/onenand/generic.c | |||
@@ -63,7 +63,7 @@ static int __devinit generic_onenand_probe(struct device *dev) | |||
63 | info->onenand.mmcontrol = pdata->mmcontrol; | 63 | info->onenand.mmcontrol = pdata->mmcontrol; |
64 | info->onenand.irq = platform_get_irq(pdev, 0); | 64 | info->onenand.irq = platform_get_irq(pdev, 0); |
65 | 65 | ||
66 | info->mtd.name = pdev->dev.bus_id; | 66 | info->mtd.name = dev_name(&pdev->dev); |
67 | info->mtd.priv = &info->onenand; | 67 | info->mtd.priv = &info->onenand; |
68 | info->mtd.owner = THIS_MODULE; | 68 | info->mtd.owner = THIS_MODULE; |
69 | 69 | ||
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c index d1e0b8e7224b..96ecc1766fa8 100644 --- a/drivers/mtd/onenand/omap2.c +++ b/drivers/mtd/onenand/omap2.c | |||
@@ -668,7 +668,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev) | |||
668 | c->onenand.base); | 668 | c->onenand.base); |
669 | 669 | ||
670 | c->pdev = pdev; | 670 | c->pdev = pdev; |
671 | c->mtd.name = pdev->dev.bus_id; | 671 | c->mtd.name = dev_name(&pdev->dev); |
672 | c->mtd.priv = &c->onenand; | 672 | c->mtd.priv = &c->onenand; |
673 | c->mtd.owner = THIS_MODULE; | 673 | c->mtd.owner = THIS_MODULE; |
674 | 674 | ||
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 90ed319f26e6..529af271db17 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -1772,7 +1772,7 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
1772 | int len; | 1772 | int len; |
1773 | int ret = 0; | 1773 | int ret = 0; |
1774 | 1774 | ||
1775 | DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len); | 1775 | DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%012llx, len = %llu\n", (unsigned long long) instr->addr, (unsigned long long) instr->len); |
1776 | 1776 | ||
1777 | block_size = (1 << this->erase_shift); | 1777 | block_size = (1 << this->erase_shift); |
1778 | 1778 | ||
@@ -1810,7 +1810,7 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
1810 | 1810 | ||
1811 | /* Check if we have a bad block, we do not erase bad blocks */ | 1811 | /* Check if we have a bad block, we do not erase bad blocks */ |
1812 | if (onenand_block_isbad_nolock(mtd, addr, 0)) { | 1812 | if (onenand_block_isbad_nolock(mtd, addr, 0)) { |
1813 | printk (KERN_WARNING "onenand_erase: attempt to erase a bad block at addr 0x%08x\n", (unsigned int) addr); | 1813 | printk (KERN_WARNING "onenand_erase: attempt to erase a bad block at addr 0x%012llx\n", (unsigned long long) addr); |
1814 | instr->state = MTD_ERASE_FAILED; | 1814 | instr->state = MTD_ERASE_FAILED; |
1815 | goto erase_exit; | 1815 | goto erase_exit; |
1816 | } | 1816 | } |
@@ -2029,7 +2029,7 @@ static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int | |||
2029 | * | 2029 | * |
2030 | * Lock one or more blocks | 2030 | * Lock one or more blocks |
2031 | */ | 2031 | */ |
2032 | static int onenand_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 2032 | static int onenand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
2033 | { | 2033 | { |
2034 | int ret; | 2034 | int ret; |
2035 | 2035 | ||
@@ -2047,7 +2047,7 @@ static int onenand_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
2047 | * | 2047 | * |
2048 | * Unlock one or more blocks | 2048 | * Unlock one or more blocks |
2049 | */ | 2049 | */ |
2050 | static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 2050 | static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
2051 | { | 2051 | { |
2052 | int ret; | 2052 | int ret; |
2053 | 2053 | ||
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index e538c0a72abb..d2aa9c46530f 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
@@ -21,8 +21,6 @@ | |||
21 | 21 | ||
22 | #include <asm/types.h> | 22 | #include <asm/types.h> |
23 | 23 | ||
24 | #define const_cpu_to_le16 __constant_cpu_to_le16 | ||
25 | |||
26 | static int block_size = 0; | 24 | static int block_size = 0; |
27 | module_param(block_size, int, 0); | 25 | module_param(block_size, int, 0); |
28 | MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size"); | 26 | MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size"); |
@@ -156,7 +154,7 @@ static int scan_header(struct partition *part) | |||
156 | size_t retlen; | 154 | size_t retlen; |
157 | 155 | ||
158 | sectors_per_block = part->block_size / SECTOR_SIZE; | 156 | sectors_per_block = part->block_size / SECTOR_SIZE; |
159 | part->total_blocks = part->mbd.mtd->size / part->block_size; | 157 | part->total_blocks = (u32)part->mbd.mtd->size / part->block_size; |
160 | 158 | ||
161 | if (part->total_blocks < 2) | 159 | if (part->total_blocks < 2) |
162 | return -ENOENT; | 160 | return -ENOENT; |
@@ -276,16 +274,17 @@ static void erase_callback(struct erase_info *erase) | |||
276 | 274 | ||
277 | part = (struct partition*)erase->priv; | 275 | part = (struct partition*)erase->priv; |
278 | 276 | ||
279 | i = erase->addr / part->block_size; | 277 | i = (u32)erase->addr / part->block_size; |
280 | if (i >= part->total_blocks || part->blocks[i].offset != erase->addr) { | 278 | if (i >= part->total_blocks || part->blocks[i].offset != erase->addr || |
281 | printk(KERN_ERR PREFIX "erase callback for unknown offset %x " | 279 | erase->addr > UINT_MAX) { |
282 | "on '%s'\n", erase->addr, part->mbd.mtd->name); | 280 | printk(KERN_ERR PREFIX "erase callback for unknown offset %llx " |
281 | "on '%s'\n", (unsigned long long)erase->addr, part->mbd.mtd->name); | ||
283 | return; | 282 | return; |
284 | } | 283 | } |
285 | 284 | ||
286 | if (erase->state != MTD_ERASE_DONE) { | 285 | if (erase->state != MTD_ERASE_DONE) { |
287 | printk(KERN_WARNING PREFIX "erase failed at 0x%x on '%s', " | 286 | printk(KERN_WARNING PREFIX "erase failed at 0x%llx on '%s', " |
288 | "state %d\n", erase->addr, | 287 | "state %d\n", (unsigned long long)erase->addr, |
289 | part->mbd.mtd->name, erase->state); | 288 | part->mbd.mtd->name, erase->state); |
290 | 289 | ||
291 | part->blocks[i].state = BLOCK_FAILED; | 290 | part->blocks[i].state = BLOCK_FAILED; |
@@ -297,7 +296,7 @@ static void erase_callback(struct erase_info *erase) | |||
297 | return; | 296 | return; |
298 | } | 297 | } |
299 | 298 | ||
300 | magic = const_cpu_to_le16(RFD_MAGIC); | 299 | magic = cpu_to_le16(RFD_MAGIC); |
301 | 300 | ||
302 | part->blocks[i].state = BLOCK_ERASED; | 301 | part->blocks[i].state = BLOCK_ERASED; |
303 | part->blocks[i].free_sectors = part->data_sectors_per_block; | 302 | part->blocks[i].free_sectors = part->data_sectors_per_block; |
@@ -345,9 +344,9 @@ static int erase_block(struct partition *part, int block) | |||
345 | rc = part->mbd.mtd->erase(part->mbd.mtd, erase); | 344 | rc = part->mbd.mtd->erase(part->mbd.mtd, erase); |
346 | 345 | ||
347 | if (rc) { | 346 | if (rc) { |
348 | printk(KERN_ERR PREFIX "erase of region %x,%x on '%s' " | 347 | printk(KERN_ERR PREFIX "erase of region %llx,%llx on '%s' " |
349 | "failed\n", erase->addr, erase->len, | 348 | "failed\n", (unsigned long long)erase->addr, |
350 | part->mbd.mtd->name); | 349 | (unsigned long long)erase->len, part->mbd.mtd->name); |
351 | kfree(erase); | 350 | kfree(erase); |
352 | } | 351 | } |
353 | 352 | ||
@@ -587,7 +586,7 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr) | |||
587 | int block, offset, rc; | 586 | int block, offset, rc; |
588 | u_long addr; | 587 | u_long addr; |
589 | size_t retlen; | 588 | size_t retlen; |
590 | u16 del = const_cpu_to_le16(SECTOR_DELETED); | 589 | u16 del = cpu_to_le16(SECTOR_DELETED); |
591 | 590 | ||
592 | block = old_addr / part->block_size; | 591 | block = old_addr / part->block_size; |
593 | offset = (old_addr % part->block_size) / SECTOR_SIZE - | 592 | offset = (old_addr % part->block_size) / SECTOR_SIZE - |
@@ -763,7 +762,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
763 | { | 762 | { |
764 | struct partition *part; | 763 | struct partition *part; |
765 | 764 | ||
766 | if (mtd->type != MTD_NORFLASH) | 765 | if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX) |
767 | return; | 766 | return; |
768 | 767 | ||
769 | part = kzalloc(sizeof(struct partition), GFP_KERNEL); | 768 | part = kzalloc(sizeof(struct partition), GFP_KERNEL); |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index 33a5d6ed6f18..3f67e00d98e0 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
@@ -294,7 +294,8 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
294 | int cis_sector; | 294 | int cis_sector; |
295 | 295 | ||
296 | /* Check for small page NAND flash */ | 296 | /* Check for small page NAND flash */ |
297 | if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE) | 297 | if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE || |
298 | mtd->size > UINT_MAX) | ||
298 | return; | 299 | return; |
299 | 300 | ||
300 | /* Check for SSDFC format by reading CIS/IDI sector */ | 301 | /* Check for SSDFC format by reading CIS/IDI sector */ |
@@ -316,7 +317,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
316 | 317 | ||
317 | ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT); | 318 | ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT); |
318 | ssfdc->erase_size = mtd->erasesize; | 319 | ssfdc->erase_size = mtd->erasesize; |
319 | ssfdc->map_len = mtd->size / mtd->erasesize; | 320 | ssfdc->map_len = (u32)mtd->size / mtd->erasesize; |
320 | 321 | ||
321 | DEBUG(MTD_DEBUG_LEVEL1, | 322 | DEBUG(MTD_DEBUG_LEVEL1, |
322 | "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n", | 323 | "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n", |
@@ -327,7 +328,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
327 | ssfdc->heads = 16; | 328 | ssfdc->heads = 16; |
328 | ssfdc->sectors = 32; | 329 | ssfdc->sectors = 32; |
329 | get_chs(mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors); | 330 | get_chs(mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors); |
330 | ssfdc->cylinders = (unsigned short)((mtd->size >> SECTOR_SHIFT) / | 331 | ssfdc->cylinders = (unsigned short)(((u32)mtd->size >> SECTOR_SHIFT) / |
331 | ((long)ssfdc->sectors * (long)ssfdc->heads)); | 332 | ((long)ssfdc->sectors * (long)ssfdc->heads)); |
332 | 333 | ||
333 | DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: using C:%d H:%d S:%d == %ld sects\n", | 334 | DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: using C:%d H:%d S:%d == %ld sects\n", |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index ba0bd3d5775b..9082768cc6c3 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -280,7 +280,7 @@ static int ubi_sysfs_init(struct ubi_device *ubi) | |||
280 | ubi->dev.release = dev_release; | 280 | ubi->dev.release = dev_release; |
281 | ubi->dev.devt = ubi->cdev.dev; | 281 | ubi->dev.devt = ubi->cdev.dev; |
282 | ubi->dev.class = ubi_class; | 282 | ubi->dev.class = ubi_class; |
283 | sprintf(&ubi->dev.bus_id[0], UBI_NAME_STR"%d", ubi->ubi_num); | 283 | dev_set_name(&ubi->dev, UBI_NAME_STR"%d", ubi->ubi_num); |
284 | err = device_register(&ubi->dev); | 284 | err = device_register(&ubi->dev); |
285 | if (err) | 285 | if (err) |
286 | return err; | 286 | return err; |
@@ -561,7 +561,7 @@ static int io_init(struct ubi_device *ubi) | |||
561 | */ | 561 | */ |
562 | 562 | ||
563 | ubi->peb_size = ubi->mtd->erasesize; | 563 | ubi->peb_size = ubi->mtd->erasesize; |
564 | ubi->peb_count = ubi->mtd->size / ubi->mtd->erasesize; | 564 | ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); |
565 | ubi->flash_size = ubi->mtd->size; | 565 | ubi->flash_size = ubi->mtd->size; |
566 | 566 | ||
567 | if (ubi->mtd->block_isbad && ubi->mtd->block_markbad) | 567 | if (ubi->mtd->block_isbad && ubi->mtd->block_markbad) |
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c index 605812bb0b1a..6dd4f5e77f82 100644 --- a/drivers/mtd/ubi/gluebi.c +++ b/drivers/mtd/ubi/gluebi.c | |||
@@ -215,7 +215,8 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
215 | struct ubi_volume *vol; | 215 | struct ubi_volume *vol; |
216 | struct ubi_device *ubi; | 216 | struct ubi_device *ubi; |
217 | 217 | ||
218 | dbg_gen("erase %u bytes at offset %u", instr->len, instr->addr); | 218 | dbg_gen("erase %llu bytes at offset %llu", (unsigned long long)instr->len, |
219 | (unsigned long long)instr->addr); | ||
219 | 220 | ||
220 | if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize) | 221 | if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize) |
221 | return -EINVAL; | 222 | return -EINVAL; |
@@ -223,11 +224,11 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
223 | if (instr->len < 0 || instr->addr + instr->len > mtd->size) | 224 | if (instr->len < 0 || instr->addr + instr->len > mtd->size) |
224 | return -EINVAL; | 225 | return -EINVAL; |
225 | 226 | ||
226 | if (instr->addr % mtd->writesize || instr->len % mtd->writesize) | 227 | if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) |
227 | return -EINVAL; | 228 | return -EINVAL; |
228 | 229 | ||
229 | lnum = instr->addr / mtd->erasesize; | 230 | lnum = mtd_div_by_eb(instr->addr, mtd); |
230 | count = instr->len / mtd->erasesize; | 231 | count = mtd_div_by_eb(instr->len, mtd); |
231 | 232 | ||
232 | vol = container_of(mtd, struct ubi_volume, gluebi_mtd); | 233 | vol = container_of(mtd, struct ubi_volume, gluebi_mtd); |
233 | ubi = vol->ubi; | 234 | ubi = vol->ubi; |
@@ -255,7 +256,7 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
255 | 256 | ||
256 | out_err: | 257 | out_err: |
257 | instr->state = MTD_ERASE_FAILED; | 258 | instr->state = MTD_ERASE_FAILED; |
258 | instr->fail_addr = lnum * mtd->erasesize; | 259 | instr->fail_addr = (long long)lnum * mtd->erasesize; |
259 | return err; | 260 | return err; |
260 | } | 261 | } |
261 | 262 | ||
@@ -294,7 +295,7 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol) | |||
294 | * bytes. | 295 | * bytes. |
295 | */ | 296 | */ |
296 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) | 297 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) |
297 | mtd->size = vol->usable_leb_size * vol->reserved_pebs; | 298 | mtd->size = (long long)vol->usable_leb_size * vol->reserved_pebs; |
298 | else | 299 | else |
299 | mtd->size = vol->used_bytes; | 300 | mtd->size = vol->used_bytes; |
300 | 301 | ||
@@ -304,8 +305,8 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol) | |||
304 | return -ENFILE; | 305 | return -ENFILE; |
305 | } | 306 | } |
306 | 307 | ||
307 | dbg_gen("added mtd%d (\"%s\"), size %u, EB size %u", | 308 | dbg_gen("added mtd%d (\"%s\"), size %llu, EB size %u", |
308 | mtd->index, mtd->name, mtd->size, mtd->erasesize); | 309 | mtd->index, mtd->name, (unsigned long long)mtd->size, mtd->erasesize); |
309 | return 0; | 310 | return 0; |
310 | } | 311 | } |
311 | 312 | ||
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 3531ca9a1e24..22e1d7398fce 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c | |||
@@ -329,7 +329,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
329 | vol->dev.devt = dev; | 329 | vol->dev.devt = dev; |
330 | vol->dev.class = ubi_class; | 330 | vol->dev.class = ubi_class; |
331 | 331 | ||
332 | sprintf(&vol->dev.bus_id[0], "%s_%d", ubi->ubi_name, vol->vol_id); | 332 | dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); |
333 | err = device_register(&vol->dev); | 333 | err = device_register(&vol->dev); |
334 | if (err) { | 334 | if (err) { |
335 | ubi_err("cannot register device"); | 335 | ubi_err("cannot register device"); |
@@ -678,7 +678,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) | |||
678 | vol->dev.parent = &ubi->dev; | 678 | vol->dev.parent = &ubi->dev; |
679 | vol->dev.devt = dev; | 679 | vol->dev.devt = dev; |
680 | vol->dev.class = ubi_class; | 680 | vol->dev.class = ubi_class; |
681 | sprintf(&vol->dev.bus_id[0], "%s_%d", ubi->ubi_name, vol->vol_id); | 681 | dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); |
682 | err = device_register(&vol->dev); | 682 | err = device_register(&vol->dev); |
683 | if (err) | 683 | if (err) |
684 | goto out_gluebi; | 684 | goto out_gluebi; |