linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>
Cc: <bhelgaas@google.com>, <guohanjun@huawei.com>,
	<yangyingliang@huawei.com>
Subject: [PATCH 1/2] iomap: move some definitions to include/linux/io.h
Date: Fri, 28 Aug 2020 14:34:02 +0800	[thread overview]
Message-ID: <20200828063403.3995421-2-yangyingliang@huawei.com> (raw)
In-Reply-To: <20200828063403.3995421-1-yangyingliang@huawei.com>

Move some IO macros and bad_io_access() to include/linux/io.h
This prepares for moving pci_iounmap() to lib/pci_iomap.c.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 include/linux/io.h | 36 ++++++++++++++++++++++++++++++++++++
 lib/iomap.c        | 36 ------------------------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/include/linux/io.h b/include/linux/io.h
index 8394c56babc26..fa040f8114eaa 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -13,6 +13,42 @@
 #include <asm/io.h>
 #include <asm/page.h>
 
+#ifndef HAVE_ARCH_PIO_SIZE
+/*
+ * We encode the physical PIO addresses (0-0xffff) into the
+ * pointer by offsetting them with a constant (0x10000) and
+ * assuming that all the low addresses are always PIO. That means
+ * we can do some sanity checks on the low bits, and don't
+ * need to just take things for granted.
+ */
+#define PIO_OFFSET	0x10000UL
+#define PIO_MASK	0x0ffffUL
+#define PIO_RESERVED	0x40000UL
+#endif
+
+static inline void bad_io_access(unsigned long port, const char *access)
+{
+	static int count = 10;
+	if (count) {
+		count--;
+		WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
+	}
+}
+
+/*
+ * Ugly macros are a way of life.
+ */
+#define IO_COND(addr, is_pio, is_mmio) do {			\
+	unsigned long port = (unsigned long __force)addr;	\
+	if (port >= PIO_RESERVED) {				\
+		is_mmio;					\
+	} else if (port > PIO_OFFSET) {				\
+		port &= PIO_MASK;				\
+		is_pio;						\
+	} else							\
+		bad_io_access(port, #is_pio);			\
+} while (0)
+
 struct device;
 struct resource;
 
diff --git a/lib/iomap.c b/lib/iomap.c
index fbaa3e8f19d6c..d40bc6f662540 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -23,42 +23,6 @@
  * implementation and should do their own copy.
  */
 
-#ifndef HAVE_ARCH_PIO_SIZE
-/*
- * We encode the physical PIO addresses (0-0xffff) into the
- * pointer by offsetting them with a constant (0x10000) and
- * assuming that all the low addresses are always PIO. That means
- * we can do some sanity checks on the low bits, and don't
- * need to just take things for granted.
- */
-#define PIO_OFFSET	0x10000UL
-#define PIO_MASK	0x0ffffUL
-#define PIO_RESERVED	0x40000UL
-#endif
-
-static void bad_io_access(unsigned long port, const char *access)
-{
-	static int count = 10;
-	if (count) {
-		count--;
-		WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
-	}
-}
-
-/*
- * Ugly macros are a way of life.
- */
-#define IO_COND(addr, is_pio, is_mmio) do {			\
-	unsigned long port = (unsigned long __force)addr;	\
-	if (port >= PIO_RESERVED) {				\
-		is_mmio;					\
-	} else if (port > PIO_OFFSET) {				\
-		port &= PIO_MASK;				\
-		is_pio;						\
-	} else							\
-		bad_io_access(port, #is_pio );			\
-} while (0)
-
 #ifndef pio_read16be
 #define pio_read16be(port) swab16(inw(port))
 #define pio_read32be(port) swab32(inl(port))
-- 
2.25.1


  reply	other threads:[~2020-08-28  6:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28  6:34 [PATCH 0/2] fix memleak when using pci_iounmap() Yang Yingliang
2020-08-28  6:34 ` Yang Yingliang [this message]
2020-08-28  6:34 ` [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap() Yang Yingliang
2020-08-28 10:19   ` kernel test robot
2020-08-28 11:24   ` kernel test robot
2020-08-28 13:35   ` kernel test robot
2020-08-28 16:06 ` [PATCH 0/2] fix memleak when using pci_iounmap() Bjorn Helgaas

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=20200828063403.3995421-2-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=guohanjun@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@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;
as well as URLs for NNTP newsgroup(s).