aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:38 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:38 -0400
commit2ac07d920604eeee8966d52e70161f9b31fe90a3 (patch)
treeea9fc0a9902da190b5fe695018a4c79740e88d18 /drivers/ide/ide-tape.c
parent7645c1514c7d34ebdf3ea0e8ee3a935c08abceb2 (diff)
ide: add ide_queue_pc_tail() helper
* Add ide_queue_pc_tail() and convert ide-{floppy,tape}.c to use it instead of ide*_queue_pc_tail(). * Remove no longer used ide*_queue_pc_tail(). There should be no functional changes caused by this patch. Acked-by: Borislav Petkov <petkovbb@gmail.com> Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r--drivers/ide/ide-tape.c69
1 files changed, 28 insertions, 41 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 7103b98eb53a..88cb94554267 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1125,26 +1125,6 @@ static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
1125 pc->c[0] = TEST_UNIT_READY; 1125 pc->c[0] = TEST_UNIT_READY;
1126} 1126}
1127 1127
1128/*
1129 * We add a special packet command request to the tail of the request queue, and
1130 * wait for it to be serviced.
1131 */
1132static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc)
1133{
1134 struct ide_tape_obj *tape = drive->driver_data;
1135 struct request *rq;
1136 int error;
1137
1138 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
1139 rq->cmd_type = REQ_TYPE_SPECIAL;
1140 rq->cmd[13] = REQ_IDETAPE_PC1;
1141 rq->buffer = (char *)pc;
1142 memcpy(rq->cmd, pc->c, 12);
1143 error = blk_execute_rq(drive->queue, tape->disk, rq, 0);
1144 blk_put_request(rq);
1145 return error;
1146}
1147
1148static void idetape_create_load_unload_cmd(ide_drive_t *drive, 1128static void idetape_create_load_unload_cmd(ide_drive_t *drive,
1149 struct ide_atapi_pc *pc, int cmd) 1129 struct ide_atapi_pc *pc, int cmd)
1150{ 1130{
@@ -1157,6 +1137,7 @@ static void idetape_create_load_unload_cmd(ide_drive_t *drive,
1157static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) 1137static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
1158{ 1138{
1159 idetape_tape_t *tape = drive->driver_data; 1139 idetape_tape_t *tape = drive->driver_data;
1140 struct gendisk *disk = tape->disk;
1160 struct ide_atapi_pc pc; 1141 struct ide_atapi_pc pc;
1161 int load_attempted = 0; 1142 int load_attempted = 0;
1162 1143
@@ -1165,7 +1146,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
1165 timeout += jiffies; 1146 timeout += jiffies;
1166 while (time_before(jiffies, timeout)) { 1147 while (time_before(jiffies, timeout)) {
1167 idetape_create_test_unit_ready_cmd(&pc); 1148 idetape_create_test_unit_ready_cmd(&pc);
1168 if (!idetape_queue_pc_tail(drive, &pc)) 1149 if (!ide_queue_pc_tail(drive, disk, &pc))
1169 return 0; 1150 return 0;
1170 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) 1151 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2)
1171 || (tape->asc == 0x3A)) { 1152 || (tape->asc == 0x3A)) {
@@ -1174,7 +1155,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
1174 return -ENOMEDIUM; 1155 return -ENOMEDIUM;
1175 idetape_create_load_unload_cmd(drive, &pc, 1156 idetape_create_load_unload_cmd(drive, &pc,
1176 IDETAPE_LU_LOAD_MASK); 1157 IDETAPE_LU_LOAD_MASK);
1177 idetape_queue_pc_tail(drive, &pc); 1158 ide_queue_pc_tail(drive, disk, &pc);
1178 load_attempted = 1; 1159 load_attempted = 1;
1179 /* not about to be ready */ 1160 /* not about to be ready */
1180 } else if (!(tape->sense_key == 2 && tape->asc == 4 && 1161 } else if (!(tape->sense_key == 2 && tape->asc == 4 &&
@@ -1187,11 +1168,12 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
1187 1168
1188static int idetape_flush_tape_buffers(ide_drive_t *drive) 1169static int idetape_flush_tape_buffers(ide_drive_t *drive)
1189{ 1170{
1171 struct ide_tape_obj *tape = drive->driver_data;
1190 struct ide_atapi_pc pc; 1172 struct ide_atapi_pc pc;
1191 int rc; 1173 int rc;
1192 1174
1193 idetape_create_write_filemark_cmd(drive, &pc, 0); 1175 idetape_create_write_filemark_cmd(drive, &pc, 0);
1194 rc = idetape_queue_pc_tail(drive, &pc); 1176 rc = ide_queue_pc_tail(drive, tape->disk, &pc);
1195 if (rc) 1177 if (rc)
1196 return rc; 1178 return rc;
1197 idetape_wait_ready(drive, 60 * 5 * HZ); 1179 idetape_wait_ready(drive, 60 * 5 * HZ);
@@ -1214,7 +1196,7 @@ static int idetape_read_position(ide_drive_t *drive)
1214 debug_log(DBG_PROCS, "Enter %s\n", __func__); 1196 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1215 1197
1216 idetape_create_read_position_cmd(&pc); 1198 idetape_create_read_position_cmd(&pc);
1217 if (idetape_queue_pc_tail(drive, &pc)) 1199 if (ide_queue_pc_tail(drive, tape->disk, &pc))
1218 return -1; 1200 return -1;
1219 position = tape->first_frame; 1201 position = tape->first_frame;
1220 return position; 1202 return position;
@@ -1249,12 +1231,13 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive,
1249 1231
1250static int ide_tape_set_media_lock(ide_drive_t *drive, int on) 1232static int ide_tape_set_media_lock(ide_drive_t *drive, int on)
1251{ 1233{
1234 struct ide_tape_obj *tape = drive->driver_data;
1252 struct ide_atapi_pc pc; 1235 struct ide_atapi_pc pc;
1253 1236
1254 if (!idetape_create_prevent_cmd(drive, &pc, on)) 1237 if (!idetape_create_prevent_cmd(drive, &pc, on))
1255 return 0; 1238 return 0;
1256 1239
1257 return idetape_queue_pc_tail(drive, &pc); 1240 return ide_queue_pc_tail(drive, tape->disk, &pc);
1258} 1241}
1259 1242
1260static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) 1243static void __ide_tape_discard_merge_buffer(ide_drive_t *drive)
@@ -1284,6 +1267,7 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block,
1284 u8 partition, int skip) 1267 u8 partition, int skip)
1285{ 1268{
1286 idetape_tape_t *tape = drive->driver_data; 1269 idetape_tape_t *tape = drive->driver_data;
1270 struct gendisk *disk = tape->disk;
1287 int retval; 1271 int retval;
1288 struct ide_atapi_pc pc; 1272 struct ide_atapi_pc pc;
1289 1273
@@ -1291,12 +1275,12 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block,
1291 __ide_tape_discard_merge_buffer(drive); 1275 __ide_tape_discard_merge_buffer(drive);
1292 idetape_wait_ready(drive, 60 * 5 * HZ); 1276 idetape_wait_ready(drive, 60 * 5 * HZ);
1293 idetape_create_locate_cmd(drive, &pc, block, partition, skip); 1277 idetape_create_locate_cmd(drive, &pc, block, partition, skip);
1294 retval = idetape_queue_pc_tail(drive, &pc); 1278 retval = ide_queue_pc_tail(drive, disk, &pc);
1295 if (retval) 1279 if (retval)
1296 return (retval); 1280 return (retval);
1297 1281
1298 idetape_create_read_position_cmd(&pc); 1282 idetape_create_read_position_cmd(&pc);
1299 return (idetape_queue_pc_tail(drive, &pc)); 1283 return ide_queue_pc_tail(drive, disk, &pc);
1300} 1284}
1301 1285
1302static void ide_tape_discard_merge_buffer(ide_drive_t *drive, 1286static void ide_tape_discard_merge_buffer(ide_drive_t *drive,
@@ -1543,20 +1527,20 @@ static void idetape_pad_zeros(ide_drive_t *drive, int bcount)
1543 */ 1527 */
1544static int idetape_rewind_tape(ide_drive_t *drive) 1528static int idetape_rewind_tape(ide_drive_t *drive)
1545{ 1529{
1530 struct ide_tape_obj *tape = drive->driver_data;
1531 struct gendisk *disk = tape->disk;
1546 int retval; 1532 int retval;
1547 struct ide_atapi_pc pc; 1533 struct ide_atapi_pc pc;
1548 idetape_tape_t *tape;
1549 tape = drive->driver_data;
1550 1534
1551 debug_log(DBG_SENSE, "Enter %s\n", __func__); 1535 debug_log(DBG_SENSE, "Enter %s\n", __func__);
1552 1536
1553 idetape_create_rewind_cmd(drive, &pc); 1537 idetape_create_rewind_cmd(drive, &pc);
1554 retval = idetape_queue_pc_tail(drive, &pc); 1538 retval = ide_queue_pc_tail(drive, disk, &pc);
1555 if (retval) 1539 if (retval)
1556 return retval; 1540 return retval;
1557 1541
1558 idetape_create_read_position_cmd(&pc); 1542 idetape_create_read_position_cmd(&pc);
1559 retval = idetape_queue_pc_tail(drive, &pc); 1543 retval = ide_queue_pc_tail(drive, disk, &pc);
1560 if (retval) 1544 if (retval)
1561 return retval; 1545 return retval;
1562 return 0; 1546 return 0;
@@ -1599,6 +1583,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
1599 int mt_count) 1583 int mt_count)
1600{ 1584{
1601 idetape_tape_t *tape = drive->driver_data; 1585 idetape_tape_t *tape = drive->driver_data;
1586 struct gendisk *disk = tape->disk;
1602 struct ide_atapi_pc pc; 1587 struct ide_atapi_pc pc;
1603 int retval, count = 0; 1588 int retval, count = 0;
1604 int sprev = !!(tape->caps[4] & 0x20); 1589 int sprev = !!(tape->caps[4] & 0x20);
@@ -1623,7 +1608,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
1623 case MTBSF: 1608 case MTBSF:
1624 idetape_create_space_cmd(&pc, mt_count - count, 1609 idetape_create_space_cmd(&pc, mt_count - count,
1625 IDETAPE_SPACE_OVER_FILEMARK); 1610 IDETAPE_SPACE_OVER_FILEMARK);
1626 return idetape_queue_pc_tail(drive, &pc); 1611 return ide_queue_pc_tail(drive, disk, &pc);
1627 case MTFSFM: 1612 case MTFSFM:
1628 case MTBSFM: 1613 case MTBSFM:
1629 if (!sprev) 1614 if (!sprev)
@@ -1812,11 +1797,12 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
1812 1797
1813static int idetape_write_filemark(ide_drive_t *drive) 1798static int idetape_write_filemark(ide_drive_t *drive)
1814{ 1799{
1800 struct ide_tape_obj *tape = drive->driver_data;
1815 struct ide_atapi_pc pc; 1801 struct ide_atapi_pc pc;
1816 1802
1817 /* Write a filemark */ 1803 /* Write a filemark */
1818 idetape_create_write_filemark_cmd(drive, &pc, 1); 1804 idetape_create_write_filemark_cmd(drive, &pc, 1);
1819 if (idetape_queue_pc_tail(drive, &pc)) { 1805 if (ide_queue_pc_tail(drive, tape->disk, &pc)) {
1820 printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); 1806 printk(KERN_ERR "ide-tape: Couldn't write a filemark\n");
1821 return -EIO; 1807 return -EIO;
1822 } 1808 }
@@ -1839,6 +1825,7 @@ static int idetape_write_filemark(ide_drive_t *drive)
1839static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) 1825static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1840{ 1826{
1841 idetape_tape_t *tape = drive->driver_data; 1827 idetape_tape_t *tape = drive->driver_data;
1828 struct gendisk *disk = tape->disk;
1842 struct ide_atapi_pc pc; 1829 struct ide_atapi_pc pc;
1843 int i, retval; 1830 int i, retval;
1844 1831
@@ -1877,7 +1864,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1877 ide_tape_discard_merge_buffer(drive, 0); 1864 ide_tape_discard_merge_buffer(drive, 0);
1878 idetape_create_load_unload_cmd(drive, &pc, 1865 idetape_create_load_unload_cmd(drive, &pc,
1879 IDETAPE_LU_LOAD_MASK); 1866 IDETAPE_LU_LOAD_MASK);
1880 return idetape_queue_pc_tail(drive, &pc); 1867 return ide_queue_pc_tail(drive, disk, &pc);
1881 case MTUNLOAD: 1868 case MTUNLOAD:
1882 case MTOFFL: 1869 case MTOFFL:
1883 /* 1870 /*
@@ -1891,7 +1878,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1891 ide_tape_discard_merge_buffer(drive, 0); 1878 ide_tape_discard_merge_buffer(drive, 0);
1892 idetape_create_load_unload_cmd(drive, &pc, 1879 idetape_create_load_unload_cmd(drive, &pc,
1893 !IDETAPE_LU_LOAD_MASK); 1880 !IDETAPE_LU_LOAD_MASK);
1894 retval = idetape_queue_pc_tail(drive, &pc); 1881 retval = ide_queue_pc_tail(drive, disk, &pc);
1895 if (!retval) 1882 if (!retval)
1896 clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); 1883 clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags);
1897 return retval; 1884 return retval;
@@ -1902,14 +1889,14 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1902 ide_tape_discard_merge_buffer(drive, 0); 1889 ide_tape_discard_merge_buffer(drive, 0);
1903 idetape_create_load_unload_cmd(drive, &pc, 1890 idetape_create_load_unload_cmd(drive, &pc,
1904 IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); 1891 IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK);
1905 return idetape_queue_pc_tail(drive, &pc); 1892 return ide_queue_pc_tail(drive, disk, &pc);
1906 case MTEOM: 1893 case MTEOM:
1907 idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); 1894 idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD);
1908 return idetape_queue_pc_tail(drive, &pc); 1895 return ide_queue_pc_tail(drive, disk, &pc);
1909 case MTERASE: 1896 case MTERASE:
1910 (void)idetape_rewind_tape(drive); 1897 (void)idetape_rewind_tape(drive);
1911 idetape_create_erase_cmd(&pc); 1898 idetape_create_erase_cmd(&pc);
1912 return idetape_queue_pc_tail(drive, &pc); 1899 return ide_queue_pc_tail(drive, disk, &pc);
1913 case MTSETBLK: 1900 case MTSETBLK:
1914 if (mt_count) { 1901 if (mt_count) {
1915 if (mt_count < tape->blk_size || 1902 if (mt_count < tape->blk_size ||
@@ -2018,7 +2005,7 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive)
2018 struct ide_atapi_pc pc; 2005 struct ide_atapi_pc pc;
2019 2006
2020 idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); 2007 idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR);
2021 if (idetape_queue_pc_tail(drive, &pc)) { 2008 if (ide_queue_pc_tail(drive, tape->disk, &pc)) {
2022 printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); 2009 printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
2023 if (tape->blk_size == 0) { 2010 if (tape->blk_size == 0) {
2024 printk(KERN_WARNING "ide-tape: Cannot deal with zero " 2011 printk(KERN_WARNING "ide-tape: Cannot deal with zero "
@@ -2170,7 +2157,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
2170 char fw_rev[4], vendor_id[8], product_id[16]; 2157 char fw_rev[4], vendor_id[8], product_id[16];
2171 2158
2172 idetape_create_inquiry_cmd(&pc); 2159 idetape_create_inquiry_cmd(&pc);
2173 if (idetape_queue_pc_tail(drive, &pc)) { 2160 if (ide_queue_pc_tail(drive, tape->disk, &pc)) {
2174 printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", 2161 printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n",
2175 tape->name); 2162 tape->name);
2176 return; 2163 return;
@@ -2199,7 +2186,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive)
2199 u8 speed, max_speed; 2186 u8 speed, max_speed;
2200 2187
2201 idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); 2188 idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE);
2202 if (idetape_queue_pc_tail(drive, &pc)) { 2189 if (ide_queue_pc_tail(drive, tape->disk, &pc)) {
2203 printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" 2190 printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming"
2204 " some default values\n"); 2191 " some default values\n");
2205 tape->blk_size = 512; 2192 tape->blk_size = 512;