aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r--drivers/ide/ide-tape.c155
1 files changed, 49 insertions, 106 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index f8c84df4a0bc..25ac60f53273 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -172,23 +172,16 @@ typedef struct ide_tape_obj {
172 struct kref kref; 172 struct kref kref;
173 173
174 /* 174 /*
175 * pc points to the current processed packet command.
176 *
177 * failed_pc points to the last failed packet command, or contains 175 * failed_pc points to the last failed packet command, or contains
178 * NULL if we do not need to retry any packet command. This is 176 * NULL if we do not need to retry any packet command. This is
179 * required since an additional packet command is needed before the 177 * required since an additional packet command is needed before the
180 * retry, to get detailed information on what went wrong. 178 * retry, to get detailed information on what went wrong.
181 */ 179 */
182 /* Current packet command */
183 struct ide_atapi_pc *pc;
184 /* Last failed packet command */ 180 /* Last failed packet command */
185 struct ide_atapi_pc *failed_pc; 181 struct ide_atapi_pc *failed_pc;
186 /* used by REQ_IDETAPE_{READ,WRITE} requests */ 182 /* used by REQ_IDETAPE_{READ,WRITE} requests */
187 struct ide_atapi_pc queued_pc; 183 struct ide_atapi_pc queued_pc;
188 184
189 struct ide_atapi_pc request_sense_pc;
190 struct request request_sense_rq;
191
192 /* 185 /*
193 * DSC polling variables. 186 * DSC polling variables.
194 * 187 *
@@ -274,11 +267,6 @@ static DEFINE_MUTEX(idetape_ref_mutex);
274 267
275static struct class *idetape_sysfs_class; 268static struct class *idetape_sysfs_class;
276 269
277#define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref)
278
279#define ide_tape_g(disk) \
280 container_of((disk)->private_data, struct ide_tape_obj, driver)
281
282static void ide_tape_release(struct kref *); 270static void ide_tape_release(struct kref *);
283 271
284static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) 272static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
@@ -286,7 +274,7 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
286 struct ide_tape_obj *tape = NULL; 274 struct ide_tape_obj *tape = NULL;
287 275
288 mutex_lock(&idetape_ref_mutex); 276 mutex_lock(&idetape_ref_mutex);
289 tape = ide_tape_g(disk); 277 tape = ide_drv_g(disk, ide_tape_obj);
290 if (tape) { 278 if (tape) {
291 if (ide_device_get(tape->drive)) 279 if (ide_device_get(tape->drive))
292 tape = NULL; 280 tape = NULL;
@@ -313,8 +301,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
313 */ 301 */
314static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; 302static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];
315 303
316#define ide_tape_f(file) ((file)->private_data)
317
318static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) 304static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
319{ 305{
320 struct ide_tape_obj *tape = NULL; 306 struct ide_tape_obj *tape = NULL;
@@ -522,14 +508,19 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
522 return 0; 508 return 0;
523} 509}
524 510
525static void ide_tape_callback(ide_drive_t *drive) 511static void ide_tape_handle_dsc(ide_drive_t *);
512
513static void ide_tape_callback(ide_drive_t *drive, int dsc)
526{ 514{
527 idetape_tape_t *tape = drive->driver_data; 515 idetape_tape_t *tape = drive->driver_data;
528 struct ide_atapi_pc *pc = tape->pc; 516 struct ide_atapi_pc *pc = drive->pc;
529 int uptodate = pc->error ? 0 : 1; 517 int uptodate = pc->error ? 0 : 1;
530 518
531 debug_log(DBG_PROCS, "Enter %s\n", __func__); 519 debug_log(DBG_PROCS, "Enter %s\n", __func__);
532 520
521 if (dsc)
522 ide_tape_handle_dsc(drive);
523
533 if (tape->failed_pc == pc) 524 if (tape->failed_pc == pc)
534 tape->failed_pc = NULL; 525 tape->failed_pc = NULL;
535 526
@@ -558,7 +549,7 @@ static void ide_tape_callback(ide_drive_t *drive)
558 if (pc->error) 549 if (pc->error)
559 uptodate = pc->error; 550 uptodate = pc->error;
560 } else if (pc->c[0] == READ_POSITION && uptodate) { 551 } else if (pc->c[0] == READ_POSITION && uptodate) {
561 u8 *readpos = tape->pc->buf; 552 u8 *readpos = pc->buf;
562 553
563 debug_log(DBG_SENSE, "BOP - %s\n", 554 debug_log(DBG_SENSE, "BOP - %s\n",
564 (readpos[0] & 0x80) ? "Yes" : "No"); 555 (readpos[0] & 0x80) ? "Yes" : "No");
@@ -583,31 +574,6 @@ static void ide_tape_callback(ide_drive_t *drive)
583 idetape_end_request(drive, uptodate, 0); 574 idetape_end_request(drive, uptodate, 0);
584} 575}
585 576
586static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
587{
588 ide_init_pc(pc);
589 pc->c[0] = REQUEST_SENSE;
590 pc->c[4] = 20;
591 pc->req_xfer = 20;
592}
593
594/*
595 * idetape_retry_pc is called when an error was detected during the
596 * last packet command. We queue a request sense packet command in
597 * the head of the request list.
598 */
599static void idetape_retry_pc(ide_drive_t *drive)
600{
601 struct ide_tape_obj *tape = drive->driver_data;
602 struct request *rq = &tape->request_sense_rq;
603 struct ide_atapi_pc *pc = &tape->request_sense_pc;
604
605 (void)ide_read_error(drive);
606 idetape_create_request_sense_cmd(pc);
607 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
608 ide_queue_pc_head(drive, tape->disk, pc, rq);
609}
610
611/* 577/*
612 * Postpone the current request so that ide.c will be able to service requests 578 * Postpone the current request so that ide.c will be able to service requests
613 * from another device on the same hwgroup while we are polling for DSC. 579 * from another device on the same hwgroup while we are polling for DSC.
@@ -646,34 +612,18 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
646} 612}
647 613
648/* 614/*
649 * This is the usual interrupt handler which will be called during a packet
650 * command. We will transfer some of the data (as requested by the drive) and
651 * will re-point interrupt handler to us. When data transfer is finished, we
652 * will act according to the algorithm described before
653 * idetape_issue_pc.
654 */
655static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
656{
657 idetape_tape_t *tape = drive->driver_data;
658
659 return ide_pc_intr(drive, tape->pc, idetape_pc_intr, WAIT_TAPE_CMD,
660 NULL, idetape_update_buffers, idetape_retry_pc,
661 ide_tape_handle_dsc, ide_tape_io_buffers);
662}
663
664/*
665 * Packet Command Interface 615 * Packet Command Interface
666 * 616 *
667 * The current Packet Command is available in tape->pc, and will not change 617 * The current Packet Command is available in drive->pc, and will not change
668 * until we finish handling it. Each packet command is associated with a 618 * until we finish handling it. Each packet command is associated with a
669 * callback function that will be called when the command is finished. 619 * callback function that will be called when the command is finished.
670 * 620 *
671 * The handling will be done in three stages: 621 * The handling will be done in three stages:
672 * 622 *
673 * 1. idetape_issue_pc will send the packet command to the drive, and will set 623 * 1. idetape_issue_pc will send the packet command to the drive, and will set
674 * the interrupt handler to idetape_pc_intr. 624 * the interrupt handler to ide_pc_intr.
675 * 625 *
676 * 2. On each interrupt, idetape_pc_intr will be called. This step will be 626 * 2. On each interrupt, ide_pc_intr will be called. This step will be
677 * repeated until the device signals us that no more interrupts will be issued. 627 * repeated until the device signals us that no more interrupts will be issued.
678 * 628 *
679 * 3. ATAPI Tape media access commands have immediate status with a delayed 629 * 3. ATAPI Tape media access commands have immediate status with a delayed
@@ -697,20 +647,13 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
697 * again, the callback function will be called and then we will handle the next 647 * again, the callback function will be called and then we will handle the next
698 * request. 648 * request.
699 */ 649 */
700static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
701{
702 idetape_tape_t *tape = drive->driver_data;
703
704 return ide_transfer_pc(drive, tape->pc, idetape_pc_intr,
705 WAIT_TAPE_CMD, NULL);
706}
707 650
708static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, 651static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
709 struct ide_atapi_pc *pc) 652 struct ide_atapi_pc *pc)
710{ 653{
711 idetape_tape_t *tape = drive->driver_data; 654 idetape_tape_t *tape = drive->driver_data;
712 655
713 if (tape->pc->c[0] == REQUEST_SENSE && 656 if (drive->pc->c[0] == REQUEST_SENSE &&
714 pc->c[0] == REQUEST_SENSE) { 657 pc->c[0] == REQUEST_SENSE) {
715 printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " 658 printk(KERN_ERR "ide-tape: possible ide-tape.c bug - "
716 "Two request sense in serial were issued\n"); 659 "Two request sense in serial were issued\n");
@@ -718,8 +661,9 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
718 661
719 if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) 662 if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE)
720 tape->failed_pc = pc; 663 tape->failed_pc = pc;
664
721 /* Set the current packet command */ 665 /* Set the current packet command */
722 tape->pc = pc; 666 drive->pc = pc;
723 667
724 if (pc->retries > IDETAPE_MAX_PC_RETRIES || 668 if (pc->retries > IDETAPE_MAX_PC_RETRIES ||
725 (pc->flags & PC_FLAG_ABORT)) { 669 (pc->flags & PC_FLAG_ABORT)) {
@@ -743,15 +687,14 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
743 pc->error = IDETAPE_ERROR_GENERAL; 687 pc->error = IDETAPE_ERROR_GENERAL;
744 } 688 }
745 tape->failed_pc = NULL; 689 tape->failed_pc = NULL;
746 drive->pc_callback(drive); 690 drive->pc_callback(drive, 0);
747 return ide_stopped; 691 return ide_stopped;
748 } 692 }
749 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); 693 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]);
750 694
751 pc->retries++; 695 pc->retries++;
752 696
753 return ide_issue_pc(drive, pc, idetape_transfer_pc, 697 return ide_issue_pc(drive, WAIT_TAPE_CMD, NULL);
754 WAIT_TAPE_CMD, NULL);
755} 698}
756 699
757/* A mode sense command is used to "sense" tape parameters. */ 700/* A mode sense command is used to "sense" tape parameters. */
@@ -785,7 +728,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
785{ 728{
786 ide_hwif_t *hwif = drive->hwif; 729 ide_hwif_t *hwif = drive->hwif;
787 idetape_tape_t *tape = drive->driver_data; 730 idetape_tape_t *tape = drive->driver_data;
788 struct ide_atapi_pc *pc = tape->pc; 731 struct ide_atapi_pc *pc = drive->pc;
789 u8 stat; 732 u8 stat;
790 733
791 stat = hwif->tp_ops->read_status(hwif); 734 stat = hwif->tp_ops->read_status(hwif);
@@ -797,7 +740,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
797 printk(KERN_ERR "ide-tape: %s: I/O error, ", 740 printk(KERN_ERR "ide-tape: %s: I/O error, ",
798 tape->name); 741 tape->name);
799 /* Retry operation */ 742 /* Retry operation */
800 idetape_retry_pc(drive); 743 ide_retry_pc(drive, tape->disk);
801 return ide_stopped; 744 return ide_stopped;
802 } 745 }
803 pc->error = 0; 746 pc->error = 0;
@@ -805,7 +748,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
805 pc->error = IDETAPE_ERROR_GENERAL; 748 pc->error = IDETAPE_ERROR_GENERAL;
806 tape->failed_pc = NULL; 749 tape->failed_pc = NULL;
807 } 750 }
808 drive->pc_callback(drive); 751 drive->pc_callback(drive, 0);
809 return ide_stopped; 752 return ide_stopped;
810} 753}
811 754
@@ -862,7 +805,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
862 } 805 }
863 806
864 /* Retry a failed packet command */ 807 /* Retry a failed packet command */
865 if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) { 808 if (tape->failed_pc && drive->pc->c[0] == REQUEST_SENSE) {
866 pc = tape->failed_pc; 809 pc = tape->failed_pc;
867 goto out; 810 goto out;
868 } 811 }
@@ -883,12 +826,13 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
883 */ 826 */
884 stat = hwif->tp_ops->read_status(hwif); 827 stat = hwif->tp_ops->read_status(hwif);
885 828
886 if (!drive->dsc_overlap && !(rq->cmd[13] & REQ_IDETAPE_PC2)) 829 if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 &&
830 (rq->cmd[13] & REQ_IDETAPE_PC2) == 0)
887 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 831 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
888 832
889 if (drive->post_reset == 1) { 833 if (drive->dev_flags & IDE_DFLAG_POST_RESET) {
890 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 834 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
891 drive->post_reset = 0; 835 drive->dev_flags &= ~IDE_DFLAG_POST_RESET;
892 } 836 }
893 837
894 if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && 838 if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) &&
@@ -1411,7 +1355,7 @@ static int idetape_init_read(ide_drive_t *drive)
1411 * No point in issuing this if DSC overlap isn't supported, some 1355 * No point in issuing this if DSC overlap isn't supported, some
1412 * drives (Seagate STT3401A) will return an error. 1356 * drives (Seagate STT3401A) will return an error.
1413 */ 1357 */
1414 if (drive->dsc_overlap) { 1358 if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) {
1415 bytes_read = idetape_queue_rw_tail(drive, 1359 bytes_read = idetape_queue_rw_tail(drive,
1416 REQ_IDETAPE_READ, 0, 1360 REQ_IDETAPE_READ, 0,
1417 tape->merge_bh); 1361 tape->merge_bh);
@@ -1592,7 +1536,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
1592static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, 1536static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
1593 size_t count, loff_t *ppos) 1537 size_t count, loff_t *ppos)
1594{ 1538{
1595 struct ide_tape_obj *tape = ide_tape_f(file); 1539 struct ide_tape_obj *tape = file->private_data;
1596 ide_drive_t *drive = tape->drive; 1540 ide_drive_t *drive = tape->drive;
1597 ssize_t bytes_read, temp, actually_read = 0, rc; 1541 ssize_t bytes_read, temp, actually_read = 0, rc;
1598 ssize_t ret = 0; 1542 ssize_t ret = 0;
@@ -1654,7 +1598,7 @@ finish:
1654static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, 1598static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
1655 size_t count, loff_t *ppos) 1599 size_t count, loff_t *ppos)
1656{ 1600{
1657 struct ide_tape_obj *tape = ide_tape_f(file); 1601 struct ide_tape_obj *tape = file->private_data;
1658 ide_drive_t *drive = tape->drive; 1602 ide_drive_t *drive = tape->drive;
1659 ssize_t actually_written = 0; 1603 ssize_t actually_written = 0;
1660 ssize_t ret = 0; 1604 ssize_t ret = 0;
@@ -1687,7 +1631,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
1687 * point in issuing this if DSC overlap isn't supported, some 1631 * point in issuing this if DSC overlap isn't supported, some
1688 * drives (Seagate STT3401A) will return an error. 1632 * drives (Seagate STT3401A) will return an error.
1689 */ 1633 */
1690 if (drive->dsc_overlap) { 1634 if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) {
1691 ssize_t retval = idetape_queue_rw_tail(drive, 1635 ssize_t retval = idetape_queue_rw_tail(drive,
1692 REQ_IDETAPE_WRITE, 0, 1636 REQ_IDETAPE_WRITE, 0,
1693 tape->merge_bh); 1637 tape->merge_bh);
@@ -1886,7 +1830,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1886static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, 1830static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
1887 unsigned int cmd, unsigned long arg) 1831 unsigned int cmd, unsigned long arg)
1888{ 1832{
1889 struct ide_tape_obj *tape = ide_tape_f(file); 1833 struct ide_tape_obj *tape = file->private_data;
1890 ide_drive_t *drive = tape->drive; 1834 ide_drive_t *drive = tape->drive;
1891 struct mtop mtop; 1835 struct mtop mtop;
1892 struct mtget mtget; 1836 struct mtget mtget;
@@ -2063,7 +2007,7 @@ static void idetape_write_release(ide_drive_t *drive, unsigned int minor)
2063 2007
2064static int idetape_chrdev_release(struct inode *inode, struct file *filp) 2008static int idetape_chrdev_release(struct inode *inode, struct file *filp)
2065{ 2009{
2066 struct ide_tape_obj *tape = ide_tape_f(filp); 2010 struct ide_tape_obj *tape = filp->private_data;
2067 ide_drive_t *drive = tape->drive; 2011 ide_drive_t *drive = tape->drive;
2068 unsigned int minor = iminor(inode); 2012 unsigned int minor = iminor(inode);
2069 2013
@@ -2202,7 +2146,7 @@ static int divf_tdsc(ide_drive_t *drive) { return HZ; }
2202static int divf_buffer(ide_drive_t *drive) { return 2; } 2146static int divf_buffer(ide_drive_t *drive) { return 2; }
2203static int divf_buffer_size(ide_drive_t *drive) { return 1024; } 2147static int divf_buffer_size(ide_drive_t *drive) { return 1024; }
2204 2148
2205ide_devset_rw_field(dsc_overlap, dsc_overlap); 2149ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP);
2206 2150
2207ide_tape_devset_rw_field(debug_mask, debug_mask); 2151ide_tape_devset_rw_field(debug_mask, debug_mask);
2208ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); 2152ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq);
@@ -2241,33 +2185,32 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
2241 unsigned long t; 2185 unsigned long t;
2242 int speed; 2186 int speed;
2243 int buffer_size; 2187 int buffer_size;
2244 u8 gcw[2];
2245 u16 *ctl = (u16 *)&tape->caps[12]; 2188 u16 *ctl = (u16 *)&tape->caps[12];
2246 2189
2247 drive->pc_callback = ide_tape_callback; 2190 drive->pc_callback = ide_tape_callback;
2191 drive->pc_update_buffers = idetape_update_buffers;
2192 drive->pc_io_buffers = ide_tape_io_buffers;
2248 2193
2249 spin_lock_init(&tape->lock); 2194 spin_lock_init(&tape->lock);
2250 drive->dsc_overlap = 1; 2195
2196 drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP;
2197
2251 if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { 2198 if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) {
2252 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", 2199 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n",
2253 tape->name); 2200 tape->name);
2254 drive->dsc_overlap = 0; 2201 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
2255 } 2202 }
2203
2256 /* Seagate Travan drives do not support DSC overlap. */ 2204 /* Seagate Travan drives do not support DSC overlap. */
2257 if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401")) 2205 if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401"))
2258 drive->dsc_overlap = 0; 2206 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
2207
2259 tape->minor = minor; 2208 tape->minor = minor;
2260 tape->name[0] = 'h'; 2209 tape->name[0] = 'h';
2261 tape->name[1] = 't'; 2210 tape->name[1] = 't';
2262 tape->name[2] = '0' + minor; 2211 tape->name[2] = '0' + minor;
2263 tape->chrdev_dir = IDETAPE_DIR_NONE; 2212 tape->chrdev_dir = IDETAPE_DIR_NONE;
2264 2213
2265 *((u16 *)&gcw) = drive->id[ATA_ID_CONFIG];
2266
2267 /* Command packet DRQ type */
2268 if (((gcw[0] & 0x60) >> 5) == 1)
2269 set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags);
2270
2271 idetape_get_inquiry_results(drive); 2214 idetape_get_inquiry_results(drive);
2272 idetape_get_mode_sense_results(drive); 2215 idetape_get_mode_sense_results(drive);
2273 ide_tape_get_bsize_from_bdesc(drive); 2216 ide_tape_get_bsize_from_bdesc(drive);
@@ -2302,7 +2245,7 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
2302 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size, 2245 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size,
2303 tape->buffer_size / 1024, 2246 tape->buffer_size / 1024,
2304 tape->best_dsc_rw_freq * 1000 / HZ, 2247 tape->best_dsc_rw_freq * 1000 / HZ,
2305 drive->using_dma ? ", DMA":""); 2248 (drive->dev_flags & IDE_DFLAG_USING_DMA) ? ", DMA" : "");
2306 2249
2307 ide_proc_register_driver(drive, tape->driver); 2250 ide_proc_register_driver(drive, tape->driver);
2308} 2251}
@@ -2320,13 +2263,13 @@ static void ide_tape_remove(ide_drive_t *drive)
2320 2263
2321static void ide_tape_release(struct kref *kref) 2264static void ide_tape_release(struct kref *kref)
2322{ 2265{
2323 struct ide_tape_obj *tape = to_ide_tape(kref); 2266 struct ide_tape_obj *tape = to_ide_drv(kref, ide_tape_obj);
2324 ide_drive_t *drive = tape->drive; 2267 ide_drive_t *drive = tape->drive;
2325 struct gendisk *g = tape->disk; 2268 struct gendisk *g = tape->disk;
2326 2269
2327 BUG_ON(tape->merge_bh_size); 2270 BUG_ON(tape->merge_bh_size);
2328 2271
2329 drive->dsc_overlap = 0; 2272 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
2330 drive->driver_data = NULL; 2273 drive->driver_data = NULL;
2331 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); 2274 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor));
2332 device_destroy(idetape_sysfs_class, 2275 device_destroy(idetape_sysfs_class,
@@ -2368,7 +2311,6 @@ static ide_driver_t idetape_driver = {
2368 .probe = ide_tape_probe, 2311 .probe = ide_tape_probe,
2369 .remove = ide_tape_remove, 2312 .remove = ide_tape_remove,
2370 .version = IDETAPE_VERSION, 2313 .version = IDETAPE_VERSION,
2371 .media = ide_tape,
2372 .do_request = idetape_do_request, 2314 .do_request = idetape_do_request,
2373 .end_request = idetape_end_request, 2315 .end_request = idetape_end_request,
2374 .error = __ide_error, 2316 .error = __ide_error,
@@ -2403,7 +2345,7 @@ static int idetape_open(struct inode *inode, struct file *filp)
2403static int idetape_release(struct inode *inode, struct file *filp) 2345static int idetape_release(struct inode *inode, struct file *filp)
2404{ 2346{
2405 struct gendisk *disk = inode->i_bdev->bd_disk; 2347 struct gendisk *disk = inode->i_bdev->bd_disk;
2406 struct ide_tape_obj *tape = ide_tape_g(disk); 2348 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj);
2407 2349
2408 ide_tape_put(tape); 2350 ide_tape_put(tape);
2409 2351
@@ -2414,7 +2356,7 @@ static int idetape_ioctl(struct inode *inode, struct file *file,
2414 unsigned int cmd, unsigned long arg) 2356 unsigned int cmd, unsigned long arg)
2415{ 2357{
2416 struct block_device *bdev = inode->i_bdev; 2358 struct block_device *bdev = inode->i_bdev;
2417 struct ide_tape_obj *tape = ide_tape_g(bdev->bd_disk); 2359 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj);
2418 ide_drive_t *drive = tape->drive; 2360 ide_drive_t *drive = tape->drive;
2419 int err = generic_ide_ioctl(drive, file, bdev, cmd, arg); 2361 int err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
2420 if (err == -EINVAL) 2362 if (err == -EINVAL)
@@ -2441,7 +2383,8 @@ static int ide_tape_probe(ide_drive_t *drive)
2441 if (drive->media != ide_tape) 2383 if (drive->media != ide_tape)
2442 goto failed; 2384 goto failed;
2443 2385
2444 if (drive->id_read == 1 && !ide_check_atapi_device(drive, DRV_NAME)) { 2386 if ((drive->dev_flags & IDE_DFLAG_ID_READ) &&
2387 ide_check_atapi_device(drive, DRV_NAME) == 0) {
2445 printk(KERN_ERR "ide-tape: %s: not supported by this version of" 2388 printk(KERN_ERR "ide-tape: %s: not supported by this version of"
2446 " the driver\n", drive->name); 2389 " the driver\n", drive->name);
2447 goto failed; 2390 goto failed;