[ide] ide_driver_t->abort() cleanup

* add drive->media != ide_disk check to ide_abort()
* kill ide_cdrom_abort() and idedisk_abort()
* split __ide_abort() out of ide_abort()
* call driver->abort() inside ide_abort()
* convert the only user of driver->abort()
* fix default_abort() and idescsi_atapi_abort()
* make idescsi_atapi_abort() static
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent de9eb7ac
......@@ -559,23 +559,6 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
(void) ide_do_drive_cmd(drive, rq, ide_preempt);
}
static ide_startstop_t ide_cdrom_abort (ide_drive_t *drive, const char *msg)
{
struct request *rq;
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, BUSY_STAT, 0);
return ide_stopped;
}
rq->errors |= ERROR_RESET;
DRIVER(drive)->end_request(drive, 0, 0);
return ide_stopped;
}
static void cdrom_end_request (ide_drive_t *drive, int uptodate)
{
struct request *rq = HWGROUP(drive)->rq;
......@@ -3330,7 +3313,6 @@ static ide_driver_t ide_cdrom_driver = {
.supports_dsc_overlap = 1,
.cleanup = ide_cdrom_cleanup,
.do_request = ide_do_rw_cdrom,
.abort = ide_cdrom_abort,
.capacity = ide_cdrom_capacity,
.attach = ide_cdrom_attach,
.drives = LIST_HEAD_INIT(ide_cdrom_driver.drives),
......
......@@ -287,26 +287,6 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s
return __ide_do_rw_disk(drive, rq, block);
}
static ide_startstop_t idedisk_abort(ide_drive_t *drive, const char *msg)
{
ide_hwif_t *hwif;
struct request *rq;
if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
return ide_stopped;
hwif = HWIF(drive);
if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) {
rq->errors = 1;
ide_end_drive_cmd(drive, BUSY_STAT, 0);
return ide_stopped;
}
DRIVER(drive)->end_request(drive, 0, 0);
return ide_stopped;
}
/*
* Queries for true maximum capacity of the drive.
* Returns maximum LBA address (> 0) of the drive, 0 if failed.
......@@ -1195,7 +1175,6 @@ static ide_driver_t idedisk_driver = {
.supports_dsc_overlap = 0,
.cleanup = idedisk_cleanup,
.do_request = ide_do_rw_disk,
.abort = idedisk_abort,
.pre_reset = idedisk_pre_reset,
.capacity = idedisk_capacity,
.special = idedisk_special,
......
......@@ -572,6 +572,15 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat)
EXPORT_SYMBOL_GPL(ide_error);
ide_startstop_t __ide_abort(ide_drive_t *drive, struct request *rq)
{
if (drive->media != ide_disk)
rq->errors |= ERROR_RESET;
DRIVER(drive)->end_request(drive, 0, 0);
return ide_stopped;
}
/**
* ide_abort - abort pending IDE operatins
* @drive: drive the error occurred on
......@@ -588,28 +597,19 @@ EXPORT_SYMBOL_GPL(ide_error);
ide_startstop_t ide_abort(ide_drive_t *drive, const char *msg)
{
ide_hwif_t *hwif;
struct request *rq;
if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
return ide_stopped;
hwif = HWIF(drive);
/* retry only "normal" I/O: */
if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) {
rq->errors = 1;
ide_end_drive_cmd(drive, BUSY_STAT, 0);
return ide_stopped;
}
if (rq->flags & REQ_DRIVE_TASKFILE) {
if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) {
rq->errors = 1;
ide_end_drive_cmd(drive, BUSY_STAT, 0);
return ide_stopped;
}
rq->errors |= ERROR_RESET;
DRIVER(drive)->end_request(drive, 0, 0);
return ide_stopped;
return drive->driver->abort(drive, rq);
}
/**
......
......@@ -1560,8 +1560,9 @@ int generic_ide_ioctl(struct file *file, struct block_device *bdev,
*/
spin_lock_irqsave(&ide_lock, flags);
DRIVER(drive)->abort(drive, "drive reset");
ide_abort(drive, "drive reset");
if(HWGROUP(drive)->handler)
BUG();
......@@ -2099,9 +2100,9 @@ static int default_attach (ide_drive_t *drive)
return 0;
}
static ide_startstop_t default_abort (ide_drive_t *drive, const char *msg)
static ide_startstop_t default_abort(ide_drive_t *drive, struct request *rq)
{
return ide_abort(drive, msg);
return __ide_abort(drive, rq);
}
static ide_startstop_t default_start_power_step(ide_drive_t *drive,
......
......@@ -313,20 +313,9 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
return ide_stopped;
}
ide_startstop_t idescsi_atapi_abort (ide_drive_t *drive, const char *msg)
static ide_startstop_t
idescsi_atapi_abort(ide_drive_t *drive, struct request *rq)
{
struct request *rq;
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, BUSY_STAT, 0);
return ide_stopped;
}
#if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_atapi_abort called for %lu\n",
((idescsi_pc_t *) rq->special)->scsi_cmd->serial_number);
......
......@@ -1098,7 +1098,7 @@ typedef struct ide_driver_s {
ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
int (*end_request)(ide_drive_t *, int, int);
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 *, struct request *rq);
int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
void (*pre_reset)(ide_drive_t *);
sector_t (*capacity)(ide_drive_t *);
......@@ -1156,6 +1156,8 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
*/
ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
/*
* Abort a running command on the controller triggering the abort
* from a host side, non error situation
......
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