From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
<linux-ide@vger.kernel.org>
Subject: [PATCH 3/4] ata: pata_hpt37x: merge hpt374_read_freq() to hpt37x_pci_clock()
Date: Sun, 15 May 2022 23:41:25 +0300 [thread overview]
Message-ID: <20220515204126.4866-4-s.shtylyov@omp.ru> (raw)
In-Reply-To: <20220515204126.4866-1-s.shtylyov@omp.ru>
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: Sergey Shtylyov <s.shtylyov@omp.ru>
---
drivers/ata/pata_hpt37x.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 38fc7f3d593c..d1a3d99d5d0a 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -23,7 +23,7 @@
#include <linux/libata.h>
#define DRV_NAME "pata_hpt37x"
-#define DRV_VERSION "0.6.29"
+#define DRV_VERSION "0.6.30"
struct hpt_clock {
u8 xfer_speed;
@@ -644,26 +644,6 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
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)
{
unsigned int freq;
@@ -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
* from FN 0 on the HPT374.
*/
- if (pdev->device == PCI_DEVICE_ID_TTI_HPT374) {
- fcnt = hpt374_read_freq(pdev);
- if (!fcnt)
+ if (pdev->device == PCI_DEVICE_ID_TTI_HPT374 &&
+ (PCI_FUNC(pdev->devfn) & 1)) {
+ 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;
+ fcnt = inl(pci_resource_start(pdev_fn0, 4) + 0x90);
+ pci_dev_put(pdev_fn0);
} else {
fcnt = inl(pci_resource_start(pdev, 4) + 0x90);
}
--
2.26.3
next prev parent reply other threads:[~2022-05-15 20:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-15 20:41 [PATCH 0/4] Unify PCI clock detection in the HPT37x/HPT3x2N drivers Sergey Shtylyov
2022-05-15 20:41 ` [PATCH 1/4] ata: pata_hpt37x: move claculating PCI clock from hpt37x_clock_slot() Sergey Shtylyov
2022-05-15 20:41 ` [PATCH 2/4] ata: pata_hpt37x: factor out hpt37x_pci_clock() Sergey Shtylyov
2022-05-15 20:41 ` Sergey Shtylyov [this message]
2022-05-15 20:41 ` [PATCH 4/4] ata: pata_hpt3x2n: pass base DPLL frequency to hpt3x2n_pci_clock() Sergey Shtylyov
2022-06-08 6:47 ` [PATCH 0/4] Unify PCI clock detection in the HPT37x/HPT3x2N drivers Damien Le Moal
2022-06-08 17:15 ` Sergey Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220515204126.4866-4-s.shtylyov@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=damien.lemoal@opensource.wdc.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox