#include <linux/comedi/comedidev.h>
 #include <linux/comedi/comedi_8254.h>
 
+#ifdef CONFIG_HAS_IOPORT
+
 static unsigned int i8254_io8_cb(struct comedi_8254 *i8254, int dir,
                                unsigned int reg, unsigned int val)
 {
        }
 }
 
+#endif /* CONFIG_HAS_IOPORT */
+
 static unsigned int i8254_mmio8_cb(struct comedi_8254 *i8254, int dir,
                                   unsigned int reg, unsigned int val)
 {
        return i8254;
 }
 
+#ifdef CONFIG_HAS_IOPORT
+
 /**
  * comedi_8254_io_alloc - allocate and initialize the 8254 device for pio access
  * @iobase:    port I/O base address
 }
 EXPORT_SYMBOL_GPL(comedi_8254_io_alloc);
 
+#endif /* CONFIG_HAS_IOPORT */
+
 /**
  * comedi_8254_mm_alloc - allocate and initialize the 8254 device for mmio access
  * @mmio:      memory mapped I/O base address
 
 #define _COMEDI_8254_H
 
 #include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/err.h>
 
 struct comedi_device;
 struct comedi_insn;
 void comedi_8254_subdevice_init(struct comedi_subdevice *s,
                                struct comedi_8254 *i8254);
 
+#ifdef CONFIG_HAS_IOPORT
 struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase,
                                         unsigned int osc_base,
                                         unsigned int iosize,
                                         unsigned int regshift);
+#else
+static inline struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase,
+                                                      unsigned int osc_base,
+                                                      unsigned int iosize,
+                                                      unsigned int regshift)
+{
+       return ERR_PTR(-ENXIO);
+}
+#endif
+
 struct comedi_8254 *comedi_8254_mm_alloc(void __iomem *mmio,
                                         unsigned int osc_base,
                                         unsigned int iosize,