mtd/drivers/mtd/chips cfi_cmdset_0001.c,1.108,1.109
Joakim Tjernlund
jocke at infradead.org
Tue Jan 7 19:16:47 EST 2003
Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv21516
Modified Files:
cfi_cmdset_0001.c
Log Message:
Replaced spin_(un)lock_bh() with spin_(un)lock() per dwmw2 suggestion.
Fixed a few error paths as well. dwmw2 does this look ok to you?
Jocke
Index: cfi_cmdset_0001.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0001.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- cfi_cmdset_0001.c 4 Jan 2003 00:57:04 -0000 1.108
+++ cfi_cmdset_0001.c 8 Jan 2003 00:16:44 -0000 1.109
@@ -315,7 +315,7 @@
timeo = jiffies + HZ;
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Check that the chip's ready to talk to us.
* If it's in FL_ERASING state, suspend it and make it talk now.
@@ -341,13 +341,13 @@
/* Urgh. Chip not yet ready to talk to us. */
if (time_after(jiffies, timeo)) {
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in read. WSM status = %llx\n", (__u64)status);
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
goto retry;
@@ -356,7 +356,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -365,7 +365,7 @@
chip->state = FL_POINT;
chip->ref_point_counter++;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
return 0;
}
static int do_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf)
@@ -441,7 +441,7 @@
else
thislen = len;
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
if(chip->state == FL_POINT){
chip->ref_point_counter--;
if(chip->ref_point_counter == 0)
@@ -449,7 +449,7 @@
} else
printk("Warning: unpoint called on non pointed region\n"); /* Should this give an error? */
wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
len -= thislen;
ofs = 0;
@@ -476,7 +476,7 @@
timeo = jiffies + HZ;
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Check that the chip's ready to talk to us.
* If it's in FL_ERASING state, suspend it and make it talk now.
@@ -508,15 +508,15 @@
/* make sure we're in 'read status' mode */
cfi_write(map, CMD(0x70), cmd_addr);
chip->state = FL_ERASING;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "Chip not ready after erase "
"suspended: status = 0x%llx\n", (__u64)status);
return -EIO;
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
suspended = 1;
@@ -548,13 +548,13 @@
/* Urgh. Chip not yet ready to talk to us. */
if (time_after(jiffies, timeo)) {
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in read. WSM status = %llx\n", (__u64)status);
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
goto retry;
@@ -564,7 +564,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -589,7 +589,7 @@
}
wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
return 0;
}
@@ -659,7 +659,7 @@
timeo = jiffies + HZ;
chip=&cfi->chips[chip_num];
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
switch (chip->state) {
case FL_READY:
@@ -673,7 +673,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -691,7 +691,7 @@
}
chip->state=FL_CFI_QUERY;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
/* Move on to the next chip */
chip_num++;
offst=base_offst;
@@ -749,7 +749,7 @@
cfi_word status, status_OK;
unsigned long timeo;
DECLARE_WAITQUEUE(wait, current);
- int z, suspended=0;
+ int z, suspended=0, ret=0;
adr += chip->start;
@@ -758,7 +758,7 @@
timeo = jiffies + HZ;
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Check that the chip's ready to talk to us.
* Later, we can actually think about interrupting it
@@ -781,13 +781,13 @@
/* Urgh. Chip not yet ready to talk to us. */
if (time_after(jiffies, timeo)) {
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in read\n");
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
goto retry;
@@ -817,15 +817,15 @@
/* make sure we're in 'read status' mode */
cfi_write(map, CMD(0x70), adr);
chip->state = FL_ERASING;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "Chip not ready after erase "
"suspended: status = 0x%x\n", status);
return -EIO;
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
suspended = 1;
chip->state = FL_STATUS;
@@ -837,7 +837,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -849,9 +849,9 @@
cfi_write(map, datum, adr);
chip->state = FL_WRITING;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(chip->word_write_time);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
timeo = jiffies + (HZ/2);
z = 0;
@@ -860,11 +860,11 @@
/* Someone's suspended the write. Sleep */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + (HZ / 2); /* FIXME */
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
continue;
}
@@ -876,16 +876,16 @@
if (time_after(jiffies, timeo)) {
chip->state = FL_STATUS;
DISABLE_VPP(map);
- spin_unlock_bh(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in word write\n");
- return -EIO;
+ ret = -EIO;
+ goto out;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
z++;
cfi_udelay(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
if (!z) {
chip->word_write_time--;
@@ -904,10 +904,10 @@
cfi_write(map, CMD(0x50), adr);
/* put back into read status register mode */
cfi_write(map, CMD(0x70), adr);
- wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
- return -EROFS;
+ ret = -EROFS;
+ goto out;
}
+ out:
if (suspended) {
chip->state = chip->oldstate;
/* What if one interleaved chip has finished and the
@@ -923,8 +923,8 @@
cfi_write(map, CMD(0x70), adr);
}
wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
- return 0;
+ spin_unlock(chip->mutex);
+ return ret;
}
@@ -1058,7 +1058,7 @@
cfi_word status, status_OK;
unsigned long cmd_adr, timeo;
DECLARE_WAITQUEUE(wait, current);
- int wbufsize, z, suspended=0;
+ int wbufsize, z, suspended=0, ret=0;
wbufsize = CFIDEV_INTERLEAVE << cfi->cfiq->MaxBufWriteSize;
adr += chip->start;
@@ -1069,7 +1069,7 @@
timeo = jiffies + HZ;
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Check that the chip's ready to talk to us.
* Later, we can actually think about interrupting it
@@ -1089,13 +1089,13 @@
break;
/* Urgh. Chip not yet ready to talk to us. */
if (time_after(jiffies, timeo)) {
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in buffer write\n");
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
goto retry;
@@ -1125,15 +1125,15 @@
/* make sure we're in 'read status' mode */
cfi_write(map, CMD(0x70), adr);
chip->state = FL_ERASING;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "Chip not ready after erase "
"suspended: status = 0x%x\n", status);
return -EIO;
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
suspended = 1;
chip->state = FL_STATUS;
@@ -1145,7 +1145,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -1172,9 +1172,9 @@
if ((status & status_OK) == status_OK)
break;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
if (++z > 20) {
/* Argh. Not ready for write to buffer */
@@ -1185,8 +1185,8 @@
/* Odd. Clear status bits */
cfi_write(map, CMD(0x50), cmd_adr);
cfi_write(map, CMD(0x70), cmd_adr);
- spin_unlock_bh(chip->mutex);
- return -EIO;
+ ret = -EIO;
+ goto out;
}
}
@@ -1205,16 +1205,17 @@
map->write64 (map, *((__u64*)buf)++, adr+z);
} else {
DISABLE_VPP(map);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
}
/* GO GO GO */
cfi_write(map, CMD(0xd0), cmd_adr);
chip->state = FL_WRITING;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(chip->buffer_write_time);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
timeo = jiffies + (HZ/2);
z = 0;
@@ -1223,11 +1224,11 @@
/* Someone's suspended the write. Sleep */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + (HZ / 2); /* FIXME */
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
continue;
}
@@ -1239,16 +1240,16 @@
if (time_after(jiffies, timeo)) {
chip->state = FL_STATUS;
DISABLE_VPP(map);
- spin_unlock_bh(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in bufwrite\n");
- return -EIO;
+ ret = -EIO;
+ goto out;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
z++;
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
if (!z) {
chip->buffer_write_time--;
@@ -1267,10 +1268,10 @@
cfi_write(map, CMD(0x50), cmd_adr);
/* put back into read status register mode */
cfi_write(map, CMD(0x70), adr);
- wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
- return -EROFS;
+ ret = -EROFS;
+ goto out;
}
+ out:
if (suspended) {
chip->state = chip->oldstate;
/* What if one interleaved chip has finished and the
@@ -1286,8 +1287,8 @@
cfi_write(map, CMD(0x70), adr);
}
wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
- return 0;
+ spin_unlock(chip->mutex);
+ return ret;
}
static int cfi_intelext_write_buffers (struct mtd_info *mtd, loff_t to,
@@ -1474,7 +1475,7 @@
timeo = jiffies + HZ;
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Check that the chip's ready to talk to us. */
switch (chip->state) {
@@ -1491,13 +1492,13 @@
/* Urgh. Chip not yet ready to talk to us. */
if (time_after(jiffies, timeo)) {
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "waiting for chip to be ready timed out in erase\n");
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
goto retry;
@@ -1506,7 +1507,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -1523,10 +1524,10 @@
chip->state = FL_ERASING;
chip->oldstate = 0;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((chip->erase_time*HZ)/(2*1000));
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* FIXME. Use a timer to check this, and return immediately. */
/* Once the state machine's known to be working I'll do that */
@@ -1537,10 +1538,10 @@
/* Someone's suspended the erase. Sleep */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
continue;
}
if (chip->oldstate) {
@@ -1564,15 +1565,15 @@
cfi_write(map, CMD(0x50), adr);
cfi_write(map, CMD(0x70), adr);
DISABLE_VPP(map);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
DISABLE_VPP(map);
@@ -1612,7 +1613,7 @@
printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%llx. Retrying...\n", adr, (__u64)status);
timeo = jiffies + HZ;
chip->state = FL_STATUS;
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
goto retry;
}
printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%llx\n", adr, (__u64)status);
@@ -1621,7 +1622,7 @@
}
wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
return ret;
}
@@ -1657,7 +1658,7 @@
chip = &cfi->chips[i];
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
switch(chip->state) {
case FL_READY:
@@ -1671,14 +1672,14 @@
* with the chip now anyway.
*/
case FL_SYNCING:
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
break;
default:
/* Not an idle state */
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
@@ -1691,13 +1692,13 @@
for (i--; i >=0; i--) {
chip = &cfi->chips[i];
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
if (chip->state == FL_SYNCING) {
chip->state = chip->oldstate;
wake_up(&chip->wq);
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
}
}
@@ -1733,7 +1734,7 @@
timeo = jiffies + HZ;
retry:
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Check that the chip's ready to talk to us. */
switch (chip->state) {
@@ -1750,13 +1751,13 @@
/* Urgh. Chip not yet ready to talk to us. */
if (time_after(jiffies, timeo)) {
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
printk(KERN_ERR "%s: waiting for chip to be ready timed out\n", __FUNCTION__);
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
goto retry;
@@ -1765,7 +1766,7 @@
someone changes the status */
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
timeo = jiffies + HZ;
@@ -1784,9 +1785,9 @@
} else
BUG();
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
schedule_timeout(HZ);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* FIXME. Use a timer to check this, and return immediately. */
/* Once the state machine's known to be working I'll do that */
@@ -1804,21 +1805,21 @@
chip->state = FL_STATUS;
printk(KERN_ERR "waiting for unlock to complete timed out. Xstatus = %llx, status = %llx.\n", (__u64)status, (__u64)cfi_read(map, adr));
DISABLE_VPP(map);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
return -EIO;
}
/* Latency issues. Drop the lock, wait a while and retry */
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
cfi_udelay(1);
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
}
/* Done and happy. */
chip->state = FL_STATUS;
DISABLE_VPP(map);
wake_up(&chip->wq);
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
return 0;
}
@@ -1880,7 +1881,7 @@
for (i=0; !ret && i<cfi->numchips; i++) {
chip = &cfi->chips[i];
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
switch(chip->state) {
case FL_READY:
@@ -1900,7 +1901,7 @@
ret = -EAGAIN;
break;
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
}
/* Unlock the chips again */
@@ -1909,7 +1910,7 @@
for (i--; i >=0; i--) {
chip = &cfi->chips[i];
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
if (chip->state == FL_PM_SUSPENDED) {
/* No need to force it into a known state here,
@@ -1918,7 +1919,7 @@
chip->state = chip->oldstate;
wake_up(&chip->wq);
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
}
}
@@ -1936,7 +1937,7 @@
chip = &cfi->chips[i];
- spin_lock_bh(chip->mutex);
+ spin_lock(chip->mutex);
/* Go to known state. Chip may have been power cycled */
if (chip->state == FL_PM_SUSPENDED) {
@@ -1945,7 +1946,7 @@
wake_up(&chip->wq);
}
- spin_unlock_bh(chip->mutex);
+ spin_unlock(chip->mutex);
}
}
More information about the linux-mtd-cvs
mailing list