Pull events into release branch
[cascardo/linux.git] / drivers / ata / sata_inic162x.c
index f099a1d..a9c948d 100644 (file)
@@ -28,7 +28,7 @@
 #include <scsi/scsi_device.h>
 
 #define DRV_NAME       "sata_inic162x"
-#define DRV_VERSION    "0.1"
+#define DRV_VERSION    "0.2"
 
 enum {
        MMIO_BAR                = 5,
@@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = {
        .slave_configure        = inic_slave_config,
        .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
-#ifdef CONFIG_PM
-       .suspend                = ata_scsi_device_suspend,
-       .resume                 = ata_scsi_device_resume,
-#endif
 };
 
 static const int scr_map[] = {
@@ -194,34 +190,34 @@ static void inic_reset_port(void __iomem *port_base)
        writew(ctl, idma_ctl);
 }
 
-static u32 inic_scr_read(struct ata_port *ap, unsigned sc_reg)
+static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val)
 {
-       void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
+       void __iomem *scr_addr = ap->ioaddr.scr_addr;
        void __iomem *addr;
-       u32 val;
 
        if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
-               return 0xffffffffU;
+               return -EINVAL;
 
        addr = scr_addr + scr_map[sc_reg] * 4;
-       val = readl(scr_addr + scr_map[sc_reg] * 4);
+       *val = readl(scr_addr + scr_map[sc_reg] * 4);
 
        /* this controller has stuck DIAG.N, ignore it */
        if (sc_reg == SCR_ERROR)
-               val &= ~SERR_PHYRDY_CHG;
-       return val;
+               *val &= ~SERR_PHYRDY_CHG;
+       return 0;
 }
 
-static void inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
+static int inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
 {
-       void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
+       void __iomem *scr_addr = ap->ioaddr.scr_addr;
        void __iomem *addr;
 
        if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
-               return;
+               return -EINVAL;
 
        addr = scr_addr + scr_map[sc_reg] * 4;
        writel(val, scr_addr + scr_map[sc_reg] * 4);
+       return 0;
 }
 
 /*
@@ -420,7 +416,8 @@ static void inic_thaw(struct ata_port *ap)
  * SRST and SControl hardreset don't give valid signature on this
  * controller.  Only controller specific hardreset mechanism works.
  */
-static int inic_hardreset(struct ata_port *ap, unsigned int *class)
+static int inic_hardreset(struct ata_port *ap, unsigned int *class,
+                         unsigned long deadline)
 {
        void __iomem *port_base = inic_port_base(ap);
        void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
@@ -437,7 +434,7 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class)
        msleep(1);
        writew(val & ~IDMA_CTL_RST_ATA, idma_ctl);
 
-       rc = sata_phy_resume(ap, timing);
+       rc = sata_phy_resume(ap, timing, deadline);
        if (rc) {
                ata_port_printk(ap, KERN_WARNING, "failed to resume "
                                "link after reset (errno=%d)\n", rc);
@@ -451,10 +448,12 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class)
                /* wait a while before checking status */
                msleep(150);
 
-               if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
-                       ata_port_printk(ap, KERN_WARNING,
-                                       "device busy after hardreset\n");
-                       return -EIO;
+               rc = ata_wait_ready(ap, deadline);
+               /* link occupied, -ENODEV too is an error */
+               if (rc) {
+                       ata_port_printk(ap, KERN_WARNING, "device not ready "
+                                       "after hardreset (errno=%d)\n", rc);
+                       return rc;
                }
 
                ata_tf_read(ap, &tf);
@@ -497,6 +496,13 @@ static void inic_dev_config(struct ata_device *dev)
        /* inic can only handle upto LBA28 max sectors */
        if (dev->max_sectors > ATA_MAX_SECTORS)
                dev->max_sectors = ATA_MAX_SECTORS;
+
+       if (dev->n_sectors >= 1 << 28) {
+               ata_dev_printk(dev, KERN_ERR,
+       "ERROR: This driver doesn't support LBA48 yet and may cause\n"
+       "                data corruption on such devices.  Disabling.\n");
+               ata_dev_disable(dev);
+       }
 }
 
 static void init_port(struct ata_port *ap)
@@ -588,7 +594,7 @@ static struct ata_port_info inic_port_info = {
        .flags                  = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
        .pio_mask               = 0x1f, /* pio0-4 */
        .mwdma_mask             = 0x07, /* mwdma0-2 */
-       .udma_mask              = 0x7f, /* udma0-6 */
+       .udma_mask              = ATA_UDMA6,
        .port_ops               = &inic_port_ops
 };