[libata sata_nv] cleanups: convert #defines to enums; remove in-file history
[sfrench/cifs-2.6.git] / drivers / scsi / sata_nv.c
index 37a4fae95ed4ffe738dd5412ca240f6506d6eafa..834003eb36a78bcca9e4a649c0688ed34648d902 100644 (file)
  *  NV-specific details such as register offsets, SATA phy location,
  *  hotplug info, etc.
  *
- *  0.09
- *     - Fixed bug introduced by 0.08's MCP51 and MCP55 support.
- *
- *  0.08
- *     - Added support for MCP51 and MCP55.
- *
- *  0.07
- *     - Added support for RAID class code.
- *
- *  0.06
- *     - Added generic SATA support by using a pci_device_id that filters on
- *       the IDE storage class code.
- *
- *  0.03
- *     - Fixed a bug where the hotplug handlers for non-CK804/MCP04 were using
- *       mmio_base, which is only set for the CK804/MCP04 case.
- *
- *  0.02
- *     - Added support for CK804 SATA controller.
- *
- *  0.01
- *     - Initial revision.
  */
 
 #include <linux/config.h>
 #define DRV_NAME                       "sata_nv"
 #define DRV_VERSION                    "0.8"
 
-#define NV_PORTS                       2
-#define NV_PIO_MASK                    0x1f
-#define NV_MWDMA_MASK                  0x07
-#define NV_UDMA_MASK                   0x7f
-#define NV_PORT0_SCR_REG_OFFSET                0x00
-#define NV_PORT1_SCR_REG_OFFSET                0x40
-
-#define NV_INT_STATUS                  0x10
-#define NV_INT_STATUS_CK804            0x440
-#define NV_INT_STATUS_PDEV_INT         0x01
-#define NV_INT_STATUS_PDEV_PM          0x02
-#define NV_INT_STATUS_PDEV_ADDED       0x04
-#define NV_INT_STATUS_PDEV_REMOVED     0x08
-#define NV_INT_STATUS_SDEV_INT         0x10
-#define NV_INT_STATUS_SDEV_PM          0x20
-#define NV_INT_STATUS_SDEV_ADDED       0x40
-#define NV_INT_STATUS_SDEV_REMOVED     0x80
-#define NV_INT_STATUS_PDEV_HOTPLUG     (NV_INT_STATUS_PDEV_ADDED | \
-                                       NV_INT_STATUS_PDEV_REMOVED)
-#define NV_INT_STATUS_SDEV_HOTPLUG     (NV_INT_STATUS_SDEV_ADDED | \
-                                       NV_INT_STATUS_SDEV_REMOVED)
-#define NV_INT_STATUS_HOTPLUG          (NV_INT_STATUS_PDEV_HOTPLUG | \
-                                       NV_INT_STATUS_SDEV_HOTPLUG)
-
-#define NV_INT_ENABLE                  0x11
-#define NV_INT_ENABLE_CK804            0x441
-#define NV_INT_ENABLE_PDEV_MASK                0x01
-#define NV_INT_ENABLE_PDEV_PM          0x02
-#define NV_INT_ENABLE_PDEV_ADDED       0x04
-#define NV_INT_ENABLE_PDEV_REMOVED     0x08
-#define NV_INT_ENABLE_SDEV_MASK                0x10
-#define NV_INT_ENABLE_SDEV_PM          0x20
-#define NV_INT_ENABLE_SDEV_ADDED       0x40
-#define NV_INT_ENABLE_SDEV_REMOVED     0x80
-#define NV_INT_ENABLE_PDEV_HOTPLUG     (NV_INT_ENABLE_PDEV_ADDED | \
-                                       NV_INT_ENABLE_PDEV_REMOVED)
-#define NV_INT_ENABLE_SDEV_HOTPLUG     (NV_INT_ENABLE_SDEV_ADDED | \
-                                       NV_INT_ENABLE_SDEV_REMOVED)
-#define NV_INT_ENABLE_HOTPLUG          (NV_INT_ENABLE_PDEV_HOTPLUG | \
-                                       NV_INT_ENABLE_SDEV_HOTPLUG)
-
-#define NV_INT_CONFIG                  0x12
-#define NV_INT_CONFIG_METHD            0x01 // 0 = INT, 1 = SMI
-
-// For PCI config register 20
-#define NV_MCP_SATA_CFG_20             0x50
-#define NV_MCP_SATA_CFG_20_SATA_SPACE_EN       0x04
+enum {
+       NV_PORTS                        = 2,
+       NV_PIO_MASK                     = 0x1f,
+       NV_MWDMA_MASK                   = 0x07,
+       NV_UDMA_MASK                    = 0x7f,
+       NV_PORT0_SCR_REG_OFFSET         = 0x00,
+       NV_PORT1_SCR_REG_OFFSET         = 0x40,
+
+       NV_INT_STATUS                   = 0x10,
+       NV_INT_STATUS_CK804             = 0x440,
+       NV_INT_STATUS_PDEV_INT          = 0x01,
+       NV_INT_STATUS_PDEV_PM           = 0x02,
+       NV_INT_STATUS_PDEV_ADDED        = 0x04,
+       NV_INT_STATUS_PDEV_REMOVED      = 0x08,
+       NV_INT_STATUS_SDEV_INT          = 0x10,
+       NV_INT_STATUS_SDEV_PM           = 0x20,
+       NV_INT_STATUS_SDEV_ADDED        = 0x40,
+       NV_INT_STATUS_SDEV_REMOVED      = 0x80,
+       NV_INT_STATUS_PDEV_HOTPLUG      = (NV_INT_STATUS_PDEV_ADDED |
+                                          NV_INT_STATUS_PDEV_REMOVED),
+       NV_INT_STATUS_SDEV_HOTPLUG      = (NV_INT_STATUS_SDEV_ADDED |
+                                          NV_INT_STATUS_SDEV_REMOVED),
+       NV_INT_STATUS_HOTPLUG           = (NV_INT_STATUS_PDEV_HOTPLUG |
+                                          NV_INT_STATUS_SDEV_HOTPLUG),
+
+       NV_INT_ENABLE                   = 0x11,
+       NV_INT_ENABLE_CK804             = 0x441,
+       NV_INT_ENABLE_PDEV_MASK         = 0x01,
+       NV_INT_ENABLE_PDEV_PM           = 0x02,
+       NV_INT_ENABLE_PDEV_ADDED        = 0x04,
+       NV_INT_ENABLE_PDEV_REMOVED      = 0x08,
+       NV_INT_ENABLE_SDEV_MASK         = 0x10,
+       NV_INT_ENABLE_SDEV_PM           = 0x20,
+       NV_INT_ENABLE_SDEV_ADDED        = 0x40,
+       NV_INT_ENABLE_SDEV_REMOVED      = 0x80,
+       NV_INT_ENABLE_PDEV_HOTPLUG      = (NV_INT_ENABLE_PDEV_ADDED |
+                                          NV_INT_ENABLE_PDEV_REMOVED),
+       NV_INT_ENABLE_SDEV_HOTPLUG      = (NV_INT_ENABLE_SDEV_ADDED |
+                                          NV_INT_ENABLE_SDEV_REMOVED),
+       NV_INT_ENABLE_HOTPLUG           = (NV_INT_ENABLE_PDEV_HOTPLUG |
+                                          NV_INT_ENABLE_SDEV_HOTPLUG),
+
+       NV_INT_CONFIG                   = 0x12,
+       NV_INT_CONFIG_METHD             = 0x01, // 0 = INT, 1 = SMI
+
+       // For PCI config register 20
+       NV_MCP_SATA_CFG_20              = 0x50,
+       NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 0x04,
+};
 
 static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
 static irqreturn_t nv_interrupt (int irq, void *dev_instance,
@@ -124,10 +104,10 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 static void nv_host_stop (struct ata_host_set *host_set);
 static void nv_enable_hotplug(struct ata_probe_ent *probe_ent);
 static void nv_disable_hotplug(struct ata_host_set *host_set);
-static void nv_check_hotplug(struct ata_host_set *host_set);
+static int nv_check_hotplug(struct ata_host_set *host_set);
 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent);
 static void nv_disable_hotplug_ck804(struct ata_host_set *host_set);
-static void nv_check_hotplug_ck804(struct ata_host_set *host_set);
+static int nv_check_hotplug_ck804(struct ata_host_set *host_set);
 
 enum nv_host_type
 {
@@ -137,7 +117,7 @@ enum nv_host_type
        CK804
 };
 
-static struct pci_device_id nv_pci_tbl[] = {
+static const struct pci_device_id nv_pci_tbl[] = {
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
                PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
@@ -176,7 +156,7 @@ struct nv_host_desc
        enum nv_host_type       host_type;
        void                    (*enable_hotplug)(struct ata_probe_ent *probe_ent);
        void                    (*disable_hotplug)(struct ata_host_set *host_set);
-       void                    (*check_hotplug)(struct ata_host_set *host_set);
+       int                     (*check_hotplug)(struct ata_host_set *host_set);
 
 };
 static struct nv_host_desc nv_device_tbl[] = {
@@ -227,7 +207,6 @@ static struct scsi_host_template nv_sht = {
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
-       .max_sectors            = ATA_MAX_SECTORS,
        .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
        .emulated               = ATA_SHT_EMULATED,
        .use_clustering         = ATA_SHT_USE_CLUSTERING,
@@ -235,7 +214,6 @@ static struct scsi_host_template nv_sht = {
        .dma_boundary           = ATA_DMA_BOUNDARY,
        .slave_configure        = ata_scsi_slave_config,
        .bios_param             = ata_std_bios_param,
-       .ordered_flush          = 1,
 };
 
 static const struct ata_port_operations nv_ops = {
@@ -310,12 +288,16 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
                        qc = ata_qc_from_tag(ap, ap->active_tag);
                        if (qc && (!(qc->tf.ctl & ATA_NIEN)))
                                handled += ata_host_intr(ap, qc);
+                       else
+                               // No request pending?  Clear interrupt status
+                               // anyway, in case there's one pending.
+                               ap->ops->check_status(ap);
                }
 
        }
 
        if (host->host_desc->check_hotplug)
-               host->host_desc->check_hotplug(host_set);
+               handled += host->host_desc->check_hotplug(host_set);
 
        spin_unlock_irqrestore(&host_set->lock, flags);
 
@@ -498,7 +480,7 @@ static void nv_disable_hotplug(struct ata_host_set *host_set)
        outb(intr_mask, host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
 }
 
-static void nv_check_hotplug(struct ata_host_set *host_set)
+static int nv_check_hotplug(struct ata_host_set *host_set)
 {
        u8 intr_status;
 
@@ -523,7 +505,11 @@ static void nv_check_hotplug(struct ata_host_set *host_set)
                if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
                        printk(KERN_WARNING "nv_sata: "
                                "Secondary device removed\n");
+
+               return 1;
        }
+
+       return 0;
 }
 
 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
@@ -561,7 +547,7 @@ static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
        pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
 }
 
-static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
+static int nv_check_hotplug_ck804(struct ata_host_set *host_set)
 {
        u8 intr_status;
 
@@ -586,7 +572,11 @@ static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
                if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
                        printk(KERN_WARNING "nv_sata: "
                                "Secondary device removed\n");
+
+               return 1;
        }
+
+       return 0;
 }
 
 static int __init nv_init(void)