diff options
| -rw-r--r-- | drivers/mtd/devices/blkmtd.c | 10 | ||||
| -rw-r--r-- | drivers/mtd/devices/block2mtd.c | 13 | ||||
| -rw-r--r-- | drivers/mtd/devices/doc2000.c | 30 | ||||
| -rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 32 | ||||
| -rw-r--r-- | drivers/mtd/mtdblock.c | 14 | ||||
| -rw-r--r-- | drivers/mtd/mtdcore.c | 32 | ||||
| -rw-r--r-- | include/linux/mtd/blktrans.h | 4 | ||||
| -rw-r--r-- | include/linux/mtd/doc2000.h | 4 |
8 files changed, 71 insertions, 68 deletions
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c index 04f864d238db..d732532635a1 100644 --- a/drivers/mtd/devices/blkmtd.c +++ b/drivers/mtd/devices/blkmtd.c | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #include <linux/list.h> | 29 | #include <linux/list.h> |
| 30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
| 31 | #include <linux/mtd/mtd.h> | 31 | #include <linux/mtd/mtd.h> |
| 32 | 32 | #include <linux/mutex.h> | |
| 33 | 33 | ||
| 34 | #define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg) | 34 | #define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg) |
| 35 | #define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg) | 35 | #define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg) |
| @@ -46,7 +46,7 @@ struct blkmtd_dev { | |||
| 46 | struct list_head list; | 46 | struct list_head list; |
| 47 | struct block_device *blkdev; | 47 | struct block_device *blkdev; |
| 48 | struct mtd_info mtd_info; | 48 | struct mtd_info mtd_info; |
| 49 | struct semaphore wrbuf_mutex; | 49 | struct mutex wrbuf_mutex; |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | 52 | ||
| @@ -268,7 +268,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to, | |||
| 268 | if(end_len) | 268 | if(end_len) |
| 269 | pagecnt++; | 269 | pagecnt++; |
| 270 | 270 | ||
| 271 | down(&dev->wrbuf_mutex); | 271 | mutex_lock(&dev->wrbuf_mutex); |
| 272 | 272 | ||
| 273 | DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n", | 273 | DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n", |
| 274 | start_len, len, end_len, pagecnt); | 274 | start_len, len, end_len, pagecnt); |
| @@ -376,7 +376,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to, | |||
| 376 | blkmtd_write_out(bio); | 376 | blkmtd_write_out(bio); |
| 377 | 377 | ||
| 378 | DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err); | 378 | DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err); |
| 379 | up(&dev->wrbuf_mutex); | 379 | mutex_unlock(&dev->wrbuf_mutex); |
| 380 | 380 | ||
| 381 | if(retlen) | 381 | if(retlen) |
| 382 | *retlen = thislen; | 382 | *retlen = thislen; |
| @@ -659,7 +659,7 @@ static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size | |||
| 659 | memset(dev, 0, sizeof(struct blkmtd_dev)); | 659 | memset(dev, 0, sizeof(struct blkmtd_dev)); |
| 660 | dev->blkdev = bdev; | 660 | dev->blkdev = bdev; |
| 661 | if(!readonly) { | 661 | if(!readonly) { |
| 662 | init_MUTEX(&dev->wrbuf_mutex); | 662 | mutex_init(&dev->wrbuf_mutex); |
| 663 | } | 663 | } |
| 664 | 664 | ||
| 665 | dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; | 665 | 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 0f2c956a90d3..23e7a5c7d2c1 100644 --- a/drivers/mtd/devices/doc2000.c +++ b/drivers/mtd/devices/doc2000.c | |||
| @@ -606,7 +606,7 @@ static void DoC2k_init(struct mtd_info *mtd) | |||
| 606 | 606 | ||
| 607 | this->curfloor = -1; | 607 | this->curfloor = -1; |
| 608 | this->curchip = -1; | 608 | this->curchip = -1; |
| 609 | init_MUTEX(&this->lock); | 609 | mutex_init(&this->lock); |
| 610 | 610 | ||
| 611 | /* Ident all the chips present. */ | 611 | /* Ident all the chips present. */ |
| 612 | DoC_ScanChips(this, maxchips); | 612 | DoC_ScanChips(this, maxchips); |
| @@ -646,7 +646,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 646 | if (from >= this->totlen) | 646 | if (from >= this->totlen) |
| 647 | return -EINVAL; | 647 | return -EINVAL; |
| 648 | 648 | ||
| 649 | down(&this->lock); | 649 | mutex_lock(&this->lock); |
| 650 | 650 | ||
| 651 | *retlen = 0; | 651 | *retlen = 0; |
| 652 | while (left) { | 652 | while (left) { |
| @@ -775,7 +775,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 775 | buf += len; | 775 | buf += len; |
| 776 | } | 776 | } |
| 777 | 777 | ||
| 778 | up(&this->lock); | 778 | mutex_unlock(&this->lock); |
| 779 | 779 | ||
| 780 | return ret; | 780 | return ret; |
| 781 | } | 781 | } |
| @@ -804,7 +804,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
| 804 | if (to >= this->totlen) | 804 | if (to >= this->totlen) |
| 805 | return -EINVAL; | 805 | return -EINVAL; |
| 806 | 806 | ||
| 807 | down(&this->lock); | 807 | mutex_lock(&this->lock); |
| 808 | 808 | ||
| 809 | *retlen = 0; | 809 | *retlen = 0; |
| 810 | while (left) { | 810 | while (left) { |
| @@ -874,7 +874,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
| 874 | printk(KERN_ERR "Error programming flash\n"); | 874 | printk(KERN_ERR "Error programming flash\n"); |
| 875 | /* Error in programming */ | 875 | /* Error in programming */ |
| 876 | *retlen = 0; | 876 | *retlen = 0; |
| 877 | up(&this->lock); | 877 | mutex_unlock(&this->lock); |
| 878 | return -EIO; | 878 | return -EIO; |
| 879 | } | 879 | } |
| 880 | 880 | ||
| @@ -936,7 +936,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
| 936 | printk(KERN_ERR "Error programming flash\n"); | 936 | printk(KERN_ERR "Error programming flash\n"); |
| 937 | /* Error in programming */ | 937 | /* Error in programming */ |
| 938 | *retlen = 0; | 938 | *retlen = 0; |
| 939 | up(&this->lock); | 939 | mutex_unlock(&this->lock); |
| 940 | return -EIO; | 940 | return -EIO; |
| 941 | } | 941 | } |
| 942 | 942 | ||
| @@ -957,7 +957,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
| 957 | 957 | ||
| 958 | ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x); | 958 | ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x); |
| 959 | if (ret) { | 959 | if (ret) { |
| 960 | up(&this->lock); | 960 | mutex_unlock(&this->lock); |
| 961 | return ret; | 961 | return ret; |
| 962 | } | 962 | } |
| 963 | } | 963 | } |
| @@ -967,7 +967,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
| 967 | buf += len; | 967 | buf += len; |
| 968 | } | 968 | } |
| 969 | 969 | ||
| 970 | up(&this->lock); | 970 | mutex_unlock(&this->lock); |
| 971 | return 0; | 971 | return 0; |
| 972 | } | 972 | } |
| 973 | 973 | ||
| @@ -1038,7 +1038,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | |||
| 1038 | int len256 = 0, ret; | 1038 | int len256 = 0, ret; |
| 1039 | struct Nand *mychip; | 1039 | struct Nand *mychip; |
| 1040 | 1040 | ||
| 1041 | down(&this->lock); | 1041 | mutex_lock(&this->lock); |
| 1042 | 1042 | ||
| 1043 | mychip = &this->chips[ofs >> this->chipshift]; | 1043 | mychip = &this->chips[ofs >> this->chipshift]; |
| 1044 | 1044 | ||
| @@ -1084,7 +1084,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | |||
| 1084 | 1084 | ||
| 1085 | ret = DoC_WaitReady(this); | 1085 | ret = DoC_WaitReady(this); |
| 1086 | 1086 | ||
| 1087 | up(&this->lock); | 1087 | mutex_unlock(&this->lock); |
| 1088 | return ret; | 1088 | return ret; |
| 1089 | 1089 | ||
| 1090 | } | 1090 | } |
| @@ -1198,10 +1198,10 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, | |||
| 1198 | struct DiskOnChip *this = mtd->priv; | 1198 | struct DiskOnChip *this = mtd->priv; |
| 1199 | int ret; | 1199 | int ret; |
| 1200 | 1200 | ||
| 1201 | down(&this->lock); | 1201 | mutex_lock(&this->lock); |
| 1202 | ret = doc_write_oob_nolock(mtd, ofs, len, retlen, buf); | 1202 | ret = doc_write_oob_nolock(mtd, ofs, len, retlen, buf); |
| 1203 | 1203 | ||
| 1204 | up(&this->lock); | 1204 | mutex_unlock(&this->lock); |
| 1205 | return ret; | 1205 | return ret; |
| 1206 | } | 1206 | } |
| 1207 | 1207 | ||
| @@ -1215,10 +1215,10 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
| 1215 | struct Nand *mychip; | 1215 | struct Nand *mychip; |
| 1216 | int status; | 1216 | int status; |
| 1217 | 1217 | ||
| 1218 | down(&this->lock); | 1218 | mutex_lock(&this->lock); |
| 1219 | 1219 | ||
| 1220 | if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) { | 1220 | if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) { |
| 1221 | up(&this->lock); | 1221 | mutex_unlock(&this->lock); |
| 1222 | return -EINVAL; | 1222 | return -EINVAL; |
| 1223 | } | 1223 | } |
| 1224 | 1224 | ||
| @@ -1266,7 +1266,7 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
| 1266 | callback: | 1266 | callback: |
| 1267 | mtd_erase_callback(instr); | 1267 | mtd_erase_callback(instr); |
| 1268 | 1268 | ||
| 1269 | up(&this->lock); | 1269 | mutex_unlock(&this->lock); |
| 1270 | return 0; | 1270 | return 0; |
| 1271 | } | 1271 | } |
| 1272 | 1272 | ||
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..9c3813486a1a 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
| @@ -27,7 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | /* These are exported solely for the purpose of mtd_blkdevs.c. You | 28 | /* These are exported solely for the purpose of mtd_blkdevs.c. You |
| 29 | should not use them for _anything_ else */ | 29 | should not use them for _anything_ else */ |
| 30 | DECLARE_MUTEX(mtd_table_mutex); | 30 | DEFINE_MUTEX(mtd_table_mutex); |
| 31 | struct mtd_info *mtd_table[MAX_MTD_DEVICES]; | 31 | struct mtd_info *mtd_table[MAX_MTD_DEVICES]; |
| 32 | 32 | ||
| 33 | EXPORT_SYMBOL_GPL(mtd_table_mutex); | 33 | EXPORT_SYMBOL_GPL(mtd_table_mutex); |
| @@ -49,7 +49,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
| 49 | { | 49 | { |
| 50 | int i; | 50 | int i; |
| 51 | 51 | ||
| 52 | down(&mtd_table_mutex); | 52 | mutex_lock(&mtd_table_mutex); |
| 53 | 53 | ||
| 54 | for (i=0; i < MAX_MTD_DEVICES; i++) | 54 | for (i=0; i < MAX_MTD_DEVICES; i++) |
| 55 | if (!mtd_table[i]) { | 55 | if (!mtd_table[i]) { |
| @@ -67,7 +67,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
| 67 | not->add(mtd); | 67 | not->add(mtd); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | up(&mtd_table_mutex); | 70 | mutex_unlock(&mtd_table_mutex); |
| 71 | /* We _know_ we aren't being removed, because | 71 | /* We _know_ we aren't being removed, because |
| 72 | our caller is still holding us here. So none | 72 | our caller is still holding us here. So none |
| 73 | of this try_ nonsense, and no bitching about it | 73 | of this try_ nonsense, and no bitching about it |
| @@ -76,7 +76,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
| 76 | return 0; | 76 | return 0; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | up(&mtd_table_mutex); | 79 | mutex_unlock(&mtd_table_mutex); |
| 80 | return 1; | 80 | return 1; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| @@ -94,7 +94,7 @@ int del_mtd_device (struct mtd_info *mtd) | |||
| 94 | { | 94 | { |
| 95 | int ret; | 95 | int ret; |
| 96 | 96 | ||
| 97 | down(&mtd_table_mutex); | 97 | mutex_lock(&mtd_table_mutex); |
| 98 | 98 | ||
| 99 | if (mtd_table[mtd->index] != mtd) { | 99 | if (mtd_table[mtd->index] != mtd) { |
| 100 | ret = -ENODEV; | 100 | ret = -ENODEV; |
| @@ -118,7 +118,7 @@ int del_mtd_device (struct mtd_info *mtd) | |||
| 118 | ret = 0; | 118 | ret = 0; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | up(&mtd_table_mutex); | 121 | mutex_unlock(&mtd_table_mutex); |
| 122 | return ret; | 122 | return ret; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| @@ -135,7 +135,7 @@ void register_mtd_user (struct mtd_notifier *new) | |||
| 135 | { | 135 | { |
| 136 | int i; | 136 | int i; |
| 137 | 137 | ||
| 138 | down(&mtd_table_mutex); | 138 | mutex_lock(&mtd_table_mutex); |
| 139 | 139 | ||
| 140 | list_add(&new->list, &mtd_notifiers); | 140 | list_add(&new->list, &mtd_notifiers); |
| 141 | 141 | ||
| @@ -145,7 +145,7 @@ void register_mtd_user (struct mtd_notifier *new) | |||
| 145 | if (mtd_table[i]) | 145 | if (mtd_table[i]) |
| 146 | new->add(mtd_table[i]); | 146 | new->add(mtd_table[i]); |
| 147 | 147 | ||
| 148 | up(&mtd_table_mutex); | 148 | mutex_unlock(&mtd_table_mutex); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | /** | 151 | /** |
| @@ -162,7 +162,7 @@ int unregister_mtd_user (struct mtd_notifier *old) | |||
| 162 | { | 162 | { |
| 163 | int i; | 163 | int i; |
| 164 | 164 | ||
| 165 | down(&mtd_table_mutex); | 165 | mutex_lock(&mtd_table_mutex); |
| 166 | 166 | ||
| 167 | module_put(THIS_MODULE); | 167 | module_put(THIS_MODULE); |
| 168 | 168 | ||
| @@ -171,7 +171,7 @@ int unregister_mtd_user (struct mtd_notifier *old) | |||
| 171 | old->remove(mtd_table[i]); | 171 | old->remove(mtd_table[i]); |
| 172 | 172 | ||
| 173 | list_del(&old->list); | 173 | list_del(&old->list); |
| 174 | up(&mtd_table_mutex); | 174 | mutex_unlock(&mtd_table_mutex); |
| 175 | return 0; | 175 | return 0; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| @@ -193,7 +193,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) | |||
| 193 | struct mtd_info *ret = NULL; | 193 | struct mtd_info *ret = NULL; |
| 194 | int i; | 194 | int i; |
| 195 | 195 | ||
| 196 | down(&mtd_table_mutex); | 196 | mutex_lock(&mtd_table_mutex); |
| 197 | 197 | ||
| 198 | if (num == -1) { | 198 | if (num == -1) { |
| 199 | for (i=0; i< MAX_MTD_DEVICES; i++) | 199 | for (i=0; i< MAX_MTD_DEVICES; i++) |
| @@ -211,7 +211,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) | |||
| 211 | if (ret) | 211 | if (ret) |
| 212 | ret->usecount++; | 212 | ret->usecount++; |
| 213 | 213 | ||
| 214 | up(&mtd_table_mutex); | 214 | mutex_unlock(&mtd_table_mutex); |
| 215 | return ret; | 215 | return ret; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| @@ -219,9 +219,9 @@ void put_mtd_device(struct mtd_info *mtd) | |||
| 219 | { | 219 | { |
| 220 | int c; | 220 | int c; |
| 221 | 221 | ||
| 222 | down(&mtd_table_mutex); | 222 | mutex_lock(&mtd_table_mutex); |
| 223 | c = --mtd->usecount; | 223 | c = --mtd->usecount; |
| 224 | up(&mtd_table_mutex); | 224 | mutex_unlock(&mtd_table_mutex); |
| 225 | BUG_ON(c < 0); | 225 | BUG_ON(c < 0); |
| 226 | 226 | ||
| 227 | module_put(mtd->owner); | 227 | module_put(mtd->owner); |
| @@ -319,7 +319,7 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count, | |||
| 319 | int len, l, i; | 319 | int len, l, i; |
| 320 | off_t begin = 0; | 320 | off_t begin = 0; |
| 321 | 321 | ||
| 322 | down(&mtd_table_mutex); | 322 | mutex_lock(&mtd_table_mutex); |
| 323 | 323 | ||
| 324 | len = sprintf(page, "dev: size erasesize name\n"); | 324 | len = sprintf(page, "dev: size erasesize name\n"); |
| 325 | for (i=0; i< MAX_MTD_DEVICES; i++) { | 325 | for (i=0; i< MAX_MTD_DEVICES; i++) { |
| @@ -337,7 +337,7 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count, | |||
| 337 | *eof = 1; | 337 | *eof = 1; |
| 338 | 338 | ||
| 339 | done: | 339 | done: |
| 340 | up(&mtd_table_mutex); | 340 | mutex_unlock(&mtd_table_mutex); |
| 341 | if (off >= len+begin) | 341 | if (off >= len+begin) |
| 342 | return 0; | 342 | return 0; |
| 343 | *start = page + (off-begin); | 343 | *start = page + (off-begin); |
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h index f46afec6fbf8..72fc68c5ee96 100644 --- a/include/linux/mtd/blktrans.h +++ b/include/linux/mtd/blktrans.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | #ifndef __MTD_TRANS_H__ | 10 | #ifndef __MTD_TRANS_H__ |
| 11 | #define __MTD_TRANS_H__ | 11 | #define __MTD_TRANS_H__ |
| 12 | 12 | ||
| 13 | #include <asm/semaphore.h> | 13 | #include <linux/mutex.h> |
| 14 | 14 | ||
| 15 | struct hd_geometry; | 15 | struct hd_geometry; |
| 16 | struct mtd_info; | 16 | struct mtd_info; |
| @@ -22,7 +22,7 @@ struct mtd_blktrans_dev { | |||
| 22 | struct mtd_blktrans_ops *tr; | 22 | struct mtd_blktrans_ops *tr; |
| 23 | struct list_head list; | 23 | struct list_head list; |
| 24 | struct mtd_info *mtd; | 24 | struct mtd_info *mtd; |
| 25 | struct semaphore sem; | 25 | struct mutex lock; |
| 26 | int devnum; | 26 | int devnum; |
| 27 | int blksize; | 27 | int blksize; |
| 28 | unsigned long size; | 28 | unsigned long size; |
diff --git a/include/linux/mtd/doc2000.h b/include/linux/mtd/doc2000.h index 386a52cf8b1b..9addd073bf15 100644 --- a/include/linux/mtd/doc2000.h +++ b/include/linux/mtd/doc2000.h | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | #define __MTD_DOC2000_H__ | 15 | #define __MTD_DOC2000_H__ |
| 16 | 16 | ||
| 17 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
| 18 | #include <asm/semaphore.h> | 18 | #include <linux/mutex.h> |
| 19 | 19 | ||
| 20 | #define DoC_Sig1 0 | 20 | #define DoC_Sig1 0 |
| 21 | #define DoC_Sig2 1 | 21 | #define DoC_Sig2 1 |
| @@ -187,7 +187,7 @@ struct DiskOnChip { | |||
| 187 | int numchips; | 187 | int numchips; |
| 188 | struct Nand *chips; | 188 | struct Nand *chips; |
| 189 | struct mtd_info *nextdoc; | 189 | struct mtd_info *nextdoc; |
| 190 | struct semaphore lock; | 190 | struct mutex lock; |
| 191 | }; | 191 | }; |
| 192 | 192 | ||
| 193 | int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); | 193 | int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); |
