diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 160 |
1 files changed, 78 insertions, 82 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index bc5fb12b913c..9d6f62baac27 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/major.h> | 31 | #include <linux/major.h> |
32 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
33 | #include <linux/genhd.h> | 33 | #include <linux/genhd.h> |
34 | #include <linux/seq_file.h> | ||
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
36 | #include <linux/ide.h> | 37 | #include <linux/ide.h> |
@@ -47,28 +48,13 @@ | |||
47 | #include <asm/unaligned.h> | 48 | #include <asm/unaligned.h> |
48 | #include <linux/mtio.h> | 49 | #include <linux/mtio.h> |
49 | 50 | ||
50 | enum { | ||
51 | /* output errors only */ | ||
52 | DBG_ERR = (1 << 0), | ||
53 | /* output all sense key/asc */ | ||
54 | DBG_SENSE = (1 << 1), | ||
55 | /* info regarding all chrdev-related procedures */ | ||
56 | DBG_CHRDEV = (1 << 2), | ||
57 | /* all remaining procedures */ | ||
58 | DBG_PROCS = (1 << 3), | ||
59 | }; | ||
60 | |||
61 | /* define to see debug info */ | 51 | /* define to see debug info */ |
62 | #define IDETAPE_DEBUG_LOG 0 | 52 | #undef IDETAPE_DEBUG_LOG |
63 | 53 | ||
64 | #if IDETAPE_DEBUG_LOG | 54 | #ifdef IDETAPE_DEBUG_LOG |
65 | #define debug_log(lvl, fmt, args...) \ | 55 | #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) |
66 | { \ | ||
67 | if (tape->debug_mask & lvl) \ | ||
68 | printk(KERN_INFO "ide-tape: " fmt, ## args); \ | ||
69 | } | ||
70 | #else | 56 | #else |
71 | #define debug_log(lvl, fmt, args...) do {} while (0) | 57 | #define ide_debug_log(lvl, fmt, args...) do {} while (0) |
72 | #endif | 58 | #endif |
73 | 59 | ||
74 | /**************************** Tunable parameters *****************************/ | 60 | /**************************** Tunable parameters *****************************/ |
@@ -170,7 +156,8 @@ typedef struct ide_tape_obj { | |||
170 | * other device. Note that at most we will have only one DSC (usually | 156 | * other device. Note that at most we will have only one DSC (usually |
171 | * data transfer) request in the device request queue. | 157 | * data transfer) request in the device request queue. |
172 | */ | 158 | */ |
173 | struct request *postponed_rq; | 159 | bool postponed_rq; |
160 | |||
174 | /* The time in which we started polling for DSC */ | 161 | /* The time in which we started polling for DSC */ |
175 | unsigned long dsc_polling_start; | 162 | unsigned long dsc_polling_start; |
176 | /* Timer used to poll for dsc */ | 163 | /* Timer used to poll for dsc */ |
@@ -230,8 +217,6 @@ typedef struct ide_tape_obj { | |||
230 | char drv_write_prot; | 217 | char drv_write_prot; |
231 | /* the tape is write protected (hardware or opened as read-only) */ | 218 | /* the tape is write protected (hardware or opened as read-only) */ |
232 | char write_prot; | 219 | char write_prot; |
233 | |||
234 | u32 debug_mask; | ||
235 | } idetape_tape_t; | 220 | } idetape_tape_t; |
236 | 221 | ||
237 | static DEFINE_MUTEX(idetape_ref_mutex); | 222 | static DEFINE_MUTEX(idetape_ref_mutex); |
@@ -290,8 +275,9 @@ static void idetape_analyze_error(ide_drive_t *drive) | |||
290 | tape->asc = sense[12]; | 275 | tape->asc = sense[12]; |
291 | tape->ascq = sense[13]; | 276 | tape->ascq = sense[13]; |
292 | 277 | ||
293 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", | 278 | ide_debug_log(IDE_DBG_FUNC, |
294 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); | 279 | "cmd: 0x%x, sense key = %x, asc = %x, ascq = %x", |
280 | rq->cmd[0], tape->sense_key, tape->asc, tape->ascq); | ||
295 | 281 | ||
296 | /* correct remaining bytes to transfer */ | 282 | /* correct remaining bytes to transfer */ |
297 | if (pc->flags & PC_FLAG_DMA_ERROR) | 283 | if (pc->flags & PC_FLAG_DMA_ERROR) |
@@ -344,7 +330,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
344 | int uptodate = pc->error ? 0 : 1; | 330 | int uptodate = pc->error ? 0 : 1; |
345 | int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; | 331 | int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; |
346 | 332 | ||
347 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 333 | ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc: %d, err: %d", rq->cmd[0], |
334 | dsc, err); | ||
348 | 335 | ||
349 | if (dsc) | 336 | if (dsc) |
350 | ide_tape_handle_dsc(drive); | 337 | ide_tape_handle_dsc(drive); |
@@ -387,13 +374,14 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
387 | * Postpone the current request so that ide.c will be able to service requests | 374 | * Postpone the current request so that ide.c will be able to service requests |
388 | * from another device on the same port while we are polling for DSC. | 375 | * from another device on the same port while we are polling for DSC. |
389 | */ | 376 | */ |
390 | static void idetape_postpone_request(ide_drive_t *drive) | 377 | static void ide_tape_stall_queue(ide_drive_t *drive) |
391 | { | 378 | { |
392 | idetape_tape_t *tape = drive->driver_data; | 379 | idetape_tape_t *tape = drive->driver_data; |
393 | 380 | ||
394 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 381 | ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu", |
382 | drive->hwif->rq->cmd[0], tape->dsc_poll_freq); | ||
395 | 383 | ||
396 | tape->postponed_rq = drive->hwif->rq; | 384 | tape->postponed_rq = true; |
397 | 385 | ||
398 | ide_stall_queue(drive, tape->dsc_poll_freq); | 386 | ide_stall_queue(drive, tape->dsc_poll_freq); |
399 | } | 387 | } |
@@ -407,7 +395,7 @@ static void ide_tape_handle_dsc(ide_drive_t *drive) | |||
407 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; | 395 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; |
408 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; | 396 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; |
409 | /* Allow ide.c to handle other requests */ | 397 | /* Allow ide.c to handle other requests */ |
410 | idetape_postpone_request(drive); | 398 | ide_tape_stall_queue(drive); |
411 | } | 399 | } |
412 | 400 | ||
413 | /* | 401 | /* |
@@ -488,7 +476,8 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
488 | ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); | 476 | ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); |
489 | return ide_stopped; | 477 | return ide_stopped; |
490 | } | 478 | } |
491 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 479 | ide_debug_log(IDE_DBG_SENSE, "retry #%d, cmd: 0x%02x", pc->retries, |
480 | pc->c[0]); | ||
492 | 481 | ||
493 | pc->retries++; | 482 | pc->retries++; |
494 | 483 | ||
@@ -579,12 +568,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
579 | ide_hwif_t *hwif = drive->hwif; | 568 | ide_hwif_t *hwif = drive->hwif; |
580 | idetape_tape_t *tape = drive->driver_data; | 569 | idetape_tape_t *tape = drive->driver_data; |
581 | struct ide_atapi_pc *pc = NULL; | 570 | struct ide_atapi_pc *pc = NULL; |
582 | struct request *postponed_rq = tape->postponed_rq; | ||
583 | struct ide_cmd cmd; | 571 | struct ide_cmd cmd; |
584 | u8 stat; | 572 | u8 stat; |
585 | 573 | ||
586 | debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n" | 574 | ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u", |
587 | (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); | 575 | rq->cmd[0], (unsigned long long)blk_rq_pos(rq), |
576 | blk_rq_sectors(rq)); | ||
588 | 577 | ||
589 | BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); | 578 | BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); |
590 | 579 | ||
@@ -594,18 +583,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
594 | goto out; | 583 | goto out; |
595 | } | 584 | } |
596 | 585 | ||
597 | if (postponed_rq != NULL) | ||
598 | if (rq != postponed_rq) { | ||
599 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " | ||
600 | "Two DSC requests were queued\n"); | ||
601 | drive->failed_pc = NULL; | ||
602 | rq->errors = 0; | ||
603 | ide_complete_rq(drive, 0, blk_rq_bytes(rq)); | ||
604 | return ide_stopped; | ||
605 | } | ||
606 | |||
607 | tape->postponed_rq = NULL; | ||
608 | |||
609 | /* | 586 | /* |
610 | * If the tape is still busy, postpone our request and service | 587 | * If the tape is still busy, postpone our request and service |
611 | * the other device meanwhile. | 588 | * the other device meanwhile. |
@@ -623,7 +600,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
623 | 600 | ||
624 | if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && | 601 | if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && |
625 | !(stat & ATA_DSC)) { | 602 | !(stat & ATA_DSC)) { |
626 | if (postponed_rq == NULL) { | 603 | if (!tape->postponed_rq) { |
627 | tape->dsc_polling_start = jiffies; | 604 | tape->dsc_polling_start = jiffies; |
628 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; | 605 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; |
629 | tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; | 606 | tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; |
@@ -640,10 +617,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
640 | tape->dsc_polling_start + | 617 | tape->dsc_polling_start + |
641 | IDETAPE_DSC_MA_THRESHOLD)) | 618 | IDETAPE_DSC_MA_THRESHOLD)) |
642 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; | 619 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; |
643 | idetape_postpone_request(drive); | 620 | ide_tape_stall_queue(drive); |
644 | return ide_stopped; | 621 | return ide_stopped; |
645 | } else | 622 | } else { |
646 | drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; | 623 | drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; |
624 | tape->postponed_rq = false; | ||
625 | } | ||
647 | 626 | ||
648 | if (rq->cmd[13] & REQ_IDETAPE_READ) { | 627 | if (rq->cmd[13] & REQ_IDETAPE_READ) { |
649 | pc = &tape->queued_pc; | 628 | pc = &tape->queued_pc; |
@@ -745,7 +724,7 @@ static int ide_tape_read_position(ide_drive_t *drive) | |||
745 | struct ide_atapi_pc pc; | 724 | struct ide_atapi_pc pc; |
746 | u8 buf[20]; | 725 | u8 buf[20]; |
747 | 726 | ||
748 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 727 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
749 | 728 | ||
750 | /* prep cmd */ | 729 | /* prep cmd */ |
751 | ide_init_pc(&pc); | 730 | ide_init_pc(&pc); |
@@ -756,9 +735,9 @@ static int ide_tape_read_position(ide_drive_t *drive) | |||
756 | return -1; | 735 | return -1; |
757 | 736 | ||
758 | if (!pc.error) { | 737 | if (!pc.error) { |
759 | debug_log(DBG_SENSE, "BOP - %s\n", | 738 | ide_debug_log(IDE_DBG_FUNC, "BOP - %s", |
760 | (buf[0] & 0x80) ? "Yes" : "No"); | 739 | (buf[0] & 0x80) ? "Yes" : "No"); |
761 | debug_log(DBG_SENSE, "EOP - %s\n", | 740 | ide_debug_log(IDE_DBG_FUNC, "EOP - %s", |
762 | (buf[0] & 0x40) ? "Yes" : "No"); | 741 | (buf[0] & 0x40) ? "Yes" : "No"); |
763 | 742 | ||
764 | if (buf[0] & 0x4) { | 743 | if (buf[0] & 0x4) { |
@@ -768,8 +747,8 @@ static int ide_tape_read_position(ide_drive_t *drive) | |||
768 | &drive->atapi_flags); | 747 | &drive->atapi_flags); |
769 | return -1; | 748 | return -1; |
770 | } else { | 749 | } else { |
771 | debug_log(DBG_SENSE, "Block Location - %u\n", | 750 | ide_debug_log(IDE_DBG_FUNC, "Block Location: %u", |
772 | be32_to_cpup((__be32 *)&buf[4])); | 751 | be32_to_cpup((__be32 *)&buf[4])); |
773 | 752 | ||
774 | tape->partition = buf[1]; | 753 | tape->partition = buf[1]; |
775 | tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); | 754 | tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); |
@@ -866,7 +845,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) | |||
866 | struct request *rq; | 845 | struct request *rq; |
867 | int ret; | 846 | int ret; |
868 | 847 | ||
869 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); | 848 | ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, size: %d", cmd, size); |
849 | |||
870 | BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); | 850 | BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); |
871 | BUG_ON(size < 0 || size % tape->blk_size); | 851 | BUG_ON(size < 0 || size % tape->blk_size); |
872 | 852 | ||
@@ -1029,7 +1009,7 @@ static int idetape_rewind_tape(ide_drive_t *drive) | |||
1029 | struct ide_atapi_pc pc; | 1009 | struct ide_atapi_pc pc; |
1030 | int ret; | 1010 | int ret; |
1031 | 1011 | ||
1032 | debug_log(DBG_SENSE, "Enter %s\n", __func__); | 1012 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
1033 | 1013 | ||
1034 | idetape_create_rewind_cmd(drive, &pc); | 1014 | idetape_create_rewind_cmd(drive, &pc); |
1035 | ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); | 1015 | ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
@@ -1055,7 +1035,7 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, | |||
1055 | int nr_stages; | 1035 | int nr_stages; |
1056 | } config; | 1036 | } config; |
1057 | 1037 | ||
1058 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1038 | ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%04x", cmd); |
1059 | 1039 | ||
1060 | switch (cmd) { | 1040 | switch (cmd) { |
1061 | case 0x0340: | 1041 | case 0x0340: |
@@ -1085,6 +1065,9 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
1085 | int retval, count = 0; | 1065 | int retval, count = 0; |
1086 | int sprev = !!(tape->caps[4] & 0x20); | 1066 | int sprev = !!(tape->caps[4] & 0x20); |
1087 | 1067 | ||
1068 | |||
1069 | ide_debug_log(IDE_DBG_FUNC, "mt_op: %d, mt_count: %d", mt_op, mt_count); | ||
1070 | |||
1088 | if (mt_count == 0) | 1071 | if (mt_count == 0) |
1089 | return 0; | 1072 | return 0; |
1090 | if (MTBSF == mt_op || MTBSFM == mt_op) { | 1073 | if (MTBSF == mt_op || MTBSFM == mt_op) { |
@@ -1148,7 +1131,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1148 | ssize_t ret = 0; | 1131 | ssize_t ret = 0; |
1149 | int rc; | 1132 | int rc; |
1150 | 1133 | ||
1151 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 1134 | ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); |
1152 | 1135 | ||
1153 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 1136 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
1154 | if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) | 1137 | if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) |
@@ -1187,8 +1170,6 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1187 | } | 1170 | } |
1188 | 1171 | ||
1189 | if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { | 1172 | if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { |
1190 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); | ||
1191 | |||
1192 | idetape_space_over_filemarks(drive, MTFSF, 1); | 1173 | idetape_space_over_filemarks(drive, MTFSF, 1); |
1193 | return 0; | 1174 | return 0; |
1194 | } | 1175 | } |
@@ -1209,7 +1190,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
1209 | if (tape->write_prot) | 1190 | if (tape->write_prot) |
1210 | return -EACCES; | 1191 | return -EACCES; |
1211 | 1192 | ||
1212 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 1193 | ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); |
1213 | 1194 | ||
1214 | /* Initialize write operation */ | 1195 | /* Initialize write operation */ |
1215 | rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); | 1196 | rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); |
@@ -1273,8 +1254,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1273 | struct ide_atapi_pc pc; | 1254 | struct ide_atapi_pc pc; |
1274 | int i, retval; | 1255 | int i, retval; |
1275 | 1256 | ||
1276 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", | 1257 | ide_debug_log(IDE_DBG_FUNC, "MTIOCTOP ioctl: mt_op: %d, mt_count: %d", |
1277 | mt_op, mt_count); | 1258 | mt_op, mt_count); |
1278 | 1259 | ||
1279 | switch (mt_op) { | 1260 | switch (mt_op) { |
1280 | case MTFSF: | 1261 | case MTFSF: |
@@ -1393,7 +1374,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
1393 | int block_offset = 0, position = tape->first_frame; | 1374 | int block_offset = 0, position = tape->first_frame; |
1394 | void __user *argp = (void __user *)arg; | 1375 | void __user *argp = (void __user *)arg; |
1395 | 1376 | ||
1396 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); | 1377 | ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x", cmd); |
1397 | 1378 | ||
1398 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { | 1379 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { |
1399 | ide_tape_flush_merge_buffer(drive); | 1380 | ide_tape_flush_merge_buffer(drive); |
@@ -1461,6 +1442,9 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
1461 | (buf[4 + 6] << 8) + | 1442 | (buf[4 + 6] << 8) + |
1462 | buf[4 + 7]; | 1443 | buf[4 + 7]; |
1463 | tape->drv_write_prot = (buf[2] & 0x80) >> 7; | 1444 | tape->drv_write_prot = (buf[2] & 0x80) >> 7; |
1445 | |||
1446 | ide_debug_log(IDE_DBG_FUNC, "blk_size: %d, write_prot: %d", | ||
1447 | tape->blk_size, tape->drv_write_prot); | ||
1464 | } | 1448 | } |
1465 | 1449 | ||
1466 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) | 1450 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) |
@@ -1480,7 +1464,10 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1480 | return -ENXIO; | 1464 | return -ENXIO; |
1481 | } | 1465 | } |
1482 | 1466 | ||
1483 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); | 1467 | drive = tape->drive; |
1468 | filp->private_data = tape; | ||
1469 | |||
1470 | ide_debug_log(IDE_DBG_FUNC, "enter"); | ||
1484 | 1471 | ||
1485 | /* | 1472 | /* |
1486 | * We really want to do nonseekable_open(inode, filp); here, but some | 1473 | * We really want to do nonseekable_open(inode, filp); here, but some |
@@ -1489,9 +1476,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1489 | */ | 1476 | */ |
1490 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); | 1477 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); |
1491 | 1478 | ||
1492 | drive = tape->drive; | ||
1493 | |||
1494 | filp->private_data = tape; | ||
1495 | 1479 | ||
1496 | if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { | 1480 | if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { |
1497 | retval = -EBUSY; | 1481 | retval = -EBUSY; |
@@ -1570,7 +1554,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1570 | lock_kernel(); | 1554 | lock_kernel(); |
1571 | tape = drive->driver_data; | 1555 | tape = drive->driver_data; |
1572 | 1556 | ||
1573 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); | 1557 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
1574 | 1558 | ||
1575 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) | 1559 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) |
1576 | idetape_write_release(drive, minor); | 1560 | idetape_write_release(drive, minor); |
@@ -1707,7 +1691,6 @@ static int divf_buffer_size(ide_drive_t *drive) { return 1024; } | |||
1707 | 1691 | ||
1708 | ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); | 1692 | ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); |
1709 | 1693 | ||
1710 | ide_tape_devset_rw_field(debug_mask, debug_mask); | ||
1711 | ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); | 1694 | ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); |
1712 | 1695 | ||
1713 | ide_tape_devset_r_field(avg_speed, avg_speed); | 1696 | ide_tape_devset_r_field(avg_speed, avg_speed); |
@@ -1719,7 +1702,6 @@ static const struct ide_proc_devset idetape_settings[] = { | |||
1719 | __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), | 1702 | __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), |
1720 | __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), | 1703 | __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), |
1721 | __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), | 1704 | __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), |
1722 | __IDE_PROC_DEVSET(debug_mask, 0, 0xffff, NULL, NULL), | ||
1723 | __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), | 1705 | __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), |
1724 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), | 1706 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), |
1725 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, | 1707 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, |
@@ -1746,7 +1728,9 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
1746 | int buffer_size; | 1728 | int buffer_size; |
1747 | u16 *ctl = (u16 *)&tape->caps[12]; | 1729 | u16 *ctl = (u16 *)&tape->caps[12]; |
1748 | 1730 | ||
1749 | drive->pc_callback = ide_tape_callback; | 1731 | ide_debug_log(IDE_DBG_FUNC, "minor: %d", minor); |
1732 | |||
1733 | drive->pc_callback = ide_tape_callback; | ||
1750 | 1734 | ||
1751 | drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; | 1735 | drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; |
1752 | 1736 | ||
@@ -1833,22 +1817,32 @@ static void ide_tape_release(struct device *dev) | |||
1833 | } | 1817 | } |
1834 | 1818 | ||
1835 | #ifdef CONFIG_IDE_PROC_FS | 1819 | #ifdef CONFIG_IDE_PROC_FS |
1836 | static int proc_idetape_read_name | 1820 | static int idetape_name_proc_show(struct seq_file *m, void *v) |
1837 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
1838 | { | 1821 | { |
1839 | ide_drive_t *drive = (ide_drive_t *) data; | 1822 | ide_drive_t *drive = (ide_drive_t *) m->private; |
1840 | idetape_tape_t *tape = drive->driver_data; | 1823 | idetape_tape_t *tape = drive->driver_data; |
1841 | char *out = page; | ||
1842 | int len; | ||
1843 | 1824 | ||
1844 | len = sprintf(out, "%s\n", tape->name); | 1825 | seq_printf(m, "%s\n", tape->name); |
1845 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 1826 | return 0; |
1827 | } | ||
1828 | |||
1829 | static int idetape_name_proc_open(struct inode *inode, struct file *file) | ||
1830 | { | ||
1831 | return single_open(file, idetape_name_proc_show, PDE(inode)->data); | ||
1846 | } | 1832 | } |
1847 | 1833 | ||
1834 | static const struct file_operations idetape_name_proc_fops = { | ||
1835 | .owner = THIS_MODULE, | ||
1836 | .open = idetape_name_proc_open, | ||
1837 | .read = seq_read, | ||
1838 | .llseek = seq_lseek, | ||
1839 | .release = single_release, | ||
1840 | }; | ||
1841 | |||
1848 | static ide_proc_entry_t idetape_proc[] = { | 1842 | static ide_proc_entry_t idetape_proc[] = { |
1849 | { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL }, | 1843 | { "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops }, |
1850 | { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, | 1844 | { "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops }, |
1851 | { NULL, 0, NULL, NULL } | 1845 | {} |
1852 | }; | 1846 | }; |
1853 | 1847 | ||
1854 | static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) | 1848 | static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) |
@@ -1932,7 +1926,9 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
1932 | struct gendisk *g; | 1926 | struct gendisk *g; |
1933 | int minor; | 1927 | int minor; |
1934 | 1928 | ||
1935 | if (!strstr("ide-tape", drive->driver_req)) | 1929 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
1930 | |||
1931 | if (!strstr(DRV_NAME, drive->driver_req)) | ||
1936 | goto failed; | 1932 | goto failed; |
1937 | 1933 | ||
1938 | if (drive->media != ide_tape) | 1934 | if (drive->media != ide_tape) |