Commit 48b19268 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] sem2mutex: drivers/mtd/

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 040d79f9
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mutex.h>
#define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg) #define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg)
#define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg) #define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg)
...@@ -46,7 +46,7 @@ struct blkmtd_dev { ...@@ -46,7 +46,7 @@ struct blkmtd_dev {
struct list_head list; struct list_head list;
struct block_device *blkdev; struct block_device *blkdev;
struct mtd_info mtd_info; struct mtd_info mtd_info;
struct semaphore wrbuf_mutex; struct mutex wrbuf_mutex;
}; };
...@@ -268,7 +268,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to, ...@@ -268,7 +268,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
if(end_len) if(end_len)
pagecnt++; pagecnt++;
down(&dev->wrbuf_mutex); mutex_lock(&dev->wrbuf_mutex);
DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n", DEBUG(3, "blkmtd: write: start_len = %zd len = %zd end_len = %zd pagecnt = %d\n",
start_len, len, end_len, pagecnt); 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,7 +376,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
blkmtd_write_out(bio); blkmtd_write_out(bio);
DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err); DEBUG(2, "blkmtd: write: end, retlen = %zd, err = %d\n", *retlen, err);
up(&dev->wrbuf_mutex); mutex_unlock(&dev->wrbuf_mutex);
if(retlen) if(retlen)
*retlen = thislen; *retlen = thislen;
...@@ -659,7 +659,7 @@ static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size ...@@ -659,7 +659,7 @@ static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size
memset(dev, 0, sizeof(struct blkmtd_dev)); memset(dev, 0, sizeof(struct blkmtd_dev));
dev->blkdev = bdev; dev->blkdev = bdev;
if(!readonly) { if(!readonly) {
init_MUTEX(&dev->wrbuf_mutex); mutex_init(&dev->wrbuf_mutex);
} }
dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/mutex.h>
#define VERSION "$Revision: 1.30 $" #define VERSION "$Revision: 1.30 $"
...@@ -31,7 +32,7 @@ struct block2mtd_dev { ...@@ -31,7 +32,7 @@ struct block2mtd_dev {
struct list_head list; struct list_head list;
struct block_device *blkdev; struct block_device *blkdev;
struct mtd_info mtd; struct mtd_info mtd;
struct semaphore write_mutex; struct mutex write_mutex;
}; };
...@@ -134,9 +135,9 @@ static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -134,9 +135,9 @@ static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
int err; int err;
instr->state = MTD_ERASING; instr->state = MTD_ERASING;
down(&dev->write_mutex); mutex_lock(&dev->write_mutex);
err = _block2mtd_erase(dev, from, len); err = _block2mtd_erase(dev, from, len);
up(&dev->write_mutex); mutex_unlock(&dev->write_mutex);
if (err) { if (err) {
ERROR("erase failed err = %d", err); ERROR("erase failed err = %d", err);
instr->state = MTD_ERASE_FAILED; instr->state = MTD_ERASE_FAILED;
...@@ -249,9 +250,9 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -249,9 +250,9 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
if (to + len > mtd->size) if (to + len > mtd->size)
len = mtd->size - to; len = mtd->size - to;
down(&dev->write_mutex); mutex_lock(&dev->write_mutex);
err = _block2mtd_write(dev, buf, to, len, retlen); err = _block2mtd_write(dev, buf, to, len, retlen);
up(&dev->write_mutex); mutex_unlock(&dev->write_mutex);
if (err > 0) if (err > 0)
err = 0; err = 0;
return err; return err;
...@@ -310,7 +311,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) ...@@ -310,7 +311,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
goto devinit_err; goto devinit_err;
} }
init_MUTEX(&dev->write_mutex); mutex_init(&dev->write_mutex);
/* Setup the MTD structure */ /* Setup the MTD structure */
/* make the name contain the block device in */ /* make the name contain the block device in */
......
...@@ -606,7 +606,7 @@ static void DoC2k_init(struct mtd_info *mtd) ...@@ -606,7 +606,7 @@ static void DoC2k_init(struct mtd_info *mtd)
this->curfloor = -1; this->curfloor = -1;
this->curchip = -1; this->curchip = -1;
init_MUTEX(&this->lock); mutex_init(&this->lock);
/* Ident all the chips present. */ /* Ident all the chips present. */
DoC_ScanChips(this, maxchips); DoC_ScanChips(this, maxchips);
...@@ -646,7 +646,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -646,7 +646,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
if (from >= this->totlen) if (from >= this->totlen)
return -EINVAL; return -EINVAL;
down(&this->lock); mutex_lock(&this->lock);
*retlen = 0; *retlen = 0;
while (left) { while (left) {
...@@ -775,7 +775,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -775,7 +775,7 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
buf += len; buf += len;
} }
up(&this->lock); mutex_unlock(&this->lock);
return ret; return ret;
} }
...@@ -804,7 +804,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -804,7 +804,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
if (to >= this->totlen) if (to >= this->totlen)
return -EINVAL; return -EINVAL;
down(&this->lock); mutex_lock(&this->lock);
*retlen = 0; *retlen = 0;
while (left) { while (left) {
...@@ -874,7 +874,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -874,7 +874,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
printk(KERN_ERR "Error programming flash\n"); printk(KERN_ERR "Error programming flash\n");
/* Error in programming */ /* Error in programming */
*retlen = 0; *retlen = 0;
up(&this->lock); mutex_unlock(&this->lock);
return -EIO; return -EIO;
} }
...@@ -936,7 +936,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -936,7 +936,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
printk(KERN_ERR "Error programming flash\n"); printk(KERN_ERR "Error programming flash\n");
/* Error in programming */ /* Error in programming */
*retlen = 0; *retlen = 0;
up(&this->lock); mutex_unlock(&this->lock);
return -EIO; return -EIO;
} }
...@@ -957,7 +957,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -957,7 +957,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x); ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x);
if (ret) { if (ret) {
up(&this->lock); mutex_unlock(&this->lock);
return ret; return ret;
} }
} }
...@@ -967,7 +967,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -967,7 +967,7 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
buf += len; buf += len;
} }
up(&this->lock); mutex_unlock(&this->lock);
return 0; return 0;
} }
...@@ -1038,7 +1038,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, ...@@ -1038,7 +1038,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
int len256 = 0, ret; int len256 = 0, ret;
struct Nand *mychip; struct Nand *mychip;
down(&this->lock); mutex_lock(&this->lock);
mychip = &this->chips[ofs >> this->chipshift]; mychip = &this->chips[ofs >> this->chipshift];
...@@ -1084,7 +1084,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len, ...@@ -1084,7 +1084,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
ret = DoC_WaitReady(this); ret = DoC_WaitReady(this);
up(&this->lock); mutex_unlock(&this->lock);
return ret; return ret;
} }
...@@ -1198,10 +1198,10 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len, ...@@ -1198,10 +1198,10 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
struct DiskOnChip *this = mtd->priv; struct DiskOnChip *this = mtd->priv;
int ret; int ret;
down(&this->lock); mutex_lock(&this->lock);
ret = doc_write_oob_nolock(mtd, ofs, len, retlen, buf); ret = doc_write_oob_nolock(mtd, ofs, len, retlen, buf);
up(&this->lock); mutex_unlock(&this->lock);
return ret; return ret;
} }
...@@ -1215,10 +1215,10 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -1215,10 +1215,10 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
struct Nand *mychip; struct Nand *mychip;
int status; int status;
down(&this->lock); mutex_lock(&this->lock);
if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) { if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) {
up(&this->lock); mutex_unlock(&this->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1266,7 +1266,7 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -1266,7 +1266,7 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
callback: callback:
mtd_erase_callback(instr); mtd_erase_callback(instr);
up(&this->lock); mutex_unlock(&this->lock);
return 0; return 0;
} }
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
static LIST_HEAD(blktrans_majors); static LIST_HEAD(blktrans_majors);
extern struct semaphore mtd_table_mutex; extern struct mutex mtd_table_mutex;
extern struct mtd_info *mtd_table[]; extern struct mtd_info *mtd_table[];
struct mtd_blkcore_priv { struct mtd_blkcore_priv {
...@@ -122,9 +122,9 @@ static int mtd_blktrans_thread(void *arg) ...@@ -122,9 +122,9 @@ static int mtd_blktrans_thread(void *arg)
spin_unlock_irq(rq->queue_lock); spin_unlock_irq(rq->queue_lock);
down(&dev->sem); mutex_lock(&dev->lock);
res = do_blktrans_request(tr, dev, req); res = do_blktrans_request(tr, dev, req);
up(&dev->sem); mutex_unlock(&dev->lock);
spin_lock_irq(rq->queue_lock); spin_lock_irq(rq->queue_lock);
...@@ -235,8 +235,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -235,8 +235,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
int last_devnum = -1; int last_devnum = -1;
struct gendisk *gd; struct gendisk *gd;
if (!down_trylock(&mtd_table_mutex)) { if (!!mutex_trylock(&mtd_table_mutex)) {
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
BUG(); BUG();
} }
...@@ -267,7 +267,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -267,7 +267,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
return -EBUSY; return -EBUSY;
} }
init_MUTEX(&new->sem); mutex_init(&new->lock);
list_add_tail(&new->list, &tr->devs); list_add_tail(&new->list, &tr->devs);
added: added:
if (!tr->writesect) if (!tr->writesect)
...@@ -313,8 +313,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -313,8 +313,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
{ {
if (!down_trylock(&mtd_table_mutex)) { if (!!mutex_trylock(&mtd_table_mutex)) {
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
BUG(); BUG();
} }
...@@ -378,14 +378,14 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -378,14 +378,14 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv));
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
ret = register_blkdev(tr->major, tr->name); ret = register_blkdev(tr->major, tr->name);
if (ret) { if (ret) {
printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n", printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
tr->name, tr->major, ret); tr->name, tr->major, ret);
kfree(tr->blkcore_priv); kfree(tr->blkcore_priv);
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return ret; return ret;
} }
spin_lock_init(&tr->blkcore_priv->queue_lock); spin_lock_init(&tr->blkcore_priv->queue_lock);
...@@ -396,7 +396,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -396,7 +396,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
if (!tr->blkcore_priv->rq) { if (!tr->blkcore_priv->rq) {
unregister_blkdev(tr->major, tr->name); unregister_blkdev(tr->major, tr->name);
kfree(tr->blkcore_priv); kfree(tr->blkcore_priv);
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return -ENOMEM; return -ENOMEM;
} }
...@@ -407,7 +407,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -407,7 +407,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
blk_cleanup_queue(tr->blkcore_priv->rq); blk_cleanup_queue(tr->blkcore_priv->rq);
unregister_blkdev(tr->major, tr->name); unregister_blkdev(tr->major, tr->name);
kfree(tr->blkcore_priv); kfree(tr->blkcore_priv);
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return ret; return ret;
} }
...@@ -419,7 +419,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -419,7 +419,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
tr->add_mtd(tr, mtd_table[i]); tr->add_mtd(tr, mtd_table[i]);
} }
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return 0; return 0;
} }
...@@ -428,7 +428,7 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -428,7 +428,7 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
{ {
struct list_head *this, *next; struct list_head *this, *next;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
/* Clean up the kernel thread */ /* Clean up the kernel thread */
tr->blkcore_priv->exiting = 1; tr->blkcore_priv->exiting = 1;
...@@ -446,7 +446,7 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -446,7 +446,7 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
blk_cleanup_queue(tr->blkcore_priv->rq); blk_cleanup_queue(tr->blkcore_priv->rq);
unregister_blkdev(tr->major, tr->name); unregister_blkdev(tr->major, tr->name);
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
kfree(tr->blkcore_priv); kfree(tr->blkcore_priv);
......
...@@ -19,11 +19,13 @@ ...@@ -19,11 +19,13 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/blktrans.h> #include <linux/mtd/blktrans.h>
#include <linux/mutex.h>
static struct mtdblk_dev { static struct mtdblk_dev {
struct mtd_info *mtd; struct mtd_info *mtd;
int count; int count;
struct semaphore cache_sem; struct mutex cache_mutex;
unsigned char *cache_data; unsigned char *cache_data;
unsigned long cache_offset; unsigned long cache_offset;
unsigned int cache_size; unsigned int cache_size;
...@@ -284,7 +286,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd) ...@@ -284,7 +286,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
mtdblk->count = 1; mtdblk->count = 1;
mtdblk->mtd = mtd; mtdblk->mtd = mtd;
init_MUTEX (&mtdblk->cache_sem); mutex_init(&mtdblk->cache_mutex);
mtdblk->cache_state = STATE_EMPTY; mtdblk->cache_state = STATE_EMPTY;
if ((mtdblk->mtd->flags & MTD_CAP_RAM) != MTD_CAP_RAM && if ((mtdblk->mtd->flags & MTD_CAP_RAM) != MTD_CAP_RAM &&
mtdblk->mtd->erasesize) { mtdblk->mtd->erasesize) {
...@@ -306,9 +308,9 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd) ...@@ -306,9 +308,9 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
down(&mtdblk->cache_sem); mutex_lock(&mtdblk->cache_mutex);
write_cached_data(mtdblk); write_cached_data(mtdblk);
up(&mtdblk->cache_sem); mutex_unlock(&mtdblk->cache_mutex);
if (!--mtdblk->count) { if (!--mtdblk->count) {
/* It was the last usage. Free the device */ /* It was the last usage. Free the device */
...@@ -327,9 +329,9 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev) ...@@ -327,9 +329,9 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev)
{ {
struct mtdblk_dev *mtdblk = mtdblks[dev->devnum]; struct mtdblk_dev *mtdblk = mtdblks[dev->devnum];
down(&mtdblk->cache_sem); mutex_lock(&mtdblk->cache_mutex);
write_cached_data(mtdblk); write_cached_data(mtdblk);
up(&mtdblk->cache_sem); mutex_unlock(&mtdblk->cache_mutex);
if (mtdblk->mtd->sync) if (mtdblk->mtd->sync)
mtdblk->mtd->sync(mtdblk->mtd); mtdblk->mtd->sync(mtdblk->mtd);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
/* These are exported solely for the purpose of mtd_blkdevs.c. You /* These are exported solely for the purpose of mtd_blkdevs.c. You
should not use them for _anything_ else */ should not use them for _anything_ else */
DECLARE_MUTEX(mtd_table_mutex); DEFINE_MUTEX(mtd_table_mutex);
struct mtd_info *mtd_table[MAX_MTD_DEVICES]; struct mtd_info *mtd_table[MAX_MTD_DEVICES];
EXPORT_SYMBOL_GPL(mtd_table_mutex); EXPORT_SYMBOL_GPL(mtd_table_mutex);
...@@ -49,7 +49,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -49,7 +49,7 @@ int add_mtd_device(struct mtd_info *mtd)
{ {
int i; int i;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
for (i=0; i < MAX_MTD_DEVICES; i++) for (i=0; i < MAX_MTD_DEVICES; i++)
if (!mtd_table[i]) { if (!mtd_table[i]) {
...@@ -67,7 +67,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -67,7 +67,7 @@ int add_mtd_device(struct mtd_info *mtd)
not->add(mtd); not->add(mtd);
} }
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
/* We _know_ we aren't being removed, because /* We _know_ we aren't being removed, because
our caller is still holding us here. So none our caller is still holding us here. So none
of this try_ nonsense, and no bitching about it of this try_ nonsense, and no bitching about it
...@@ -76,7 +76,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -76,7 +76,7 @@ int add_mtd_device(struct mtd_info *mtd)
return 0; return 0;
} }
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return 1; return 1;
} }
...@@ -94,7 +94,7 @@ int del_mtd_device (struct mtd_info *mtd) ...@@ -94,7 +94,7 @@ int del_mtd_device (struct mtd_info *mtd)
{ {
int ret; int ret;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
if (mtd_table[mtd->index] != mtd) { if (mtd_table[mtd->index] != mtd) {
ret = -ENODEV; ret = -ENODEV;
...@@ -118,7 +118,7 @@ int del_mtd_device (struct mtd_info *mtd) ...@@ -118,7 +118,7 @@ int del_mtd_device (struct mtd_info *mtd)
ret = 0; ret = 0;
} }
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return ret; return ret;
} }
...@@ -135,7 +135,7 @@ void register_mtd_user (struct mtd_notifier *new) ...@@ -135,7 +135,7 @@ void register_mtd_user (struct mtd_notifier *new)
{ {
int i; int i;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
list_add(&new->list, &mtd_notifiers); list_add(&new->list, &mtd_notifiers);
...@@ -145,7 +145,7 @@ void register_mtd_user (struct mtd_notifier *new) ...@@ -145,7 +145,7 @@ void register_mtd_user (struct mtd_notifier *new)
if (mtd_table[i]) if (mtd_table[i])
new->add(mtd_table[i]); new->add(mtd_table[i]);
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
} }
/** /**
...@@ -162,7 +162,7 @@ int unregister_mtd_user (struct mtd_notifier *old) ...@@ -162,7 +162,7 @@ int unregister_mtd_user (struct mtd_notifier *old)
{ {
int i; int i;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
module_put(THIS_MODULE); module_put(THIS_MODULE);
...@@ -171,7 +171,7 @@ int unregister_mtd_user (struct mtd_notifier *old) ...@@ -171,7 +171,7 @@ int unregister_mtd_user (struct mtd_notifier *old)
old->remove(mtd_table[i]); old->remove(mtd_table[i]);
list_del(&old->list); list_del(&old->list);
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return 0; return 0;
} }
...@@ -193,7 +193,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) ...@@ -193,7 +193,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
struct mtd_info *ret = NULL; struct mtd_info *ret = NULL;
int i; int i;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
if (num == -1) { if (num == -1) {
for (i=0; i< MAX_MTD_DEVICES; i++) 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,7 +211,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
if (ret) if (ret)
ret->usecount++; ret->usecount++;
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
return ret; return ret;
} }
...@@ -219,9 +219,9 @@ void put_mtd_device(struct mtd_info *mtd) ...@@ -219,9 +219,9 @@ void put_mtd_device(struct mtd_info *mtd)
{ {
int c; int c;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
c = --mtd->usecount; c = --mtd->usecount;
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
BUG_ON(c < 0); BUG_ON(c < 0);
module_put(mtd->owner); module_put(mtd->owner);
...@@ -319,7 +319,7 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count, ...@@ -319,7 +319,7 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count,
int len, l, i; int len, l, i;
off_t begin = 0; off_t begin = 0;
down(&mtd_table_mutex); mutex_lock(&mtd_table_mutex);
len = sprintf(page, "dev: size erasesize name\n"); len = sprintf(page, "dev: size erasesize name\n");
for (i=0; i< MAX_MTD_DEVICES; i++) { 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,7 +337,7 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count,
*eof = 1; *eof = 1;
done: done:
up(&mtd_table_mutex); mutex_unlock(&mtd_table_mutex);
if (off >= len+begin) if (off >= len+begin)
return 0; return 0;
*start = page + (off-begin); *start = page + (off-begin);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#ifndef __MTD_TRANS_H__ #ifndef __MTD_TRANS_H__
#define __MTD_TRANS_H__ #define __MTD_TRANS_H__
#include <asm/semaphore.h> #include <linux/mutex.h>
struct hd_geometry; struct hd_geometry;
struct mtd_info; struct mtd_info;
...@@ -22,7 +22,7 @@ struct mtd_blktrans_dev { ...@@ -22,7 +22,7 @@ struct mtd_blktrans_dev {
struct mtd_blktrans_ops *tr; struct mtd_blktrans_ops *tr;
struct list_head list; struct list_head list;
struct mtd_info *mtd; struct mtd_info *mtd;
struct semaphore sem; struct mutex lock;
int devnum; int devnum;
int blksize; int blksize;
unsigned long size; unsigned long size;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define __MTD_DOC2000_H__ #define __MTD_DOC2000_H__
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#define DoC_Sig1 0 #define DoC_Sig1 0
#define DoC_Sig2 1 #define DoC_Sig2 1
...@@ -187,7 +187,7 @@ struct DiskOnChip { ...@@ -187,7 +187,7 @@ struct DiskOnChip {
int numchips; int numchips;
struct Nand *chips; struct Nand *chips;
struct mtd_info *nextdoc; struct mtd_info *nextdoc;
struct semaphore lock; struct mutex lock;
}; };
int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment