Lines Matching refs:tape
234 struct ide_tape_obj *tape = NULL; in ide_tape_get() local
239 tape = idetape_devs[i]; in ide_tape_get()
241 tape = ide_drv_g(disk, ide_tape_obj); in ide_tape_get()
243 if (tape) { in ide_tape_get()
244 if (ide_device_get(tape->drive)) in ide_tape_get()
245 tape = NULL; in ide_tape_get()
247 get_device(&tape->dev); in ide_tape_get()
251 return tape; in ide_tape_get()
254 static void ide_tape_put(struct ide_tape_obj *tape) in ide_tape_put() argument
256 ide_drive_t *drive = tape->drive; in ide_tape_put()
259 put_device(&tape->dev); in ide_tape_put()
270 idetape_tape_t *tape = drive->driver_data; in idetape_analyze_error() local
275 tape->sense_key = sense[2] & 0xF; in idetape_analyze_error()
276 tape->asc = sense[12]; in idetape_analyze_error()
277 tape->ascq = sense[13]; in idetape_analyze_error()
281 rq->cmd[0], tape->sense_key, tape->asc, tape->ascq); in idetape_analyze_error()
285 rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); in idetape_analyze_error()
295 if (tape->sense_key == 5) { in idetape_analyze_error()
307 if ((sense[2] & 0x40) || (tape->sense_key == 0xd in idetape_analyze_error()
308 && tape->asc == 0x0 && tape->ascq == 0x2)) { in idetape_analyze_error()
314 if (tape->sense_key == 8) { in idetape_analyze_error()
328 idetape_tape_t *tape = drive->driver_data; in ide_tape_callback() local
351 (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; in ide_tape_callback()
353 tape->avg_size += blocks * tape->blk_size; in ide_tape_callback()
355 if (time_after_eq(jiffies, tape->avg_time + HZ)) { in ide_tape_callback()
356 tape->avg_speed = tape->avg_size * HZ / in ide_tape_callback()
357 (jiffies - tape->avg_time) / 1024; in ide_tape_callback()
358 tape->avg_size = 0; in ide_tape_callback()
359 tape->avg_time = jiffies; in ide_tape_callback()
362 tape->first_frame += blocks; in ide_tape_callback()
380 idetape_tape_t *tape = drive->driver_data; in ide_tape_stall_queue() local
383 drive->hwif->rq->cmd[0], tape->dsc_poll_freq); in ide_tape_stall_queue()
385 tape->postponed_rq = true; in ide_tape_stall_queue()
387 ide_stall_queue(drive, tape->dsc_poll_freq); in ide_tape_stall_queue()
392 idetape_tape_t *tape = drive->driver_data; in ide_tape_handle_dsc() local
395 tape->dsc_polling_start = jiffies; in ide_tape_handle_dsc()
396 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; in ide_tape_handle_dsc()
397 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; in ide_tape_handle_dsc()
443 idetape_tape_t *tape = drive->driver_data; in ide_tape_issue_pc() local
462 tape->sense_key == 2 && tape->asc == 4 && in ide_tape_issue_pc()
463 (tape->ascq == 1 || tape->ascq == 8))) { in ide_tape_issue_pc()
467 tape->name, pc->c[0], in ide_tape_issue_pc()
468 tape->sense_key, tape->asc, in ide_tape_issue_pc()
469 tape->ascq); in ide_tape_issue_pc()
518 idetape_tape_t *tape = drive->driver_data; in idetape_media_access_finished() local
529 tape->name); in idetape_media_access_finished()
543 static void ide_tape_create_rw_cmd(idetape_tape_t *tape, in ide_tape_create_rw_cmd() argument
547 unsigned int length = blk_rq_sectors(rq) / (tape->blk_size >> 9); in ide_tape_create_rw_cmd()
553 if (blk_rq_bytes(rq) == tape->buffer_size) in ide_tape_create_rw_cmd()
570 idetape_tape_t *tape = drive->driver_data; in idetape_do_request() local
605 if (!tape->postponed_rq) { in idetape_do_request()
606 tape->dsc_polling_start = jiffies; in idetape_do_request()
607 tape->dsc_poll_freq = tape->best_dsc_rw_freq; in idetape_do_request()
608 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; in idetape_do_request()
609 } else if (time_after(jiffies, tape->dsc_timeout)) { in idetape_do_request()
611 tape->name); in idetape_do_request()
619 tape->dsc_polling_start + in idetape_do_request()
621 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; in idetape_do_request()
626 tape->postponed_rq = false; in idetape_do_request()
630 pc = &tape->queued_pc; in idetape_do_request()
631 ide_tape_create_rw_cmd(tape, pc, rq, READ_6); in idetape_do_request()
635 pc = &tape->queued_pc; in idetape_do_request()
636 ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); in idetape_do_request()
683 idetape_tape_t *tape = drive->driver_data; in idetape_wait_ready() local
684 struct gendisk *disk = tape->disk; in idetape_wait_ready()
693 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) in idetape_wait_ready()
694 || (tape->asc == 0x3A)) { in idetape_wait_ready()
701 } else if (!(tape->sense_key == 2 && tape->asc == 4 && in idetape_wait_ready()
702 (tape->ascq == 1 || tape->ascq == 8))) in idetape_wait_ready()
711 struct ide_tape_obj *tape = drive->driver_data; in idetape_flush_tape_buffers() local
716 rc = ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0); in idetape_flush_tape_buffers()
725 idetape_tape_t *tape = drive->driver_data; in ide_tape_read_position() local
736 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) in ide_tape_read_position()
755 tape->partition = buf[1]; in ide_tape_read_position()
756 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); in ide_tape_read_position()
762 return tape->first_frame; in ide_tape_read_position()
779 idetape_tape_t *tape = drive->driver_data; in __ide_tape_discard_merge_buffer() local
781 if (tape->chrdev_dir != IDETAPE_DIR_READ) in __ide_tape_discard_merge_buffer()
785 tape->valid = 0; in __ide_tape_discard_merge_buffer()
786 if (tape->buf != NULL) { in __ide_tape_discard_merge_buffer()
787 kfree(tape->buf); in __ide_tape_discard_merge_buffer()
788 tape->buf = NULL; in __ide_tape_discard_merge_buffer()
791 tape->chrdev_dir = IDETAPE_DIR_NONE; in __ide_tape_discard_merge_buffer()
803 idetape_tape_t *tape = drive->driver_data; in idetape_position_tape() local
804 struct gendisk *disk = tape->disk; in idetape_position_tape()
808 if (tape->chrdev_dir == IDETAPE_DIR_READ) in idetape_position_tape()
825 idetape_tape_t *tape = drive->driver_data; in ide_tape_discard_merge_buffer() local
834 " %s\n", tape->name, __func__); in ide_tape_discard_merge_buffer()
846 idetape_tape_t *tape = drive->driver_data; in idetape_queue_rw_tail() local
853 BUG_ON(size < 0 || size % tape->blk_size); in idetape_queue_rw_tail()
858 rq->rq_disk = tape->disk; in idetape_queue_rw_tail()
859 rq->__sector = tape->first_frame; in idetape_queue_rw_tail()
862 ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size, in idetape_queue_rw_tail()
868 blk_execute_rq(drive->queue, tape->disk, rq, 0); in idetape_queue_rw_tail()
872 tape->cur = tape->buf; in idetape_queue_rw_tail()
874 tape->valid = size; in idetape_queue_rw_tail()
876 tape->valid = 0; in idetape_queue_rw_tail()
921 idetape_tape_t *tape = drive->driver_data; in ide_tape_flush_merge_buffer() local
923 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { in ide_tape_flush_merge_buffer()
928 if (tape->buf) { in ide_tape_flush_merge_buffer()
929 size_t aligned = roundup(tape->valid, tape->blk_size); in ide_tape_flush_merge_buffer()
931 memset(tape->cur, 0, aligned - tape->valid); in ide_tape_flush_merge_buffer()
933 kfree(tape->buf); in ide_tape_flush_merge_buffer()
934 tape->buf = NULL; in ide_tape_flush_merge_buffer()
936 tape->chrdev_dir = IDETAPE_DIR_NONE; in ide_tape_flush_merge_buffer()
941 idetape_tape_t *tape = drive->driver_data; in idetape_init_rw() local
946 if (tape->chrdev_dir == dir) in idetape_init_rw()
949 if (tape->chrdev_dir == IDETAPE_DIR_READ) in idetape_init_rw()
951 else if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { in idetape_init_rw()
956 if (tape->buf || tape->valid) { in idetape_init_rw()
958 tape->valid = 0; in idetape_init_rw()
961 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); in idetape_init_rw()
962 if (!tape->buf) in idetape_init_rw()
964 tape->chrdev_dir = dir; in idetape_init_rw()
965 tape->cur = tape->buf; in idetape_init_rw()
979 kfree(tape->buf); in idetape_init_rw()
980 tape->buf = NULL; in idetape_init_rw()
981 tape->chrdev_dir = IDETAPE_DIR_NONE; in idetape_init_rw()
991 idetape_tape_t *tape = drive->driver_data; in idetape_pad_zeros() local
993 memset(tape->buf, 0, tape->buffer_size); in idetape_pad_zeros()
996 unsigned int count = min(tape->buffer_size, bcount); in idetape_pad_zeros()
1009 struct ide_tape_obj *tape = drive->driver_data; in idetape_rewind_tape() local
1010 struct gendisk *disk = tape->disk; in idetape_rewind_tape()
1031 idetape_tape_t *tape = drive->driver_data; in idetape_blkdev_ioctl() local
1046 tape->best_dsc_rw_freq = config.dsc_rw_frequency; in idetape_blkdev_ioctl()
1050 config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; in idetape_blkdev_ioctl()
1064 idetape_tape_t *tape = drive->driver_data; in idetape_space_over_filemarks() local
1065 struct gendisk *disk = tape->disk; in idetape_space_over_filemarks()
1068 int sprev = !!(tape->caps[4] & 0x20); in idetape_space_over_filemarks()
1081 if (tape->chrdev_dir == IDETAPE_DIR_READ) { in idetape_space_over_filemarks()
1082 tape->valid = 0; in idetape_space_over_filemarks()
1130 struct ide_tape_obj *tape = file->private_data; in idetape_chrdev_read() local
1131 ide_drive_t *drive = tape->drive; in idetape_chrdev_read()
1138 if (tape->chrdev_dir != IDETAPE_DIR_READ) { in idetape_chrdev_read()
1140 if (count > tape->blk_size && in idetape_chrdev_read()
1141 (count % tape->blk_size) == 0) in idetape_chrdev_read()
1142 tape->user_bs_factor = count / tape->blk_size; in idetape_chrdev_read()
1153 if (!tape->valid) { in idetape_chrdev_read()
1160 tape->buffer_size) <= 0) in idetape_chrdev_read()
1165 todo = min_t(size_t, count - done, tape->valid); in idetape_chrdev_read()
1166 if (copy_to_user(buf + done, tape->cur, todo)) in idetape_chrdev_read()
1169 tape->cur += todo; in idetape_chrdev_read()
1170 tape->valid -= todo; in idetape_chrdev_read()
1185 struct ide_tape_obj *tape = file->private_data; in idetape_chrdev_write() local
1186 ide_drive_t *drive = tape->drive; in idetape_chrdev_write()
1192 if (tape->write_prot) in idetape_chrdev_write()
1206 if (tape->valid == tape->buffer_size && in idetape_chrdev_write()
1208 tape->buffer_size) <= 0) in idetape_chrdev_write()
1213 tape->buffer_size - tape->valid); in idetape_chrdev_write()
1214 if (copy_from_user(tape->cur, buf + done, todo)) in idetape_chrdev_write()
1217 tape->cur += todo; in idetape_chrdev_write()
1218 tape->valid += todo; in idetape_chrdev_write()
1227 struct ide_tape_obj *tape = drive->driver_data; in idetape_write_filemark() local
1232 if (ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0)) { in idetape_write_filemark()
1254 idetape_tape_t *tape = drive->driver_data; in idetape_mtioctop() local
1255 struct gendisk *disk = tape->disk; in idetape_mtioctop()
1276 if (tape->write_prot) in idetape_mtioctop()
1299 if (tape->door_locked) { in idetape_mtioctop()
1301 tape->door_locked = DOOR_UNLOCKED; in idetape_mtioctop()
1325 if (mt_count < tape->blk_size || in idetape_mtioctop()
1326 mt_count % tape->blk_size) in idetape_mtioctop()
1328 tape->user_bs_factor = mt_count / tape->blk_size; in idetape_mtioctop()
1338 mt_count * tape->user_bs_factor, tape->partition, 0); in idetape_mtioctop()
1348 tape->door_locked = DOOR_EXPLICITLY_LOCKED; in idetape_mtioctop()
1354 tape->door_locked = DOOR_UNLOCKED; in idetape_mtioctop()
1371 struct ide_tape_obj *tape = file->private_data; in do_idetape_chrdev_ioctl() local
1372 ide_drive_t *drive = tape->drive; in do_idetape_chrdev_ioctl()
1376 int block_offset = 0, position = tape->first_frame; in do_idetape_chrdev_ioctl()
1381 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { in do_idetape_chrdev_ioctl()
1386 block_offset = tape->valid / in do_idetape_chrdev_ioctl()
1387 (tape->blk_size * tape->user_bs_factor); in do_idetape_chrdev_ioctl()
1400 mtget.mt_blkno = position / tape->user_bs_factor - block_offset; in do_idetape_chrdev_ioctl()
1402 ((tape->blk_size * tape->user_bs_factor) in do_idetape_chrdev_ioctl()
1405 if (tape->drv_write_prot) in do_idetape_chrdev_ioctl()
1412 mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; in do_idetape_chrdev_ioctl()
1417 if (tape->chrdev_dir == IDETAPE_DIR_READ) in do_idetape_chrdev_ioctl()
1439 idetape_tape_t *tape = drive->driver_data; in ide_tape_get_bsize_from_bdesc() local
1444 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { in ide_tape_get_bsize_from_bdesc()
1446 if (tape->blk_size == 0) { in ide_tape_get_bsize_from_bdesc()
1449 tape->blk_size = 32768; in ide_tape_get_bsize_from_bdesc()
1453 tape->blk_size = (buf[4 + 5] << 16) + in ide_tape_get_bsize_from_bdesc()
1456 tape->drv_write_prot = (buf[2] & 0x80) >> 7; in ide_tape_get_bsize_from_bdesc()
1459 tape->blk_size, tape->drv_write_prot); in ide_tape_get_bsize_from_bdesc()
1466 idetape_tape_t *tape; in idetape_chrdev_open() local
1474 tape = ide_tape_get(NULL, true, i); in idetape_chrdev_open()
1475 if (!tape) { in idetape_chrdev_open()
1480 drive = tape->drive; in idetape_chrdev_open()
1481 filp->private_data = tape; in idetape_chrdev_open()
1501 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); in idetape_chrdev_open()
1514 tape->write_prot = 1; in idetape_chrdev_open()
1516 tape->write_prot = tape->drv_write_prot; in idetape_chrdev_open()
1519 if (tape->write_prot) { in idetape_chrdev_open()
1529 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { in idetape_chrdev_open()
1530 if (!ide_set_media_lock(drive, tape->disk, 1)) { in idetape_chrdev_open()
1531 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) in idetape_chrdev_open()
1532 tape->door_locked = DOOR_LOCKED; in idetape_chrdev_open()
1540 ide_tape_put(tape); in idetape_chrdev_open()
1549 idetape_tape_t *tape = drive->driver_data; in idetape_write_release() local
1552 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); in idetape_write_release()
1553 if (tape->buf != NULL) { in idetape_write_release()
1554 idetape_pad_zeros(drive, tape->blk_size * in idetape_write_release()
1555 (tape->user_bs_factor - 1)); in idetape_write_release()
1556 kfree(tape->buf); in idetape_write_release()
1557 tape->buf = NULL; in idetape_write_release()
1566 struct ide_tape_obj *tape = filp->private_data; in idetape_chrdev_release() local
1567 ide_drive_t *drive = tape->drive; in idetape_chrdev_release()
1572 tape = drive->driver_data; in idetape_chrdev_release()
1576 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) in idetape_chrdev_release()
1578 if (tape->chrdev_dir == IDETAPE_DIR_READ) { in idetape_chrdev_release()
1587 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { in idetape_chrdev_release()
1588 if (tape->door_locked == DOOR_LOCKED) { in idetape_chrdev_release()
1589 if (!ide_set_media_lock(drive, tape->disk, 0)) in idetape_chrdev_release()
1590 tape->door_locked = DOOR_UNLOCKED; in idetape_chrdev_release()
1594 ide_tape_put(tape); in idetape_chrdev_release()
1603 idetape_tape_t *tape = drive->driver_data; in idetape_get_inquiry_results() local
1609 if (ide_queue_pc_tail(drive, tape->disk, &pc, pc_buf, pc.req_xfer)) { in idetape_get_inquiry_results()
1611 tape->name); in idetape_get_inquiry_results()
1623 drive->name, tape->name, vendor_id, product_id, fw_rev); in idetape_get_inquiry_results()
1632 idetape_tape_t *tape = drive->driver_data; in idetape_get_mode_sense_results() local
1638 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { in idetape_get_mode_sense_results()
1641 tape->blk_size = 512; in idetape_get_mode_sense_results()
1642 put_unaligned(52, (u16 *)&tape->caps[12]); in idetape_get_mode_sense_results()
1643 put_unaligned(540, (u16 *)&tape->caps[14]); in idetape_get_mode_sense_results()
1644 put_unaligned(6*52, (u16 *)&tape->caps[16]); in idetape_get_mode_sense_results()
1669 memcpy(&tape->caps, caps, 20); in idetape_get_mode_sense_results()
1676 tape->blk_size = 512; in idetape_get_mode_sense_results()
1678 tape->blk_size = 1024; in idetape_get_mode_sense_results()
1685 idetape_tape_t *tape = drive->driver_data; \
1686 return tape->field; \
1692 idetape_tape_t *tape = drive->driver_data; \
1693 tape->field = arg; \
1743 static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) in idetape_setup() argument
1748 u16 *ctl = (u16 *)&tape->caps[12]; in idetape_setup()
1758 tape->name); in idetape_setup()
1766 tape->minor = minor; in idetape_setup()
1767 tape->name[0] = 'h'; in idetape_setup()
1768 tape->name[1] = 't'; in idetape_setup()
1769 tape->name[2] = '0' + minor; in idetape_setup()
1770 tape->chrdev_dir = IDETAPE_DIR_NONE; in idetape_setup()
1775 tape->user_bs_factor = 1; in idetape_setup()
1776 tape->buffer_size = *ctl * tape->blk_size; in idetape_setup()
1777 while (tape->buffer_size > 0xffff) { in idetape_setup()
1780 tape->buffer_size = *ctl * tape->blk_size; in idetape_setup()
1782 buffer_size = tape->buffer_size; in idetape_setup()
1785 speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); in idetape_setup()
1787 t = (IDETAPE_FIFO_THRESHOLD * tape->buffer_size * HZ) / (speed * 1000); in idetape_setup()
1793 tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN, in idetape_setup()
1797 drive->name, tape->name, *(u16 *)&tape->caps[14], in idetape_setup()
1798 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size, in idetape_setup()
1799 tape->buffer_size / 1024, in idetape_setup()
1800 tape->best_dsc_rw_freq * 1000 / HZ, in idetape_setup()
1803 ide_proc_register_driver(drive, tape->driver); in idetape_setup()
1808 idetape_tape_t *tape = drive->driver_data; in ide_tape_remove() local
1810 ide_proc_unregister_driver(drive, tape->driver); in ide_tape_remove()
1811 device_del(&tape->dev); in ide_tape_remove()
1812 ide_unregister_region(tape->disk); in ide_tape_remove()
1815 put_device(&tape->dev); in ide_tape_remove()
1821 struct ide_tape_obj *tape = to_ide_drv(dev, ide_tape_obj); in ide_tape_release() local
1822 ide_drive_t *drive = tape->drive; in ide_tape_release()
1823 struct gendisk *g = tape->disk; in ide_tape_release()
1825 BUG_ON(tape->valid); in ide_tape_release()
1829 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); in ide_tape_release()
1831 MKDEV(IDETAPE_MAJOR, tape->minor + 128)); in ide_tape_release()
1832 idetape_devs[tape->minor] = NULL; in ide_tape_release()
1835 kfree(tape); in ide_tape_release()
1842 idetape_tape_t *tape = drive->driver_data; in idetape_name_proc_show() local
1844 seq_printf(m, "%s\n", tape->name); in idetape_name_proc_show()
1909 struct ide_tape_obj *tape; in idetape_open() local
1912 tape = ide_tape_get(bdev->bd_disk, false, 0); in idetape_open()
1915 if (!tape) in idetape_open()
1923 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); in idetape_release() local
1926 ide_tape_put(tape); in idetape_release()
1935 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); in idetape_ioctl() local
1936 ide_drive_t *drive = tape->drive; in idetape_ioctl()
1957 idetape_tape_t *tape; in ide_tape_probe() local
1975 tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); in ide_tape_probe()
1976 if (tape == NULL) { in ide_tape_probe()
1988 tape->dev.parent = &drive->gendev; in ide_tape_probe()
1989 tape->dev.release = ide_tape_release; in ide_tape_probe()
1990 dev_set_name(&tape->dev, dev_name(&drive->gendev)); in ide_tape_probe()
1992 if (device_register(&tape->dev)) in ide_tape_probe()
1995 tape->drive = drive; in ide_tape_probe()
1996 tape->driver = &idetape_driver; in ide_tape_probe()
1997 tape->disk = g; in ide_tape_probe()
1999 g->private_data = &tape->driver; in ide_tape_probe()
2001 drive->driver_data = tape; in ide_tape_probe()
2006 idetape_devs[minor] = tape; in ide_tape_probe()
2009 idetape_setup(drive, tape, minor); in ide_tape_probe()
2012 MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name); in ide_tape_probe()
2015 "n%s", tape->name); in ide_tape_probe()
2025 kfree(tape); in ide_tape_probe()