[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260130170416.49994-35-abbotti@mev.co.uk>
Date: Fri, 30 Jan 2026 16:47:59 +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 34/46] comedi: pcl726: Add sanity checks for I/O base address
The "pcl726" driver uses an admin-supplied configuration option
(`it->options[0]`) to configure the I/O port base address of various
analog output ISA boards from Advantech (PCL-726/727/728) and ADLINK
(ACL-6126/6128). (Most of them also have digital I/O.) It currently
allows any base address to be configured but the hardware only supports
base addresses (configured by on-board DIP switches) from 0 or 0x200 up
to nearly 0x3FF, depending on the model.
Store the minimum and maximum supported I/O address ranges in the static
board information array elements (the required alignment is already
stored in the `io_len` member), 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/pcl726.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/comedi/drivers/pcl726.c b/drivers/comedi/drivers/pcl726.c
index b542896fa0e4..d3b1f4388643 100644
--- a/drivers/comedi/drivers/pcl726.c
+++ b/drivers/comedi/drivers/pcl726.c
@@ -91,7 +91,8 @@ static const struct comedi_lrange *const rangelist_728[] = {
struct pcl726_board {
const char *name;
- unsigned long io_len;
+ unsigned int io_len;
+ unsigned int min_io_start;
unsigned int irq_mask;
const struct comedi_lrange *const *ao_ranges;
int ao_num_ranges;
@@ -104,6 +105,7 @@ static const struct pcl726_board pcl726_boards[] = {
{
.name = "pcl726",
.io_len = 0x10,
+ .min_io_start = 0x200,
.ao_ranges = &rangelist_726[0],
.ao_num_ranges = ARRAY_SIZE(rangelist_726),
.ao_nchan = 6,
@@ -111,6 +113,7 @@ static const struct pcl726_board pcl726_boards[] = {
}, {
.name = "pcl727",
.io_len = 0x20,
+ .min_io_start = 0x200,
.ao_ranges = &rangelist_727[0],
.ao_num_ranges = ARRAY_SIZE(rangelist_727),
.ao_nchan = 12,
@@ -119,12 +122,14 @@ static const struct pcl726_board pcl726_boards[] = {
}, {
.name = "pcl728",
.io_len = 0x08,
+ .min_io_start = 0,
.ao_num_ranges = ARRAY_SIZE(rangelist_728),
.ao_ranges = &rangelist_728[0],
.ao_nchan = 2,
}, {
.name = "acl6126",
.io_len = 0x10,
+ .min_io_start = 0x200,
.irq_mask = 0x96e8,
.ao_num_ranges = ARRAY_SIZE(rangelist_726),
.ao_ranges = &rangelist_726[0],
@@ -133,6 +138,7 @@ static const struct pcl726_board pcl726_boards[] = {
}, {
.name = "acl6128",
.io_len = 0x08,
+ .min_io_start = 0,
.ao_num_ranges = ARRAY_SIZE(rangelist_728),
.ao_ranges = &rangelist_728[0],
.ao_nchan = 2,
@@ -316,7 +322,9 @@ static int pcl726_attach(struct comedi_device *dev,
int ret;
int i;
- ret = comedi_request_region(dev, it->options[0], board->io_len);
+ ret = comedi_check_request_region(dev, it->options[0], board->io_len,
+ board->min_io_start, 0x3ff,
+ board->io_len);
if (ret)
return ret;
--
2.51.0
Powered by blists - more mailing lists