Skip to content

Commit 0ccb86a

Browse files
ian-abbottgregkh
authored andcommitted
comedi: 8255_pci: Conditionally remove devices that use port I/O
In a future patch, the port I/O functions (`inb()`, `outb()`, and friends will only be declared in the `HAS_IOPORT` configuration option is enabled. The 8255_pci module supports PCI digital I/O devices from various manufacturers that consist of one or more 8255 Programmable Peripheral Interface chips (or equivalent hardware) to provide their digital I/O ports. Some of the devices use port I/O and some only use memory-mapped I/O. Conditionally compile in support for the devices that need port I/O if and only if the `CONFIG_HAS_IOPORT` macro is defined. Change `pci_8255_auto_attach()` to return an error if the device actually requires port I/O (based on the PCI BAR resource flags) but the `HAS_IOPORT` configuration is not enabled. Cc: Arnd Bergmann <arnd@kernel.org> Cc: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Link: https://lore.kernel.org/r/20230913170712.111719-6-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 90d2567 commit 0ccb86a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/comedi/drivers/8255_pci.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include <linux/comedi/comedi_8255.h>
5858

5959
enum pci_8255_boardid {
60+
#ifdef CONFIG_HAS_IOPORT
6061
BOARD_ADLINK_PCI7224,
6162
BOARD_ADLINK_PCI7248,
6263
BOARD_ADLINK_PCI7296,
@@ -65,6 +66,7 @@ enum pci_8255_boardid {
6566
BOARD_CB_PCIDIO48H_OLD,
6667
BOARD_CB_PCIDIO48H_NEW,
6768
BOARD_CB_PCIDIO96H,
69+
#endif /* CONFIG_HAS_IOPORT */
6870
BOARD_NI_PCIDIO96,
6971
BOARD_NI_PCIDIO96B,
7072
BOARD_NI_PXI6508,
@@ -82,6 +84,7 @@ struct pci_8255_boardinfo {
8284
};
8385

8486
static const struct pci_8255_boardinfo pci_8255_boards[] = {
87+
#ifdef CONFIG_HAS_IOPORT
8588
[BOARD_ADLINK_PCI7224] = {
8689
.name = "adl_pci-7224",
8790
.dio_badr = 2,
@@ -122,6 +125,7 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = {
122125
.dio_badr = 2,
123126
.n_8255 = 4,
124127
},
128+
#endif /* CONFIG_HAS_IOPORT */
125129
[BOARD_NI_PCIDIO96] = {
126130
.name = "ni_pci-dio-96",
127131
.dio_badr = 1,
@@ -219,8 +223,11 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
219223
dev->mmio = pci_ioremap_bar(pcidev, board->dio_badr);
220224
if (!dev->mmio)
221225
return -ENOMEM;
222-
} else {
226+
} else if (IS_ENABLED(CONFIG_HAS_IOPORT)) {
223227
dev->iobase = pci_resource_start(pcidev, board->dio_badr);
228+
} else {
229+
dev_err(dev->class_dev, "error! need I/O port support\n");
230+
return -ENXIO;
224231
}
225232

226233
/*
@@ -259,6 +266,7 @@ static int pci_8255_pci_probe(struct pci_dev *dev,
259266
}
260267

261268
static const struct pci_device_id pci_8255_pci_table[] = {
269+
#ifdef CONFIG_HAS_IOPORT
262270
{ PCI_VDEVICE(ADLINK, 0x7224), BOARD_ADLINK_PCI7224 },
263271
{ PCI_VDEVICE(ADLINK, 0x7248), BOARD_ADLINK_PCI7248 },
264272
{ PCI_VDEVICE(ADLINK, 0x7296), BOARD_ADLINK_PCI7296 },
@@ -269,6 +277,7 @@ static const struct pci_device_id pci_8255_pci_table[] = {
269277
{ PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, PCI_VENDOR_ID_CB, 0x000b),
270278
.driver_data = BOARD_CB_PCIDIO48H_NEW },
271279
{ PCI_VDEVICE(CB, 0x0017), BOARD_CB_PCIDIO96H },
280+
#endif /* CONFIG_HAS_IOPORT */
272281
{ PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 },
273282
{ PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B },
274283
{ PCI_VDEVICE(NI, 0x13c0), BOARD_NI_PXI6508 },

0 commit comments

Comments
 (0)