libata: clear dev->ering in smarter way
[safe/jmp/linux-2.6] / drivers / ata / pata_qdi.c
index ccb8682..3080f37 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *    pata_qdi.c - QDI VLB ATA controllers
- *     (C) 2006 Red Hat <alan@redhat.com>
+ *     (C) 2006 Red Hat
  *
  * This driver mostly exists as a proof of concept for non PCI devices under
  * libata. While the QDI6580 was 'neat' in 1993 it is no longer terribly
@@ -60,11 +60,11 @@ static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)
        ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
 
        if (qdi->fast) {
-               active = 8 - FIT(t.active, 1, 8);
-               recovery = 18 - FIT(t.recover, 3, 18);
+               active = 8 - clamp_val(t.active, 1, 8);
+               recovery = 18 - clamp_val(t.recover, 3, 18);
        } else {
-               active = 9 - FIT(t.active, 2, 9);
-               recovery = 15 - FIT(t.recover, 0, 15);
+               active = 9 - clamp_val(t.active, 2, 9);
+               recovery = 15 - clamp_val(t.recover, 0, 15);
        }
        timing = (recovery << 4) | active | 0x08;
 
@@ -84,11 +84,11 @@ static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)
        ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
 
        if (qdi->fast) {
-               active = 8 - FIT(t.active, 1, 8);
-               recovery = 18 - FIT(t.recover, 3, 18);
+               active = 8 - clamp_val(t.active, 1, 8);
+               recovery = 18 - clamp_val(t.recover, 3, 18);
        } else {
-               active = 9 - FIT(t.active, 2, 9);
-               recovery = 15 - FIT(t.recover, 0, 15);
+               active = 9 - clamp_val(t.active, 2, 9);
+               recovery = 15 - clamp_val(t.recover, 0, 15);
        }
        timing = (recovery << 4) | active | 0x08;
 
@@ -102,14 +102,14 @@ static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)
 }
 
 /**
- *     qdi_qc_issue_prot       -       command issue
+ *     qdi_qc_issue            -       command issue
  *     @qc: command pending
  *
  *     Called when the libata layer is about to issue a command. We wrap
  *     this interface so that we can load the correct ATA timings.
  */
 
-static unsigned int qdi_qc_issue_prot(struct ata_queued_cmd *qc)
+static unsigned int qdi_qc_issue(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct ata_device *adev = qc->dev;
@@ -121,7 +121,7 @@ static unsigned int qdi_qc_issue_prot(struct ata_queued_cmd *qc)
                        outb(qdi->clock[adev->devno], qdi->timing);
                }
        }
-       return ata_qc_issue_prot(qc);
+       return ata_sff_qc_issue(qc);
 }
 
 static unsigned int qdi_data_xfer(struct ata_device *dev, unsigned char *buf,
@@ -137,7 +137,7 @@ static unsigned int qdi_data_xfer(struct ata_device *dev, unsigned char *buf,
                        iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
                if (unlikely(slop)) {
-                       u32 pad;
+                       __le32 pad;
                        if (rw == READ) {
                                pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
                                memcpy(buf + buflen - slop, &pad, slop);
@@ -148,7 +148,7 @@ static unsigned int qdi_data_xfer(struct ata_device *dev, unsigned char *buf,
                        buflen += 4 - slop;
                }
        } else
-               buflen = ata_data_xfer(dev, buf, buflen, rw);
+               buflen = ata_sff_data_xfer(dev, buf, buflen, rw);
 
        return buflen;
 }
@@ -158,55 +158,16 @@ static struct scsi_host_template qdi_sht = {
 };
 
 static struct ata_port_operations qdi6500_port_ops = {
-       .set_piomode    = qdi6500_set_piomode,
-
-       .tf_load        = ata_tf_load,
-       .tf_read        = ata_tf_read,
-       .check_status   = ata_check_status,
-       .exec_command   = ata_exec_command,
-       .dev_select     = ata_std_dev_select,
-
-       .freeze         = ata_bmdma_freeze,
-       .thaw           = ata_bmdma_thaw,
-       .error_handler  = ata_bmdma_error_handler,
-       .post_internal_cmd = ata_bmdma_post_internal_cmd,
+       .inherits       = &ata_sff_port_ops,
+       .qc_issue       = qdi_qc_issue,
+       .sff_data_xfer  = qdi_data_xfer,
        .cable_detect   = ata_cable_40wire,
-
-       .qc_prep        = ata_qc_prep,
-       .qc_issue       = qdi_qc_issue_prot,
-
-       .data_xfer      = qdi_data_xfer,
-
-       .irq_clear      = ata_noop_irq_clear,
-       .irq_on         = ata_irq_on,
-
-       .port_start     = ata_sff_port_start,
+       .set_piomode    = qdi6500_set_piomode,
 };
 
 static struct ata_port_operations qdi6580_port_ops = {
+       .inherits       = &qdi6500_port_ops,
        .set_piomode    = qdi6580_set_piomode,
-
-       .tf_load        = ata_tf_load,
-       .tf_read        = ata_tf_read,
-       .check_status   = ata_check_status,
-       .exec_command   = ata_exec_command,
-       .dev_select     = ata_std_dev_select,
-
-       .freeze         = ata_bmdma_freeze,
-       .thaw           = ata_bmdma_thaw,
-       .error_handler  = ata_bmdma_error_handler,
-       .post_internal_cmd = ata_bmdma_post_internal_cmd,
-       .cable_detect   = ata_cable_40wire,
-
-       .qc_prep        = ata_qc_prep,
-       .qc_issue       = qdi_qc_issue_prot,
-
-       .data_xfer      = qdi_data_xfer,
-
-       .irq_clear      = ata_noop_irq_clear,
-       .irq_on         = ata_irq_on,
-
-       .port_start     = ata_sff_port_start,
 };
 
 /**
@@ -262,7 +223,7 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
        ap->ioaddr.cmd_addr = io_addr;
        ap->ioaddr.altstatus_addr = ctl_addr;
        ap->ioaddr.ctl_addr = ctl_addr;
-       ata_std_ports(&ap->ioaddr);
+       ata_sff_std_ports(&ap->ioaddr);
 
        ata_port_desc(ap, "cmd %lx ctl %lx", io, ctl);
 
@@ -278,7 +239,7 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
        printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io);
 
        /* activate */
-       ret = ata_host_activate(host, irq, ata_interrupt, 0, &qdi_sht);
+       ret = ata_host_activate(host, irq, ata_sff_interrupt, 0, &qdi_sht);
        if (ret)
                goto fail;