Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

comedi: comedi_8254: Conditionally remove I/O port support

The comedi_8254 module supports both port I/O and memory-mapped I/O.
In a future patch, the port I/O functions (`inb()`, `outb()`, and
friends) will only be declared if the `HAS_IOPORT` configuration option
is enabled.

Conditionally compile the parts of the module that use port I/O so they
are compiled if and only if the `CONFIG_HAS_IOPORT` macro is defined, so
that it can still be built if the port I/O functions have not been
declared. If `CONFIG_HAS_IOPORT` is undefined, replace the GPL-exported
`comedi_8254_io_alloc()` function with a dummy static inline version
that just returns `ERR_PTR(-ENXIO)`.

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-5-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
90d25675 fade5e5b

+21
+8
drivers/comedi/drivers/comedi_8254.c
··· 122 122 #include <linux/comedi/comedidev.h> 123 123 #include <linux/comedi/comedi_8254.h> 124 124 125 + #ifdef CONFIG_HAS_IOPORT 126 + 125 127 static unsigned int i8254_io8_cb(struct comedi_8254 *i8254, int dir, 126 128 unsigned int reg, unsigned int val) 127 129 { ··· 165 163 return inl(iobase + reg_offset); 166 164 } 167 165 } 166 + 167 + #endif /* CONFIG_HAS_IOPORT */ 168 168 169 169 static unsigned int i8254_mmio8_cb(struct comedi_8254 *i8254, int dir, 170 170 unsigned int reg, unsigned int val) ··· 652 648 return i8254; 653 649 } 654 650 651 + #ifdef CONFIG_HAS_IOPORT 652 + 655 653 /** 656 654 * comedi_8254_io_alloc - allocate and initialize the 8254 device for pio access 657 655 * @iobase: port I/O base address ··· 687 681 return __i8254_init(iocb, iobase, osc_base, iosize, regshift); 688 682 } 689 683 EXPORT_SYMBOL_GPL(comedi_8254_io_alloc); 684 + 685 + #endif /* CONFIG_HAS_IOPORT */ 690 686 691 687 /** 692 688 * comedi_8254_mm_alloc - allocate and initialize the 8254 device for mmio access
+13
include/linux/comedi/comedi_8254.h
··· 12 12 #define _COMEDI_8254_H 13 13 14 14 #include <linux/types.h> 15 + #include <linux/errno.h> 16 + #include <linux/err.h> 15 17 16 18 struct comedi_device; 17 19 struct comedi_insn; ··· 138 136 void comedi_8254_subdevice_init(struct comedi_subdevice *s, 139 137 struct comedi_8254 *i8254); 140 138 139 + #ifdef CONFIG_HAS_IOPORT 141 140 struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase, 142 141 unsigned int osc_base, 143 142 unsigned int iosize, 144 143 unsigned int regshift); 144 + #else 145 + static inline struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase, 146 + unsigned int osc_base, 147 + unsigned int iosize, 148 + unsigned int regshift) 149 + { 150 + return ERR_PTR(-ENXIO); 151 + } 152 + #endif 153 + 145 154 struct comedi_8254 *comedi_8254_mm_alloc(void __iomem *mmio, 146 155 unsigned int osc_base, 147 156 unsigned int iosize,