lkml.org 
[lkml]   [2017]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 08/10] MIPS: Introduce check_legacy_ioport() interface
Date
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
\
 
 \ /
  Last update: 2017-06-28 18:02    [W:1.229 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site