All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: linux-mips@linux-mips.org
Subject: [PATCH v2 08/10] MIPS: Introduce check_legacy_ioport() interface
Date: Wed, 28 Jun 2017 17:36:25 +0200	[thread overview]
Message-ID: <1498664187-27995-9-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
In-Reply-To: <1498664187-27995-1-git-send-email-aleksandar.markovic@rt-rk.com>

From: Miodrag Dinic <miodrag.dinic@imgtec.com>

Some drivers may try to probe some I/O ports which can lead to kernel
panic if the device is not present and mapped. This function should be
used to check for existence of such devices and return 0 for MIPS
boards which implement them, otherwise it should return -ENODEV and
the affected device driver should never try to read/write the
requested I/O port.

This is particularly useful for multiplaform kernels which are board
agnostic and this interface can be used to match drivers against
available devices on a specific board in runtime.

This patch just adds a no-op check_legacy_ioport() function which will
be enriched with logic in a later patch.

Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
---
 arch/mips/include/asm/io.h |  5 +++++
 arch/mips/kernel/setup.c   | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index ecabc00..62b9f89 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -78,6 +78,11 @@ static inline void set_io_port_base(unsigned long base)
 }
 
 /*
+ * Check for existence of legacy devices
+ */
+extern int check_legacy_ioport(unsigned long base_port);
+
+/*
  * Thanks to James van Artsdalen for a better timing-fix than
  * the two short jumps: using outb's to a nonexistent port seems
  * to guarantee better timings even on fast machines.
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 01d1dbd..c22cde8 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -78,6 +78,31 @@ static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
 const unsigned long mips_io_port_base = -1;
 EXPORT_SYMBOL(mips_io_port_base);
 
+/*
+ * Check for existence of legacy devices
+ *
+ * Some drivers may try to probe some I/O ports which can lead to
+ * kernel panic if the device is not present and mapped. This method
+ * should check for existence of such devices and return 0 for MIPS
+ * boards which actually have them, otherwise it will return -ENODEV
+ * and the affected device driver should never try to read/write the
+ * requested I/O port.
+ */
+int check_legacy_ioport(unsigned long base_port)
+{
+	int ret = 0;
+
+	switch (base_port) {
+	default:
+		/* We will assume that the I/O device port exists if
+		 * not explicitly added to the blacklist match table
+		 */
+		break;
+	}
+	return ret;
+}
+EXPORT_SYMBOL(check_legacy_ioport);
+
 static struct resource code_resource = { .name = "Kernel code", };
 static struct resource data_resource = { .name = "Kernel data", };
 
-- 
2.7.4

  parent reply	other threads:[~2017-06-28 15:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28 15:36 [PATCH v2 00/10] MIPS: Add virtual Ranchu board as a generic-based board Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 01/10] Documentation: Add device tree binding for Goldfish RTC driver Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 02/10] MIPS: ranchu: Add " Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 03/10] Documentation: Add device tree binding for Goldfish PIC driver Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 04/10] MIPS: ranchu: Add " Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 05/10] MIPS: ranchu: Add Ranchu as a new generic-based board Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 06/10] Documentation: Add device tree binding for Goldfish FB driver Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 07/10] video: goldfishfb: Add support for device tree bindings Aleksandar Markovic
2017-06-28 15:36 ` Aleksandar Markovic [this message]
2017-06-28 15:36 ` [PATCH v2 09/10] MIPS: i8042: Probe this device only if it exists Aleksandar Markovic
2017-06-28 15:36 ` [PATCH v2 10/10] MIPS: generic: Add optional support for Android kernel Aleksandar Markovic
2017-06-28 15:46 [PATCH v2 00/10] MIPS: Add virtual Ranchu board as a generic-based board Aleksandar Markovic
2017-06-28 15:47 ` [PATCH v2 08/10] MIPS: Introduce check_legacy_ioport() interface Aleksandar Markovic

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=1498664187-27995-9-git-send-email-aleksandar.markovic@rt-rk.com \
    --to=aleksandar.markovic@rt-rk.com \
    --cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.