Commit 75b4d58c authored by Sergey Shtylyov's avatar Sergey Shtylyov Committed by Damien Le Moal

ata: pata_hpt37x: merge hpt374_read_freq() to hpt37x_pci_clock()

With hpt374_read_freq() implemented as a separate function, there's
some code duplication going on, not to mention that this function is
named incorrectly: it returns the f_CNT register value saved by BIOS,
not the PCI clock frequency.
Folding hpt374_read_freq() into hpt37x_pci_clock() saves 20 bytes of
object code with x86_64 gcc 10.3.1...
Signed-off-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
parent 96c34ac4
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/libata.h> #include <linux/libata.h>
#define DRV_NAME "pata_hpt37x" #define DRV_NAME "pata_hpt37x"
#define DRV_VERSION "0.6.29" #define DRV_VERSION "0.6.30"
struct hpt_clock { struct hpt_clock {
u8 xfer_speed; u8 xfer_speed;
...@@ -644,26 +644,6 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) ...@@ -644,26 +644,6 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
return 0; return 0;
} }
static u32 hpt374_read_freq(struct pci_dev *pdev)
{
u32 freq;
unsigned long io_base = pci_resource_start(pdev, 4);
if (PCI_FUNC(pdev->devfn) & 1) {
struct pci_dev *pdev_0;
pdev_0 = pci_get_slot(pdev->bus, pdev->devfn - 1);
/* Someone hot plugged the controller on us ? */
if (pdev_0 == NULL)
return 0;
io_base = pci_resource_start(pdev_0, 4);
freq = inl(io_base + 0x90);
pci_dev_put(pdev_0);
} else
freq = inl(io_base + 0x90);
return freq;
}
static int hpt37x_pci_clock(struct pci_dev *pdev, unsigned int base) static int hpt37x_pci_clock(struct pci_dev *pdev, unsigned int base)
{ {
unsigned int freq; unsigned int freq;
...@@ -674,10 +654,16 @@ static int hpt37x_pci_clock(struct pci_dev *pdev, unsigned int base) ...@@ -674,10 +654,16 @@ static int hpt37x_pci_clock(struct pci_dev *pdev, unsigned int base)
* according to the old driver. In addition we must use the value * according to the old driver. In addition we must use the value
* from FN 0 on the HPT374. * from FN 0 on the HPT374.
*/ */
if (pdev->device == PCI_DEVICE_ID_TTI_HPT374) { if (pdev->device == PCI_DEVICE_ID_TTI_HPT374 &&
fcnt = hpt374_read_freq(pdev); (PCI_FUNC(pdev->devfn) & 1)) {
if (!fcnt) struct pci_dev *pdev_fn0;
pdev_fn0 = pci_get_slot(pdev->bus, pdev->devfn - 1);
/* Someone hot plugged the controller on us? */
if (!pdev_fn0)
return 0; return 0;
fcnt = inl(pci_resource_start(pdev_fn0, 4) + 0x90);
pci_dev_put(pdev_fn0);
} else { } else {
fcnt = inl(pci_resource_start(pdev, 4) + 0x90); fcnt = inl(pci_resource_start(pdev, 4) + 0x90);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment