mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
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@mev.co.uk> Link: https://patch.msgid.link/20260130170416.49994-37-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b5218a9897
commit
c245434637
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user