diff options
Diffstat (limited to 'drivers/mtd')
37 files changed, 168 insertions, 156 deletions
diff --git a/drivers/mtd/chips/amd_flash.c b/drivers/mtd/chips/amd_flash.c index fdb91b6f1d97..57115618c496 100644 --- a/drivers/mtd/chips/amd_flash.c +++ b/drivers/mtd/chips/amd_flash.c | |||
@@ -664,7 +664,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map) | |||
664 | printk("%s: Probing for AMD compatible flash...\n", map->name); | 664 | printk("%s: Probing for AMD compatible flash...\n", map->name); |
665 | 665 | ||
666 | if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table, | 666 | if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table, |
667 | sizeof(table)/sizeof(table[0]))) | 667 | ARRAY_SIZE(table))) |
668 | == -1) { | 668 | == -1) { |
669 | printk(KERN_WARNING | 669 | printk(KERN_WARNING |
670 | "%s: Found no AMD compatible device at location zero\n", | 670 | "%s: Found no AMD compatible device at location zero\n", |
@@ -696,7 +696,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map) | |||
696 | base += (1 << temp.chipshift)) { | 696 | base += (1 << temp.chipshift)) { |
697 | int numchips = temp.numchips; | 697 | int numchips = temp.numchips; |
698 | table_pos[numchips] = probe_new_chip(mtd, base, chips, | 698 | table_pos[numchips] = probe_new_chip(mtd, base, chips, |
699 | &temp, table, sizeof(table)/sizeof(table[0])); | 699 | &temp, table, ARRAY_SIZE(table)); |
700 | } | 700 | } |
701 | 701 | ||
702 | mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * | 702 | mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * |
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c index edb306c03c0a..517ea33e7260 100644 --- a/drivers/mtd/chips/jedec_probe.c +++ b/drivers/mtd/chips/jedec_probe.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #define MANUFACTURER_MACRONIX 0x00C2 | 34 | #define MANUFACTURER_MACRONIX 0x00C2 |
35 | #define MANUFACTURER_NEC 0x0010 | 35 | #define MANUFACTURER_NEC 0x0010 |
36 | #define MANUFACTURER_PMC 0x009D | 36 | #define MANUFACTURER_PMC 0x009D |
37 | #define MANUFACTURER_SHARP 0x00b0 | ||
37 | #define MANUFACTURER_SST 0x00BF | 38 | #define MANUFACTURER_SST 0x00BF |
38 | #define MANUFACTURER_ST 0x0020 | 39 | #define MANUFACTURER_ST 0x0020 |
39 | #define MANUFACTURER_TOSHIBA 0x0098 | 40 | #define MANUFACTURER_TOSHIBA 0x0098 |
@@ -124,6 +125,9 @@ | |||
124 | #define PM49FL004 0x006E | 125 | #define PM49FL004 0x006E |
125 | #define PM49FL008 0x006A | 126 | #define PM49FL008 0x006A |
126 | 127 | ||
128 | /* Sharp */ | ||
129 | #define LH28F640BF 0x00b0 | ||
130 | |||
127 | /* ST - www.st.com */ | 131 | /* ST - www.st.com */ |
128 | #define M29W800DT 0x00D7 | 132 | #define M29W800DT 0x00D7 |
129 | #define M29W800DB 0x005B | 133 | #define M29W800DB 0x005B |
@@ -1267,6 +1271,19 @@ static const struct amd_flash_info jedec_table[] = { | |||
1267 | .regions = { | 1271 | .regions = { |
1268 | ERASEINFO( 0x01000, 256 ) | 1272 | ERASEINFO( 0x01000, 256 ) |
1269 | } | 1273 | } |
1274 | }, { | ||
1275 | .mfr_id = MANUFACTURER_SHARP, | ||
1276 | .dev_id = LH28F640BF, | ||
1277 | .name = "LH28F640BF", | ||
1278 | .uaddr = { | ||
1279 | [0] = MTD_UADDR_UNNECESSARY, /* x8 */ | ||
1280 | }, | ||
1281 | .DevSize = SIZE_4MiB, | ||
1282 | .CmdSet = P_ID_INTEL_STD, | ||
1283 | .NumEraseRegions= 1, | ||
1284 | .regions = { | ||
1285 | ERASEINFO(0x40000,16), | ||
1286 | } | ||
1270 | }, { | 1287 | }, { |
1271 | .mfr_id = MANUFACTURER_SST, | 1288 | .mfr_id = MANUFACTURER_SST, |
1272 | .dev_id = SST39LF512, | 1289 | .dev_id = SST39LF512, |
@@ -2035,7 +2052,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base, | |||
2035 | DEBUG(MTD_DEBUG_LEVEL3, | 2052 | DEBUG(MTD_DEBUG_LEVEL3, |
2036 | "Search for id:(%02x %02x) interleave(%d) type(%d)\n", | 2053 | "Search for id:(%02x %02x) interleave(%d) type(%d)\n", |
2037 | cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type); | 2054 | cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type); |
2038 | for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) { | 2055 | for (i = 0; i < ARRAY_SIZE(jedec_table); i++) { |
2039 | if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) { | 2056 | if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) { |
2040 | DEBUG( MTD_DEBUG_LEVEL3, | 2057 | DEBUG( MTD_DEBUG_LEVEL3, |
2041 | "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n", | 2058 | "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n", |
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c index 36f61a6a766e..3cc0b23c5865 100644 --- a/drivers/mtd/chips/sharp.c +++ b/drivers/mtd/chips/sharp.c | |||
@@ -64,7 +64,7 @@ | |||
64 | 64 | ||
65 | #undef AUTOUNLOCK /* automatically unlocks blocks before erasing */ | 65 | #undef AUTOUNLOCK /* automatically unlocks blocks before erasing */ |
66 | 66 | ||
67 | struct mtd_info *sharp_probe(struct map_info *); | 67 | static struct mtd_info *sharp_probe(struct map_info *); |
68 | 68 | ||
69 | static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd); | 69 | static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd); |
70 | 70 | ||
@@ -96,7 +96,6 @@ struct sharp_info{ | |||
96 | struct flchip chips[1]; | 96 | struct flchip chips[1]; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | struct mtd_info *sharp_probe(struct map_info *map); | ||
100 | static void sharp_destroy(struct mtd_info *mtd); | 99 | static void sharp_destroy(struct mtd_info *mtd); |
101 | 100 | ||
102 | static struct mtd_chip_driver sharp_chipdrv = { | 101 | static struct mtd_chip_driver sharp_chipdrv = { |
@@ -107,7 +106,7 @@ static struct mtd_chip_driver sharp_chipdrv = { | |||
107 | }; | 106 | }; |
108 | 107 | ||
109 | 108 | ||
110 | struct mtd_info *sharp_probe(struct map_info *map) | 109 | static struct mtd_info *sharp_probe(struct map_info *map) |
111 | { | 110 | { |
112 | struct mtd_info *mtd = NULL; | 111 | struct mtd_info *mtd = NULL; |
113 | struct sharp_info *sharp = NULL; | 112 | struct sharp_info *sharp = NULL; |
@@ -581,7 +580,7 @@ static void sharp_destroy(struct mtd_info *mtd) | |||
581 | 580 | ||
582 | } | 581 | } |
583 | 582 | ||
584 | int __init sharp_probe_init(void) | 583 | static int __init sharp_probe_init(void) |
585 | { | 584 | { |
586 | printk("MTD Sharp chip driver <ds@lineo.com>\n"); | 585 | printk("MTD Sharp chip driver <ds@lineo.com>\n"); |
587 | 586 | ||
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index 6b8bb2e4dcfd..a7a7bfe33879 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c | |||
@@ -42,7 +42,8 @@ | |||
42 | 42 | ||
43 | 43 | ||
44 | /* special size referring to all the remaining space in a partition */ | 44 | /* special size referring to all the remaining space in a partition */ |
45 | #define SIZE_REMAINING 0xffffffff | 45 | #define SIZE_REMAINING UINT_MAX |
46 | #define OFFSET_CONTINUOUS UINT_MAX | ||
46 | 47 | ||
47 | struct cmdline_mtd_partition { | 48 | struct cmdline_mtd_partition { |
48 | struct cmdline_mtd_partition *next; | 49 | struct cmdline_mtd_partition *next; |
@@ -75,7 +76,7 @@ static struct mtd_partition * newpart(char *s, | |||
75 | { | 76 | { |
76 | struct mtd_partition *parts; | 77 | struct mtd_partition *parts; |
77 | unsigned long size; | 78 | unsigned long size; |
78 | unsigned long offset = 0; | 79 | unsigned long offset = OFFSET_CONTINUOUS; |
79 | char *name; | 80 | char *name; |
80 | int name_len; | 81 | int name_len; |
81 | unsigned char *extra_mem; | 82 | unsigned char *extra_mem; |
@@ -314,7 +315,7 @@ static int parse_cmdline_partitions(struct mtd_info *master, | |||
314 | { | 315 | { |
315 | for(i = 0, offset = 0; i < part->num_parts; i++) | 316 | for(i = 0, offset = 0; i < part->num_parts; i++) |
316 | { | 317 | { |
317 | if (!part->parts[i].offset) | 318 | if (part->parts[i].offset == OFFSET_CONTINUOUS) |
318 | part->parts[i].offset = offset; | 319 | part->parts[i].offset = offset; |
319 | else | 320 | else |
320 | offset = part->parts[i].offset; | 321 | offset = part->parts[i].offset; |
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c index 04f864d238db..79f2e1f23ebd 100644 --- a/drivers/mtd/devices/blkmtd.c +++ b/drivers/mtd/devices/blkmtd.c | |||
@@ -28,8 +28,9 @@ | |||
28 | #include <linux/pagemap.h> | 28 | #include <linux/pagemap.h> |
29 | #include <linux/list.h> | 29 | #include <linux/list.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/mount.h> | ||
31 | #include <linux/mtd/mtd.h> | 32 | #include <linux/mtd/mtd.h> |
32 | 33 | #include <linux/mutex.h> | |
33 | 34 | ||
34 | #define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg) | 35 | #define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg) |
35 | #define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg) | 36 | #define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg) |
@@ -46,7 +47,7 @@ struct blkmtd_dev { | |||
46 | struct list_head list; | 47 | struct list_head list; |
47 | struct block_device *blkdev; | 48 | struct block_device *blkdev; |
48 | struct mtd_info mtd_info; | 49 | struct mtd_info mtd_info; |
49 | struct semaphore wrbuf_mutex; | 50 | struct mutex wrbuf_mutex; |
50 | }; | 51 | }; |
51 | 52 | ||
52 | 53 | ||
@@ -268,7 +269,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to, | |||
268 | if(end_len) | 269 | if(end_len) |
269 | pagecnt++; | 270 | pagecnt++; |
270 | 271 | ||
271 | down(&dev->wrbuf_mutex); | 272 | mutex_lock(&dev->wrbuf_mutex); |
272 | 273 | ||
273 | DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n", | 274 | DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n", |
274 | start_len, len, end_len, pagecnt); | 275 | start_len, len, end_len, pagecnt); |
@@ -376,7 +377,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to, | |||
376 | blkmtd_write_out(bio); | 377 | blkmtd_write_out(bio); |
377 | 378 | ||
378 | DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err); | 379 | DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err); |
379 | up(&dev->wrbuf_mutex); | 380 | mutex_unlock(&dev->wrbuf_mutex); |
380 | 381 | ||
381 | if(retlen) | 382 | if(retlen) |
382 | *retlen = thislen; | 383 | *retlen = thislen; |
@@ -614,8 +615,6 @@ static struct mtd_erase_region_info *calc_erase_regions( | |||
614 | } | 615 | } |
615 | 616 | ||
616 | 617 | ||
617 | extern dev_t __init name_to_dev_t(const char *line); | ||
618 | |||
619 | static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size) | 618 | static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size) |
620 | { | 619 | { |
621 | struct block_device *bdev; | 620 | struct block_device *bdev; |
@@ -659,7 +658,7 @@ static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size | |||
659 | memset(dev, 0, sizeof(struct blkmtd_dev)); | 658 | memset(dev, 0, sizeof(struct blkmtd_dev)); |
660 | dev->blkdev = bdev; | 659 | dev->blkdev = bdev; |
661 | if(!readonly) { | 660 | if(!readonly) { |
662 | init_MUTEX(&dev->wrbuf_mutex); | 661 | mutex_init(&dev->wrbuf_mutex); |
663 | } | 662 | } |
664 | 663 | ||
665 | dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; | 664 | dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; |
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 7ff403b2a0a0..4160b8334c53 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/buffer_head.h> | 20 | #include <linux/buffer_head.h> |
21 | #include <linux/mutex.h> | ||
21 | 22 | ||
22 | #define VERSION "$Revision: 1.30 $" | 23 | #define VERSION "$Revision: 1.30 $" |
23 | 24 | ||
@@ -31,7 +32,7 @@ struct block2mtd_dev { | |||
31 | struct list_head list; | 32 | struct list_head list; |
32 | struct block_device *blkdev; | 33 | struct block_device *blkdev; |
33 | struct mtd_info mtd; | 34 | struct mtd_info mtd; |
34 | struct semaphore write_mutex; | 35 | struct mutex write_mutex; |
35 | }; | 36 | }; |
36 | 37 | ||
37 | 38 | ||
@@ -134,9 +135,9 @@ static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
134 | int err; | 135 | int err; |
135 | 136 | ||
136 | instr->state = MTD_ERASING; | 137 | instr->state = MTD_ERASING; |
137 | down(&dev->write_mutex); | 138 | mutex_lock(&dev->write_mutex); |
138 | err = _block2mtd_erase(dev, from, len); | 139 | err = _block2mtd_erase(dev, from, len); |
139 | up(&dev->write_mutex); | 140 | mutex_unlock(&dev->write_mutex); |
140 | if (err) { | 141 | if (err) { |
141 | ERROR("erase failed err = %d", err); | 142 | ERROR("erase failed err = %d", err); |
142 | instr->state = MTD_ERASE_FAILED; | 143 | instr->state = MTD_ERASE_FAILED; |
@@ -249,9 +250,9 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
249 | if (to + len > mtd->size) | 250 | if (to + len > mtd->size) |
250 | len = mtd->size - to; | 251 | len = mtd->size - to; |
251 | 252 | ||
252 | down(&dev->write_mutex); | 253 | mutex_lock(&dev->write_mutex); |
253 | err = _block2mtd_write(dev, buf, to, len, retlen); | 254 | err = _block2mtd_write(dev, buf, to, len, retlen); |
254 | up(&dev->write_mutex); | 255 | mutex_unlock(&dev->write_mutex); |
255 | if (err > 0) | 256 | if (err > 0) |
256 | err = 0; | 257 | err = 0; |
257 | return err; | 258 | return err; |
@@ -310,7 +311,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
310 | goto devinit_err; | 311 | goto devinit_err; |
311 | } | 312 | } |
312 | 313 | ||
313 | init_MUTEX(&dev->write_mutex); | 314 | mutex_init(&dev->write_mutex); |
314 | 315 | ||
315 | /* Setup the MTD structure */ | 316 | /* Setup the MTD structure */ |
316 | /* make the name contain the block device in */ | 317 | /* make the name contain the block device in */ |
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c index e4345cf744a2..23e7a5c7d2c1 100644 --- a/drivers/mtd/devices/doc2000.c +++ b/drivers/mtd/devices/doc2000.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/mutex.h> | ||
23 | 24 | ||
24 | #include <linux/mtd/mtd.h> | 25 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/nand.h> | 26 | #include <linux/mtd/nand.h> |
@@ -605,7 +606,7 @@ static void DoC2k_init(struct mtd_info *mtd) | |||
605 | 606 | ||
606 | this->curfloor = -1; | 607 | this->curfloor = -1; |
607 | this->curchip = -1; | 608 | this->curchip = -1; |
608 | init_MUTEX(&this->lock); | 609 | mutex_init(&this->lock); |
609 | 610 | ||
610 | /* Ident all the chips present. */ | 611 | /* Ident all the chips present. */ |
611 | DoC_ScanChips(this, maxchips); | 612 | DoC_ScanChips(this, maxchips); |
@@ -645,7 +646,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
645 | if (from >= this->totlen) | 646 | if (from >= this->totlen) |
646 | return -EINVAL; | 647 | return -EINVAL; |
647 | 648 | ||
648 | down(&this->lock); | 649 | mutex_lock(&this->lock); |
649 | 650 | ||
650 | *retlen = 0; | 651 | *retlen = 0; |
651 | while (left) { | 652 | while (left) { |
@@ -774,7 +775,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
774 | buf += len; | 775 | buf += len; |
775 | } | 776 | } |
776 | 777 | ||
777 | up(&this->lock); | 778 | mutex_unlock(&this->lock); |
778 | 779 | ||
779 | return ret; | 780 | return ret; |
780 | } | 781 | } |
@@ -803,7 +804,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
803 | if (to >= this->totlen) | 804 | if (to >= this->totlen) |
804 | return -EINVAL; | 805 | return -EINVAL; |
805 | 806 | ||
806 | down(&this->lock); | 807 | mutex_lock(&this->lock); |
807 | 808 | ||
808 | *retlen = 0; | 809 | *retlen = 0; |
809 | while (left) { | 810 | while (left) { |
@@ -873,7 +874,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
873 | printk(KERN_ERR "Error programming flash\n"); | 874 | printk(KERN_ERR "Error programming flash\n"); |
874 | /* Error in programming */ | 875 | /* Error in programming */ |
875 | *retlen = 0; | 876 | *retlen = 0; |
876 | up(&this->lock); | 877 | mutex_unlock(&this->lock); |
877 | return -EIO; | 878 | return -EIO; |
878 | } | 879 | } |
879 | 880 | ||
@@ -935,7 +936,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
935 | printk(KERN_ERR "Error programming flash\n"); | 936 | printk(KERN_ERR "Error programming flash\n"); |
936 | /* Error in programming */ | 937 | /* Error in programming */ |
937 | *retlen = 0; | 938 | *retlen = 0; |
938 | up(&this->lock); | 939 | mutex_unlock(&this->lock); |
939 | return -EIO; | 940 | return -EIO; |
940 | } | 941 | } |
941 | 942 | ||
@@ -956,7 +957,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
956 | 957 | ||
957 | ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x); | 958 | ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x); |
958 | if (ret) { | 959 | if (ret) { |
959 | up(&this->lock); | 960 | mutex_unlock(&this->lock); |
960 | return ret; | 961 | return ret; |
961 | } | 962 | } |
962 | } | 963 | } |
@@ -966,7 +967,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
966 | buf += len; | 967 | buf += len; |
967 | } | 968 | } |
968 | 969 | ||
969 | up(&this->lock); | 970 | mutex_unlock(&this->lock); |
970 | return 0; | 971 | return 0; |
971 | } | 972 | } |
972 | 973 | ||
@@ -975,13 +976,13 @@ static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | |||
975 | u_char *eccbuf, struct nand_oobinfo *oobsel) | 976 | u_char *eccbuf, struct nand_oobinfo *oobsel) |
976 | { | 977 | { |
977 | static char static_buf[512]; | 978 | static char static_buf[512]; |
978 | static DECLARE_MUTEX(writev_buf_sem); | 979 | static DEFINE_MUTEX(writev_buf_mutex); |
979 | 980 | ||
980 | size_t totretlen = 0; | 981 | size_t totretlen = 0; |
981 | size_t thisvecofs = 0; | 982 | size_t thisvecofs = 0; |
982 | int ret= 0; | 983 | int ret= 0; |
983 | 984 | ||
984 | down(&writev_buf_sem); | 985 | mutex_lock(&writev_buf_mutex); |
985 | 986 | ||
986 | while(count) { | 987 | while(count) { |
987 | size_t thislen, thisretlen; | 988 | size_t thislen, thisretlen; |
@@ -1024,7 +1025,7 @@ static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | |||
1024 | to += thislen; | 1025 | to += thislen; |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | up(&writev_buf_sem); | 1028 | mutex_unlock(&writev_buf_mutex); |
1028 | *retlen = totretlen; | 1029 | *retlen = totretlen; |
1029 | return ret; | 1030 | return ret; |
1030 | } | 1031 | } |
@@ -1037,7 +1038,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | |||
1037 | int len256 = 0, ret; | 1038 | int len256 = 0, ret; |
1038 | struct Nand *mychip; | 1039 | struct Nand *mychip; |
1039 | 1040 | ||
1040 | down(&this->lock); | 1041 | mutex_lock(&this->lock); |
1041 | 1042 | ||
1042 | mychip = &this->chips[ofs >> this->chipshift]; | 1043 | mychip = &this->chips[ofs >> this->chipshift]; |
1043 | 1044 | ||
@@ -1083,7 +1084,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | |||
1083 | 1084 | ||
1084 | ret = DoC_WaitReady(this); | 1085 | ret = DoC_WaitReady(this); |
1085 | 1086 | ||
1086 | up(&this->lock); | 1087 | mutex_unlock(&this->lock); |
1087 | return ret; | 1088 | return ret; |
1088 | 1089 | ||
1089 | } | 1090 | } |
@@ -1197,10 +1198,10 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | |||
1197 | struct DiskOnChip *this = mtd->priv; | 1198 | struct DiskOnChip *this = mtd->priv; |
1198 | int ret; | 1199 | int ret; |
1199 | 1200 | ||
1200 | down(&this->lock); | 1201 | mutex_lock(&this->lock); |
1201 | ret = doc_write_oob_nolock(mtd, ofs, len, retlen, buf); | 1202 | ret = doc_write_oob_nolock(mtd, ofs, len, retlen, buf); |
1202 | 1203 | ||
1203 | up(&this->lock); | 1204 | mutex_unlock(&this->lock); |
1204 | return ret; | 1205 | return ret; |
1205 | } | 1206 | } |
1206 | 1207 | ||
@@ -1214,10 +1215,10 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
1214 | struct Nand *mychip; | 1215 | struct Nand *mychip; |
1215 | int status; | 1216 | int status; |
1216 | 1217 | ||
1217 | down(&this->lock); | 1218 | mutex_lock(&this->lock); |
1218 | 1219 | ||
1219 | if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) { | 1220 | if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) { |
1220 | up(&this->lock); | 1221 | mutex_unlock(&this->lock); |
1221 | return -EINVAL; | 1222 | return -EINVAL; |
1222 | } | 1223 | } |
1223 | 1224 | ||
@@ -1265,7 +1266,7 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
1265 | callback: | 1266 | callback: |
1266 | mtd_erase_callback(instr); | 1267 | mtd_erase_callback(instr); |
1267 | 1268 | ||
1268 | up(&this->lock); | 1269 | mutex_unlock(&this->lock); |
1269 | return 0; | 1270 | return 0; |
1270 | } | 1271 | } |
1271 | 1272 | ||
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c index 1e876fcb0408..29b0ddaa324e 100644 --- a/drivers/mtd/devices/lart.c +++ b/drivers/mtd/devices/lart.c | |||
@@ -581,8 +581,6 @@ static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen | |||
581 | 581 | ||
582 | /***************************************************************************************************/ | 582 | /***************************************************************************************************/ |
583 | 583 | ||
584 | #define NB_OF(x) (sizeof (x) / sizeof (x[0])) | ||
585 | |||
586 | static struct mtd_info mtd; | 584 | static struct mtd_info mtd; |
587 | 585 | ||
588 | static struct mtd_erase_region_info erase_regions[] = { | 586 | static struct mtd_erase_region_info erase_regions[] = { |
@@ -640,7 +638,7 @@ int __init lart_flash_init (void) | |||
640 | mtd.flags = MTD_CAP_NORFLASH; | 638 | mtd.flags = MTD_CAP_NORFLASH; |
641 | mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN; | 639 | mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN; |
642 | mtd.erasesize = FLASH_BLOCKSIZE_MAIN; | 640 | mtd.erasesize = FLASH_BLOCKSIZE_MAIN; |
643 | mtd.numeraseregions = NB_OF (erase_regions); | 641 | mtd.numeraseregions = ARRAY_SIZE(erase_regions); |
644 | mtd.eraseregions = erase_regions; | 642 | mtd.eraseregions = erase_regions; |
645 | mtd.erase = flash_erase; | 643 | mtd.erase = flash_erase; |
646 | mtd.read = flash_read; | 644 | mtd.read = flash_read; |
@@ -670,9 +668,9 @@ int __init lart_flash_init (void) | |||
670 | result,mtd.eraseregions[result].numblocks); | 668 | result,mtd.eraseregions[result].numblocks); |
671 | 669 | ||
672 | #ifdef HAVE_PARTITIONS | 670 | #ifdef HAVE_PARTITIONS |
673 | printk ("\npartitions = %d\n",NB_OF (lart_partitions)); | 671 | printk ("\npartitions = %d\n", ARRAY_SIZE(lart_partitions)); |
674 | 672 | ||
675 | for (result = 0; result < NB_OF (lart_partitions); result++) | 673 | for (result = 0; result < ARRAY_SIZE(lart_partitions); result++) |
676 | printk (KERN_DEBUG | 674 | printk (KERN_DEBUG |
677 | "\n\n" | 675 | "\n\n" |
678 | "lart_partitions[%d].name = %s\n" | 676 | "lart_partitions[%d].name = %s\n" |
@@ -687,7 +685,7 @@ int __init lart_flash_init (void) | |||
687 | #ifndef HAVE_PARTITIONS | 685 | #ifndef HAVE_PARTITIONS |
688 | result = add_mtd_device (&mtd); | 686 | result = add_mtd_device (&mtd); |
689 | #else | 687 | #else |
690 | result = add_mtd_partitions (&mtd,lart_partitions,NB_OF (lart_partitions)); | 688 | result = add_mtd_partitions (&mtd,lart_partitions, ARRAY_SIZE(lart_partitions)); |
691 | #endif | 689 | #endif |
692 | 690 | ||
693 | return (result); | 691 | return (result); |
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index d5f24089be71..04e65d5dae00 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -186,7 +186,7 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
186 | struct m25p *flash = mtd_to_m25p(mtd); | 186 | struct m25p *flash = mtd_to_m25p(mtd); |
187 | u32 addr,len; | 187 | u32 addr,len; |
188 | 188 | ||
189 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", | 189 | DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %d\n", |
190 | flash->spi->dev.bus_id, __FUNCTION__, "at", | 190 | flash->spi->dev.bus_id, __FUNCTION__, "at", |
191 | (u32)instr->addr, instr->len); | 191 | (u32)instr->addr, instr->len); |
192 | 192 | ||
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c index 0ff2e4378244..485f663493d2 100644 --- a/drivers/mtd/devices/ms02-nv.c +++ b/drivers/mtd/devices/ms02-nv.c | |||
@@ -308,7 +308,7 @@ static int __init ms02nv_init(void) | |||
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | 310 | ||
311 | for (i = 0; i < (sizeof(ms02nv_addrs) / sizeof(*ms02nv_addrs)); i++) | 311 | for (i = 0; i < ARRAY_SIZE(ms02nv_addrs); i++) |
312 | if (!ms02nv_init_one(ms02nv_addrs[i] << stride)) | 312 | if (!ms02nv_init_one(ms02nv_addrs[i] << stride)) |
313 | count++; | 313 | count++; |
314 | 314 | ||
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index 8a544890173d..a3b92479719d 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -47,9 +47,6 @@ | |||
47 | */ | 47 | */ |
48 | #define MAX_LOOPS 10000 | 48 | #define MAX_LOOPS 10000 |
49 | 49 | ||
50 | extern void INFTL_dumptables(struct INFTLrecord *inftl); | ||
51 | extern void INFTL_dumpVUchains(struct INFTLrecord *inftl); | ||
52 | |||
53 | static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | 50 | static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) |
54 | { | 51 | { |
55 | struct INFTLrecord *inftl; | 52 | struct INFTLrecord *inftl; |
@@ -132,7 +129,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
132 | return; | 129 | return; |
133 | } | 130 | } |
134 | #ifdef PSYCHO_DEBUG | 131 | #ifdef PSYCHO_DEBUG |
135 | printk(KERN_INFO "INFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a'); | 132 | printk(KERN_INFO "INFTL: Found new inftl%c\n", inftl->mbd.devnum + 'a'); |
136 | #endif | 133 | #endif |
137 | return; | 134 | return; |
138 | } | 135 | } |
@@ -885,8 +882,6 @@ static struct mtd_blktrans_ops inftl_tr = { | |||
885 | .owner = THIS_MODULE, | 882 | .owner = THIS_MODULE, |
886 | }; | 883 | }; |
887 | 884 | ||
888 | extern char inftlmountrev[]; | ||
889 | |||
890 | static int __init init_inftl(void) | 885 | static int __init init_inftl(void) |
891 | { | 886 | { |
892 | printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.19 $, " | 887 | printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.19 $, " |
diff --git a/drivers/mtd/maps/alchemy-flash.c b/drivers/mtd/maps/alchemy-flash.c index a57791a6ce40..b933a2a27b18 100644 --- a/drivers/mtd/maps/alchemy-flash.c +++ b/drivers/mtd/maps/alchemy-flash.c | |||
@@ -126,8 +126,6 @@ static struct mtd_partition alchemy_partitions[] = { | |||
126 | } | 126 | } |
127 | }; | 127 | }; |
128 | 128 | ||
129 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
130 | |||
131 | static struct mtd_info *mymtd; | 129 | static struct mtd_info *mymtd; |
132 | 130 | ||
133 | int __init alchemy_mtd_init(void) | 131 | int __init alchemy_mtd_init(void) |
@@ -154,7 +152,7 @@ int __init alchemy_mtd_init(void) | |||
154 | * Static partition definition selection | 152 | * Static partition definition selection |
155 | */ | 153 | */ |
156 | parts = alchemy_partitions; | 154 | parts = alchemy_partitions; |
157 | nb_parts = NB_OF(alchemy_partitions); | 155 | nb_parts = ARRAY_SIZE(alchemy_partitions); |
158 | alchemy_map.size = window_size; | 156 | alchemy_map.size = window_size; |
159 | 157 | ||
160 | /* | 158 | /* |
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c index 6a8c0415bde8..fd0f0d3187de 100644 --- a/drivers/mtd/maps/cfi_flagadm.c +++ b/drivers/mtd/maps/cfi_flagadm.c | |||
@@ -86,7 +86,7 @@ struct mtd_partition flagadm_parts[] = { | |||
86 | } | 86 | } |
87 | }; | 87 | }; |
88 | 88 | ||
89 | #define PARTITION_COUNT (sizeof(flagadm_parts)/sizeof(struct mtd_partition)) | 89 | #define PARTITION_COUNT ARRAY_SIZE(flagadm_parts) |
90 | 90 | ||
91 | static struct mtd_info *mymtd; | 91 | static struct mtd_info *mymtd; |
92 | 92 | ||
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c index 49d90542fc75..652813cd6c2d 100644 --- a/drivers/mtd/maps/dbox2-flash.c +++ b/drivers/mtd/maps/dbox2-flash.c | |||
@@ -57,7 +57,7 @@ static struct mtd_partition partition_info[]= { | |||
57 | } | 57 | } |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #define NUM_PARTITIONS (sizeof(partition_info) / sizeof(partition_info[0])) | 60 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
61 | 61 | ||
62 | #define WINDOW_ADDR 0x10000000 | 62 | #define WINDOW_ADDR 0x10000000 |
63 | #define WINDOW_SIZE 0x800000 | 63 | #define WINDOW_SIZE 0x800000 |
diff --git a/drivers/mtd/maps/dilnetpc.c b/drivers/mtd/maps/dilnetpc.c index efb221692641..c299d10b33e6 100644 --- a/drivers/mtd/maps/dilnetpc.c +++ b/drivers/mtd/maps/dilnetpc.c | |||
@@ -300,7 +300,7 @@ static struct mtd_partition partition_info[]= | |||
300 | }, | 300 | }, |
301 | }; | 301 | }; |
302 | 302 | ||
303 | #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) | 303 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
304 | 304 | ||
305 | static struct mtd_info *mymtd; | 305 | static struct mtd_info *mymtd; |
306 | static struct mtd_info *lowlvl_parts[NUM_PARTITIONS]; | 306 | static struct mtd_info *lowlvl_parts[NUM_PARTITIONS]; |
@@ -345,7 +345,7 @@ static struct mtd_partition higlvl_partition_info[]= | |||
345 | }, | 345 | }, |
346 | }; | 346 | }; |
347 | 347 | ||
348 | #define NUM_HIGHLVL_PARTITIONS (sizeof(higlvl_partition_info)/sizeof(partition_info[0])) | 348 | #define NUM_HIGHLVL_PARTITIONS ARRAY_SIZE(higlvl_partition_info) |
349 | 349 | ||
350 | 350 | ||
351 | static int dnp_adnp_probe(void) | 351 | static int dnp_adnp_probe(void) |
diff --git a/drivers/mtd/maps/dmv182.c b/drivers/mtd/maps/dmv182.c index b993ac01a9a5..2bb3c0f0f970 100644 --- a/drivers/mtd/maps/dmv182.c +++ b/drivers/mtd/maps/dmv182.c | |||
@@ -99,7 +99,7 @@ static struct mtd_info *this_mtd; | |||
99 | static int __init init_svme182(void) | 99 | static int __init init_svme182(void) |
100 | { | 100 | { |
101 | struct mtd_partition *partitions; | 101 | struct mtd_partition *partitions; |
102 | int num_parts = sizeof(svme182_partitions) / sizeof(struct mtd_partition); | 102 | int num_parts = ARRAY_SIZE(svme182_partitions); |
103 | 103 | ||
104 | partitions = svme182_partitions; | 104 | partitions = svme182_partitions; |
105 | 105 | ||
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c index 319094821101..0667101ccbe1 100644 --- a/drivers/mtd/maps/h720x-flash.c +++ b/drivers/mtd/maps/h720x-flash.c | |||
@@ -59,7 +59,7 @@ static struct mtd_partition h720x_partitions[] = { | |||
59 | } | 59 | } |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #define NUM_PARTITIONS (sizeof(h720x_partitions)/sizeof(h720x_partitions[0])) | 62 | #define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions) |
63 | 63 | ||
64 | static int nr_mtd_parts; | 64 | static int nr_mtd_parts; |
65 | static struct mtd_partition *mtd_parts; | 65 | static struct mtd_partition *mtd_parts; |
diff --git a/drivers/mtd/maps/netsc520.c b/drivers/mtd/maps/netsc520.c index 33060a315722..ed215470158b 100644 --- a/drivers/mtd/maps/netsc520.c +++ b/drivers/mtd/maps/netsc520.c | |||
@@ -76,7 +76,7 @@ static struct mtd_partition partition_info[]={ | |||
76 | .size = 0x80000 | 76 | .size = 0x80000 |
77 | }, | 77 | }, |
78 | }; | 78 | }; |
79 | #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) | 79 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
80 | 80 | ||
81 | #define WINDOW_SIZE 0x00100000 | 81 | #define WINDOW_SIZE 0x00100000 |
82 | #define WINDOW_ADDR 0x00200000 | 82 | #define WINDOW_ADDR 0x00200000 |
@@ -88,7 +88,7 @@ static struct map_info netsc520_map = { | |||
88 | .phys = WINDOW_ADDR, | 88 | .phys = WINDOW_ADDR, |
89 | }; | 89 | }; |
90 | 90 | ||
91 | #define NUM_FLASH_BANKS (sizeof(netsc520_map)/sizeof(struct map_info)) | 91 | #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map) |
92 | 92 | ||
93 | static struct mtd_info *mymtd; | 93 | static struct mtd_info *mymtd; |
94 | 94 | ||
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index 632eb2aa968f..54a3102ab19a 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c | |||
@@ -128,8 +128,7 @@ static struct mtd_partition nettel_amd_partitions[] = { | |||
128 | } | 128 | } |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #define NUM_AMD_PARTITIONS \ | 131 | #define NUM_AMD_PARTITIONS ARRAY_SIZE(nettel_amd_partitions) |
132 | (sizeof(nettel_amd_partitions)/sizeof(nettel_amd_partitions[0])) | ||
133 | 132 | ||
134 | /****************************************************************************/ | 133 | /****************************************************************************/ |
135 | 134 | ||
diff --git a/drivers/mtd/maps/ocotea.c b/drivers/mtd/maps/ocotea.c index c223514ca2eb..a21fcd195ab4 100644 --- a/drivers/mtd/maps/ocotea.c +++ b/drivers/mtd/maps/ocotea.c | |||
@@ -58,8 +58,6 @@ static struct mtd_partition ocotea_large_partitions[] = { | |||
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | 60 | ||
61 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
62 | |||
63 | int __init init_ocotea(void) | 61 | int __init init_ocotea(void) |
64 | { | 62 | { |
65 | u8 fpga0_reg; | 63 | u8 fpga0_reg; |
@@ -97,7 +95,7 @@ int __init init_ocotea(void) | |||
97 | if (flash) { | 95 | if (flash) { |
98 | flash->owner = THIS_MODULE; | 96 | flash->owner = THIS_MODULE; |
99 | add_mtd_partitions(flash, ocotea_small_partitions, | 97 | add_mtd_partitions(flash, ocotea_small_partitions, |
100 | NB_OF(ocotea_small_partitions)); | 98 | ARRAY_SIZE(ocotea_small_partitions)); |
101 | } else { | 99 | } else { |
102 | printk("map probe failed for flash\n"); | 100 | printk("map probe failed for flash\n"); |
103 | return -ENXIO; | 101 | return -ENXIO; |
@@ -118,7 +116,7 @@ int __init init_ocotea(void) | |||
118 | if (flash) { | 116 | if (flash) { |
119 | flash->owner = THIS_MODULE; | 117 | flash->owner = THIS_MODULE; |
120 | add_mtd_partitions(flash, ocotea_large_partitions, | 118 | add_mtd_partitions(flash, ocotea_large_partitions, |
121 | NB_OF(ocotea_large_partitions)); | 119 | ARRAY_SIZE(ocotea_large_partitions)); |
122 | } else { | 120 | } else { |
123 | printk("map probe failed for flash\n"); | 121 | printk("map probe failed for flash\n"); |
124 | return -ENXIO; | 122 | return -ENXIO; |
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c index 21822c2edbe4..d2ab1bae9c34 100644 --- a/drivers/mtd/maps/pci.c +++ b/drivers/mtd/maps/pci.c | |||
@@ -334,9 +334,6 @@ mtd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
334 | return 0; | 334 | return 0; |
335 | 335 | ||
336 | release: | 336 | release: |
337 | if (mtd) | ||
338 | map_destroy(mtd); | ||
339 | |||
340 | if (map) { | 337 | if (map) { |
341 | map->exit(dev, map); | 338 | map->exit(dev, map); |
342 | kfree(map); | 339 | kfree(map); |
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index a01e04bf484a..d27f4129afd3 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -610,7 +610,7 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
610 | } else if(mem_type == 2) { | 610 | } else if(mem_type == 2) { |
611 | mtd = do_map_probe("map_rom", &dev->pcmcia_map); | 611 | mtd = do_map_probe("map_rom", &dev->pcmcia_map); |
612 | } else { | 612 | } else { |
613 | for(i = 0; i < sizeof(probes) / sizeof(char *); i++) { | 613 | for(i = 0; i < ARRAY_SIZE(probes); i++) { |
614 | DEBUG(1, "Trying %s", probes[i]); | 614 | DEBUG(1, "Trying %s", probes[i]); |
615 | mtd = do_map_probe(probes[i], &dev->pcmcia_map); | 615 | mtd = do_map_probe(probes[i], &dev->pcmcia_map); |
616 | if(mtd) | 616 | if(mtd) |
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c index 5b76ed886185..50b14033613f 100644 --- a/drivers/mtd/maps/redwood.c +++ b/drivers/mtd/maps/redwood.c | |||
@@ -121,8 +121,7 @@ struct map_info redwood_flash_map = { | |||
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
124 | #define NUM_REDWOOD_FLASH_PARTITIONS \ | 124 | #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions) |
125 | (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0])) | ||
126 | 125 | ||
127 | static struct mtd_info *redwood_mtd; | 126 | static struct mtd_info *redwood_mtd; |
128 | 127 | ||
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c index 225cdd9ba5b2..350286dc1d2e 100644 --- a/drivers/mtd/maps/sbc8240.c +++ b/drivers/mtd/maps/sbc8240.c | |||
@@ -66,7 +66,7 @@ static struct map_info sbc8240_map[2] = { | |||
66 | } | 66 | } |
67 | }; | 67 | }; |
68 | 68 | ||
69 | #define NUM_FLASH_BANKS (sizeof(sbc8240_map) / sizeof(struct map_info)) | 69 | #define NUM_FLASH_BANKS ARRAY_SIZE(sbc8240_map) |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * The following defines the partition layout of SBC8240 boards. | 72 | * The following defines the partition layout of SBC8240 boards. |
@@ -125,8 +125,6 @@ static struct mtd_partition sbc8240_fs_partitions [] = { | |||
125 | } | 125 | } |
126 | }; | 126 | }; |
127 | 127 | ||
128 | #define NB_OF(x) (sizeof (x) / sizeof (x[0])) | ||
129 | |||
130 | /* trivial struct to describe partition information */ | 128 | /* trivial struct to describe partition information */ |
131 | struct mtd_part_def | 129 | struct mtd_part_def |
132 | { | 130 | { |
@@ -190,10 +188,10 @@ int __init init_sbc8240_mtd (void) | |||
190 | #ifdef CONFIG_MTD_PARTITIONS | 188 | #ifdef CONFIG_MTD_PARTITIONS |
191 | sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions; | 189 | sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions; |
192 | sbc8240_part_banks[0].type = "static image"; | 190 | sbc8240_part_banks[0].type = "static image"; |
193 | sbc8240_part_banks[0].nums = NB_OF(sbc8240_uboot_partitions); | 191 | sbc8240_part_banks[0].nums = ARRAY_SIZE(sbc8240_uboot_partitions); |
194 | sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions; | 192 | sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions; |
195 | sbc8240_part_banks[1].type = "static file system"; | 193 | sbc8240_part_banks[1].type = "static file system"; |
196 | sbc8240_part_banks[1].nums = NB_OF(sbc8240_fs_partitions); | 194 | sbc8240_part_banks[1].nums = ARRAY_SIZE(sbc8240_fs_partitions); |
197 | 195 | ||
198 | for (i = 0; i < NUM_FLASH_BANKS; i++) { | 196 | for (i = 0; i < NUM_FLASH_BANKS; i++) { |
199 | 197 | ||
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c index ed92afadd8a9..e8c130e1efd3 100644 --- a/drivers/mtd/maps/sc520cdp.c +++ b/drivers/mtd/maps/sc520cdp.c | |||
@@ -107,7 +107,7 @@ static struct map_info sc520cdp_map[] = { | |||
107 | }, | 107 | }, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | #define NUM_FLASH_BANKS (sizeof(sc520cdp_map)/sizeof(struct map_info)) | 110 | #define NUM_FLASH_BANKS ARRAY_SIZE(sc520cdp_map) |
111 | 111 | ||
112 | static struct mtd_info *mymtd[NUM_FLASH_BANKS]; | 112 | static struct mtd_info *mymtd[NUM_FLASH_BANKS]; |
113 | static struct mtd_info *merged_mtd; | 113 | static struct mtd_info *merged_mtd; |
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c index 2c91dff8bb60..28b8a571a91a 100644 --- a/drivers/mtd/maps/scx200_docflash.c +++ b/drivers/mtd/maps/scx200_docflash.c | |||
@@ -70,7 +70,7 @@ static struct mtd_partition partition_info[] = { | |||
70 | .size = 0x80000 | 70 | .size = 0x80000 |
71 | }, | 71 | }, |
72 | }; | 72 | }; |
73 | #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) | 73 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | 76 | ||
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c index 999f4bb3d845..12fe53c0d2fc 100644 --- a/drivers/mtd/maps/sharpsl-flash.c +++ b/drivers/mtd/maps/sharpsl-flash.c | |||
@@ -49,8 +49,6 @@ static struct mtd_partition sharpsl_partitions[1] = { | |||
49 | } | 49 | } |
50 | }; | 50 | }; |
51 | 51 | ||
52 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
53 | |||
54 | int __init init_sharpsl(void) | 52 | int __init init_sharpsl(void) |
55 | { | 53 | { |
56 | struct mtd_partition *parts; | 54 | struct mtd_partition *parts; |
@@ -92,7 +90,7 @@ int __init init_sharpsl(void) | |||
92 | } | 90 | } |
93 | 91 | ||
94 | parts = sharpsl_partitions; | 92 | parts = sharpsl_partitions; |
95 | nb_parts = NB_OF(sharpsl_partitions); | 93 | nb_parts = ARRAY_SIZE(sharpsl_partitions); |
96 | 94 | ||
97 | printk(KERN_NOTICE "Using %s partision definition\n", part_type); | 95 | printk(KERN_NOTICE "Using %s partision definition\n", part_type); |
98 | add_mtd_partitions(mymtd, parts, nb_parts); | 96 | add_mtd_partitions(mymtd, parts, nb_parts); |
diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c index 4b372bcb17f1..a7422c200567 100644 --- a/drivers/mtd/maps/ts5500_flash.c +++ b/drivers/mtd/maps/ts5500_flash.c | |||
@@ -64,7 +64,7 @@ static struct mtd_partition ts5500_partitions[] = { | |||
64 | } | 64 | } |
65 | }; | 65 | }; |
66 | 66 | ||
67 | #define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition)) | 67 | #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions) |
68 | 68 | ||
69 | static struct mtd_info *mymtd; | 69 | static struct mtd_info *mymtd; |
70 | 70 | ||
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c index 79d92808b766..f7264dc2ac9b 100644 --- a/drivers/mtd/maps/uclinux.c +++ b/drivers/mtd/maps/uclinux.c | |||
@@ -37,7 +37,7 @@ struct mtd_partition uclinux_romfs[] = { | |||
37 | { .name = "ROMfs" } | 37 | { .name = "ROMfs" } |
38 | }; | 38 | }; |
39 | 39 | ||
40 | #define NUM_PARTITIONS (sizeof(uclinux_romfs) / sizeof(uclinux_romfs[0])) | 40 | #define NUM_PARTITIONS ARRAY_SIZE(uclinux_romfs) |
41 | 41 | ||
42 | /****************************************************************************/ | 42 | /****************************************************************************/ |
43 | 43 | ||
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c index e0063941c0df..b3e487395435 100644 --- a/drivers/mtd/maps/vmax301.c +++ b/drivers/mtd/maps/vmax301.c | |||
@@ -182,7 +182,7 @@ int __init init_vmax301(void) | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | if (!vmax_mtd[1] && !vmax_mtd[2]) { | 185 | if (!vmax_mtd[0] && !vmax_mtd[1]) { |
186 | iounmap((void *)iomapadr); | 186 | iounmap((void *)iomapadr); |
187 | return -ENXIO; | 187 | return -ENXIO; |
188 | } | 188 | } |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 840dd66ce2dc..458d3c8ae1ee 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -19,12 +19,12 @@ | |||
19 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
20 | #include <linux/hdreg.h> | 20 | #include <linux/hdreg.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <asm/semaphore.h> | 22 | #include <linux/mutex.h> |
23 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
24 | 24 | ||
25 | static LIST_HEAD(blktrans_majors); | 25 | static LIST_HEAD(blktrans_majors); |
26 | 26 | ||
27 | extern struct semaphore mtd_table_mutex; | 27 | extern struct mutex mtd_table_mutex; |
28 | extern struct mtd_info *mtd_table[]; | 28 | extern struct mtd_info *mtd_table[]; |
29 | 29 | ||
30 | struct mtd_blkcore_priv { | 30 | struct mtd_blkcore_priv { |
@@ -122,9 +122,9 @@ static int mtd_blktrans_thread(void *arg) | |||
122 | 122 | ||
123 | spin_unlock_irq(rq->queue_lock); | 123 | spin_unlock_irq(rq->queue_lock); |
124 | 124 | ||
125 | down(&dev->sem); | 125 | mutex_lock(&dev->lock); |
126 | res = do_blktrans_request(tr, dev, req); | 126 | res = do_blktrans_request(tr, dev, req); |
127 | up(&dev->sem); | 127 | mutex_unlock(&dev->lock); |
128 | 128 | ||
129 | spin_lock_irq(rq->queue_lock); | 129 | spin_lock_irq(rq->queue_lock); |
130 | 130 | ||
@@ -235,8 +235,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
235 | int last_devnum = -1; | 235 | int last_devnum = -1; |
236 | struct gendisk *gd; | 236 | struct gendisk *gd; |
237 | 237 | ||
238 | if (!down_trylock(&mtd_table_mutex)) { | 238 | if (!!mutex_trylock(&mtd_table_mutex)) { |
239 | up(&mtd_table_mutex); | 239 | mutex_unlock(&mtd_table_mutex); |
240 | BUG(); | 240 | BUG(); |
241 | } | 241 | } |
242 | 242 | ||
@@ -267,7 +267,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
267 | return -EBUSY; | 267 | return -EBUSY; |
268 | } | 268 | } |
269 | 269 | ||
270 | init_MUTEX(&new->sem); | 270 | mutex_init(&new->lock); |
271 | list_add_tail(&new->list, &tr->devs); | 271 | list_add_tail(&new->list, &tr->devs); |
272 | added: | 272 | added: |
273 | if (!tr->writesect) | 273 | if (!tr->writesect) |
@@ -313,8 +313,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
313 | 313 | ||
314 | int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) | 314 | int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) |
315 | { | 315 | { |
316 | if (!down_trylock(&mtd_table_mutex)) { | 316 | if (!!mutex_trylock(&mtd_table_mutex)) { |
317 | up(&mtd_table_mutex); | 317 | mutex_unlock(&mtd_table_mutex); |
318 | BUG(); | 318 | BUG(); |
319 | } | 319 | } |
320 | 320 | ||
@@ -378,14 +378,14 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
378 | 378 | ||
379 | memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); | 379 | memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); |
380 | 380 | ||
381 | down(&mtd_table_mutex); | 381 | mutex_lock(&mtd_table_mutex); |
382 | 382 | ||
383 | ret = register_blkdev(tr->major, tr->name); | 383 | ret = register_blkdev(tr->major, tr->name); |
384 | if (ret) { | 384 | if (ret) { |
385 | printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n", | 385 | printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n", |
386 | tr->name, tr->major, ret); | 386 | tr->name, tr->major, ret); |
387 | kfree(tr->blkcore_priv); | 387 | kfree(tr->blkcore_priv); |
388 | up(&mtd_table_mutex); | 388 | mutex_unlock(&mtd_table_mutex); |
389 | return ret; | 389 | return ret; |
390 | } | 390 | } |
391 | spin_lock_init(&tr->blkcore_priv->queue_lock); | 391 | spin_lock_init(&tr->blkcore_priv->queue_lock); |
@@ -396,7 +396,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
396 | if (!tr->blkcore_priv->rq) { | 396 | if (!tr->blkcore_priv->rq) { |
397 | unregister_blkdev(tr->major, tr->name); | 397 | unregister_blkdev(tr->major, tr->name); |
398 | kfree(tr->blkcore_priv); | 398 | kfree(tr->blkcore_priv); |
399 | up(&mtd_table_mutex); | 399 | mutex_unlock(&mtd_table_mutex); |
400 | return -ENOMEM; | 400 | return -ENOMEM; |
401 | } | 401 | } |
402 | 402 | ||
@@ -407,7 +407,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
407 | blk_cleanup_queue(tr->blkcore_priv->rq); | 407 | blk_cleanup_queue(tr->blkcore_priv->rq); |
408 | unregister_blkdev(tr->major, tr->name); | 408 | unregister_blkdev(tr->major, tr->name); |
409 | kfree(tr->blkcore_priv); | 409 | kfree(tr->blkcore_priv); |
410 | up(&mtd_table_mutex); | 410 | mutex_unlock(&mtd_table_mutex); |
411 | return ret; | 411 | return ret; |
412 | } | 412 | } |
413 | 413 | ||
@@ -419,7 +419,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
419 | tr->add_mtd(tr, mtd_table[i]); | 419 | tr->add_mtd(tr, mtd_table[i]); |
420 | } | 420 | } |
421 | 421 | ||
422 | up(&mtd_table_mutex); | 422 | mutex_unlock(&mtd_table_mutex); |
423 | 423 | ||
424 | return 0; | 424 | return 0; |
425 | } | 425 | } |
@@ -428,7 +428,7 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
428 | { | 428 | { |
429 | struct list_head *this, *next; | 429 | struct list_head *this, *next; |
430 | 430 | ||
431 | down(&mtd_table_mutex); | 431 | mutex_lock(&mtd_table_mutex); |
432 | 432 | ||
433 | /* Clean up the kernel thread */ | 433 | /* Clean up the kernel thread */ |
434 | tr->blkcore_priv->exiting = 1; | 434 | tr->blkcore_priv->exiting = 1; |
@@ -446,7 +446,7 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
446 | blk_cleanup_queue(tr->blkcore_priv->rq); | 446 | blk_cleanup_queue(tr->blkcore_priv->rq); |
447 | unregister_blkdev(tr->major, tr->name); | 447 | unregister_blkdev(tr->major, tr->name); |
448 | 448 | ||
449 | up(&mtd_table_mutex); | 449 | mutex_unlock(&mtd_table_mutex); |
450 | 450 | ||
451 | kfree(tr->blkcore_priv); | 451 | kfree(tr->blkcore_priv); |
452 | 452 | ||
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index e84756644fd1..2cef280e388c 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c | |||
@@ -19,11 +19,13 @@ | |||
19 | 19 | ||
20 | #include <linux/mtd/mtd.h> | 20 | #include <linux/mtd/mtd.h> |
21 | #include <linux/mtd/blktrans.h> | 21 | #include <linux/mtd/blktrans.h> |
22 | #include <linux/mutex.h> | ||
23 | |||
22 | 24 | ||
23 | static struct mtdblk_dev { | 25 | static struct mtdblk_dev { |
24 | struct mtd_info *mtd; | 26 | struct mtd_info *mtd; |
25 | int count; | 27 | int count; |
26 | struct semaphore cache_sem; | 28 | struct mutex cache_mutex; |
27 | unsigned char *cache_data; | 29 | unsigned char *cache_data; |
28 | unsigned long cache_offset; | 30 | unsigned long cache_offset; |
29 | unsigned int cache_size; | 31 | unsigned int cache_size; |
@@ -284,7 +286,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd) | |||
284 | mtdblk->count = 1; | 286 | mtdblk->count = 1; |
285 | mtdblk->mtd = mtd; | 287 | mtdblk->mtd = mtd; |
286 | 288 | ||
287 | init_MUTEX (&mtdblk->cache_sem); | 289 | mutex_init(&mtdblk->cache_mutex); |
288 | mtdblk->cache_state = STATE_EMPTY; | 290 | mtdblk->cache_state = STATE_EMPTY; |
289 | if ((mtdblk->mtd->flags & MTD_CAP_RAM) != MTD_CAP_RAM && | 291 | if ((mtdblk->mtd->flags & MTD_CAP_RAM) != MTD_CAP_RAM && |
290 | mtdblk->mtd->erasesize) { | 292 | mtdblk->mtd->erasesize) { |
@@ -306,9 +308,9 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd) | |||
306 | 308 | ||
307 | DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); | 309 | DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); |
308 | 310 | ||
309 | down(&mtdblk->cache_sem); | 311 | mutex_lock(&mtdblk->cache_mutex); |
310 | write_cached_data(mtdblk); | 312 | write_cached_data(mtdblk); |
311 | up(&mtdblk->cache_sem); | 313 | mutex_unlock(&mtdblk->cache_mutex); |
312 | 314 | ||
313 | if (!--mtdblk->count) { | 315 | if (!--mtdblk->count) { |
314 | /* It was the last usage. Free the device */ | 316 | /* It was the last usage. Free the device */ |
@@ -327,9 +329,9 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev) | |||
327 | { | 329 | { |
328 | struct mtdblk_dev *mtdblk = mtdblks[dev->devnum]; | 330 | struct mtdblk_dev *mtdblk = mtdblks[dev->devnum]; |
329 | 331 | ||
330 | down(&mtdblk->cache_sem); | 332 | mutex_lock(&mtdblk->cache_mutex); |
331 | write_cached_data(mtdblk); | 333 | write_cached_data(mtdblk); |
332 | up(&mtdblk->cache_sem); | 334 | mutex_unlock(&mtdblk->cache_mutex); |
333 | 335 | ||
334 | if (mtdblk->mtd->sync) | 336 | if (mtdblk->mtd->sync) |
335 | mtdblk->mtd->sync(mtdblk->mtd); | 337 | mtdblk->mtd->sync(mtdblk->mtd); |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index dade02ab0687..9905870f56e5 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -19,15 +19,13 @@ | |||
19 | #include <linux/ioctl.h> | 19 | #include <linux/ioctl.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/mtd/compatmac.h> | 21 | #include <linux/mtd/compatmac.h> |
22 | #ifdef CONFIG_PROC_FS | ||
23 | #include <linux/proc_fs.h> | 22 | #include <linux/proc_fs.h> |
24 | #endif | ||
25 | 23 | ||
26 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
27 | 25 | ||
28 | /* These are exported solely for the purpose of mtd_blkdevs.c. You | 26 | /* These are exported solely for the purpose of mtd_blkdevs.c. You |
29 | should not use them for _anything_ else */ | 27 | should not use them for _anything_ else */ |
30 | DECLARE_MUTEX(mtd_table_mutex); | 28 | DEFINE_MUTEX(mtd_table_mutex); |
31 | struct mtd_info *mtd_table[MAX_MTD_DEVICES]; | 29 | struct mtd_info *mtd_table[MAX_MTD_DEVICES]; |
32 | 30 | ||
33 | EXPORT_SYMBOL_GPL(mtd_table_mutex); | 31 | EXPORT_SYMBOL_GPL(mtd_table_mutex); |
@@ -49,7 +47,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
49 | { | 47 | { |
50 | int i; | 48 | int i; |
51 | 49 | ||
52 | down(&mtd_table_mutex); | 50 | mutex_lock(&mtd_table_mutex); |
53 | 51 | ||
54 | for (i=0; i < MAX_MTD_DEVICES; i++) | 52 | for (i=0; i < MAX_MTD_DEVICES; i++) |
55 | if (!mtd_table[i]) { | 53 | if (!mtd_table[i]) { |
@@ -67,7 +65,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
67 | not->add(mtd); | 65 | not->add(mtd); |
68 | } | 66 | } |
69 | 67 | ||
70 | up(&mtd_table_mutex); | 68 | mutex_unlock(&mtd_table_mutex); |
71 | /* We _know_ we aren't being removed, because | 69 | /* We _know_ we aren't being removed, because |
72 | our caller is still holding us here. So none | 70 | our caller is still holding us here. So none |
73 | of this try_ nonsense, and no bitching about it | 71 | of this try_ nonsense, and no bitching about it |
@@ -76,7 +74,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
76 | return 0; | 74 | return 0; |
77 | } | 75 | } |
78 | 76 | ||
79 | up(&mtd_table_mutex); | 77 | mutex_unlock(&mtd_table_mutex); |
80 | return 1; | 78 | return 1; |
81 | } | 79 | } |
82 | 80 | ||
@@ -94,7 +92,7 @@ int del_mtd_device (struct mtd_info *mtd) | |||
94 | { | 92 | { |
95 | int ret; | 93 | int ret; |
96 | 94 | ||
97 | down(&mtd_table_mutex); | 95 | mutex_lock(&mtd_table_mutex); |
98 | 96 | ||
99 | if (mtd_table[mtd->index] != mtd) { | 97 | if (mtd_table[mtd->index] != mtd) { |
100 | ret = -ENODEV; | 98 | ret = -ENODEV; |
@@ -118,7 +116,7 @@ int del_mtd_device (struct mtd_info *mtd) | |||
118 | ret = 0; | 116 | ret = 0; |
119 | } | 117 | } |
120 | 118 | ||
121 | up(&mtd_table_mutex); | 119 | mutex_unlock(&mtd_table_mutex); |
122 | return ret; | 120 | return ret; |
123 | } | 121 | } |
124 | 122 | ||
@@ -135,7 +133,7 @@ void register_mtd_user (struct mtd_notifier *new) | |||
135 | { | 133 | { |
136 | int i; | 134 | int i; |
137 | 135 | ||
138 | down(&mtd_table_mutex); | 136 | mutex_lock(&mtd_table_mutex); |
139 | 137 | ||
140 | list_add(&new->list, &mtd_notifiers); | 138 | list_add(&new->list, &mtd_notifiers); |
141 | 139 | ||
@@ -145,7 +143,7 @@ void register_mtd_user (struct mtd_notifier *new) | |||
145 | if (mtd_table[i]) | 143 | if (mtd_table[i]) |
146 | new->add(mtd_table[i]); | 144 | new->add(mtd_table[i]); |
147 | 145 | ||
148 | up(&mtd_table_mutex); | 146 | mutex_unlock(&mtd_table_mutex); |
149 | } | 147 | } |
150 | 148 | ||
151 | /** | 149 | /** |
@@ -162,7 +160,7 @@ int unregister_mtd_user (struct mtd_notifier *old) | |||
162 | { | 160 | { |
163 | int i; | 161 | int i; |
164 | 162 | ||
165 | down(&mtd_table_mutex); | 163 | mutex_lock(&mtd_table_mutex); |
166 | 164 | ||
167 | module_put(THIS_MODULE); | 165 | module_put(THIS_MODULE); |
168 | 166 | ||
@@ -171,7 +169,7 @@ int unregister_mtd_user (struct mtd_notifier *old) | |||
171 | old->remove(mtd_table[i]); | 169 | old->remove(mtd_table[i]); |
172 | 170 | ||
173 | list_del(&old->list); | 171 | list_del(&old->list); |
174 | up(&mtd_table_mutex); | 172 | mutex_unlock(&mtd_table_mutex); |
175 | return 0; | 173 | return 0; |
176 | } | 174 | } |
177 | 175 | ||
@@ -193,7 +191,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) | |||
193 | struct mtd_info *ret = NULL; | 191 | struct mtd_info *ret = NULL; |
194 | int i; | 192 | int i; |
195 | 193 | ||
196 | down(&mtd_table_mutex); | 194 | mutex_lock(&mtd_table_mutex); |
197 | 195 | ||
198 | if (num == -1) { | 196 | if (num == -1) { |
199 | for (i=0; i< MAX_MTD_DEVICES; i++) | 197 | for (i=0; i< MAX_MTD_DEVICES; i++) |
@@ -211,7 +209,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) | |||
211 | if (ret) | 209 | if (ret) |
212 | ret->usecount++; | 210 | ret->usecount++; |
213 | 211 | ||
214 | up(&mtd_table_mutex); | 212 | mutex_unlock(&mtd_table_mutex); |
215 | return ret; | 213 | return ret; |
216 | } | 214 | } |
217 | 215 | ||
@@ -219,9 +217,9 @@ void put_mtd_device(struct mtd_info *mtd) | |||
219 | { | 217 | { |
220 | int c; | 218 | int c; |
221 | 219 | ||
222 | down(&mtd_table_mutex); | 220 | mutex_lock(&mtd_table_mutex); |
223 | c = --mtd->usecount; | 221 | c = --mtd->usecount; |
224 | up(&mtd_table_mutex); | 222 | mutex_unlock(&mtd_table_mutex); |
225 | BUG_ON(c < 0); | 223 | BUG_ON(c < 0); |
226 | 224 | ||
227 | module_put(mtd->owner); | 225 | module_put(mtd->owner); |
@@ -296,10 +294,11 @@ EXPORT_SYMBOL(unregister_mtd_user); | |||
296 | EXPORT_SYMBOL(default_mtd_writev); | 294 | EXPORT_SYMBOL(default_mtd_writev); |
297 | EXPORT_SYMBOL(default_mtd_readv); | 295 | EXPORT_SYMBOL(default_mtd_readv); |
298 | 296 | ||
297 | #ifdef CONFIG_PROC_FS | ||
298 | |||
299 | /*====================================================================*/ | 299 | /*====================================================================*/ |
300 | /* Support for /proc/mtd */ | 300 | /* Support for /proc/mtd */ |
301 | 301 | ||
302 | #ifdef CONFIG_PROC_FS | ||
303 | static struct proc_dir_entry *proc_mtd; | 302 | static struct proc_dir_entry *proc_mtd; |
304 | 303 | ||
305 | static inline int mtd_proc_info (char *buf, int i) | 304 | static inline int mtd_proc_info (char *buf, int i) |
@@ -319,7 +318,7 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count, | |||
319 | int len, l, i; | 318 | int len, l, i; |
320 | off_t begin = 0; | 319 | off_t begin = 0; |
321 | 320 | ||
322 | down(&mtd_table_mutex); | 321 | mutex_lock(&mtd_table_mutex); |
323 | 322 | ||
324 | len = sprintf(page, "dev: size erasesize name\n"); | 323 | len = sprintf(page, "dev: size erasesize name\n"); |
325 | for (i=0; i< MAX_MTD_DEVICES; i++) { | 324 | for (i=0; i< MAX_MTD_DEVICES; i++) { |
@@ -337,38 +336,34 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count, | |||
337 | *eof = 1; | 336 | *eof = 1; |
338 | 337 | ||
339 | done: | 338 | done: |
340 | up(&mtd_table_mutex); | 339 | mutex_unlock(&mtd_table_mutex); |
341 | if (off >= len+begin) | 340 | if (off >= len+begin) |
342 | return 0; | 341 | return 0; |
343 | *start = page + (off-begin); | 342 | *start = page + (off-begin); |
344 | return ((count < begin+len-off) ? count : begin+len-off); | 343 | return ((count < begin+len-off) ? count : begin+len-off); |
345 | } | 344 | } |
346 | 345 | ||
347 | #endif /* CONFIG_PROC_FS */ | ||
348 | |||
349 | /*====================================================================*/ | 346 | /*====================================================================*/ |
350 | /* Init code */ | 347 | /* Init code */ |
351 | 348 | ||
352 | static int __init init_mtd(void) | 349 | static int __init init_mtd(void) |
353 | { | 350 | { |
354 | #ifdef CONFIG_PROC_FS | ||
355 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) | 351 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) |
356 | proc_mtd->read_proc = mtd_read_proc; | 352 | proc_mtd->read_proc = mtd_read_proc; |
357 | #endif | ||
358 | return 0; | 353 | return 0; |
359 | } | 354 | } |
360 | 355 | ||
361 | static void __exit cleanup_mtd(void) | 356 | static void __exit cleanup_mtd(void) |
362 | { | 357 | { |
363 | #ifdef CONFIG_PROC_FS | ||
364 | if (proc_mtd) | 358 | if (proc_mtd) |
365 | remove_proc_entry( "mtd", NULL); | 359 | remove_proc_entry( "mtd", NULL); |
366 | #endif | ||
367 | } | 360 | } |
368 | 361 | ||
369 | module_init(init_mtd); | 362 | module_init(init_mtd); |
370 | module_exit(cleanup_mtd); | 363 | module_exit(cleanup_mtd); |
371 | 364 | ||
365 | #endif /* CONFIG_PROC_FS */ | ||
366 | |||
372 | 367 | ||
373 | MODULE_LICENSE("GPL"); | 368 | MODULE_LICENSE("GPL"); |
374 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); | 369 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); |
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index 1fc4c134d939..cfe288a6e853 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -178,17 +178,16 @@ config MTD_NAND_DISKONCHIP_BBTWRITE | |||
178 | Even if you leave this disabled, you can enable BBT writes at module | 178 | Even if you leave this disabled, you can enable BBT writes at module |
179 | load time (assuming you build diskonchip as a module) with the module | 179 | load time (assuming you build diskonchip as a module) with the module |
180 | parameter "inftl_bbt_write=1". | 180 | parameter "inftl_bbt_write=1". |
181 | |||
182 | config MTD_NAND_SHARPSL | ||
183 | bool "Support for NAND Flash on Sharp SL Series (C7xx + others)" | ||
184 | depends on MTD_NAND && ARCH_PXA | ||
185 | |||
186 | config MTD_NAND_NANDSIM | ||
187 | bool "Support for NAND Flash Simulator" | ||
188 | depends on MTD_NAND && MTD_PARTITIONS | ||
189 | 181 | ||
182 | config MTD_NAND_SHARPSL | ||
183 | tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)" | ||
184 | depends on MTD_NAND && ARCH_PXA | ||
185 | |||
186 | config MTD_NAND_NANDSIM | ||
187 | tristate "Support for NAND Flash Simulator" | ||
188 | depends on MTD_NAND && MTD_PARTITIONS | ||
190 | help | 189 | help |
191 | The simulator may simulate verious NAND flash chips for the | 190 | The simulator may simulate verious NAND flash chips for the |
192 | MTD nand layer. | 191 | MTD nand layer. |
193 | 192 | ||
194 | endmenu | 193 | endmenu |
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index 201e1362da14..bde3550910a2 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c | |||
@@ -55,8 +55,6 @@ static const struct mtd_partition partition_info[] = { | |||
55 | .size = MTDPART_SIZ_FULL | 55 | .size = MTDPART_SIZ_FULL |
56 | } | 56 | } |
57 | }; | 57 | }; |
58 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
59 | |||
60 | 58 | ||
61 | /** | 59 | /** |
62 | * au_read_byte - read one byte from the chip | 60 | * au_read_byte - read one byte from the chip |
@@ -462,7 +460,7 @@ int __init au1xxx_nand_init (void) | |||
462 | } | 460 | } |
463 | 461 | ||
464 | /* Register the partitions */ | 462 | /* Register the partitions */ |
465 | add_mtd_partitions(au1550_mtd, partition_info, NB_OF(partition_info)); | 463 | add_mtd_partitions(au1550_mtd, partition_info, ARRAY_SIZE(partition_info)); |
466 | 464 | ||
467 | return 0; | 465 | return 0; |
468 | 466 | ||
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 5d222460b42a..95e96fa1fceb 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/mtd/compatmac.h> | 80 | #include <linux/mtd/compatmac.h> |
81 | #include <linux/interrupt.h> | 81 | #include <linux/interrupt.h> |
82 | #include <linux/bitops.h> | 82 | #include <linux/bitops.h> |
83 | #include <linux/leds.h> | ||
83 | #include <asm/io.h> | 84 | #include <asm/io.h> |
84 | 85 | ||
85 | #ifdef CONFIG_MTD_PARTITIONS | 86 | #ifdef CONFIG_MTD_PARTITIONS |
@@ -515,6 +516,8 @@ static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, i | |||
515 | return nand_isbad_bbt (mtd, ofs, allowbbt); | 516 | return nand_isbad_bbt (mtd, ofs, allowbbt); |
516 | } | 517 | } |
517 | 518 | ||
519 | DEFINE_LED_TRIGGER(nand_led_trigger); | ||
520 | |||
518 | /* | 521 | /* |
519 | * Wait for the ready pin, after a command | 522 | * Wait for the ready pin, after a command |
520 | * The timeout is catched later. | 523 | * The timeout is catched later. |
@@ -524,12 +527,14 @@ static void nand_wait_ready(struct mtd_info *mtd) | |||
524 | struct nand_chip *this = mtd->priv; | 527 | struct nand_chip *this = mtd->priv; |
525 | unsigned long timeo = jiffies + 2; | 528 | unsigned long timeo = jiffies + 2; |
526 | 529 | ||
530 | led_trigger_event(nand_led_trigger, LED_FULL); | ||
527 | /* wait until command is processed or timeout occures */ | 531 | /* wait until command is processed or timeout occures */ |
528 | do { | 532 | do { |
529 | if (this->dev_ready(mtd)) | 533 | if (this->dev_ready(mtd)) |
530 | return; | 534 | break; |
531 | touch_softlockup_watchdog(); | 535 | touch_softlockup_watchdog(); |
532 | } while (time_before(jiffies, timeo)); | 536 | } while (time_before(jiffies, timeo)); |
537 | led_trigger_event(nand_led_trigger, LED_OFF); | ||
533 | } | 538 | } |
534 | 539 | ||
535 | /** | 540 | /** |
@@ -817,6 +822,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
817 | else | 822 | else |
818 | timeo += (HZ * 20) / 1000; | 823 | timeo += (HZ * 20) / 1000; |
819 | 824 | ||
825 | led_trigger_event(nand_led_trigger, LED_FULL); | ||
826 | |||
820 | /* Apply this short delay always to ensure that we do wait tWB in | 827 | /* Apply this short delay always to ensure that we do wait tWB in |
821 | * any case on any machine. */ | 828 | * any case on any machine. */ |
822 | ndelay (100); | 829 | ndelay (100); |
@@ -840,6 +847,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
840 | } | 847 | } |
841 | cond_resched(); | 848 | cond_resched(); |
842 | } | 849 | } |
850 | led_trigger_event(nand_led_trigger, LED_OFF); | ||
851 | |||
843 | status = (int) this->read_byte(mtd); | 852 | status = (int) this->read_byte(mtd); |
844 | return status; | 853 | return status; |
845 | } | 854 | } |
@@ -2724,6 +2733,21 @@ void nand_release (struct mtd_info *mtd) | |||
2724 | EXPORT_SYMBOL_GPL (nand_scan); | 2733 | EXPORT_SYMBOL_GPL (nand_scan); |
2725 | EXPORT_SYMBOL_GPL (nand_release); | 2734 | EXPORT_SYMBOL_GPL (nand_release); |
2726 | 2735 | ||
2736 | |||
2737 | static int __init nand_base_init(void) | ||
2738 | { | ||
2739 | led_trigger_register_simple("nand-disk", &nand_led_trigger); | ||
2740 | return 0; | ||
2741 | } | ||
2742 | |||
2743 | static void __exit nand_base_exit(void) | ||
2744 | { | ||
2745 | led_trigger_unregister_simple(nand_led_trigger); | ||
2746 | } | ||
2747 | |||
2748 | module_init(nand_base_init); | ||
2749 | module_exit(nand_base_exit); | ||
2750 | |||
2727 | MODULE_LICENSE ("GPL"); | 2751 | MODULE_LICENSE ("GPL"); |
2728 | MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); | 2752 | MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); |
2729 | MODULE_DESCRIPTION ("Generic NAND flash driver code"); | 2753 | MODULE_DESCRIPTION ("Generic NAND flash driver code"); |
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 8815c8dbef2d..c077d2ec9cdd 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -85,10 +85,6 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
85 | 85 | ||
86 | numslots = (master->erasesize / sizeof(struct fis_image_desc)); | 86 | numslots = (master->erasesize / sizeof(struct fis_image_desc)); |
87 | for (i = 0; i < numslots; i++) { | 87 | for (i = 0; i < numslots; i++) { |
88 | if (buf[i].name[0] == 0xff) { | ||
89 | i = numslots; | ||
90 | break; | ||
91 | } | ||
92 | if (!memcmp(buf[i].name, "FIS directory", 14)) { | 88 | if (!memcmp(buf[i].name, "FIS directory", 14)) { |
93 | /* This is apparently the FIS directory entry for the | 89 | /* This is apparently the FIS directory entry for the |
94 | * FIS directory itself. The FIS directory size is | 90 | * FIS directory itself. The FIS directory size is |
@@ -128,7 +124,7 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
128 | struct fis_list *new_fl, **prev; | 124 | struct fis_list *new_fl, **prev; |
129 | 125 | ||
130 | if (buf[i].name[0] == 0xff) | 126 | if (buf[i].name[0] == 0xff) |
131 | break; | 127 | continue; |
132 | if (!redboot_checksum(&buf[i])) | 128 | if (!redboot_checksum(&buf[i])) |
133 | break; | 129 | break; |
134 | 130 | ||