diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-27 07:46:34 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-27 07:46:34 -0400 |
commit | 313afea7f25cc6d420179e0b316499c164e3e372 (patch) | |
tree | 573be1b3912d970951ba30c718332c6174ac8144 /drivers/ide | |
parent | c152cc1a90f9680cefa74d9ff9ce36038081ba72 (diff) |
ide-{floppy,tape}: cleanup ide*_end_request()
* ide*_end_request() is only called with uptodate == 0 or uptodate == 1
so cleanup it accordingly.
* Inline ide*_end_request() content at call sites so the only user left
is ->end_request method.
* ->end_request is now used only for private driver requests so remove
handling of other requests from ide*_end_request().
There should be no functional changes caused by this patch.
Acked-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.c | 66 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 40 |
2 files changed, 53 insertions, 53 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index fb235641da33..bdd8f8e2df6d 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -62,40 +62,21 @@ | |||
62 | #define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ | 62 | #define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Used to finish servicing a request. For read/write requests, we will call | 65 | * Used to finish servicing a private request. |
66 | * ide_end_request to pass to the next buffer. | ||
67 | */ | 66 | */ |
68 | static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) | 67 | static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) |
69 | { | 68 | { |
70 | struct request *rq = drive->hwif->rq; | 69 | struct request *rq = drive->hwif->rq; |
71 | int error; | ||
72 | 70 | ||
73 | ide_debug_log(IDE_DBG_FUNC, "enter"); | 71 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
74 | 72 | ||
75 | switch (uptodate) { | 73 | if (uptodate == 0) |
76 | case 0: | ||
77 | error = IDE_DRV_ERROR_GENERAL; | ||
78 | break; | ||
79 | |||
80 | case 1: | ||
81 | error = 0; | ||
82 | break; | ||
83 | |||
84 | default: | ||
85 | error = uptodate; | ||
86 | } | ||
87 | |||
88 | if (error) | ||
89 | drive->failed_pc = NULL; | 74 | drive->failed_pc = NULL; |
90 | 75 | ||
91 | if (!blk_special_request(rq)) { | 76 | rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; |
92 | /* our real local end request function */ | 77 | |
93 | ide_end_request(drive, uptodate, nsecs); | ||
94 | return 0; | ||
95 | } | ||
96 | rq->errors = error; | ||
97 | /* fixme: need to move this local also */ | ||
98 | ide_complete_rq(drive, 0); | 78 | ide_complete_rq(drive, 0); |
79 | |||
99 | return 0; | 80 | return 0; |
100 | } | 81 | } |
101 | 82 | ||
@@ -106,13 +87,14 @@ static void idefloppy_update_buffers(ide_drive_t *drive, | |||
106 | struct bio *bio = rq->bio; | 87 | struct bio *bio = rq->bio; |
107 | 88 | ||
108 | while ((bio = rq->bio) != NULL) | 89 | while ((bio = rq->bio) != NULL) |
109 | ide_floppy_end_request(drive, 1, 0); | 90 | ide_end_request(drive, 1, 0); |
110 | } | 91 | } |
111 | 92 | ||
112 | static void ide_floppy_callback(ide_drive_t *drive, int dsc) | 93 | static void ide_floppy_callback(ide_drive_t *drive, int dsc) |
113 | { | 94 | { |
114 | struct ide_disk_obj *floppy = drive->driver_data; | 95 | struct ide_disk_obj *floppy = drive->driver_data; |
115 | struct ide_atapi_pc *pc = drive->pc; | 96 | struct ide_atapi_pc *pc = drive->pc; |
97 | struct request *rq = pc->rq; | ||
116 | int uptodate = pc->error ? 0 : 1; | 98 | int uptodate = pc->error ? 0 : 1; |
117 | 99 | ||
118 | ide_debug_log(IDE_DBG_FUNC, "enter"); | 100 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
@@ -121,7 +103,7 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc) | |||
121 | drive->failed_pc = NULL; | 103 | drive->failed_pc = NULL; |
122 | 104 | ||
123 | if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || | 105 | if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || |
124 | (pc->rq && blk_pc_request(pc->rq))) | 106 | (rq && blk_pc_request(rq))) |
125 | uptodate = 1; /* FIXME */ | 107 | uptodate = 1; /* FIXME */ |
126 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { | 108 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { |
127 | u8 *buf = pc->buf; | 109 | u8 *buf = pc->buf; |
@@ -145,7 +127,14 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc) | |||
145 | "Aborting request!\n"); | 127 | "Aborting request!\n"); |
146 | } | 128 | } |
147 | 129 | ||
148 | ide_floppy_end_request(drive, uptodate, 0); | 130 | if (uptodate == 0) |
131 | drive->failed_pc = NULL; | ||
132 | |||
133 | if (blk_special_request(rq)) { | ||
134 | rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; | ||
135 | ide_complete_rq(drive, 0); | ||
136 | } else | ||
137 | ide_end_request(drive, uptodate, 0); | ||
149 | } | 138 | } |
150 | 139 | ||
151 | static void ide_floppy_report_error(struct ide_disk_obj *floppy, | 140 | static void ide_floppy_report_error(struct ide_disk_obj *floppy, |
@@ -286,21 +275,25 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
286 | : "dev?")); | 275 | : "dev?")); |
287 | 276 | ||
288 | if (rq->errors >= ERROR_MAX) { | 277 | if (rq->errors >= ERROR_MAX) { |
289 | if (drive->failed_pc) | 278 | if (drive->failed_pc) { |
290 | ide_floppy_report_error(floppy, drive->failed_pc); | 279 | ide_floppy_report_error(floppy, drive->failed_pc); |
291 | else | 280 | drive->failed_pc = NULL; |
281 | } else | ||
292 | printk(KERN_ERR PFX "%s: I/O error\n", drive->name); | 282 | printk(KERN_ERR PFX "%s: I/O error\n", drive->name); |
293 | 283 | ||
294 | ide_floppy_end_request(drive, 0, 0); | 284 | if (blk_special_request(rq)) { |
295 | return ide_stopped; | 285 | rq->errors = IDE_DRV_ERROR_GENERAL; |
286 | ide_complete_rq(drive, 0); | ||
287 | return ide_stopped; | ||
288 | } else | ||
289 | goto out_end; | ||
296 | } | 290 | } |
297 | if (blk_fs_request(rq)) { | 291 | if (blk_fs_request(rq)) { |
298 | if (((long)rq->sector % floppy->bs_factor) || | 292 | if (((long)rq->sector % floppy->bs_factor) || |
299 | (rq->nr_sectors % floppy->bs_factor)) { | 293 | (rq->nr_sectors % floppy->bs_factor)) { |
300 | printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", | 294 | printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", |
301 | drive->name); | 295 | drive->name); |
302 | ide_floppy_end_request(drive, 0, 0); | 296 | goto out_end; |
303 | return ide_stopped; | ||
304 | } | 297 | } |
305 | pc = &floppy->queued_pc; | 298 | pc = &floppy->queued_pc; |
306 | idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); | 299 | idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); |
@@ -311,8 +304,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
311 | idefloppy_blockpc_cmd(floppy, pc, rq); | 304 | idefloppy_blockpc_cmd(floppy, pc, rq); |
312 | } else { | 305 | } else { |
313 | blk_dump_rq_flags(rq, PFX "unsupported command in queue"); | 306 | blk_dump_rq_flags(rq, PFX "unsupported command in queue"); |
314 | ide_floppy_end_request(drive, 0, 0); | 307 | goto out_end; |
315 | return ide_stopped; | ||
316 | } | 308 | } |
317 | 309 | ||
318 | if (blk_fs_request(rq) || pc->req_xfer) { | 310 | if (blk_fs_request(rq) || pc->req_xfer) { |
@@ -326,6 +318,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
326 | pc->rq = rq; | 318 | pc->rq = rq; |
327 | 319 | ||
328 | return idefloppy_issue_pc(drive, pc); | 320 | return idefloppy_issue_pc(drive, pc); |
321 | out_end: | ||
322 | drive->failed_pc = NULL; | ||
323 | ide_end_request(drive, 0, 0); | ||
324 | return ide_stopped; | ||
329 | } | 325 | } |
330 | 326 | ||
331 | /* | 327 | /* |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index e3b4c1c39d37..35469f3069a2 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -464,23 +464,13 @@ static void ide_tape_kfree_buffer(idetape_tape_t *tape) | |||
464 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | 464 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) |
465 | { | 465 | { |
466 | struct request *rq = drive->hwif->rq; | 466 | struct request *rq = drive->hwif->rq; |
467 | int error; | ||
468 | 467 | ||
469 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 468 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
470 | 469 | ||
471 | switch (uptodate) { | 470 | rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; |
472 | case 0: error = IDE_DRV_ERROR_GENERAL; break; | ||
473 | case 1: error = 0; break; | ||
474 | default: error = uptodate; | ||
475 | } | ||
476 | rq->errors = error; | ||
477 | if (error) | ||
478 | drive->failed_pc = NULL; | ||
479 | 471 | ||
480 | if (!blk_special_request(rq)) { | 472 | if (uptodate == 0) |
481 | ide_end_request(drive, uptodate, nr_sects); | 473 | drive->failed_pc = NULL; |
482 | return 0; | ||
483 | } | ||
484 | 474 | ||
485 | ide_complete_rq(drive, 0); | 475 | ide_complete_rq(drive, 0); |
486 | 476 | ||
@@ -493,7 +483,9 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
493 | { | 483 | { |
494 | idetape_tape_t *tape = drive->driver_data; | 484 | idetape_tape_t *tape = drive->driver_data; |
495 | struct ide_atapi_pc *pc = drive->pc; | 485 | struct ide_atapi_pc *pc = drive->pc; |
486 | struct request *rq = drive->hwif->rq; | ||
496 | int uptodate = pc->error ? 0 : 1; | 487 | int uptodate = pc->error ? 0 : 1; |
488 | int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; | ||
497 | 489 | ||
498 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 490 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
499 | 491 | ||
@@ -510,7 +502,6 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
510 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | 502 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " |
511 | "itself - Aborting request!\n"); | 503 | "itself - Aborting request!\n"); |
512 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 504 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
513 | struct request *rq = drive->hwif->rq; | ||
514 | int blocks = pc->xferred / tape->blk_size; | 505 | int blocks = pc->xferred / tape->blk_size; |
515 | 506 | ||
516 | tape->avg_size += blocks * tape->blk_size; | 507 | tape->avg_size += blocks * tape->blk_size; |
@@ -525,8 +516,10 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
525 | tape->first_frame += blocks; | 516 | tape->first_frame += blocks; |
526 | rq->current_nr_sectors -= blocks; | 517 | rq->current_nr_sectors -= blocks; |
527 | 518 | ||
528 | if (pc->error) | 519 | if (pc->error) { |
529 | uptodate = pc->error; | 520 | uptodate = 0; |
521 | err = pc->error; | ||
522 | } | ||
530 | } else if (pc->c[0] == READ_POSITION && uptodate) { | 523 | } else if (pc->c[0] == READ_POSITION && uptodate) { |
531 | u8 *readpos = pc->buf; | 524 | u8 *readpos = pc->buf; |
532 | 525 | ||
@@ -540,6 +533,7 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
540 | "to the tape\n"); | 533 | "to the tape\n"); |
541 | clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 534 | clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); |
542 | uptodate = 0; | 535 | uptodate = 0; |
536 | err = IDE_DRV_ERROR_GENERAL; | ||
543 | } else { | 537 | } else { |
544 | debug_log(DBG_SENSE, "Block Location - %u\n", | 538 | debug_log(DBG_SENSE, "Block Location - %u\n", |
545 | be32_to_cpup((__be32 *)&readpos[4])); | 539 | be32_to_cpup((__be32 *)&readpos[4])); |
@@ -550,7 +544,15 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
550 | } | 544 | } |
551 | } | 545 | } |
552 | 546 | ||
553 | idetape_end_request(drive, uptodate, 0); | 547 | rq->errors = err; |
548 | |||
549 | if (uptodate == 0) | ||
550 | drive->failed_pc = NULL; | ||
551 | |||
552 | if (blk_special_request(rq)) | ||
553 | ide_complete_rq(drive, 0); | ||
554 | else | ||
555 | ide_end_request(drive, uptodate, 0); | ||
554 | } | 556 | } |
555 | 557 | ||
556 | /* | 558 | /* |
@@ -794,7 +796,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
794 | if (rq != postponed_rq) { | 796 | if (rq != postponed_rq) { |
795 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " | 797 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " |
796 | "Two DSC requests were queued\n"); | 798 | "Two DSC requests were queued\n"); |
797 | idetape_end_request(drive, 0, 0); | 799 | rq->errors = IDE_DRV_ERROR_GENERAL; |
800 | drive->failed_pc = NULL; | ||
801 | ide_complete_rq(drive, 0); | ||
798 | return ide_stopped; | 802 | return ide_stopped; |
799 | } | 803 | } |
800 | 804 | ||