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>
This commit is contained in:
parent
c152cc1a90
commit
313afea7f2
2 changed files with 53 additions and 53 deletions
|
@ -62,40 +62,21 @@
|
||||||
#define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */
|
#define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to finish servicing a request. For read/write requests, we will call
|
* Used to finish servicing a private request.
|
||||||
* ide_end_request to pass to the next buffer.
|
|
||||||
*/
|
*/
|
||||||
static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
|
static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
|
||||||
{
|
{
|
||||||
struct request *rq = drive->hwif->rq;
|
struct request *rq = drive->hwif->rq;
|
||||||
int error;
|
|
||||||
|
|
||||||
ide_debug_log(IDE_DBG_FUNC, "enter");
|
ide_debug_log(IDE_DBG_FUNC, "enter");
|
||||||
|
|
||||||
switch (uptodate) {
|
if (uptodate == 0)
|
||||||
case 0:
|
|
||||||
error = IDE_DRV_ERROR_GENERAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
error = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
error = uptodate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
drive->failed_pc = NULL;
|
drive->failed_pc = NULL;
|
||||||
|
|
||||||
if (!blk_special_request(rq)) {
|
rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
|
||||||
/* our real local end request function */
|
|
||||||
ide_end_request(drive, uptodate, nsecs);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
rq->errors = error;
|
|
||||||
/* fixme: need to move this local also */
|
|
||||||
ide_complete_rq(drive, 0);
|
ide_complete_rq(drive, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,13 +87,14 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
|
||||||
struct bio *bio = rq->bio;
|
struct bio *bio = rq->bio;
|
||||||
|
|
||||||
while ((bio = rq->bio) != NULL)
|
while ((bio = rq->bio) != NULL)
|
||||||
ide_floppy_end_request(drive, 1, 0);
|
ide_end_request(drive, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ide_floppy_callback(ide_drive_t *drive, int dsc)
|
static void ide_floppy_callback(ide_drive_t *drive, int dsc)
|
||||||
{
|
{
|
||||||
struct ide_disk_obj *floppy = drive->driver_data;
|
struct ide_disk_obj *floppy = drive->driver_data;
|
||||||
struct ide_atapi_pc *pc = drive->pc;
|
struct ide_atapi_pc *pc = drive->pc;
|
||||||
|
struct request *rq = pc->rq;
|
||||||
int uptodate = pc->error ? 0 : 1;
|
int uptodate = pc->error ? 0 : 1;
|
||||||
|
|
||||||
ide_debug_log(IDE_DBG_FUNC, "enter");
|
ide_debug_log(IDE_DBG_FUNC, "enter");
|
||||||
|
@ -121,7 +103,7 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc)
|
||||||
drive->failed_pc = NULL;
|
drive->failed_pc = NULL;
|
||||||
|
|
||||||
if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
|
if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
|
||||||
(pc->rq && blk_pc_request(pc->rq)))
|
(rq && blk_pc_request(rq)))
|
||||||
uptodate = 1; /* FIXME */
|
uptodate = 1; /* FIXME */
|
||||||
else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
|
else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
|
||||||
u8 *buf = pc->buf;
|
u8 *buf = pc->buf;
|
||||||
|
@ -145,7 +127,14 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc)
|
||||||
"Aborting request!\n");
|
"Aborting request!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ide_floppy_end_request(drive, uptodate, 0);
|
if (uptodate == 0)
|
||||||
|
drive->failed_pc = NULL;
|
||||||
|
|
||||||
|
if (blk_special_request(rq)) {
|
||||||
|
rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
|
||||||
|
ide_complete_rq(drive, 0);
|
||||||
|
} else
|
||||||
|
ide_end_request(drive, uptodate, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ide_floppy_report_error(struct ide_disk_obj *floppy,
|
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,
|
||||||
: "dev?"));
|
: "dev?"));
|
||||||
|
|
||||||
if (rq->errors >= ERROR_MAX) {
|
if (rq->errors >= ERROR_MAX) {
|
||||||
if (drive->failed_pc)
|
if (drive->failed_pc) {
|
||||||
ide_floppy_report_error(floppy, drive->failed_pc);
|
ide_floppy_report_error(floppy, drive->failed_pc);
|
||||||
else
|
drive->failed_pc = NULL;
|
||||||
|
} else
|
||||||
printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
|
printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
|
||||||
|
|
||||||
ide_floppy_end_request(drive, 0, 0);
|
if (blk_special_request(rq)) {
|
||||||
return ide_stopped;
|
rq->errors = IDE_DRV_ERROR_GENERAL;
|
||||||
|
ide_complete_rq(drive, 0);
|
||||||
|
return ide_stopped;
|
||||||
|
} else
|
||||||
|
goto out_end;
|
||||||
}
|
}
|
||||||
if (blk_fs_request(rq)) {
|
if (blk_fs_request(rq)) {
|
||||||
if (((long)rq->sector % floppy->bs_factor) ||
|
if (((long)rq->sector % floppy->bs_factor) ||
|
||||||
(rq->nr_sectors % floppy->bs_factor)) {
|
(rq->nr_sectors % floppy->bs_factor)) {
|
||||||
printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
|
printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
|
||||||
drive->name);
|
drive->name);
|
||||||
ide_floppy_end_request(drive, 0, 0);
|
goto out_end;
|
||||||
return ide_stopped;
|
|
||||||
}
|
}
|
||||||
pc = &floppy->queued_pc;
|
pc = &floppy->queued_pc;
|
||||||
idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
|
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,
|
||||||
idefloppy_blockpc_cmd(floppy, pc, rq);
|
idefloppy_blockpc_cmd(floppy, pc, rq);
|
||||||
} else {
|
} else {
|
||||||
blk_dump_rq_flags(rq, PFX "unsupported command in queue");
|
blk_dump_rq_flags(rq, PFX "unsupported command in queue");
|
||||||
ide_floppy_end_request(drive, 0, 0);
|
goto out_end;
|
||||||
return ide_stopped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blk_fs_request(rq) || pc->req_xfer) {
|
if (blk_fs_request(rq) || pc->req_xfer) {
|
||||||
|
@ -326,6 +318,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
|
||||||
pc->rq = rq;
|
pc->rq = rq;
|
||||||
|
|
||||||
return idefloppy_issue_pc(drive, pc);
|
return idefloppy_issue_pc(drive, pc);
|
||||||
|
out_end:
|
||||||
|
drive->failed_pc = NULL;
|
||||||
|
ide_end_request(drive, 0, 0);
|
||||||
|
return ide_stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -464,23 +464,13 @@ static void ide_tape_kfree_buffer(idetape_tape_t *tape)
|
||||||
static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
|
static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
|
||||||
{
|
{
|
||||||
struct request *rq = drive->hwif->rq;
|
struct request *rq = drive->hwif->rq;
|
||||||
int error;
|
|
||||||
|
|
||||||
debug_log(DBG_PROCS, "Enter %s\n", __func__);
|
debug_log(DBG_PROCS, "Enter %s\n", __func__);
|
||||||
|
|
||||||
switch (uptodate) {
|
rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
|
||||||
case 0: error = IDE_DRV_ERROR_GENERAL; break;
|
|
||||||
case 1: error = 0; break;
|
|
||||||
default: error = uptodate;
|
|
||||||
}
|
|
||||||
rq->errors = error;
|
|
||||||
if (error)
|
|
||||||
drive->failed_pc = NULL;
|
|
||||||
|
|
||||||
if (!blk_special_request(rq)) {
|
if (uptodate == 0)
|
||||||
ide_end_request(drive, uptodate, nr_sects);
|
drive->failed_pc = NULL;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ide_complete_rq(drive, 0);
|
ide_complete_rq(drive, 0);
|
||||||
|
|
||||||
|
@ -493,7 +483,9 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
|
||||||
{
|
{
|
||||||
idetape_tape_t *tape = drive->driver_data;
|
idetape_tape_t *tape = drive->driver_data;
|
||||||
struct ide_atapi_pc *pc = drive->pc;
|
struct ide_atapi_pc *pc = drive->pc;
|
||||||
|
struct request *rq = drive->hwif->rq;
|
||||||
int uptodate = pc->error ? 0 : 1;
|
int uptodate = pc->error ? 0 : 1;
|
||||||
|
int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
|
||||||
|
|
||||||
debug_log(DBG_PROCS, "Enter %s\n", __func__);
|
debug_log(DBG_PROCS, "Enter %s\n", __func__);
|
||||||
|
|
||||||
|
@ -510,7 +502,6 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
|
||||||
printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
|
printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
|
||||||
"itself - Aborting request!\n");
|
"itself - Aborting request!\n");
|
||||||
} else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
|
} else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
|
||||||
struct request *rq = drive->hwif->rq;
|
|
||||||
int blocks = pc->xferred / tape->blk_size;
|
int blocks = pc->xferred / tape->blk_size;
|
||||||
|
|
||||||
tape->avg_size += blocks * tape->blk_size;
|
tape->avg_size += blocks * tape->blk_size;
|
||||||
|
@ -525,8 +516,10 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
|
||||||
tape->first_frame += blocks;
|
tape->first_frame += blocks;
|
||||||
rq->current_nr_sectors -= blocks;
|
rq->current_nr_sectors -= blocks;
|
||||||
|
|
||||||
if (pc->error)
|
if (pc->error) {
|
||||||
uptodate = pc->error;
|
uptodate = 0;
|
||||||
|
err = pc->error;
|
||||||
|
}
|
||||||
} else if (pc->c[0] == READ_POSITION && uptodate) {
|
} else if (pc->c[0] == READ_POSITION && uptodate) {
|
||||||
u8 *readpos = pc->buf;
|
u8 *readpos = pc->buf;
|
||||||
|
|
||||||
|
@ -540,6 +533,7 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
|
||||||
"to the tape\n");
|
"to the tape\n");
|
||||||
clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags);
|
clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags);
|
||||||
uptodate = 0;
|
uptodate = 0;
|
||||||
|
err = IDE_DRV_ERROR_GENERAL;
|
||||||
} else {
|
} else {
|
||||||
debug_log(DBG_SENSE, "Block Location - %u\n",
|
debug_log(DBG_SENSE, "Block Location - %u\n",
|
||||||
be32_to_cpup((__be32 *)&readpos[4]));
|
be32_to_cpup((__be32 *)&readpos[4]));
|
||||||
|
@ -550,7 +544,15 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
idetape_end_request(drive, uptodate, 0);
|
rq->errors = err;
|
||||||
|
|
||||||
|
if (uptodate == 0)
|
||||||
|
drive->failed_pc = NULL;
|
||||||
|
|
||||||
|
if (blk_special_request(rq))
|
||||||
|
ide_complete_rq(drive, 0);
|
||||||
|
else
|
||||||
|
ide_end_request(drive, uptodate, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -794,7 +796,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
|
||||||
if (rq != postponed_rq) {
|
if (rq != postponed_rq) {
|
||||||
printk(KERN_ERR "ide-tape: ide-tape.c bug - "
|
printk(KERN_ERR "ide-tape: ide-tape.c bug - "
|
||||||
"Two DSC requests were queued\n");
|
"Two DSC requests were queued\n");
|
||||||
idetape_end_request(drive, 0, 0);
|
rq->errors = IDE_DRV_ERROR_GENERAL;
|
||||||
|
drive->failed_pc = NULL;
|
||||||
|
ide_complete_rq(drive, 0);
|
||||||
return ide_stopped;
|
return ide_stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue