aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:37 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:37 -0400
commit7bf7420a318978cd6042e5a5da34b7cfa18ae559 (patch)
tree7498ae013e3603dc66628873eaa2647fd001fe98 /drivers/ide/ide-tape.c
parent385a4b8787c70b708688bee65139f15b0f79f144 (diff)
ide: add ide_init_pc() helper
* Add IDE_PC_BUFFER_SIZE define. * Add ide_init_pc() and convert ide-{floppy,tape}.c to use it instead of ide*_init_pc(). * Remove no longer used IDE*_PC_BUFFER_SIZE and ide*_init_pc(). 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.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 26d5b0576f0a..5c879fbcca87 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -81,12 +81,6 @@ enum {
81#define IDETAPE_MAX_PC_RETRIES 3 81#define IDETAPE_MAX_PC_RETRIES 3
82 82
83/* 83/*
84 * With each packet command, we allocate a buffer of IDETAPE_PC_BUFFER_SIZE
85 * bytes. This is used for several packet commands (Not for READ/WRITE commands)
86 */
87#define IDETAPE_PC_BUFFER_SIZE 256
88
89/*
90 * Some drives (for example, Seagate STT3401A Travan) require a very long 84 * Some drives (for example, Seagate STT3401A Travan) require a very long
91 * timeout, because they don't return an interrupt or clear their busy bit 85 * timeout, because they don't return an interrupt or clear their busy bit
92 * until after the command completes (even retension commands). 86 * until after the command completes (even retension commands).
@@ -610,21 +604,9 @@ static void ide_tape_callback(ide_drive_t *drive)
610 idetape_end_request(drive, uptodate, 0); 604 idetape_end_request(drive, uptodate, 0);
611} 605}
612 606
613static void idetape_init_pc(struct ide_atapi_pc *pc)
614{
615 memset(pc->c, 0, 12);
616 pc->retries = 0;
617 pc->flags = 0;
618 pc->req_xfer = 0;
619 pc->buf = pc->pc_buf;
620 pc->buf_size = IDETAPE_PC_BUFFER_SIZE;
621 pc->bh = NULL;
622 pc->b_data = NULL;
623}
624
625static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) 607static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
626{ 608{
627 idetape_init_pc(pc); 609 ide_init_pc(pc);
628 pc->c[0] = REQUEST_SENSE; 610 pc->c[0] = REQUEST_SENSE;
629 pc->c[4] = 20; 611 pc->c[4] = 20;
630 pc->req_xfer = 20; 612 pc->req_xfer = 20;
@@ -816,7 +798,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
816/* A mode sense command is used to "sense" tape parameters. */ 798/* A mode sense command is used to "sense" tape parameters. */
817static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) 799static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code)
818{ 800{
819 idetape_init_pc(pc); 801 ide_init_pc(pc);
820 pc->c[0] = MODE_SENSE; 802 pc->c[0] = MODE_SENSE;
821 if (page_code != IDETAPE_BLOCK_DESCRIPTOR) 803 if (page_code != IDETAPE_BLOCK_DESCRIPTOR)
822 /* DBD = 1 - Don't return block descriptors */ 804 /* DBD = 1 - Don't return block descriptors */
@@ -875,7 +857,7 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape,
875 struct idetape_bh *bh = (struct idetape_bh *)rq->special; 857 struct idetape_bh *bh = (struct idetape_bh *)rq->special;
876 unsigned int length = rq->current_nr_sectors; 858 unsigned int length = rq->current_nr_sectors;
877 859
878 idetape_init_pc(pc); 860 ide_init_pc(pc);
879 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); 861 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
880 pc->c[1] = 1; 862 pc->c[1] = 1;
881 pc->bh = bh; 863 pc->bh = bh;
@@ -1165,7 +1147,7 @@ static void idetape_init_merge_buffer(idetape_tape_t *tape)
1165static void idetape_create_write_filemark_cmd(ide_drive_t *drive, 1147static void idetape_create_write_filemark_cmd(ide_drive_t *drive,
1166 struct ide_atapi_pc *pc, int write_filemark) 1148 struct ide_atapi_pc *pc, int write_filemark)
1167{ 1149{
1168 idetape_init_pc(pc); 1150 ide_init_pc(pc);
1169 pc->c[0] = WRITE_FILEMARKS; 1151 pc->c[0] = WRITE_FILEMARKS;
1170 pc->c[4] = write_filemark; 1152 pc->c[4] = write_filemark;
1171 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1153 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
@@ -1173,7 +1155,7 @@ static void idetape_create_write_filemark_cmd(ide_drive_t *drive,
1173 1155
1174static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) 1156static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
1175{ 1157{
1176 idetape_init_pc(pc); 1158 ide_init_pc(pc);
1177 pc->c[0] = TEST_UNIT_READY; 1159 pc->c[0] = TEST_UNIT_READY;
1178} 1160}
1179 1161
@@ -1200,7 +1182,7 @@ static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc)
1200static void idetape_create_load_unload_cmd(ide_drive_t *drive, 1182static void idetape_create_load_unload_cmd(ide_drive_t *drive,
1201 struct ide_atapi_pc *pc, int cmd) 1183 struct ide_atapi_pc *pc, int cmd)
1202{ 1184{
1203 idetape_init_pc(pc); 1185 ide_init_pc(pc);
1204 pc->c[0] = START_STOP; 1186 pc->c[0] = START_STOP;
1205 pc->c[4] = cmd; 1187 pc->c[4] = cmd;
1206 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1188 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
@@ -1252,7 +1234,7 @@ static int idetape_flush_tape_buffers(ide_drive_t *drive)
1252 1234
1253static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) 1235static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc)
1254{ 1236{
1255 idetape_init_pc(pc); 1237 ide_init_pc(pc);
1256 pc->c[0] = READ_POSITION; 1238 pc->c[0] = READ_POSITION;
1257 pc->req_xfer = 20; 1239 pc->req_xfer = 20;
1258} 1240}
@@ -1276,7 +1258,7 @@ static void idetape_create_locate_cmd(ide_drive_t *drive,
1276 struct ide_atapi_pc *pc, 1258 struct ide_atapi_pc *pc,
1277 unsigned int block, u8 partition, int skip) 1259 unsigned int block, u8 partition, int skip)
1278{ 1260{
1279 idetape_init_pc(pc); 1261 ide_init_pc(pc);
1280 pc->c[0] = POSITION_TO_ELEMENT; 1262 pc->c[0] = POSITION_TO_ELEMENT;
1281 pc->c[1] = 2; 1263 pc->c[1] = 2;
1282 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); 1264 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]);
@@ -1293,7 +1275,7 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive,
1293 if (!(tape->caps[6] & 0x01)) 1275 if (!(tape->caps[6] & 0x01))
1294 return 0; 1276 return 0;
1295 1277
1296 idetape_init_pc(pc); 1278 ide_init_pc(pc);
1297 pc->c[0] = ALLOW_MEDIUM_REMOVAL; 1279 pc->c[0] = ALLOW_MEDIUM_REMOVAL;
1298 pc->c[4] = prevent; 1280 pc->c[4] = prevent;
1299 return 1; 1281 return 1;
@@ -1408,7 +1390,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks,
1408 1390
1409static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) 1391static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc)
1410{ 1392{
1411 idetape_init_pc(pc); 1393 ide_init_pc(pc);
1412 pc->c[0] = INQUIRY; 1394 pc->c[0] = INQUIRY;
1413 pc->c[4] = 254; 1395 pc->c[4] = 254;
1414 pc->req_xfer = 254; 1396 pc->req_xfer = 254;
@@ -1417,14 +1399,14 @@ static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc)
1417static void idetape_create_rewind_cmd(ide_drive_t *drive, 1399static void idetape_create_rewind_cmd(ide_drive_t *drive,
1418 struct ide_atapi_pc *pc) 1400 struct ide_atapi_pc *pc)
1419{ 1401{
1420 idetape_init_pc(pc); 1402 ide_init_pc(pc);
1421 pc->c[0] = REZERO_UNIT; 1403 pc->c[0] = REZERO_UNIT;
1422 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1404 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1423} 1405}
1424 1406
1425static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) 1407static void idetape_create_erase_cmd(struct ide_atapi_pc *pc)
1426{ 1408{
1427 idetape_init_pc(pc); 1409 ide_init_pc(pc);
1428 pc->c[0] = ERASE; 1410 pc->c[0] = ERASE;
1429 pc->c[1] = 1; 1411 pc->c[1] = 1;
1430 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1412 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
@@ -1432,7 +1414,7 @@ static void idetape_create_erase_cmd(struct ide_atapi_pc *pc)
1432 1414
1433static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) 1415static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd)
1434{ 1416{
1435 idetape_init_pc(pc); 1417 ide_init_pc(pc);
1436 pc->c[0] = SPACE; 1418 pc->c[0] = SPACE;
1437 put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); 1419 put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]);
1438 pc->c[1] = cmd; 1420 pc->c[1] = cmd;