ata: pata_hpt37x: fix PCI clock detection
authorSergey Shtylyov <s.shtylyov@omp.ru>
Sat, 19 Feb 2022 20:04:29 +0000 (23:04 +0300)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tue, 22 Feb 2022 00:39:57 +0000 (09:39 +0900)
The f_CNT register (at the PCI config. address 0x78) is 16-bit, not
8-bit! The bug was there from the very start... :-(

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Fixes: 669a5db411d8 ("[libata] Add a bunch of PATA drivers.")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
drivers/ata/pata_hpt37x.c

index 7abc7e04f65616ae17a3e08ea947389d7397f613..1baaca7b72edd23fbb9fe75212cb50e7256b23bc 100644 (file)
@@ -950,14 +950,14 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 
        if ((freq >> 12) != 0xABCDE) {
                int i;
-               u8 sr;
+               u16 sr;
                u32 total = 0;
 
                dev_warn(&dev->dev, "BIOS has not set timing clocks\n");
 
                /* This is the process the HPT371 BIOS is reported to use */
                for (i = 0; i < 128; i++) {
-                       pci_read_config_byte(dev, 0x78, &sr);
+                       pci_read_config_word(dev, 0x78, &sr);
                        total += sr & 0x1FF;
                        udelay(15);
                }