From: Andreas Mohr <andi@lisas.de>
To: andim2@users.sf.net
Cc: Roger Luethi <rl@hellgate.ch>,
netdev@vger.kernel.org, Francois Romieu <romieu@fr.zoreil.com>
Subject: [PATCH RFC 07/15] via-rhine: MMIO: move register verify into helper function.
Date: Mon, 31 Dec 2012 16:25:41 +0100 [thread overview]
Message-ID: <1356967549-5056-8-git-send-email-andi@lisas.de> (raw)
In-Reply-To: <1356967549-5056-1-git-send-email-andi@lisas.de>
From: Andreas Mohr <andim2@users.sf.net>
Add mmio_verify_registers() function.
Gets rid of a useless USE_MMIO define section, too.
Reverse logging of MMIO vs. PIO values since the description suggests
different order.
Signed-off-by: Andreas Mohr <andim2@users.sf.net>
---
drivers/net/ethernet/via/via-rhine.c | 49 +++++++++++++++++++--------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 053375b..a16e227 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -338,14 +338,6 @@ enum bcr1_bits {
BCR1_MED1=0x80, /* for VT6102 */
};
-#ifdef USE_MMIO
-/* Registers we check that mmio and reg are the same. */
-static const int mmio_verify_registers[] = {
- RxConfig, TxConfig, IntrEnable, ConfigA, ConfigB, ConfigC, ConfigD,
- 0
-};
-#endif
-
/* Bits in the interrupt status/mask registers. */
enum intr_status_bits {
IntrRxDone = 0x0001,
@@ -659,6 +651,31 @@ static void enable_mmio(long pioaddr, u32 quirks)
outb(n, pioaddr + ConfigD);
}
}
+/* Check that selected MMIO registers match the PIO ones */
+static inline bool
+mmio_verify_registers(struct pci_dev *pdev, long pioaddr, void __iomem *ioaddr)
+{
+ /* Registers we check to verify that mmio and reg are the same. */
+ static const int registers_to_verify[] = {
+ RxConfig, TxConfig, IntrEnable,
+ ConfigA, ConfigB, ConfigC, ConfigD,
+ 0
+ };
+
+ int i = 0;
+ while (registers_to_verify[i]) {
+ int reg = registers_to_verify[i++];
+ unsigned char pio = inb(pioaddr+reg);
+ unsigned char mmio = readb(ioaddr+reg);
+ if (pio != mmio) {
+ dev_err(&pdev->dev,
+ "MMIO do not match PIO [%02x] (%02x != %02x)\n",
+ reg, mmio, pio);
+ return false;
+ }
+ }
+ return true;
+}
#endif
/*
@@ -969,19 +986,9 @@ static int rhine_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
#ifdef USE_MMIO
enable_mmio(rp->pioaddr, rp->quirks);
- /* Check that selected MMIO registers match the PIO ones */
- i = 0;
- while (mmio_verify_registers[i]) {
- int reg = mmio_verify_registers[i++];
- unsigned char a = inb(pioaddr+reg);
- unsigned char b = readb(ioaddr+reg);
- if (a != b) {
- rc = -EIO;
- dev_err(&pdev->dev,
- "MMIO do not match PIO [%02x] (%02x != %02x)\n",
- reg, a, b);
- goto err_out_unmap;
- }
+ if (!mmio_verify_registers(pdev, pioaddr, ioaddr)) {
+ rc = -EIO;
+ goto err_out_unmap;
}
#endif /* USE_MMIO */
--
1.7.2.5
next prev parent reply other threads:[~2012-12-31 15:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-31 15:25 [PATCH RFC 00/15] via-rhine: fix resume, cleanup, eth ops (regs) Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 01/15] via-rhine: YARB: fix broken resume of ifdown case (NetworkManager) Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 02/15] via-rhine: some suspend/resume cleanup Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 03/15] via-rhine: small rhine_wait_bit() improvement Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 04/15] via-rhine: handle compile warnings (use PCI_VDEVICE macro) Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 05/15] via-rhine: Spelling/phrases cleanup Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 06/15] via-rhine: The Great Renaming Andreas Mohr
2012-12-31 15:25 ` Andreas Mohr [this message]
2012-12-31 15:25 ` [PATCH RFC 08/15] via-rhine: MMIO: move support decision (compile-time-only to runtime) Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 09/15] via-rhine: mark some variables as __read_mostly Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 10/15] via-rhine: WOL: remove duplication into a helper Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 11/15] via-rhine: WOL: separate WOL configuration (and its logging) Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 12/15] via-rhine: implement get_regs() ethtool ops Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 13/15] via-rhine: misc. cleanup Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 14/15] via-rhine: The Great Deduplication Andreas Mohr
2012-12-31 15:25 ` [PATCH RFC 15/15] via-rhine: add helper (reduce type-unsafe void * assignments) Andreas Mohr
2012-12-31 22:21 ` David Miller
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=1356967549-5056-8-git-send-email-andi@lisas.de \
--to=andi@lisas.de \
--cc=andim2@users.sf.net \
--cc=netdev@vger.kernel.org \
--cc=rl@hellgate.ch \
--cc=romieu@fr.zoreil.com \
/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;
as well as URLs for NNTP newsgroup(s).