Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[linux-2.6-microblaze.git] / drivers / ata / pata_hpt3x2n.c
index 1f6afd8..617c955 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "pata_hpt3x2n"
-#define DRV_VERSION    "0.3.18"
+#define DRV_VERSION    "0.3.19"
 
 enum {
        PCI66           =       (1 << 1),
@@ -113,7 +113,7 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed)
  *     The Marvell bridge chips used on the HighPoint SATA cards do not seem
  *     to support the UltraDMA modes 1, 2, and 3 as well as any MWDMA modes...
  */
-static unsigned long hpt372n_filter(struct ata_device *adev, unsigned long mask)
+static unsigned int hpt372n_filter(struct ata_device *adev, unsigned int mask)
 {
        if (ata_id_is_sata(adev->id))
                mask &= ~((0xE << ATA_SHIFT_UDMA) | ATA_MASK_MWDMA);
@@ -403,17 +403,20 @@ static int hpt3xn_calibrate_dpll(struct pci_dev *dev)
        return 0;
 }
 
-static int hpt3x2n_pci_clock(struct pci_dev *pdev)
+static int hpt3x2n_pci_clock(struct pci_dev *pdev, unsigned int base)
 {
-       unsigned long freq;
+       unsigned int freq;
        u32 fcnt;
-       unsigned long iobase = pci_resource_start(pdev, 4);
 
-       fcnt = inl(iobase + 0x90);      /* Not PCI readable for some chips */
+       /*
+        * Some devices do not let this value be accessed via PCI space
+        * according to the old driver.
+        */
+       fcnt = inl(pci_resource_start(pdev, 4) + 0x90);
        if ((fcnt >> 12) != 0xABCDE) {
+               u32 total = 0;
                int i;
                u16 sr;
-               u32 total = 0;
 
                dev_warn(&pdev->dev, "BIOS clock data not set\n");
 
@@ -427,7 +430,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
        }
        fcnt &= 0x1FF;
 
-       freq = (fcnt * 77) / 192;
+       freq = (fcnt * base) / 192;     /* in MHz */
 
        /* Clamp to bands */
        if (freq < 40)
@@ -559,7 +562,7 @@ hpt372n:
         * 50 for UDMA100. Right now we always use 66
         */
 
-       pci_mhz = hpt3x2n_pci_clock(dev);
+       pci_mhz = hpt3x2n_pci_clock(dev, 77);
 
        f_low = (pci_mhz * 48) / 66;    /* PCI Mhz for 66Mhz DPLL */
        f_high = f_low + 2;             /* Tolerance */