aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@gmail.com>2008-07-15 15:21:56 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-15 15:21:56 -0400
commit81f4938239fea86d0a7529194a37fb81041171e0 (patch)
tree253aba635bc99792cc6e3e4c09426ab2489e15ff /drivers/ide
parent92f5daff2b8439fa4c57c57f47823ffc459c3bd9 (diff)
ide-floppy: merge callbacks
The appropriate functionality of the callback is established through querying the ATAPI packet command in pc->c[0]. While at it, simplify if (floppy->failed_pc)-branch to be found in the original idefloppy_request_sense_callback(). Bart: - keep handling for blk_pc_request() requests unchanged + add FIXME - add uptodate variable + leave just one idefloppy_end_request() call - add newline to the debug message Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-floppy.c69
1 files changed, 23 insertions, 46 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index dae1c90d421f..2058a6f3f331 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -312,50 +312,38 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive)
312 return (&floppy->rq_stack[floppy->rq_stack_index++]); 312 return (&floppy->rq_stack[floppy->rq_stack_index++]);
313} 313}
314 314
315static void idefloppy_request_sense_callback(ide_drive_t *drive) 315static void ide_floppy_callback(ide_drive_t *drive)
316{ 316{
317 idefloppy_floppy_t *floppy = drive->driver_data; 317 idefloppy_floppy_t *floppy = drive->driver_data;
318 u8 *buf = floppy->pc->buf; 318 struct ide_atapi_pc *pc = floppy->pc;
319 int uptodate = pc->error ? 0 : 1;
319 320
320 debug_log("Reached %s\n", __func__); 321 debug_log("Reached %s\n", __func__);
321 322
322 if (!floppy->pc->error) { 323 if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
323 floppy->sense_key = buf[2] & 0x0F; 324 (pc->rq && blk_pc_request(pc->rq)))
324 floppy->asc = buf[12]; 325 uptodate = 1; /* FIXME */
325 floppy->ascq = buf[13]; 326 else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
326 floppy->progress_indication = buf[15] & 0x80 ? 327 u8 *buf = floppy->pc->buf;
327 (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
328 328
329 if (floppy->failed_pc) 329 if (!pc->error) {
330 debug_log("pc = %x, sense key = %x, asc = %x," 330 floppy->sense_key = buf[2] & 0x0F;
331 " ascq = %x\n", 331 floppy->asc = buf[12];
332 floppy->failed_pc->c[0], 332 floppy->ascq = buf[13];
333 floppy->sense_key, 333 floppy->progress_indication = buf[15] & 0x80 ?
334 floppy->asc, 334 (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
335 floppy->ascq);
336 else
337 debug_log("sense key = %x, asc = %x, ascq = %x\n",
338 floppy->sense_key,
339 floppy->asc,
340 floppy->ascq);
341 335
336 if (floppy->failed_pc)
337 debug_log("pc = %x, ", floppy->failed_pc->c[0]);
342 338
343 idefloppy_end_request(drive, 1, 0); 339 debug_log("sense key = %x, asc = %x, ascq = %x\n",
344 } else { 340 floppy->sense_key, floppy->asc, floppy->ascq);
345 printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting" 341 } else
346 " request!\n"); 342 printk(KERN_ERR "Error in REQUEST SENSE itself - "
347 idefloppy_end_request(drive, 0, 0); 343 "Aborting request!\n");
348 } 344 }
349}
350 345
351/* General packet command callback function. */ 346 idefloppy_end_request(drive, uptodate, 0);
352static void idefloppy_pc_callback(ide_drive_t *drive)
353{
354 idefloppy_floppy_t *floppy = drive->driver_data;
355
356 debug_log("Reached %s\n", __func__);
357
358 idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
359} 347}
360 348
361static void idefloppy_init_pc(struct ide_atapi_pc *pc) 349static void idefloppy_init_pc(struct ide_atapi_pc *pc)
@@ -366,7 +354,7 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc)
366 pc->req_xfer = 0; 354 pc->req_xfer = 0;
367 pc->buf = pc->pc_buf; 355 pc->buf = pc->pc_buf;
368 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; 356 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
369 pc->idefloppy_callback = &idefloppy_pc_callback; 357 pc->idefloppy_callback = &ide_floppy_callback;
370} 358}
371 359
372static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) 360static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
@@ -375,7 +363,6 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
375 pc->c[0] = GPCMD_REQUEST_SENSE; 363 pc->c[0] = GPCMD_REQUEST_SENSE;
376 pc->c[4] = 255; 364 pc->c[4] = 255;
377 pc->req_xfer = 18; 365 pc->req_xfer = 18;
378 pc->idefloppy_callback = &idefloppy_request_sense_callback;
379} 366}
380 367
381/* 368/*
@@ -668,14 +655,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
668 } 655 }
669} 656}
670 657
671static void idefloppy_rw_callback(ide_drive_t *drive)
672{
673 debug_log("Reached %s\n", __func__);
674
675 idefloppy_end_request(drive, 1, 0);
676 return;
677}
678
679static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) 658static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent)
680{ 659{
681 debug_log("creating prevent removal command, prevent = %d\n", prevent); 660 debug_log("creating prevent removal command, prevent = %d\n", prevent);
@@ -770,7 +749,6 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
770 put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); 749 put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]);
771 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); 750 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]);
772 751
773 pc->idefloppy_callback = &idefloppy_rw_callback;
774 pc->rq = rq; 752 pc->rq = rq;
775 pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; 753 pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
776 if (rq->cmd_flags & REQ_RW) 754 if (rq->cmd_flags & REQ_RW)
@@ -784,7 +762,6 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
784 struct ide_atapi_pc *pc, struct request *rq) 762 struct ide_atapi_pc *pc, struct request *rq)
785{ 763{
786 idefloppy_init_pc(pc); 764 idefloppy_init_pc(pc);
787 pc->idefloppy_callback = &idefloppy_rw_callback;
788 memcpy(pc->c, rq->cmd, sizeof(pc->c)); 765 memcpy(pc->c, rq->cmd, sizeof(pc->c));
789 pc->rq = rq; 766 pc->rq = rq;
790 pc->b_count = rq->data_len; 767 pc->b_count = rq->data_len;