[libata reset-seq] build and merge fixes
[sfrench/cifs-2.6.git] / drivers / ata / pata_sis.c
index f482078659309edb35c53b5a9ef6048f9a895130..f5838cc11728602e8445ba126499b821d12cbab4 100644 (file)
@@ -35,7 +35,7 @@
 #include "sis.h"
 
 #define DRV_NAME       "pata_sis"
-#define DRV_VERSION    "0.5.0"
+#define DRV_VERSION    "0.5.1"
 
 struct sis_chipset {
        u16 device;                     /* PCI host ID */
@@ -86,106 +86,58 @@ static int sis_port_base(struct ata_device *adev)
 }
 
 /**
- *     sis_133_pre_reset       -       check for 40/80 pin
+ *     sis_133_cable_detect    -       check for 40/80 pin
  *     @ap: Port
+ *     @deadline: deadline jiffies for the operation
  *
  *     Perform cable detection for the later UDMA133 capable
  *     SiS chipset.
  */
 
-static int sis_133_pre_reset(struct ata_port *ap)
+static int sis_133_cable_detect(struct ata_port *ap)
 {
-       static const struct pci_bits sis_enable_bits[] = {
-               { 0x4aU, 1U, 0x02UL, 0x02UL },  /* port 0 */
-               { 0x4aU, 1U, 0x04UL, 0x04UL },  /* port 1 */
-       };
-
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        u16 tmp;
 
-       if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
-               return -ENOENT;
-
        /* The top bit of this register is the cable detect bit */
        pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp);
        if ((tmp & 0x8000) && !sis_short_ata40(pdev))
-               ap->cbl = ATA_CBL_PATA40;
-       else
-               ap->cbl = ATA_CBL_PATA80;
-
-       return ata_std_prereset(ap);
+               return ATA_CBL_PATA40;
+       return ATA_CBL_PATA80;
 }
 
 /**
- *     sis_error_handler - Probe specified port on PATA host controller
- *     @ap: Port to probe
- *
- *     LOCKING:
- *     None (inherited from caller).
- */
-
-static void sis_133_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, sis_133_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
-}
-
-
-/**
- *     sis_66_pre_reset        -       check for 40/80 pin
+ *     sis_66_cable_detect     -       check for 40/80 pin
  *     @ap: Port
+ *     @deadline: deadline jiffies for the operation
  *
  *     Perform cable detection on the UDMA66, UDMA100 and early UDMA133
  *     SiS IDE controllers.
  */
 
-static int sis_66_pre_reset(struct ata_port *ap)
+static int sis_66_cable_detect(struct ata_port *ap)
 {
-       static const struct pci_bits sis_enable_bits[] = {
-               { 0x4aU, 1U, 0x02UL, 0x02UL },  /* port 0 */
-               { 0x4aU, 1U, 0x04UL, 0x04UL },  /* port 1 */
-       };
-
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        u8 tmp;
 
-       if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
-               ata_port_disable(ap);
-               ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
-               return 0;
-       }
        /* Older chips keep cable detect in bits 4/5 of reg 0x48 */
        pci_read_config_byte(pdev, 0x48, &tmp);
        tmp >>= ap->port_no;
        if ((tmp & 0x10) && !sis_short_ata40(pdev))
-               ap->cbl = ATA_CBL_PATA40;
-       else
-               ap->cbl = ATA_CBL_PATA80;
-
-       return ata_std_prereset(ap);
+               return ATA_CBL_PATA40;
+       return ATA_CBL_PATA80;
 }
 
-/**
- *     sis_66_error_handler - Probe specified port on PATA host controller
- *     @ap: Port to probe
- *     @classes:
- *
- *     LOCKING:
- *     None (inherited from caller).
- */
-
-static void sis_66_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, sis_66_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
-}
 
 /**
- *     sis_old_pre_reset               -       probe begin
+ *     sis_pre_reset           -       probe begin
  *     @ap: ATA port
+ *     @deadline: deadline jiffies for the operation
  *
  *     Set up cable type and use generic probe init
  */
 
-static int sis_old_pre_reset(struct ata_port *ap)
+static int sis_pre_reset(struct ata_port *ap, unsigned long deadline)
 {
        static const struct pci_bits sis_enable_bits[] = {
                { 0x4aU, 1U, 0x02UL, 0x02UL },  /* port 0 */
@@ -194,27 +146,24 @@ static int sis_old_pre_reset(struct ata_port *ap)
 
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
 
-       if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
-               ata_port_disable(ap);
-               ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
-               return 0;
-       }
-       ap->cbl = ATA_CBL_PATA40;
-       return ata_std_prereset(ap);
+       if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
+               return -ENOENT;
+
+       return ata_std_prereset(ap, deadline);
 }
 
 
 /**
- *     sis_old_error_handler - Probe specified port on PATA host controller
+ *     sis_error_handler - Probe specified port on PATA host controller
  *     @ap: Port to probe
  *
  *     LOCKING:
  *     None (inherited from caller).
  */
 
-static void sis_old_error_handler(struct ata_port *ap)
+static void sis_error_handler(struct ata_port *ap)
 {
-       ata_bmdma_drive_eh(ap, sis_old_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
+       ata_bmdma_drive_eh(ap, sis_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
 }
 
 /**
@@ -494,7 +443,7 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a
        int drive_pci = sis_port_base(adev);
        u16 timing;
 
-       const u16 udma_bits[]  = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
+       static const u16 udma_bits[]  = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
 
        pci_read_config_word(pdev, drive_pci, &timing);
 
@@ -531,8 +480,8 @@ static void sis_133_set_dmamode (struct ata_port *ap, struct ata_device *adev)
        u32 reg54;
 
        /* bits 4- cycle time 8 - cvs time */
-       const u32 timing_u100[] = { 0x6B0, 0x470, 0x350, 0x140, 0x120, 0x110, 0x000 };
-       const u32 timing_u133[] = { 0x9F0, 0x6A0, 0x470, 0x250, 0x230, 0x220, 0x210 };
+       static const u32 timing_u100[] = { 0x6B0, 0x470, 0x350, 0x140, 0x120, 0x110, 0x000 };
+       static const u32 timing_u133[] = { 0x9F0, 0x6A0, 0x470, 0x250, 0x230, 0x220, 0x210 };
 
        /* If bit 14 is set then the registers are mapped at 0x70 not 0x40 */
        pci_read_config_dword(pdev, 0x54, &reg54);
@@ -595,8 +544,9 @@ static const struct ata_port_operations sis_133_ops = {
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_133_error_handler,
+       .error_handler          = sis_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+       .cable_detect           = sis_133_cable_detect,
 
        .bmdma_setup            = ata_bmdma_setup,
        .bmdma_start            = ata_bmdma_start,
@@ -628,8 +578,9 @@ static const struct ata_port_operations sis_133_early_ops = {
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_66_error_handler,
+       .error_handler          = sis_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+       .cable_detect           = sis_66_cable_detect,
 
        .bmdma_setup            = ata_bmdma_setup,
        .bmdma_start            = ata_bmdma_start,
@@ -661,9 +612,9 @@ static const struct ata_port_operations sis_100_ops = {
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_66_error_handler,
+       .error_handler          = sis_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
-
+       .cable_detect           = sis_66_cable_detect,
 
        .bmdma_setup            = ata_bmdma_setup,
        .bmdma_start            = ata_bmdma_start,
@@ -692,10 +643,11 @@ static const struct ata_port_operations sis_66_ops = {
        .check_status           = ata_check_status,
        .exec_command           = ata_exec_command,
        .dev_select             = ata_std_dev_select,
+       .cable_detect           = sis_66_cable_detect,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_66_error_handler,
+       .error_handler          = sis_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
 
        .bmdma_setup            = ata_bmdma_setup,
@@ -728,8 +680,9 @@ static const struct ata_port_operations sis_old_ops = {
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_old_error_handler,
+       .error_handler          = sis_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+       .cable_detect           = ata_cable_40wire,
 
        .bmdma_setup            = ata_bmdma_setup,
        .bmdma_start            = ata_bmdma_start,
@@ -878,6 +831,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ata_port_info *port;
        struct pci_dev *host = NULL;
        struct sis_chipset *chipset = NULL;
+       struct sis_chipset *sets;
 
        static struct sis_chipset sis_chipsets[] = {
 
@@ -932,10 +886,11 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
        /* We have to find the bridge first */
 
-       for (chipset = &sis_chipsets[0]; chipset->device; chipset++) {
-               host = pci_get_device(PCI_VENDOR_ID_SI, chipset->device, NULL);
+       for (sets = &sis_chipsets[0]; sets->device; sets++) {
+               host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL);
                if (host != NULL) {
-                       if (chipset->device == 0x630) { /* SIS630 */
+                       chipset = sets;                 /* Match found */
+                       if (sets->device == 0x630) {    /* SIS630 */
                                u8 host_rev;
                                pci_read_config_byte(host, PCI_REVISION_ID, &host_rev);
                                if (host_rev >= 0x30)   /* 630 ET */
@@ -946,7 +901,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        /* Look for concealed bridges */
-       if (host == NULL) {
+       if (chipset == NULL) {
                /* Second check */
                u32 idemisc;
                u16 trueid;