aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-atapi.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:32 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:32 -0400
commit6b0da28b2d0f4f4e2c55689fc062db569075ff60 (patch)
treee7113f6db70fe3c2dd16bd2e7e1538fba4236c49 /drivers/ide/ide-atapi.c
parent67c56364df843fb9e3ed1af014b8fbe4b22ff25d (diff)
ide: add ide_retry_pc() helper
* Add ide_create_request_sense_cmd() and ide_retry_pc() helpers and convert ide-{atapi,floppy,tape}.c to use them. * Remove no longer used ide*_create_request_sense_cmd(), ide*_retry_pc() and 'retry_pc' argument from ide_pc_intr(). * Make ide_queue_pc_head() static. There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-atapi.c')
-rw-r--r--drivers/ide/ide-atapi.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 184835141412..d758dcd87178 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -124,8 +124,8 @@ EXPORT_SYMBOL_GPL(ide_init_pc);
124 * the current request, so that it will be processed immediately, on the next 124 * the current request, so that it will be processed immediately, on the next
125 * pass through the driver. 125 * pass through the driver.
126 */ 126 */
127void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, 127static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
128 struct ide_atapi_pc *pc, struct request *rq) 128 struct ide_atapi_pc *pc, struct request *rq)
129{ 129{
130 blk_rq_init(NULL, rq); 130 blk_rq_init(NULL, rq);
131 rq->cmd_type = REQ_TYPE_SPECIAL; 131 rq->cmd_type = REQ_TYPE_SPECIAL;
@@ -137,7 +137,6 @@ void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
137 rq->cmd[13] = REQ_IDETAPE_PC1; 137 rq->cmd[13] = REQ_IDETAPE_PC1;
138 ide_do_drive_cmd(drive, rq); 138 ide_do_drive_cmd(drive, rq);
139} 139}
140EXPORT_SYMBOL_GPL(ide_queue_pc_head);
141 140
142/* 141/*
143 * Add a special packet command request to the tail of the request queue, 142 * Add a special packet command request to the tail of the request queue,
@@ -203,6 +202,37 @@ int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on)
203} 202}
204EXPORT_SYMBOL_GPL(ide_set_media_lock); 203EXPORT_SYMBOL_GPL(ide_set_media_lock);
205 204
205void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc)
206{
207 ide_init_pc(pc);
208 pc->c[0] = REQUEST_SENSE;
209 if (drive->media == ide_floppy) {
210 pc->c[4] = 255;
211 pc->req_xfer = 18;
212 } else {
213 pc->c[4] = 20;
214 pc->req_xfer = 20;
215 }
216}
217EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);
218
219/*
220 * Called when an error was detected during the last packet command.
221 * We queue a request sense packet command in the head of the request list.
222 */
223void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk)
224{
225 struct request *rq = &drive->request_sense_rq;
226 struct ide_atapi_pc *pc = &drive->request_sense_pc;
227
228 (void)ide_read_error(drive);
229 ide_create_request_sense_cmd(drive, pc);
230 if (drive->media == ide_tape)
231 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
232 ide_queue_pc_head(drive, disk, pc, rq);
233}
234EXPORT_SYMBOL_GPL(ide_retry_pc);
235
206int ide_scsi_expiry(ide_drive_t *drive) 236int ide_scsi_expiry(ide_drive_t *drive)
207{ 237{
208 struct ide_atapi_pc *pc = drive->pc; 238 struct ide_atapi_pc *pc = drive->pc;
@@ -219,7 +249,6 @@ EXPORT_SYMBOL_GPL(ide_scsi_expiry);
219/* TODO: unify the code thus making some arguments go away */ 249/* TODO: unify the code thus making some arguments go away */
220ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler, 250ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
221 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 251 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
222 void (*retry_pc)(ide_drive_t *),
223 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) 252 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
224{ 253{
225 struct ide_atapi_pc *pc = drive->pc; 254 struct ide_atapi_pc *pc = drive->pc;
@@ -299,7 +328,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
299 debug_log("[cmd %x]: check condition\n", rq->cmd[0]); 328 debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
300 329
301 /* Retry operation */ 330 /* Retry operation */
302 retry_pc(drive); 331 ide_retry_pc(drive, rq->rq_disk);
303 332
304 /* queued, but not started */ 333 /* queued, but not started */
305 return ide_stopped; 334 return ide_stopped;