diff options
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/mtd_dataflash.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index a987e917f4e0..a5ed6d232c35 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | #include <linux/mutex.h> | ||
17 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
18 | #include <linux/spi/flash.h> | 19 | #include <linux/spi/flash.h> |
19 | 20 | ||
@@ -89,7 +90,7 @@ struct dataflash { | |||
89 | unsigned short page_offset; /* offset in flash address */ | 90 | unsigned short page_offset; /* offset in flash address */ |
90 | unsigned int page_size; /* of bytes per page */ | 91 | unsigned int page_size; /* of bytes per page */ |
91 | 92 | ||
92 | struct semaphore lock; | 93 | struct mutex lock; |
93 | struct spi_device *spi; | 94 | struct spi_device *spi; |
94 | 95 | ||
95 | struct mtd_info mtd; | 96 | struct mtd_info mtd; |
@@ -167,7 +168,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
167 | x.len = 4; | 168 | x.len = 4; |
168 | spi_message_add_tail(&x, &msg); | 169 | spi_message_add_tail(&x, &msg); |
169 | 170 | ||
170 | down(&priv->lock); | 171 | mutex_lock(&priv->lock); |
171 | while (instr->len > 0) { | 172 | while (instr->len > 0) { |
172 | unsigned int pageaddr; | 173 | unsigned int pageaddr; |
173 | int status; | 174 | int status; |
@@ -210,7 +211,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
210 | instr->len -= priv->page_size; | 211 | instr->len -= priv->page_size; |
211 | } | 212 | } |
212 | } | 213 | } |
213 | up(&priv->lock); | 214 | mutex_unlock(&priv->lock); |
214 | 215 | ||
215 | /* Inform MTD subsystem that erase is complete */ | 216 | /* Inform MTD subsystem that erase is complete */ |
216 | instr->state = MTD_ERASE_DONE; | 217 | instr->state = MTD_ERASE_DONE; |
@@ -266,7 +267,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
266 | x[1].len = len; | 267 | x[1].len = len; |
267 | spi_message_add_tail(&x[1], &msg); | 268 | spi_message_add_tail(&x[1], &msg); |
268 | 269 | ||
269 | down(&priv->lock); | 270 | mutex_lock(&priv->lock); |
270 | 271 | ||
271 | /* Continuous read, max clock = f(car) which may be less than | 272 | /* Continuous read, max clock = f(car) which may be less than |
272 | * the peak rate available. Some chips support commands with | 273 | * the peak rate available. Some chips support commands with |
@@ -279,7 +280,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
279 | /* plus 4 "don't care" bytes */ | 280 | /* plus 4 "don't care" bytes */ |
280 | 281 | ||
281 | status = spi_sync(priv->spi, &msg); | 282 | status = spi_sync(priv->spi, &msg); |
282 | up(&priv->lock); | 283 | mutex_unlock(&priv->lock); |
283 | 284 | ||
284 | if (status >= 0) { | 285 | if (status >= 0) { |
285 | *retlen = msg.actual_length - 8; | 286 | *retlen = msg.actual_length - 8; |
@@ -336,7 +337,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
336 | else | 337 | else |
337 | writelen = len; | 338 | writelen = len; |
338 | 339 | ||
339 | down(&priv->lock); | 340 | mutex_lock(&priv->lock); |
340 | while (remaining > 0) { | 341 | while (remaining > 0) { |
341 | DEBUG(MTD_DEBUG_LEVEL3, "write @ %i:%i len=%i\n", | 342 | DEBUG(MTD_DEBUG_LEVEL3, "write @ %i:%i len=%i\n", |
342 | pageaddr, offset, writelen); | 343 | pageaddr, offset, writelen); |
@@ -441,7 +442,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
441 | else | 442 | else |
442 | writelen = remaining; | 443 | writelen = remaining; |
443 | } | 444 | } |
444 | up(&priv->lock); | 445 | mutex_unlock(&priv->lock); |
445 | 446 | ||
446 | return status; | 447 | return status; |
447 | } | 448 | } |
@@ -463,7 +464,7 @@ add_dataflash(struct spi_device *spi, char *name, | |||
463 | if (!priv) | 464 | if (!priv) |
464 | return -ENOMEM; | 465 | return -ENOMEM; |
465 | 466 | ||
466 | init_MUTEX(&priv->lock); | 467 | mutex_init(&priv->lock); |
467 | priv->spi = spi; | 468 | priv->spi = spi; |
468 | priv->page_size = pagesize; | 469 | priv->page_size = pagesize; |
469 | priv->page_offset = pageoffset; | 470 | priv->page_offset = pageoffset; |