libata: clean up SFF init mess
[linux-2.6-block.git] / drivers / ata / pata_marvell.c
index 13a70ac6f1dc2f536b132229ac7706aa87e7d6e5..edbfe0dbbf7824188be84e2d41d3bfe8ed230eb6 100644 (file)
 #include <linux/ata.h>
 
 #define DRV_NAME       "pata_marvell"
-#define DRV_VERSION    "0.1.1"
+#define DRV_VERSION    "0.1.4"
 
 /**
  *     marvell_pre_reset       -       check for 40/80 pin
  *     @ap: Port
+ *     @deadline: deadline jiffies for the operation
  *
  *     Perform the PATA port setup we need.
  */
 
-static int marvell_pre_reset(struct ata_port *ap)
+static int marvell_pre_reset(struct ata_port *ap, unsigned long deadline)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        u32 devices;
@@ -53,21 +54,24 @@ static int marvell_pre_reset(struct ata_port *ap)
            (!(devices & 0x10)))        /* PATA enable ? */
                return -ENOENT;
 
+       return ata_std_prereset(ap, deadline);
+}
+
+static int marvell_cable_detect(struct ata_port *ap)
+{
        /* Cable type */
        switch(ap->port_no)
        {
        case 0:
                if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
-                       ap->cbl = ATA_CBL_PATA40;
-               else
-                       ap->cbl = ATA_CBL_PATA80;
-               break;
-
+                       return ATA_CBL_PATA40;
+               return ATA_CBL_PATA80;
        case 1: /* Legacy SATA port */
-               ap->cbl = ATA_CBL_SATA;
-               break;
+               return ATA_CBL_SATA;
        }
-       return ata_std_prereset(ap);
+
+       BUG();
+       return 0;       /* Our BUG macro needs the right markup */
 }
 
 /**
@@ -103,8 +107,6 @@ static struct scsi_host_template marvell_sht = {
        .slave_destroy          = ata_scsi_slave_destroy,
        /* Use standard CHS mapping rules */
        .bios_param             = ata_std_bios_param,
-       .resume                 = ata_scsi_device_resume,
-       .suspend                = ata_scsi_device_suspend,
 };
 
 static const struct ata_port_operations marvell_ops = {
@@ -121,6 +123,7 @@ static const struct ata_port_operations marvell_ops = {
        .thaw                   = ata_bmdma_thaw,
        .error_handler          = marvell_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+       .cable_detect           = marvell_cable_detect,
 
        /* BMDMA handling is PCI ATA format, use helpers */
        .bmdma_setup            = ata_bmdma_setup,
@@ -158,7 +161,7 @@ static const struct ata_port_operations marvell_ops = {
 
 static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
 {
-       static struct ata_port_info info = {
+       static const struct ata_port_info info = {
                .sht            = &marvell_sht,
                .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
 
@@ -168,7 +171,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
 
                .port_ops       = &marvell_ops,
        };
-       static struct ata_port_info info_sata = {
+       static const struct ata_port_info info_sata = {
                .sht            = &marvell_sht,
                /* Slave possible as its magically mapped not real */
                .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -179,13 +182,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
 
                .port_ops       = &marvell_ops,
        };
-       struct ata_port_info *port_info[2] = { &info, &info_sata };
-       int n_port = 2;
+       const struct ata_port_info *ppi[] = { &info, &info_sata };
 
        if (pdev->device == 0x6101)
-               n_port = 1;
+               ppi[1] = &ata_dummy_port_info;
 
-       return ata_pci_init_one(pdev, port_info, n_port);
+       return ata_pci_init_one(pdev, ppi);
 }
 
 static const struct pci_device_id marvell_pci_tbl[] = {
@@ -199,8 +201,10 @@ static struct pci_driver marvell_pci_driver = {
        .id_table               = marvell_pci_tbl,
        .probe                  = marvell_init_one,
        .remove                 = ata_pci_remove_one,
+#ifdef CONFIG_PM
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
+#endif
 };
 
 static int __init marvell_init(void)