diff options
Diffstat (limited to 'drivers/mtd/devices/m25p80.c')
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 56 |
1 files changed, 6 insertions, 50 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 7c60dddbefc0..1924d247c1cb 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -288,9 +288,6 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
288 | __func__, (long long)instr->addr, | 288 | __func__, (long long)instr->addr, |
289 | (long long)instr->len); | 289 | (long long)instr->len); |
290 | 290 | ||
291 | /* sanity checks */ | ||
292 | if (instr->addr + instr->len > flash->mtd.size) | ||
293 | return -EINVAL; | ||
294 | div_u64_rem(instr->len, mtd->erasesize, &rem); | 291 | div_u64_rem(instr->len, mtd->erasesize, &rem); |
295 | if (rem) | 292 | if (rem) |
296 | return -EINVAL; | 293 | return -EINVAL; |
@@ -349,13 +346,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
349 | pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), | 346 | pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), |
350 | __func__, (u32)from, len); | 347 | __func__, (u32)from, len); |
351 | 348 | ||
352 | /* sanity checks */ | ||
353 | if (!len) | ||
354 | return 0; | ||
355 | |||
356 | if (from + len > flash->mtd.size) | ||
357 | return -EINVAL; | ||
358 | |||
359 | spi_message_init(&m); | 349 | spi_message_init(&m); |
360 | memset(t, 0, (sizeof t)); | 350 | memset(t, 0, (sizeof t)); |
361 | 351 | ||
@@ -371,9 +361,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
371 | t[1].len = len; | 361 | t[1].len = len; |
372 | spi_message_add_tail(&t[1], &m); | 362 | spi_message_add_tail(&t[1], &m); |
373 | 363 | ||
374 | /* Byte count starts at zero. */ | ||
375 | *retlen = 0; | ||
376 | |||
377 | mutex_lock(&flash->lock); | 364 | mutex_lock(&flash->lock); |
378 | 365 | ||
379 | /* Wait till previous write/erase is done. */ | 366 | /* Wait till previous write/erase is done. */ |
@@ -417,15 +404,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
417 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), | 404 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), |
418 | __func__, (u32)to, len); | 405 | __func__, (u32)to, len); |
419 | 406 | ||
420 | *retlen = 0; | ||
421 | |||
422 | /* sanity checks */ | ||
423 | if (!len) | ||
424 | return(0); | ||
425 | |||
426 | if (to + len > flash->mtd.size) | ||
427 | return -EINVAL; | ||
428 | |||
429 | spi_message_init(&m); | 407 | spi_message_init(&m); |
430 | memset(t, 0, (sizeof t)); | 408 | memset(t, 0, (sizeof t)); |
431 | 409 | ||
@@ -509,15 +487,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
509 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), | 487 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), |
510 | __func__, (u32)to, len); | 488 | __func__, (u32)to, len); |
511 | 489 | ||
512 | *retlen = 0; | ||
513 | |||
514 | /* sanity checks */ | ||
515 | if (!len) | ||
516 | return 0; | ||
517 | |||
518 | if (to + len > flash->mtd.size) | ||
519 | return -EINVAL; | ||
520 | |||
521 | spi_message_init(&m); | 490 | spi_message_init(&m); |
522 | memset(t, 0, (sizeof t)); | 491 | memset(t, 0, (sizeof t)); |
523 | 492 | ||
@@ -908,14 +877,14 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
908 | flash->mtd.writesize = 1; | 877 | flash->mtd.writesize = 1; |
909 | flash->mtd.flags = MTD_CAP_NORFLASH; | 878 | flash->mtd.flags = MTD_CAP_NORFLASH; |
910 | flash->mtd.size = info->sector_size * info->n_sectors; | 879 | flash->mtd.size = info->sector_size * info->n_sectors; |
911 | flash->mtd.erase = m25p80_erase; | 880 | flash->mtd._erase = m25p80_erase; |
912 | flash->mtd.read = m25p80_read; | 881 | flash->mtd._read = m25p80_read; |
913 | 882 | ||
914 | /* sst flash chips use AAI word program */ | 883 | /* sst flash chips use AAI word program */ |
915 | if (JEDEC_MFR(info->jedec_id) == CFI_MFR_SST) | 884 | if (JEDEC_MFR(info->jedec_id) == CFI_MFR_SST) |
916 | flash->mtd.write = sst_write; | 885 | flash->mtd._write = sst_write; |
917 | else | 886 | else |
918 | flash->mtd.write = m25p80_write; | 887 | flash->mtd._write = m25p80_write; |
919 | 888 | ||
920 | /* prefer "small sector" erase if possible */ | 889 | /* prefer "small sector" erase if possible */ |
921 | if (info->flags & SECT_4K) { | 890 | if (info->flags & SECT_4K) { |
@@ -932,6 +901,7 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
932 | ppdata.of_node = spi->dev.of_node; | 901 | ppdata.of_node = spi->dev.of_node; |
933 | flash->mtd.dev.parent = &spi->dev; | 902 | flash->mtd.dev.parent = &spi->dev; |
934 | flash->page_size = info->page_size; | 903 | flash->page_size = info->page_size; |
904 | flash->mtd.writebufsize = flash->page_size; | ||
935 | 905 | ||
936 | if (info->addr_width) | 906 | if (info->addr_width) |
937 | flash->addr_width = info->addr_width; | 907 | flash->addr_width = info->addr_width; |
@@ -1004,21 +974,7 @@ static struct spi_driver m25p80_driver = { | |||
1004 | */ | 974 | */ |
1005 | }; | 975 | }; |
1006 | 976 | ||
1007 | 977 | module_spi_driver(m25p80_driver); | |
1008 | static int __init m25p80_init(void) | ||
1009 | { | ||
1010 | return spi_register_driver(&m25p80_driver); | ||
1011 | } | ||
1012 | |||
1013 | |||
1014 | static void __exit m25p80_exit(void) | ||
1015 | { | ||
1016 | spi_unregister_driver(&m25p80_driver); | ||
1017 | } | ||
1018 | |||
1019 | |||
1020 | module_init(m25p80_init); | ||
1021 | module_exit(m25p80_exit); | ||
1022 | 978 | ||
1023 | MODULE_LICENSE("GPL"); | 979 | MODULE_LICENSE("GPL"); |
1024 | MODULE_AUTHOR("Mike Lavender"); | 980 | MODULE_AUTHOR("Mike Lavender"); |