提交 a0123703 编写于 作者: T Tejun Heo 提交者: Jeff Garzik

[PATCH] libata: use ata_exec_internal()

This patch converts all users of libata internal commands to use
ata_exec_internal().
Signed-off-by: NTejun Heo <htejun@gmail.com>
Signed-off-by: NJeff Garzik <jgarzik@pobox.com>
上级 a2a7a662
...@@ -1198,9 +1198,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ...@@ -1198,9 +1198,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
u16 tmp; u16 tmp;
unsigned long xfer_modes; unsigned long xfer_modes;
unsigned int using_edd; unsigned int using_edd;
DECLARE_COMPLETION(wait); struct ata_taskfile tf;
struct ata_queued_cmd *qc; unsigned int err_mask;
unsigned long flags;
int rc; int rc;
if (!ata_dev_present(dev)) { if (!ata_dev_present(dev)) {
...@@ -1221,40 +1220,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ...@@ -1221,40 +1220,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ ata_dev_select(ap, device, 1, 1); /* select device 0/1 */
qc = ata_qc_new_init(ap, dev);
BUG_ON(qc == NULL);
ata_sg_init_one(qc, dev->id, sizeof(dev->id));
qc->dma_dir = DMA_FROM_DEVICE;
qc->tf.protocol = ATA_PROT_PIO;
qc->nsect = 1;
retry: retry:
ata_tf_init(ap, &tf, device);
if (dev->class == ATA_DEV_ATA) { if (dev->class == ATA_DEV_ATA) {
qc->tf.command = ATA_CMD_ID_ATA; tf.command = ATA_CMD_ID_ATA;
DPRINTK("do ATA identify\n"); DPRINTK("do ATA identify\n");
} else { } else {
qc->tf.command = ATA_CMD_ID_ATAPI; tf.command = ATA_CMD_ID_ATAPI;
DPRINTK("do ATAPI identify\n"); DPRINTK("do ATAPI identify\n");
} }
qc->waiting = &wait; tf.protocol = ATA_PROT_PIO;
qc->complete_fn = ata_qc_complete_noop;
spin_lock_irqsave(&ap->host_set->lock, flags);
rc = ata_qc_issue(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
if (rc) err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
goto err_out; dev->id, sizeof(dev->id));
else
ata_qc_wait_err(qc, &wait);
spin_lock_irqsave(&ap->host_set->lock, flags); if (err_mask) {
ap->ops->tf_read(ap, &qc->tf); if (err_mask & ~AC_ERR_DEV)
spin_unlock_irqrestore(&ap->host_set->lock, flags); goto err_out;
if (qc->tf.command & ATA_ERR) {
/* /*
* arg! EDD works for all test cases, but seems to return * arg! EDD works for all test cases, but seems to return
* the ATA signature for some ATAPI devices. Until the * the ATA signature for some ATAPI devices. Until the
...@@ -1267,14 +1252,9 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ...@@ -1267,14 +1252,9 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
* to have this problem. * to have this problem.
*/ */
if ((using_edd) && (dev->class == ATA_DEV_ATA)) { if ((using_edd) && (dev->class == ATA_DEV_ATA)) {
u8 err = qc->tf.feature; u8 err = tf.feature;
if (err & ATA_ABORTED) { if (err & ATA_ABORTED) {
dev->class = ATA_DEV_ATAPI; dev->class = ATA_DEV_ATAPI;
qc->cursg = 0;
qc->cursg_ofs = 0;
qc->cursect = 0;
qc->nsect = 1;
qc->err_mask = 0;
goto retry; goto retry;
} }
} }
...@@ -2378,34 +2358,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap, ...@@ -2378,34 +2358,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap,
static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
{ {
DECLARE_COMPLETION(wait); struct ata_taskfile tf;
struct ata_queued_cmd *qc;
int rc;
unsigned long flags;
/* set up set-features taskfile */ /* set up set-features taskfile */
DPRINTK("set features - xfer mode\n"); DPRINTK("set features - xfer mode\n");
qc = ata_qc_new_init(ap, dev); ata_tf_init(ap, &tf, dev->devno);
BUG_ON(qc == NULL); tf.command = ATA_CMD_SET_FEATURES;
tf.feature = SETFEATURES_XFER;
qc->tf.command = ATA_CMD_SET_FEATURES; tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
qc->tf.feature = SETFEATURES_XFER; tf.protocol = ATA_PROT_NODATA;
qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.nsect = dev->xfer_mode;
qc->tf.protocol = ATA_PROT_NODATA;
qc->tf.nsect = dev->xfer_mode;
qc->waiting = &wait;
qc->complete_fn = ata_qc_complete_noop;
spin_lock_irqsave(&ap->host_set->lock, flags);
rc = ata_qc_issue(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
if (rc) if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n",
ap->id);
ata_port_disable(ap); ata_port_disable(ap);
else }
ata_qc_wait_err(qc, &wait);
DPRINTK("EXIT\n"); DPRINTK("EXIT\n");
} }
...@@ -2420,41 +2389,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) ...@@ -2420,41 +2389,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
{ {
DECLARE_COMPLETION(wait); struct ata_taskfile tf;
struct ata_queued_cmd *qc;
unsigned long flags;
int rc;
qc = ata_qc_new_init(ap, dev);
BUG_ON(qc == NULL);
ata_sg_init_one(qc, dev->id, sizeof(dev->id)); ata_tf_init(ap, &tf, dev->devno);
qc->dma_dir = DMA_FROM_DEVICE;
if (dev->class == ATA_DEV_ATA) { if (dev->class == ATA_DEV_ATA) {
qc->tf.command = ATA_CMD_ID_ATA; tf.command = ATA_CMD_ID_ATA;
DPRINTK("do ATA identify\n"); DPRINTK("do ATA identify\n");
} else { } else {
qc->tf.command = ATA_CMD_ID_ATAPI; tf.command = ATA_CMD_ID_ATAPI;
DPRINTK("do ATAPI identify\n"); DPRINTK("do ATAPI identify\n");
} }
qc->tf.flags |= ATA_TFLAG_DEVICE; tf.flags |= ATA_TFLAG_DEVICE;
qc->tf.protocol = ATA_PROT_PIO; tf.protocol = ATA_PROT_PIO;
qc->nsect = 1;
qc->waiting = &wait;
qc->complete_fn = ata_qc_complete_noop;
spin_lock_irqsave(&ap->host_set->lock, flags);
rc = ata_qc_issue(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
if (rc) if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
dev->id, sizeof(dev->id)))
goto err_out; goto err_out;
ata_qc_wait_err(qc, &wait);
swap_buf_le16(dev->id, ATA_ID_WORDS); swap_buf_le16(dev->id, ATA_ID_WORDS);
ata_dump_id(dev); ata_dump_id(dev);
...@@ -2463,6 +2416,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) ...@@ -2463,6 +2416,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
return; return;
err_out: err_out:
printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id);
ata_port_disable(ap); ata_port_disable(ap);
} }
...@@ -2476,10 +2430,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) ...@@ -2476,10 +2430,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
{ {
DECLARE_COMPLETION(wait); struct ata_taskfile tf;
struct ata_queued_cmd *qc;
int rc;
unsigned long flags;
u16 sectors = dev->id[6]; u16 sectors = dev->id[6];
u16 heads = dev->id[3]; u16 heads = dev->id[3];
...@@ -2490,26 +2441,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) ...@@ -2490,26 +2441,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
/* set up init dev params taskfile */ /* set up init dev params taskfile */
DPRINTK("init dev params \n"); DPRINTK("init dev params \n");
qc = ata_qc_new_init(ap, dev); ata_tf_init(ap, &tf, dev->devno);
BUG_ON(qc == NULL); tf.command = ATA_CMD_INIT_DEV_PARAMS;
tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; tf.protocol = ATA_PROT_NODATA;
qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.nsect = sectors;
qc->tf.protocol = ATA_PROT_NODATA; tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
qc->tf.nsect = sectors;
qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
qc->waiting = &wait;
qc->complete_fn = ata_qc_complete_noop;
spin_lock_irqsave(&ap->host_set->lock, flags);
rc = ata_qc_issue(qc);
spin_unlock_irqrestore(&ap->host_set->lock, flags);
if (rc) if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
printk(KERN_ERR "ata%u: failed to init parameters, disabled\n",
ap->id);
ata_port_disable(ap); ata_port_disable(ap);
else }
ata_qc_wait_err(qc, &wait);
DPRINTK("EXIT\n"); DPRINTK("EXIT\n");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册