diff options
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/blkmtd.c | 13 | ||||
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 13 | ||||
-rw-r--r-- | drivers/mtd/devices/doc2000.c | 37 | ||||
-rw-r--r-- | drivers/mtd/devices/lart.c | 10 | ||||
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 2 | ||||
-rw-r--r-- | drivers/mtd/devices/ms02-nv.c | 2 |
6 files changed, 38 insertions, 39 deletions
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 | ||