diff options
author | Borislav Petkov <petkovbb@googlemail.com> | 2009-06-07 09:37:06 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-06-07 09:37:06 -0400 |
commit | 49d8078ad1c3dca5b11ce18391bf6bd9af9acdf5 (patch) | |
tree | f425afffeec4eb8d9019637a5ee4ceacbb1b79db /drivers/ide/ide-tape.c | |
parent | 626542ca2277961aaa64855206574f8ca4f360e3 (diff) |
ide-tape: fix IDE_AFLAG_* atomic accesses
These flags used to be bit numbers and now are single bits in the
->atapi_flags vector. Use them properly.
Spotted-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index f1d3c7b2a2b5..055f52e1ea0e 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -397,7 +397,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
397 | if (readpos[0] & 0x4) { | 397 | if (readpos[0] & 0x4) { |
398 | printk(KERN_INFO "ide-tape: Block location is unknown" | 398 | printk(KERN_INFO "ide-tape: Block location is unknown" |
399 | "to the tape\n"); | 399 | "to the tape\n"); |
400 | clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 400 | clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), |
401 | &drive->atapi_flags); | ||
401 | uptodate = 0; | 402 | uptodate = 0; |
402 | err = IDE_DRV_ERROR_GENERAL; | 403 | err = IDE_DRV_ERROR_GENERAL; |
403 | } else { | 404 | } else { |
@@ -406,7 +407,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
406 | 407 | ||
407 | tape->partition = readpos[1]; | 408 | tape->partition = readpos[1]; |
408 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); | 409 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); |
409 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 410 | set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), |
411 | &drive->atapi_flags); | ||
410 | } | 412 | } |
411 | } | 413 | } |
412 | 414 | ||
@@ -746,7 +748,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
746 | int load_attempted = 0; | 748 | int load_attempted = 0; |
747 | 749 | ||
748 | /* Wait for the tape to become ready */ | 750 | /* Wait for the tape to become ready */ |
749 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 751 | set_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), &drive->atapi_flags); |
750 | timeout += jiffies; | 752 | timeout += jiffies; |
751 | while (time_before(jiffies, timeout)) { | 753 | while (time_before(jiffies, timeout)) { |
752 | if (ide_do_test_unit_ready(drive, disk) == 0) | 754 | if (ide_do_test_unit_ready(drive, disk) == 0) |
@@ -822,7 +824,7 @@ static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) | |||
822 | if (tape->chrdev_dir != IDETAPE_DIR_READ) | 824 | if (tape->chrdev_dir != IDETAPE_DIR_READ) |
823 | return; | 825 | return; |
824 | 826 | ||
825 | clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags); | 827 | clear_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags); |
826 | tape->valid = 0; | 828 | tape->valid = 0; |
827 | if (tape->buf != NULL) { | 829 | if (tape->buf != NULL) { |
828 | kfree(tape->buf); | 830 | kfree(tape->buf); |
@@ -1115,7 +1117,8 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
1115 | 1117 | ||
1116 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 1118 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
1117 | tape->valid = 0; | 1119 | tape->valid = 0; |
1118 | if (test_and_clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) | 1120 | if (test_and_clear_bit(ilog2(IDE_AFLAG_FILEMARK), |
1121 | &drive->atapi_flags)) | ||
1119 | ++count; | 1122 | ++count; |
1120 | ide_tape_discard_merge_buffer(drive, 0); | 1123 | ide_tape_discard_merge_buffer(drive, 0); |
1121 | } | 1124 | } |
@@ -1170,7 +1173,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1170 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 1173 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); |
1171 | 1174 | ||
1172 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 1175 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
1173 | if (test_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags)) | 1176 | if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) |
1174 | if (count > tape->blk_size && | 1177 | if (count > tape->blk_size && |
1175 | (count % tape->blk_size) == 0) | 1178 | (count % tape->blk_size) == 0) |
1176 | tape->user_bs_factor = count / tape->blk_size; | 1179 | tape->user_bs_factor = count / tape->blk_size; |
@@ -1186,7 +1189,8 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1186 | /* refill if staging buffer is empty */ | 1189 | /* refill if staging buffer is empty */ |
1187 | if (!tape->valid) { | 1190 | if (!tape->valid) { |
1188 | /* If we are at a filemark, nothing more to read */ | 1191 | /* If we are at a filemark, nothing more to read */ |
1189 | if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) | 1192 | if (test_bit(ilog2(IDE_AFLAG_FILEMARK), |
1193 | &drive->atapi_flags)) | ||
1190 | break; | 1194 | break; |
1191 | /* read */ | 1195 | /* read */ |
1192 | if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, | 1196 | if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, |
@@ -1204,7 +1208,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1204 | done += todo; | 1208 | done += todo; |
1205 | } | 1209 | } |
1206 | 1210 | ||
1207 | if (!done && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) { | 1211 | if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { |
1208 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); | 1212 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); |
1209 | 1213 | ||
1210 | idetape_space_over_filemarks(drive, MTFSF, 1); | 1214 | idetape_space_over_filemarks(drive, MTFSF, 1); |
@@ -1338,7 +1342,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1338 | ide_tape_discard_merge_buffer(drive, 0); | 1342 | ide_tape_discard_merge_buffer(drive, 0); |
1339 | retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); | 1343 | retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); |
1340 | if (!retval) | 1344 | if (!retval) |
1341 | clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 1345 | clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), |
1346 | &drive->atapi_flags); | ||
1342 | return retval; | 1347 | return retval; |
1343 | case MTNOP: | 1348 | case MTNOP: |
1344 | ide_tape_discard_merge_buffer(drive, 0); | 1349 | ide_tape_discard_merge_buffer(drive, 0); |
@@ -1360,9 +1365,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1360 | mt_count % tape->blk_size) | 1365 | mt_count % tape->blk_size) |
1361 | return -EIO; | 1366 | return -EIO; |
1362 | tape->user_bs_factor = mt_count / tape->blk_size; | 1367 | tape->user_bs_factor = mt_count / tape->blk_size; |
1363 | clear_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); | 1368 | clear_bit(ilog2(IDE_AFLAG_DETECT_BS), |
1369 | &drive->atapi_flags); | ||
1364 | } else | 1370 | } else |
1365 | set_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); | 1371 | set_bit(ilog2(IDE_AFLAG_DETECT_BS), |
1372 | &drive->atapi_flags); | ||
1366 | return 0; | 1373 | return 0; |
1367 | case MTSEEK: | 1374 | case MTSEEK: |
1368 | ide_tape_discard_merge_buffer(drive, 0); | 1375 | ide_tape_discard_merge_buffer(drive, 0); |
@@ -1507,20 +1514,20 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1507 | 1514 | ||
1508 | filp->private_data = tape; | 1515 | filp->private_data = tape; |
1509 | 1516 | ||
1510 | if (test_and_set_bit(IDE_AFLAG_BUSY, &drive->atapi_flags)) { | 1517 | if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { |
1511 | retval = -EBUSY; | 1518 | retval = -EBUSY; |
1512 | goto out_put_tape; | 1519 | goto out_put_tape; |
1513 | } | 1520 | } |
1514 | 1521 | ||
1515 | retval = idetape_wait_ready(drive, 60 * HZ); | 1522 | retval = idetape_wait_ready(drive, 60 * HZ); |
1516 | if (retval) { | 1523 | if (retval) { |
1517 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 1524 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1518 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); | 1525 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); |
1519 | goto out_put_tape; | 1526 | goto out_put_tape; |
1520 | } | 1527 | } |
1521 | 1528 | ||
1522 | idetape_read_position(drive); | 1529 | idetape_read_position(drive); |
1523 | if (!test_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags)) | 1530 | if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags)) |
1524 | (void)idetape_rewind_tape(drive); | 1531 | (void)idetape_rewind_tape(drive); |
1525 | 1532 | ||
1526 | /* Read block size and write protect status from drive. */ | 1533 | /* Read block size and write protect status from drive. */ |
@@ -1536,7 +1543,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1536 | if (tape->write_prot) { | 1543 | if (tape->write_prot) { |
1537 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || | 1544 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || |
1538 | (filp->f_flags & O_ACCMODE) == O_RDWR) { | 1545 | (filp->f_flags & O_ACCMODE) == O_RDWR) { |
1539 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 1546 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1540 | retval = -EROFS; | 1547 | retval = -EROFS; |
1541 | goto out_put_tape; | 1548 | goto out_put_tape; |
1542 | } | 1549 | } |
@@ -1593,15 +1600,17 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1593 | ide_tape_discard_merge_buffer(drive, 1); | 1600 | ide_tape_discard_merge_buffer(drive, 1); |
1594 | } | 1601 | } |
1595 | 1602 | ||
1596 | if (minor < 128 && test_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags)) | 1603 | if (minor < 128 && test_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), |
1604 | &drive->atapi_flags)) | ||
1597 | (void) idetape_rewind_tape(drive); | 1605 | (void) idetape_rewind_tape(drive); |
1606 | |||
1598 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 1607 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
1599 | if (tape->door_locked == DOOR_LOCKED) { | 1608 | if (tape->door_locked == DOOR_LOCKED) { |
1600 | if (!ide_set_media_lock(drive, tape->disk, 0)) | 1609 | if (!ide_set_media_lock(drive, tape->disk, 0)) |
1601 | tape->door_locked = DOOR_UNLOCKED; | 1610 | tape->door_locked = DOOR_UNLOCKED; |
1602 | } | 1611 | } |
1603 | } | 1612 | } |
1604 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 1613 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1605 | ide_tape_put(tape); | 1614 | ide_tape_put(tape); |
1606 | unlock_kernel(); | 1615 | unlock_kernel(); |
1607 | return 0; | 1616 | return 0; |