[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260130170416.49994-37-abbotti@mev.co.uk>
Date: Fri, 30 Jan 2026 16:48:01 +0000
From: Ian Abbott <abbotti@....co.uk>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ian Abbott <abbotti@....co.uk>,
H Hartley Sweeten <hsweeten@...ionengravers.com>
Subject: [PATCH 36/46] comedi: pcl812: Add sanity checks for I/O base address
The "pcl812" driver uses an admin-supplied configuration option
(`it->options[0]`) to configure the I/O port base address of various
analog/digital I/O ISA boards from Advantech, ADLINK, and ICP DAS. It
currently allows any base address to be configured but the hardware
devices only support base addresses (configured by on-board DIP
switches) from 0 or 0x200 (depending on the model) to 0x3F0 on 16-byte
boundaries.
Store the minimum supported I/O base addresses in the static board
information array elements and add a sanity check to ensure the device
is not configured at an unsupported base address.
Signed-off-by: Ian Abbott <abbotti@....co.uk>
---
drivers/comedi/drivers/pcl812.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/comedi/drivers/pcl812.c b/drivers/comedi/drivers/pcl812.c
index abca61a72cf7..98b75792c09b 100644
--- a/drivers/comedi/drivers/pcl812.c
+++ b/drivers/comedi/drivers/pcl812.c
@@ -331,6 +331,7 @@ enum pcl812_boardtype {
struct pcl812_board {
const char *name;
enum pcl812_boardtype board_type;
+ unsigned short min_io_start;
int n_aichan;
int n_aochan;
unsigned int ai_ns_min;
@@ -346,6 +347,7 @@ static const struct pcl812_board boardtypes[] = {
{
.name = "pcl812",
.board_type = BOARD_PCL812,
+ .min_io_start = 0,
.n_aichan = 16,
.n_aochan = 2,
.ai_ns_min = 33000,
@@ -355,6 +357,7 @@ static const struct pcl812_board boardtypes[] = {
.has_dio = 1,
}, {
.name = "pcl812pg",
+ .min_io_start = 0,
.board_type = BOARD_PCL812PG,
.n_aichan = 16,
.n_aochan = 2,
@@ -366,6 +369,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "acl8112pg",
.board_type = BOARD_PCL812PG,
+ .min_io_start = 0x200,
.n_aichan = 16,
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -376,6 +380,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "acl8112dg",
.board_type = BOARD_ACL8112,
+ .min_io_start = 0x200,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -387,6 +392,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "acl8112hg",
.board_type = BOARD_ACL8112,
+ .min_io_start = 0x200,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -398,6 +404,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a821pgl",
.board_type = BOARD_A821,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 1,
.ai_ns_min = 10000,
@@ -407,6 +414,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a821pglnda",
.board_type = BOARD_A821,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.ai_ns_min = 10000,
.rangelist_ai = &range_pcl813b_ai,
@@ -414,6 +422,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a821pgh",
.board_type = BOARD_A821,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 1,
.ai_ns_min = 10000,
@@ -423,6 +432,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a822pgl",
.board_type = BOARD_ACL8112,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -433,6 +443,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a822pgh",
.board_type = BOARD_ACL8112,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -443,6 +454,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a823pgl",
.board_type = BOARD_ACL8112,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 8000,
@@ -453,6 +465,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a823pgh",
.board_type = BOARD_ACL8112,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 8000,
@@ -463,26 +476,31 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "pcl813",
.board_type = BOARD_PCL813,
+ .min_io_start = 0,
.n_aichan = 32,
.rangelist_ai = &range_pcl813b_ai,
}, {
.name = "pcl813b",
.board_type = BOARD_PCL813B,
+ .min_io_start = 0,
.n_aichan = 32,
.rangelist_ai = &range_pcl813b_ai,
}, {
.name = "acl8113",
.board_type = BOARD_ACL8113,
+ .min_io_start = 0x200,
.n_aichan = 32,
.rangelist_ai = &range_acl8113_1_ai,
}, {
.name = "iso813",
.board_type = BOARD_ISO813,
+ .min_io_start = 0,
.n_aichan = 32,
.rangelist_ai = &range_iso813_1_ai,
}, {
.name = "acl8216",
.board_type = BOARD_ACL8216,
+ .min_io_start = 0x200,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -495,6 +513,7 @@ static const struct pcl812_board boardtypes[] = {
}, {
.name = "a826pg",
.board_type = BOARD_ACL8216,
+ .min_io_start = 0,
.n_aichan = 16, /* 8 differential */
.n_aochan = 2,
.ai_ns_min = 10000,
@@ -1138,7 +1157,8 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (!devpriv)
return -ENOMEM;
- ret = comedi_request_region(dev, it->options[0], 0x10);
+ ret = comedi_check_request_region(dev, it->options[0], 0x10,
+ board->min_io_start, 0x3ff, 16);
if (ret)
return ret;
--
2.51.0
Powered by blists - more mailing lists