aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-floppy.c32
-rw-r--r--drivers/ide/ide-tape.c48
2 files changed, 13 insertions, 67 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 41bb61037da2..58cd6e6c687d 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -75,13 +75,6 @@
75 */ 75 */
76#define IDEFLOPPY_PC_BUFFER_SIZE 256 76#define IDEFLOPPY_PC_BUFFER_SIZE 256
77 77
78/*
79 * In various places in the driver, we need to allocate storage for packet
80 * commands, which will remain valid while we leave the driver to wait for
81 * an interrupt or a timeout event.
82 */
83#define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES)
84
85/* format capacities descriptor codes */ 78/* format capacities descriptor codes */
86#define CAPACITY_INVALID 0x00 79#define CAPACITY_INVALID 0x00
87#define CAPACITY_UNFORMATTED 0x01 80#define CAPACITY_UNFORMATTED 0x01
@@ -104,11 +97,10 @@ typedef struct ide_floppy_obj {
104 struct ide_atapi_pc *pc; 97 struct ide_atapi_pc *pc;
105 /* Last failed packet command */ 98 /* Last failed packet command */
106 struct ide_atapi_pc *failed_pc; 99 struct ide_atapi_pc *failed_pc;
107 /* Packet command stack */ 100 /* used for blk_{fs,pc}_request() requests */
108 struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK]; 101 struct ide_atapi_pc queued_pc;
109 /* Next free packet command storage space */
110 int pc_stack_index;
111 102
103 struct ide_atapi_pc request_sense_pc;
112 struct request request_sense_rq; 104 struct request request_sense_rq;
113 105
114 /* Last error information */ 106 /* Last error information */
@@ -296,15 +288,6 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
296 ide_do_drive_cmd(drive, rq); 288 ide_do_drive_cmd(drive, rq);
297} 289}
298 290
299static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive)
300{
301 idefloppy_floppy_t *floppy = drive->driver_data;
302
303 if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK)
304 floppy->pc_stack_index = 0;
305 return (&floppy->pc_stack[floppy->pc_stack_index++]);
306}
307
308static void ide_floppy_callback(ide_drive_t *drive) 291static void ide_floppy_callback(ide_drive_t *drive)
309{ 292{
310 idefloppy_floppy_t *floppy = drive->driver_data; 293 idefloppy_floppy_t *floppy = drive->driver_data;
@@ -365,10 +348,9 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
365{ 348{
366 struct ide_floppy_obj *floppy = drive->driver_data; 349 struct ide_floppy_obj *floppy = drive->driver_data;
367 struct request *rq = &floppy->request_sense_rq; 350 struct request *rq = &floppy->request_sense_rq;
368 struct ide_atapi_pc *pc; 351 struct ide_atapi_pc *pc = &floppy->request_sense_pc;
369 352
370 (void)ide_read_error(drive); 353 (void)ide_read_error(drive);
371 pc = idefloppy_next_pc_storage(drive);
372 idefloppy_create_request_sense_cmd(pc); 354 idefloppy_create_request_sense_cmd(pc);
373 idefloppy_queue_pc_head(drive, pc, rq); 355 idefloppy_queue_pc_head(drive, pc, rq);
374} 356}
@@ -629,12 +611,12 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
629 idefloppy_end_request(drive, 0, 0); 611 idefloppy_end_request(drive, 0, 0);
630 return ide_stopped; 612 return ide_stopped;
631 } 613 }
632 pc = idefloppy_next_pc_storage(drive); 614 pc = &floppy->queued_pc;
633 idefloppy_create_rw_cmd(floppy, pc, rq, block); 615 idefloppy_create_rw_cmd(floppy, pc, rq, block);
634 } else if (blk_special_request(rq)) { 616 } else if (blk_special_request(rq)) {
635 pc = (struct ide_atapi_pc *) rq->buffer; 617 pc = (struct ide_atapi_pc *) rq->buffer;
636 } else if (blk_pc_request(rq)) { 618 } else if (blk_pc_request(rq)) {
637 pc = idefloppy_next_pc_storage(drive); 619 pc = &floppy->queued_pc;
638 idefloppy_blockpc_cmd(floppy, pc, rq); 620 idefloppy_blockpc_cmd(floppy, pc, rq);
639 } else { 621 } else {
640 blk_dump_rq_flags(rq, 622 blk_dump_rq_flags(rq,
@@ -1010,7 +992,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
1010 u8 gcw[2]; 992 u8 gcw[2];
1011 993
1012 *((u16 *)&gcw) = id[ATA_ID_CONFIG]; 994 *((u16 *)&gcw) = id[ATA_ID_CONFIG];
1013 floppy->pc = floppy->pc_stack; 995
1014 drive->pc_callback = ide_floppy_callback; 996 drive->pc_callback = ide_floppy_callback;
1015 997
1016 if (((gcw[0] & 0x60) >> 5) == 1) 998 if (((gcw[0] & 0x60) >> 5) == 1)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index dd3533505e3b..ba05e03f482b 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -56,8 +56,6 @@ enum {
56 DBG_CHRDEV = (1 << 2), 56 DBG_CHRDEV = (1 << 2),
57 /* all remaining procedures */ 57 /* all remaining procedures */
58 DBG_PROCS = (1 << 3), 58 DBG_PROCS = (1 << 3),
59 /* buffer alloc info (pc_stack) */
60 DBG_PC_STACK = (1 << 4),
61}; 59};
62 60
63/* define to see debug info */ 61/* define to see debug info */
@@ -89,13 +87,6 @@ enum {
89#define IDETAPE_PC_BUFFER_SIZE 256 87#define IDETAPE_PC_BUFFER_SIZE 256
90 88
91/* 89/*
92 * In various places in the driver, we need to allocate storage for packet
93 * commands, which will remain valid while we leave the driver to wait for
94 * an interrupt or a timeout event.
95 */
96#define IDETAPE_PC_STACK (10 + IDETAPE_MAX_PC_RETRIES)
97
98/*
99 * Some drives (for example, Seagate STT3401A Travan) require a very long 90 * Some drives (for example, Seagate STT3401A Travan) require a very long
100 * timeout, because they don't return an interrupt or clear their busy bit 91 * timeout, because they don't return an interrupt or clear their busy bit
101 * until after the command completes (even retension commands). 92 * until after the command completes (even retension commands).
@@ -208,13 +199,6 @@ typedef struct ide_tape_obj {
208 struct kref kref; 199 struct kref kref;
209 200
210 /* 201 /*
211 * Since a typical character device operation requires more
212 * than one packet command, we provide here enough memory
213 * for the maximum of interconnected packet commands.
214 * The packet commands are stored in the circular array pc_stack.
215 * pc_stack_index points to the last used entry, and warps around
216 * to the start when we get to the last array entry.
217 *
218 * pc points to the current processed packet command. 202 * pc points to the current processed packet command.
219 * 203 *
220 * failed_pc points to the last failed packet command, or contains 204 * failed_pc points to the last failed packet command, or contains
@@ -226,11 +210,10 @@ typedef struct ide_tape_obj {
226 struct ide_atapi_pc *pc; 210 struct ide_atapi_pc *pc;
227 /* Last failed packet command */ 211 /* Last failed packet command */
228 struct ide_atapi_pc *failed_pc; 212 struct ide_atapi_pc *failed_pc;
229 /* Packet command stack */ 213 /* used by REQ_IDETAPE_{READ,WRITE} requests */
230 struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK]; 214 struct ide_atapi_pc queued_pc;
231 /* Next free packet command storage space */
232 int pc_stack_index;
233 215
216 struct ide_atapi_pc request_sense_pc;
234 struct request request_sense_rq; 217 struct request request_sense_rq;
235 218
236 /* 219 /*
@@ -452,23 +435,6 @@ static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc)
452} 435}
453 436
454/* 437/*
455 * idetape_next_pc_storage returns a pointer to a place in which we can
456 * safely store a packet command, even though we intend to leave the
457 * driver. A storage space for a maximum of IDETAPE_PC_STACK packet
458 * commands is allocated at initialization time.
459 */
460static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive)
461{
462 idetape_tape_t *tape = drive->driver_data;
463
464 debug_log(DBG_PC_STACK, "pc_stack_index=%d\n", tape->pc_stack_index);
465
466 if (tape->pc_stack_index == IDETAPE_PC_STACK)
467 tape->pc_stack_index = 0;
468 return (&tape->pc_stack[tape->pc_stack_index++]);
469}
470
471/*
472 * called on each failed packet command retry to analyze the request sense. We 438 * called on each failed packet command retry to analyze the request sense. We
473 * currently do not utilize this information. 439 * currently do not utilize this information.
474 */ 440 */
@@ -693,10 +659,9 @@ static void idetape_retry_pc(ide_drive_t *drive)
693{ 659{
694 struct ide_tape_obj *tape = drive->driver_data; 660 struct ide_tape_obj *tape = drive->driver_data;
695 struct request *rq = &tape->request_sense_rq; 661 struct request *rq = &tape->request_sense_rq;
696 struct ide_atapi_pc *pc; 662 struct ide_atapi_pc *pc = &tape->request_sense_pc;
697 663
698 (void)ide_read_error(drive); 664 (void)ide_read_error(drive);
699 pc = idetape_next_pc_storage(drive);
700 idetape_create_request_sense_cmd(pc); 665 idetape_create_request_sense_cmd(pc);
701 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 666 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
702 idetape_queue_pc_head(drive, pc, rq); 667 idetape_queue_pc_head(drive, pc, rq);
@@ -1006,12 +971,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1006 return ide_stopped; 971 return ide_stopped;
1007 } 972 }
1008 if (rq->cmd[13] & REQ_IDETAPE_READ) { 973 if (rq->cmd[13] & REQ_IDETAPE_READ) {
1009 pc = idetape_next_pc_storage(drive); 974 pc = &tape->queued_pc;
1010 ide_tape_create_rw_cmd(tape, pc, rq, READ_6); 975 ide_tape_create_rw_cmd(tape, pc, rq, READ_6);
1011 goto out; 976 goto out;
1012 } 977 }
1013 if (rq->cmd[13] & REQ_IDETAPE_WRITE) { 978 if (rq->cmd[13] & REQ_IDETAPE_WRITE) {
1014 pc = idetape_next_pc_storage(drive); 979 pc = &tape->queued_pc;
1015 ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); 980 ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6);
1016 goto out; 981 goto out;
1017 } 982 }
@@ -2412,7 +2377,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
2412 tape->name[1] = 't'; 2377 tape->name[1] = 't';
2413 tape->name[2] = '0' + minor; 2378 tape->name[2] = '0' + minor;
2414 tape->chrdev_dir = IDETAPE_DIR_NONE; 2379 tape->chrdev_dir = IDETAPE_DIR_NONE;
2415 tape->pc = tape->pc_stack;
2416 2380
2417 *((u16 *)&gcw) = drive->id[ATA_ID_CONFIG]; 2381 *((u16 *)&gcw) = drive->id[ATA_ID_CONFIG];
2418 2382