}
EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
-static inline void ide_complete_drive_reset(ide_drive_t *drive)
+static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
{
struct request *rq = drive->hwif->hwgroup->rq;
if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET)
- ide_end_request(drive, 1, 0);
+ ide_end_request(drive, err ? err : 1, 0);
}
/* needed below */
}
/* done polling */
hwgroup->polling = 0;
- ide_complete_drive_reset(drive);
+ ide_complete_drive_reset(drive, 0);
return ide_stopped;
}
ide_hwif_t *hwif = HWIF(drive);
const struct ide_port_ops *port_ops = hwif->port_ops;
u8 tmp;
+ int err = 0;
if (port_ops && port_ops->reset_poll) {
- if (port_ops->reset_poll(drive)) {
+ err = port_ops->reset_poll(drive);
+ if (err) {
printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
hwif->name, drive->name);
goto out;
}
printk("%s: reset timed-out, status=0x%02x\n", hwif->name, tmp);
drive->failures++;
+ err = -EIO;
} else {
printk("%s: reset: ", hwif->name);
tmp = ide_read_error(drive);
if (tmp & 0x80)
printk("; slave: failed");
printk("\n");
+ err = -EIO;
}
}
- hwgroup->polling = 0; /* done polling */
out:
- ide_complete_drive_reset(drive);
+ hwgroup->polling = 0; /* done polling */
+ ide_complete_drive_reset(drive, err);
return ide_stopped;
}
if (io_ports->ctl_addr == 0) {
spin_unlock_irqrestore(&ide_lock, flags);
- ide_complete_drive_reset(drive);
+ ide_complete_drive_reset(drive, -ENXIO);
return ide_stopped;
}
return err;
}
-static void generic_drive_reset(ide_drive_t *drive)
+static int generic_drive_reset(ide_drive_t *drive)
{
struct request *rq;
+ int ret = 0;
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_SPECIAL;
rq->cmd_len = 1;
rq->cmd[0] = REQ_DRIVE_RESET;
rq->cmd_flags |= REQ_SOFTBARRIER;
- blk_execute_rq(drive->queue, NULL, rq, 1);
+ if (blk_execute_rq(drive->queue, NULL, rq, 1))
+ ret = rq->errors;
blk_put_request(rq);
+ return ret;
}
int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- generic_drive_reset(drive);
- return 0;
+ return generic_drive_reset(drive);
case HDIO_GET_BUSSTATE:
if (!capable(CAP_SYS_ADMIN))