]> err.no Git - linux-2.6/blobdiff - drivers/ata/sata_sil.c
libata-link: linkify reset
[linux-2.6] / drivers / ata / sata_sil.c
index c3f0a86cb73584896c1b59e0c92ddf65fcf3957a..4c9295a49a49fc669d6982d76b9d9bc7a0eff6e4 100644 (file)
@@ -46,7 +46,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "sata_sil"
-#define DRV_VERSION    "2.2"
+#define DRV_VERSION    "2.3"
 
 enum {
        SIL_MMIO_BAR            = 5,
@@ -115,8 +115,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
 static int sil_pci_device_resume(struct pci_dev *pdev);
 #endif
 static void sil_dev_config(struct ata_device *dev);
-static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg);
-static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
+static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
+static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
 static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed);
 static void sil_freeze(struct ata_port *ap);
 static void sil_thaw(struct ata_port *ap);
@@ -218,7 +218,7 @@ static const struct ata_port_info sil_port_info[] = {
                .flags          = SIL_DFL_PORT_FLAGS | SIL_FLAG_MOD15WRITE,
                .pio_mask       = 0x1f,                 /* pio0-4 */
                .mwdma_mask     = 0x07,                 /* mwdma0-2 */
-               .udma_mask      = 0x3f,                 /* udma0-5 */
+               .udma_mask      = ATA_UDMA5,
                .port_ops       = &sil_ops,
        },
        /* sil_3112_no_sata_irq */
@@ -227,7 +227,7 @@ static const struct ata_port_info sil_port_info[] = {
                                  SIL_FLAG_NO_SATA_IRQ,
                .pio_mask       = 0x1f,                 /* pio0-4 */
                .mwdma_mask     = 0x07,                 /* mwdma0-2 */
-               .udma_mask      = 0x3f,                 /* udma0-5 */
+               .udma_mask      = ATA_UDMA5,
                .port_ops       = &sil_ops,
        },
        /* sil_3512 */
@@ -235,7 +235,7 @@ static const struct ata_port_info sil_port_info[] = {
                .flags          = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
                .pio_mask       = 0x1f,                 /* pio0-4 */
                .mwdma_mask     = 0x07,                 /* mwdma0-2 */
-               .udma_mask      = 0x3f,                 /* udma0-5 */
+               .udma_mask      = ATA_UDMA5,
                .port_ops       = &sil_ops,
        },
        /* sil_3114 */
@@ -243,7 +243,7 @@ static const struct ata_port_info sil_port_info[] = {
                .flags          = SIL_DFL_PORT_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
                .pio_mask       = 0x1f,                 /* pio0-4 */
                .mwdma_mask     = 0x07,                 /* mwdma0-2 */
-               .udma_mask      = 0x3f,                 /* udma0-5 */
+               .udma_mask      = ATA_UDMA5,
                .port_ops       = &sil_ops,
        },
 };
@@ -303,22 +303,20 @@ static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed)
        struct ata_device *dev;
        void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
        void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode;
-       u32 tmp, dev_mode[2];
-       unsigned int i;
+       u32 tmp, dev_mode[2] = { };
        int rc;
 
        rc = ata_do_set_mode(ap, r_failed);
        if (rc)
                return rc;
 
-       for (i = 0; i < 2; i++) {
-               dev = &ap->device[i];
+       ata_link_for_each_dev(dev, &ap->link) {
                if (!ata_dev_enabled(dev))
-                       dev_mode[i] = 0;        /* PIO0/1/2 */
+                       dev_mode[dev->devno] = 0;       /* PIO0/1/2 */
                else if (dev->flags & ATA_DFLAG_PIO)
-                       dev_mode[i] = 1;        /* PIO3/4 */
+                       dev_mode[dev->devno] = 1;       /* PIO3/4 */
                else
-                       dev_mode[i] = 3;        /* UDMA */
+                       dev_mode[dev->devno] = 3;       /* UDMA */
                /* value 2 indicates MDMA */
        }
 
@@ -350,25 +348,32 @@ static inline void __iomem *sil_scr_addr(struct ata_port *ap, unsigned int sc_re
        return NULL;
 }
 
-static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
+static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
 {
        void __iomem *mmio = sil_scr_addr(ap, sc_reg);
-       if (mmio)
-               return readl(mmio);
-       return 0xffffffffU;
+
+       if (mmio) {
+               *val = readl(mmio);
+               return 0;
+       }
+       return -EINVAL;
 }
 
-static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
+static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
 {
        void __iomem *mmio = sil_scr_addr(ap, sc_reg);
-       if (mmio)
+
+       if (mmio) {
                writel(val, mmio);
+               return 0;
+       }
+       return -EINVAL;
 }
 
 static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
 {
-       struct ata_eh_info *ehi = &ap->eh_info;
-       struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
+       struct ata_eh_info *ehi = &ap->link.eh_info;
+       struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag);
        u8 status;
 
        if (unlikely(bmdma2 & SIL_DMA_SATA_IRQ)) {
@@ -378,7 +383,7 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
                 * controllers continue to assert IRQ as long as
                 * SError bits are pending.  Clear SError immediately.
                 */
-               serror = sil_scr_read(ap, SCR_ERROR);
+               sil_scr_read(ap, SCR_ERROR, &serror);
                sil_scr_write(ap, SCR_ERROR, serror);
 
                /* Trigger hotplug and accumulate SError only if the
@@ -387,8 +392,8 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
                 * repeat probing needlessly.
                 */
                if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
-                       ata_ehi_hotplugged(&ap->eh_info);
-                       ap->eh_info.serror |= serror;
+                       ata_ehi_hotplugged(&ap->link.eh_info);
+                       ap->link.eh_info.serror |= serror;
                }
 
                goto freeze;
@@ -555,8 +560,8 @@ static void sil_thaw(struct ata_port *ap)
  */
 static void sil_dev_config(struct ata_device *dev)
 {
-       struct ata_port *ap = dev->ap;
-       int print_info = ap->eh_context.i.flags & ATA_EHI_PRINTINFO;
+       struct ata_port *ap = dev->link->ap;
+       int print_info = ap->link.eh_context.i.flags & ATA_EHI_PRINTINFO;
        unsigned int n, quirks = 0;
        unsigned char model_num[ATA_ID_PROD_LEN + 1];