aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-atapi.c20
-rw-r--r--drivers/ide/ide-floppy.c21
-rw-r--r--drivers/ide/ide-tape.c36
-rw-r--r--include/linux/ide.h16
4 files changed, 38 insertions, 55 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 8f0842ce77f5..da71bfce92e8 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -119,6 +119,26 @@ void ide_init_pc(struct ide_atapi_pc *pc)
119} 119}
120EXPORT_SYMBOL_GPL(ide_init_pc); 120EXPORT_SYMBOL_GPL(ide_init_pc);
121 121
122/*
123 * Generate a new packet command request in front of the request queue, before
124 * the current request, so that it will be processed immediately, on the next
125 * pass through the driver.
126 */
127void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
128 struct ide_atapi_pc *pc, struct request *rq)
129{
130 blk_rq_init(NULL, rq);
131 rq->cmd_type = REQ_TYPE_SPECIAL;
132 rq->cmd_flags |= REQ_PREEMPT;
133 rq->buffer = (char *)pc;
134 rq->rq_disk = disk;
135 memcpy(rq->cmd, pc->c, 12);
136 if (drive->media == ide_tape)
137 rq->cmd[13] = REQ_IDETAPE_PC1;
138 ide_do_drive_cmd(drive, rq);
139}
140EXPORT_SYMBOL_GPL(ide_queue_pc_head);
141
122/* TODO: unify the code thus making some arguments go away */ 142/* TODO: unify the code thus making some arguments go away */
123ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, 143ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
124 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, 144 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index e04eaa49a8bf..ddce28e77a4e 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -212,25 +212,6 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
212 idefloppy_end_request(drive, 1, 0); 212 idefloppy_end_request(drive, 1, 0);
213} 213}
214 214
215/*
216 * Generate a new packet command request in front of the request queue, before
217 * the current request so that it will be processed immediately, on the next
218 * pass through the driver.
219 */
220static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
221 struct request *rq)
222{
223 struct ide_floppy_obj *floppy = drive->driver_data;
224
225 blk_rq_init(NULL, rq);
226 rq->buffer = (char *) pc;
227 rq->cmd_type = REQ_TYPE_SPECIAL;
228 rq->cmd_flags |= REQ_PREEMPT;
229 rq->rq_disk = floppy->disk;
230 memcpy(rq->cmd, pc->c, 12);
231 ide_do_drive_cmd(drive, rq);
232}
233
234static void ide_floppy_callback(ide_drive_t *drive) 215static void ide_floppy_callback(ide_drive_t *drive)
235{ 216{
236 idefloppy_floppy_t *floppy = drive->driver_data; 217 idefloppy_floppy_t *floppy = drive->driver_data;
@@ -288,7 +269,7 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
288 269
289 (void)ide_read_error(drive); 270 (void)ide_read_error(drive);
290 idefloppy_create_request_sense_cmd(pc); 271 idefloppy_create_request_sense_cmd(pc);
291 idefloppy_queue_pc_head(drive, pc, rq); 272 ide_queue_pc_head(drive, floppy->disk, pc, rq);
292} 273}
293 274
294/* The usual interrupt handler called during a packet command. */ 275/* The usual interrupt handler called during a packet command. */
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 5c879fbcca87..7103b98eb53a 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -159,20 +159,6 @@ struct idetape_bh {
159#define IDETAPE_LU_RETENSION_MASK 2 159#define IDETAPE_LU_RETENSION_MASK 2
160#define IDETAPE_LU_EOT_MASK 4 160#define IDETAPE_LU_EOT_MASK 4
161 161
162/*
163 * Special requests for our block device strategy routine.
164 *
165 * In order to service a character device command, we add special requests to
166 * the tail of our block device request queue and wait for their completion.
167 */
168
169enum {
170 REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
171 REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */
172 REQ_IDETAPE_READ = (1 << 2),
173 REQ_IDETAPE_WRITE = (1 << 3),
174};
175
176/* Error codes returned in rq->errors to the higher part of the driver. */ 162/* Error codes returned in rq->errors to the higher part of the driver. */
177#define IDETAPE_ERROR_GENERAL 101 163#define IDETAPE_ERROR_GENERAL 101
178#define IDETAPE_ERROR_FILEMARK 102 164#define IDETAPE_ERROR_FILEMARK 102
@@ -613,26 +599,6 @@ static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
613} 599}
614 600
615/* 601/*
616 * Generate a new packet command request in front of the request queue, before
617 * the current request, so that it will be processed immediately, on the next
618 * pass through the driver.
619 */
620static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
621 struct request *rq)
622{
623 struct ide_tape_obj *tape = drive->driver_data;
624
625 blk_rq_init(NULL, rq);
626 rq->cmd_type = REQ_TYPE_SPECIAL;
627 rq->cmd_flags |= REQ_PREEMPT;
628 rq->buffer = (char *) pc;
629 rq->rq_disk = tape->disk;
630 memcpy(rq->cmd, pc->c, 12);
631 rq->cmd[13] = REQ_IDETAPE_PC1;
632 ide_do_drive_cmd(drive, rq);
633}
634
635/*
636 * idetape_retry_pc is called when an error was detected during the 602 * idetape_retry_pc is called when an error was detected during the
637 * last packet command. We queue a request sense packet command in 603 * last packet command. We queue a request sense packet command in
638 * the head of the request list. 604 * the head of the request list.
@@ -646,7 +612,7 @@ static void idetape_retry_pc(ide_drive_t *drive)
646 (void)ide_read_error(drive); 612 (void)ide_read_error(drive);
647 idetape_create_request_sense_cmd(pc); 613 idetape_create_request_sense_cmd(pc);
648 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 614 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
649 idetape_queue_pc_head(drive, pc, rq); 615 ide_queue_pc_head(drive, tape->disk, pc, rq);
650} 616}
651 617
652/* 618/*
diff --git a/include/linux/ide.h b/include/linux/ide.h
index bba2f73b99a0..1bd49784e4da 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1121,6 +1121,22 @@ int ide_check_atapi_device(ide_drive_t *, const char *);
1121 1121
1122void ide_init_pc(struct ide_atapi_pc *); 1122void ide_init_pc(struct ide_atapi_pc *);
1123 1123
1124/*
1125 * Special requests for ide-tape block device strategy routine.
1126 *
1127 * In order to service a character device command, we add special requests to
1128 * the tail of our block device request queue and wait for their completion.
1129 */
1130enum {
1131 REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
1132 REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */
1133 REQ_IDETAPE_READ = (1 << 2),
1134 REQ_IDETAPE_WRITE = (1 << 3),
1135};
1136
1137void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *,
1138 struct request *);
1139
1124ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, 1140ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
1125 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, 1141 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
1126 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 1142 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),