[ide] rework ide_driver_t->error

* split __ide_error() out of ide_error()
* call driver->error() inside ide_error()
* convert all users of driver->error()
* fix default_cleanup() and idescsi_atapi_error()
* make idescsi_atapi_error() static
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 2fb30540
...@@ -423,7 +423,7 @@ static ide_startstop_t icside_dmaintr(ide_drive_t *drive) ...@@ -423,7 +423,7 @@ static ide_startstop_t icside_dmaintr(ide_drive_t *drive)
drive->name, dma_stat); drive->name, dma_stat);
} }
return DRIVER(drive)->error(drive, __FUNCTION__, stat); return ide_error(drive, __FUNCTION__, stat);
} }
static int icside_dma_setup(ide_drive_t *drive) static int icside_dma_setup(ide_drive_t *drive)
......
...@@ -773,7 +773,7 @@ static ide_startstop_t etrax_dma_intr (ide_drive_t *drive) ...@@ -773,7 +773,7 @@ static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
} }
printk("%s: bad DMA status\n", drive->name); printk("%s: bad DMA status\n", drive->name);
} }
return DRIVER(drive)->error(drive, "dma_intr", stat); return ide_error(drive, "dma_intr", stat);
} }
/* /*
......
...@@ -651,7 +651,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) ...@@ -651,7 +651,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
rq->flags |= REQ_FAILED; rq->flags |= REQ_FAILED;
cdrom_end_request(drive, 0); cdrom_end_request(drive, 0);
DRIVER(drive)->error(drive, "request sense failure", stat); ide_error(drive, "request sense failure", stat);
return 1; return 1;
} else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) { } else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) {
...@@ -762,7 +762,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) ...@@ -762,7 +762,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
} else if ((err & ~ABRT_ERR) != 0) { } else if ((err & ~ABRT_ERR) != 0) {
/* Go to the default handler /* Go to the default handler
for other errors. */ for other errors. */
DRIVER(drive)->error(drive, "cdrom_decode_status",stat); ide_error(drive, "cdrom_decode_status", stat);
return 1; return 1;
} else if ((++rq->errors > ERROR_MAX)) { } else if ((++rq->errors > ERROR_MAX)) {
/* We've racked up too many retries. Abort. */ /* We've racked up too many retries. Abort. */
...@@ -1031,7 +1031,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) ...@@ -1031,7 +1031,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
ide_end_request(drive, 1, rq->nr_sectors); ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped; return ide_stopped;
} else } else
return DRIVER(drive)->error(drive, "dma error", stat); return ide_error(drive, "dma error", stat);
} }
/* Read the interrupt reason and the transfer length. */ /* Read the interrupt reason and the transfer length. */
...@@ -1634,7 +1634,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -1634,7 +1634,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
if (dma_error) { if (dma_error) {
printk("ide-cd: dma error\n"); printk("ide-cd: dma error\n");
__ide_dma_off(drive); __ide_dma_off(drive);
return DRIVER(drive)->error(drive, "dma error", stat); return ide_error(drive, "dma error", stat);
} }
end_that_request_chunk(rq, 1, rq->data_len); end_that_request_chunk(rq, 1, rq->data_len);
...@@ -1772,7 +1772,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) ...@@ -1772,7 +1772,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
*/ */
if (dma) { if (dma) {
if (dma_error) if (dma_error)
return DRIVER(drive)->error(drive, "dma error", stat); return ide_error(drive, "dma error", stat);
ide_end_request(drive, 1, rq->nr_sectors); ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped; return ide_stopped;
......
...@@ -183,7 +183,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) ...@@ -183,7 +183,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n", printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n",
drive->name, dma_stat); drive->name, dma_stat);
} }
return DRIVER(drive)->error(drive, "dma_intr", stat); return ide_error(drive, "dma_intr", stat);
} }
EXPORT_SYMBOL_GPL(ide_dma_intr); EXPORT_SYMBOL_GPL(ide_dma_intr);
......
...@@ -529,6 +529,14 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u ...@@ -529,6 +529,14 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
return ide_stopped; return ide_stopped;
} }
ide_startstop_t
__ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
{
if (drive->media == ide_disk)
return ide_ata_error(drive, rq, stat, err);
return ide_atapi_error(drive, rq, stat, err);
}
/** /**
* ide_error - handle an error on the IDE * ide_error - handle an error on the IDE
* @drive: drive the error occurred on * @drive: drive the error occurred on
...@@ -559,11 +567,11 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat) ...@@ -559,11 +567,11 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat)
return ide_stopped; return ide_stopped;
} }
if (drive->media == ide_disk) return drive->driver->error(drive, rq, stat, err);
return ide_ata_error(drive, rq, stat, err);
return ide_atapi_error(drive, rq, stat, err);
} }
EXPORT_SYMBOL_GPL(ide_error);
/** /**
* ide_abort - abort pending IDE operatins * ide_abort - abort pending IDE operatins
* @drive: drive the error occurred on * @drive: drive the error occurred on
...@@ -655,7 +663,7 @@ static ide_startstop_t drive_cmd_intr (ide_drive_t *drive) ...@@ -655,7 +663,7 @@ static ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
} }
if (!OK_STAT(stat, READY_STAT, BAD_STAT) && DRIVER(drive) != NULL) if (!OK_STAT(stat, READY_STAT, BAD_STAT) && DRIVER(drive) != NULL)
return DRIVER(drive)->error(drive, "drive_cmd", stat); return ide_error(drive, "drive_cmd", stat);
/* calls ide_end_drive_cmd */ /* calls ide_end_drive_cmd */
ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG)); ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG));
return ide_stopped; return ide_stopped;
...@@ -1202,7 +1210,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) ...@@ -1202,7 +1210,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
if (error < 0) { if (error < 0) {
printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
(void)HWIF(drive)->ide_dma_end(drive); (void)HWIF(drive)->ide_dma_end(drive);
ret = DRIVER(drive)->error(drive, "dma timeout error", ret = ide_error(drive, "dma timeout error",
hwif->INB(IDE_STATUS_REG)); hwif->INB(IDE_STATUS_REG));
} else { } else {
printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
...@@ -1325,7 +1333,7 @@ void ide_timer_expiry (unsigned long data) ...@@ -1325,7 +1333,7 @@ void ide_timer_expiry (unsigned long data)
startstop = ide_dma_timeout_retry(drive, wait); startstop = ide_dma_timeout_retry(drive, wait);
} else } else
startstop = startstop =
DRIVER(drive)->error(drive, "irq timeout", hwif->INB(IDE_STATUS_REG)); ide_error(drive, "irq timeout", hwif->INB(IDE_STATUS_REG));
} }
drive->service_time = jiffies - drive->service_start; drive->service_time = jiffies - drive->service_start;
spin_lock_irq(&ide_lock); spin_lock_irq(&ide_lock);
......
...@@ -576,7 +576,7 @@ int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 b ...@@ -576,7 +576,7 @@ int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 b
break; break;
local_irq_restore(flags); local_irq_restore(flags);
*startstop = DRIVER(drive)->error(drive, "status timeout", stat); *startstop = ide_error(drive, "status timeout", stat);
return 1; return 1;
} }
} }
...@@ -594,7 +594,7 @@ int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 b ...@@ -594,7 +594,7 @@ int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 b
if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad)) if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad))
return 0; return 0;
} }
*startstop = DRIVER(drive)->error(drive, "status error", stat); *startstop = ide_error(drive, "status error", stat);
return 1; return 1;
} }
......
...@@ -199,7 +199,7 @@ ide_startstop_t set_geometry_intr (ide_drive_t *drive) ...@@ -199,7 +199,7 @@ ide_startstop_t set_geometry_intr (ide_drive_t *drive)
return ide_stopped; return ide_stopped;
if (stat & (ERR_STAT|DRQ_STAT)) if (stat & (ERR_STAT|DRQ_STAT))
return DRIVER(drive)->error(drive, "set_geometry_intr", stat); return ide_error(drive, "set_geometry_intr", stat);
if (HWGROUP(drive)->handler != NULL) if (HWGROUP(drive)->handler != NULL)
BUG(); BUG();
...@@ -218,7 +218,7 @@ ide_startstop_t recal_intr (ide_drive_t *drive) ...@@ -218,7 +218,7 @@ ide_startstop_t recal_intr (ide_drive_t *drive)
u8 stat; u8 stat;
if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT)) if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT))
return DRIVER(drive)->error(drive, "recal_intr", stat); return ide_error(drive, "recal_intr", stat);
return ide_stopped; return ide_stopped;
} }
...@@ -235,7 +235,7 @@ ide_startstop_t task_no_data_intr (ide_drive_t *drive) ...@@ -235,7 +235,7 @@ ide_startstop_t task_no_data_intr (ide_drive_t *drive)
local_irq_enable(); local_irq_enable();
if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
return DRIVER(drive)->error(drive, "task_no_data_intr", stat); return ide_error(drive, "task_no_data_intr", stat);
/* calls ide_end_drive_cmd */ /* calls ide_end_drive_cmd */
} }
if (args) if (args)
...@@ -363,7 +363,7 @@ static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq, ...@@ -363,7 +363,7 @@ static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
if (sectors > 0) if (sectors > 0)
drive->driver->end_request(drive, 1, sectors); drive->driver->end_request(drive, 1, sectors);
} }
return drive->driver->error(drive, s, stat); return ide_error(drive, s, stat);
} }
static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
......
...@@ -2067,9 +2067,10 @@ static int default_end_request (ide_drive_t *drive, int uptodate, int nr_sects) ...@@ -2067,9 +2067,10 @@ static int default_end_request (ide_drive_t *drive, int uptodate, int nr_sects)
return ide_end_request(drive, uptodate, nr_sects); return ide_end_request(drive, uptodate, nr_sects);
} }
static ide_startstop_t default_error (ide_drive_t *drive, const char *msg, u8 stat) static ide_startstop_t
default_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
{ {
return ide_error(drive, msg, stat); return __ide_error(drive, rq, stat, err);
} }
static void default_pre_reset (ide_drive_t *drive) static void default_pre_reset (ide_drive_t *drive)
......
...@@ -301,23 +301,9 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co ...@@ -301,23 +301,9 @@ static int idescsi_check_condition(ide_drive_t *drive, struct request *failed_co
return ide_do_drive_cmd(drive, rq, ide_preempt); return ide_do_drive_cmd(drive, rq, ide_preempt);
} }
ide_startstop_t idescsi_atapi_error (ide_drive_t *drive, const char *msg, byte stat) static ide_startstop_t
idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
{ {
struct request *rq;
byte err;
err = ide_dump_status(drive, msg, stat);
if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
return ide_stopped;
/* retry only "normal" I/O: */
if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) {
rq->errors = 1;
ide_end_drive_cmd(drive, stat, err);
return ide_stopped;
}
if (HWIF(drive)->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) if (HWIF(drive)->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
/* force an abort */ /* force an abort */
HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG); HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG);
......
...@@ -1097,7 +1097,7 @@ typedef struct ide_driver_s { ...@@ -1097,7 +1097,7 @@ typedef struct ide_driver_s {
int (*cleanup)(ide_drive_t *); int (*cleanup)(ide_drive_t *);
ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
int (*end_request)(ide_drive_t *, int, int); int (*end_request)(ide_drive_t *, int, int);
ide_startstop_t (*error)(ide_drive_t *, const char *, u8); ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
ide_startstop_t (*abort)(ide_drive_t *, const char *); ide_startstop_t (*abort)(ide_drive_t *, const char *);
int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
void (*pre_reset)(ide_drive_t *); void (*pre_reset)(ide_drive_t *);
...@@ -1146,6 +1146,8 @@ extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigne ...@@ -1146,6 +1146,8 @@ extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigne
*/ */
extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *); extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *);
ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
/* /*
* ide_error() takes action based on the error returned by the controller. * ide_error() takes action based on the error returned by the controller.
* The caller should return immediately after invoking this. * The caller should return immediately after invoking this.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment