From patchwork Wed Sep 13 17:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp70133vqb; Wed, 13 Sep 2023 13:30:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPUu+Fv+JSciMIQMyKLMkfAPh/+hTTPgZiigCYWR9ljH6yk0D1XjKwEzAQrJS34dsIhBSp X-Received: by 2002:a05:6a00:168a:b0:68a:5877:bfb1 with SMTP id k10-20020a056a00168a00b0068a5877bfb1mr4804999pfc.20.1694637059328; Wed, 13 Sep 2023 13:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694637059; cv=none; d=google.com; s=arc-20160816; b=DxTkKWqYEgE0DaSugM+4zjop8kM1+/Nz1IFiVyutlmFHpfHljEd/rGum89o1sJu8zQ MbC1wf+NPd31THnRlUUZ6BoDm+OJ/7wzXhyU28VgU7hmt7vmrn5yWjr7AFC8B8P0OOgQ 4zuTorKbBE6fNCaMPuWZ6ARhWnF0sc1XRNYDs8qrevsVHGa2WbNte7wNDops1tMQLVy+ Lg6x0YGJbmc8ahg6YdX6bnYOFP/8yWkUdHwuFA2cWtqkHg0UQxBT9r+94vLyy5/e0OQl aNEQvt1kVkxzl6TJ9J1OmeyRMnJqbE51oKFm8ikskFDJugJruRCLfwwIgg4f7L8XiZyI z6HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9Ji4W6wSo3g0Jyn/7d+QwvyH3QSopfIskFYGuzRfKTI=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=P4UjHZqEORyTrhK+QT5Scs7zwb8EVaBwDSR4ZIZ4YFJJr4faekmW/Eww12Zh5C+CPY Jl8b1P5hkLv4b9vqC1KB+uDppSx4UI5cgxX+N4QnxmLUQZstZIhrpSsM91yErF0tPdTt bE3BPgct3Ajh19BJ+1o1yX2Sh+2rNLSBaYmVRON0V3Nc/MEDqrXO6oljqbWYCRX+vg5d Zlm67fyk0Oqt51eSVRHrwhWt6F+amD+Sd+m2teyGx/94MreVE1dtg/lZ9BFjN5Ro88hE qcIxBSXw6dLfclrBV1V1uidtvZ4fs+Gb4uISvyXnyMH6uclqsZQmkXjm5GioAHXp9OQM PVvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=y3EHCsEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id o21-20020a056a0015d500b0068e4d216325si10924225pfu.204.2023.09.13.13.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=y3EHCsEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 896D180746B0; Wed, 13 Sep 2023 10:07:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbjIMRHd (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbjIMRH3 (ORCPT ); Wed, 13 Sep 2023 13:07:29 -0400 Received: from smtp119.iad3a.emailsrvr.com (smtp119.iad3a.emailsrvr.com [173.203.187.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6811DC for ; Wed, 13 Sep 2023 10:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624844; bh=D/wC20Fkt6ePYdsegxM/YzWBm7HHmhjYqdqZZT2iwwg=; h=From:To:Subject:Date:From; b=y3EHCsEGm4/mhkmPNcaSS6fZDhQU5hKSVIsIclCk3bghyyhC2u48/azeKIviyqrmC x9jRgUpDWLIv/P4rsT/zyLCx7vWQFH5R+Df9D/0YLJziDMouwdeJMc5DDTBs6pwlVr b9av9d+MUpCI1qsE0t99KfgHnmNBAMSaoQawCcHM= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 36FE25520; Wed, 13 Sep 2023 13:07:23 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 02/13] comedi: comedi_8254: Use a call-back function for register access Date: Wed, 13 Sep 2023 18:07:01 +0100 Message-Id: <20230913170712.111719-3-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-3-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:07:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776955749385091682 X-GMAIL-MSGID: 1776955749385091682 Rework the comedi_8254 module to use a call-back function for register access. This will make it easier to isolate the parts that will depend on the `CONFIG_HAS_IOPORT` macro being defined and also allows the possibility of supplying an external callback function during initialization by a variant of the `comedi_8254_init()` and `comedi_8254_mm_init()` functions, although that has not been implemented yet. The `struct comedi_8254` members have been changed to use a pointer to a callback function and a context of type `unsigned long`. The `comedi_8254_init()` and `comedi_8254_mm_init()` functions use an internal callback function and set the context to the base address of the registers (for `comedi_8254_mm_init()` that involves converting a `void __iomem *` to `unsigned long`). A minor change to `dio200_subdev_8254_offset()` in the amplc_dio200_common module has been made due to the changes in `struct comedi_8254`. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: N/A. v3: N/A. --- drivers/comedi/drivers/amplc_dio200_common.c | 4 +- drivers/comedi/drivers/comedi_8254.c | 177 +++++++++++++------ include/linux/comedi/comedi_8254.h | 22 ++- 3 files changed, 144 insertions(+), 59 deletions(-) diff --git a/drivers/comedi/drivers/amplc_dio200_common.c b/drivers/comedi/drivers/amplc_dio200_common.c index ff651f2eb86c..2c1507a23f8a 100644 --- a/drivers/comedi/drivers/amplc_dio200_common.c +++ b/drivers/comedi/drivers/amplc_dio200_common.c @@ -149,9 +149,9 @@ static unsigned int dio200_subdev_8254_offset(struct comedi_device *dev, /* get the offset that was passed to comedi_8254_*_init() */ if (dev->mmio) - offset = i8254->mmio - dev->mmio; + offset = (void __iomem *)i8254->context - dev->mmio; else - offset = i8254->iobase - dev->iobase; + offset = i8254->context - dev->iobase; /* remove the shift that was added for PCIe boards */ if (board->is_pcie) diff --git a/drivers/comedi/drivers/comedi_8254.c b/drivers/comedi/drivers/comedi_8254.c index b4185c1b2695..3f8657fc7ee5 100644 --- a/drivers/comedi/drivers/comedi_8254.c +++ b/drivers/comedi/drivers/comedi_8254.c @@ -119,63 +119,101 @@ #include #include -static unsigned int __i8254_read(struct comedi_8254 *i8254, unsigned int reg) +static unsigned int i8254_io8_cb(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val) { - unsigned int reg_offset = (reg * i8254->iosize) << i8254->regshift; - unsigned int val; + unsigned long iobase = i8254->context; + unsigned int reg_offset = (reg * I8254_IO8) << i8254->regshift; - switch (i8254->iosize) { - default: - case I8254_IO8: - if (i8254->mmio) - val = readb(i8254->mmio + reg_offset); - else - val = inb(i8254->iobase + reg_offset); - break; - case I8254_IO16: - if (i8254->mmio) - val = readw(i8254->mmio + reg_offset); - else - val = inw(i8254->iobase + reg_offset); - break; - case I8254_IO32: - if (i8254->mmio) - val = readl(i8254->mmio + reg_offset); - else - val = inl(i8254->iobase + reg_offset); - break; + if (dir) { + outb(val, iobase + reg_offset); + return 0; + } else { + return inb(iobase + reg_offset); } - return val & 0xff; } -static void __i8254_write(struct comedi_8254 *i8254, - unsigned int val, unsigned int reg) +static unsigned int i8254_io16_cb(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val) { - unsigned int reg_offset = (reg * i8254->iosize) << i8254->regshift; + unsigned long iobase = i8254->context; + unsigned int reg_offset = (reg * I8254_IO16) << i8254->regshift; - switch (i8254->iosize) { - default: - case I8254_IO8: - if (i8254->mmio) - writeb(val, i8254->mmio + reg_offset); - else - outb(val, i8254->iobase + reg_offset); - break; - case I8254_IO16: - if (i8254->mmio) - writew(val, i8254->mmio + reg_offset); - else - outw(val, i8254->iobase + reg_offset); - break; - case I8254_IO32: - if (i8254->mmio) - writel(val, i8254->mmio + reg_offset); - else - outl(val, i8254->iobase + reg_offset); - break; + if (dir) { + outw(val, iobase + reg_offset); + return 0; + } else { + return inw(iobase + reg_offset); + } +} + +static unsigned int i8254_io32_cb(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val) +{ + unsigned long iobase = i8254->context; + unsigned int reg_offset = (reg * I8254_IO32) << i8254->regshift; + + if (dir) { + outl(val, iobase + reg_offset); + return 0; + } else { + return inl(iobase + reg_offset); + } +} + +static unsigned int i8254_mmio8_cb(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val) +{ + void __iomem *mmiobase = (void __iomem *)i8254->context; + unsigned int reg_offset = (reg * I8254_IO8) << i8254->regshift; + + if (dir) { + writeb(val, mmiobase + reg_offset); + return 0; + } else { + return readb(mmiobase + reg_offset); + } +} + +static unsigned int i8254_mmio16_cb(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val) +{ + void __iomem *mmiobase = (void __iomem *)i8254->context; + unsigned int reg_offset = (reg * I8254_IO16) << i8254->regshift; + + if (dir) { + writew(val, mmiobase + reg_offset); + return 0; + } else { + return readw(mmiobase + reg_offset); } } +static unsigned int i8254_mmio32_cb(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val) +{ + void __iomem *mmiobase = (void __iomem *)i8254->context; + unsigned int reg_offset = (reg * I8254_IO32) << i8254->regshift; + + if (dir) { + writel(val, mmiobase + reg_offset); + return 0; + } else { + return readl(mmiobase + reg_offset); + } +} + +static unsigned int __i8254_read(struct comedi_8254 *i8254, unsigned int reg) +{ + return 0xff & i8254->iocb(i8254, 0, reg, 0); +} + +static void __i8254_write(struct comedi_8254 *i8254, + unsigned int val, unsigned int reg) +{ + i8254->iocb(i8254, 1, reg, val); +} + /** * comedi_8254_status - return the status of a counter * @i8254: comedi_8254 struct for the timer @@ -571,8 +609,8 @@ void comedi_8254_subdevice_init(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_8254_subdevice_init); -static struct comedi_8254 *__i8254_init(unsigned long iobase, - void __iomem *mmio, +static struct comedi_8254 *__i8254_init(comedi_8254_iocb_fn *iocb, + unsigned long context, unsigned int osc_base, unsigned int iosize, unsigned int regshift) @@ -585,12 +623,15 @@ static struct comedi_8254 *__i8254_init(unsigned long iobase, iosize == I8254_IO32)) return NULL; + if (!iocb) + return NULL; + i8254 = kzalloc(sizeof(*i8254), GFP_KERNEL); if (!i8254) return NULL; - i8254->iobase = iobase; - i8254->mmio = mmio; + i8254->iocb = iocb; + i8254->context = context; i8254->iosize = iosize; i8254->regshift = regshift; @@ -617,7 +658,22 @@ struct comedi_8254 *comedi_8254_init(unsigned long iobase, unsigned int iosize, unsigned int regshift) { - return __i8254_init(iobase, NULL, osc_base, iosize, regshift); + comedi_8254_iocb_fn *iocb; + + switch (iosize) { + case I8254_IO8: + iocb = i8254_io8_cb; + break; + case I8254_IO16: + iocb = i8254_io16_cb; + break; + case I8254_IO32: + iocb = i8254_io32_cb; + break; + default: + return NULL; + } + return __i8254_init(iocb, iobase, osc_base, iosize, regshift); } EXPORT_SYMBOL_GPL(comedi_8254_init); @@ -634,7 +690,22 @@ struct comedi_8254 *comedi_8254_mm_init(void __iomem *mmio, unsigned int iosize, unsigned int regshift) { - return __i8254_init(0, mmio, osc_base, iosize, regshift); + comedi_8254_iocb_fn *iocb; + + switch (iosize) { + case I8254_IO8: + iocb = i8254_mmio8_cb; + break; + case I8254_IO16: + iocb = i8254_mmio16_cb; + break; + case I8254_IO32: + iocb = i8254_mmio32_cb; + break; + default: + return NULL; + } + return __i8254_init(iocb, (unsigned long)mmio, osc_base, iosize, regshift); } EXPORT_SYMBOL_GPL(comedi_8254_mm_init); diff --git a/include/linux/comedi/comedi_8254.h b/include/linux/comedi/comedi_8254.h index d8264417e53c..18d12321c87d 100644 --- a/include/linux/comedi/comedi_8254.h +++ b/include/linux/comedi/comedi_8254.h @@ -57,10 +57,24 @@ struct comedi_subdevice; /* counter maps zero to 0x10000 */ #define I8254_MAX_COUNT 0x10000 +struct comedi_8254; + +/** + * typedef comedi_8254_iocb_fn - call-back function type for 8254 register access + * @i8254: pointer to struct comedi_8254 + * @dir: direction (0 = read, 1 = write) + * @reg: register number + * @val: value to write + * + * Return: Register value when reading, 0 when writing. + */ +typedef unsigned int comedi_8254_iocb_fn(struct comedi_8254 *i8254, int dir, + unsigned int reg, unsigned int val); + /** * struct comedi_8254 - private data used by this module - * @iobase: PIO base address of the registers (in/out) - * @mmio: MMIO base address of the registers (read/write) + * @iocb: I/O call-back function for register access + * @context: context for register access (e.g. a base address) * @iosize: I/O size used to access the registers (b/w/l) * @regshift: register gap shift * @osc_base: cascaded oscillator speed in ns @@ -76,8 +90,8 @@ struct comedi_subdevice; * @insn_config: driver specific (*insn_config) callback */ struct comedi_8254 { - unsigned long iobase; - void __iomem *mmio; + comedi_8254_iocb_fn *iocb; + unsigned long context; unsigned int iosize; unsigned int regshift; unsigned int osc_base; From patchwork Wed Sep 13 17:07:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp67166vqb; Wed, 13 Sep 2023 13:24:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcBI0Y3hsO3qcuAC41ticexKKyiGNpOde6TA1jo4cbNqfo1/ABwZzPibrIo2ajOZRG1mLw X-Received: by 2002:a17:902:eb46:b0:1bc:6266:d0e4 with SMTP id i6-20020a170902eb4600b001bc6266d0e4mr3423522pli.69.1694636689016; Wed, 13 Sep 2023 13:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694636689; cv=none; d=google.com; s=arc-20160816; b=Vni/m+6Xd9fFUwUZD++DrxyRl9CncNnnWOlcLnBK0Cic8bO6RouA/XyD1yh2kwa4Cm 1qIaluZb1dIqeKPmbyem8EyyQ92l08clQkx/XvtbZA30MVMtNt5bdjsnAxSaEF/Tbrwh daZRFE1AUVvhafgERny3Uu+UoIbXoy3S4jjIYKhyJfrSeWlV1RMu3qIBei7z5E0mCcS8 Fxo311trqGCLppctPEhis3VKu2s57ldiHmkzP0+zQBlk05hPkNPUvFGlCsjmGa98jWtR eA3pLsDiP32eyxPCZ57p+qQYw6CNd+Hjqdp4IQnXn5SdWBCjE1u7rFO8cp/Kj9gvAeLM x6Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hyan7kXKjxJXLwE+OGZbVRXctv+F1SfwhSVKkiN0d1E=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=kjc7HhZ6lvuIzIB0XbJFW9M4qKburyUQiuvVyE2XmSi/HDcRSntplOyC0lFCrRbkCS Lr9+qZW4ZxL0HJyFVnzWoT51DpllQzwRW1EdW7eAl1gMx7FtrX7PL6dkrcika5WaRjiN ri60vZTVu/iBvRZUZWDKCPYJSD0tuA0aSKscqsEw0teZZPHuZzWL4gc+lfSQZ53MNGvd CA2o31LG2kxwxfHNHWBtd7AuZfbD/Ky9ZCmixjjHCONFdE8pFCZ+UURWMYX4WIqXPta0 zEK3Q5pRM05b+eLRdtHeRMQM4ydOHGksIsMmwOIRXwqFrHlxot5zh93ZWg11MKBJfbl3 dUtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=tNTVTGeP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cp2-20020a170902e78200b001b8c824e826si46122plb.533.2023.09.13.13.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=tNTVTGeP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 879AB8051908; Wed, 13 Sep 2023 10:07:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbjIMRHg (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbjIMRHb (ORCPT ); Wed, 13 Sep 2023 13:07:31 -0400 Received: from smtp112.iad3a.emailsrvr.com (smtp112.iad3a.emailsrvr.com [173.203.187.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD1A51BCB for ; Wed, 13 Sep 2023 10:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624847; bh=I/tHvGfvIq4pfoyP88Yoc/G05xULJ8fWaIvY9vzRiPo=; h=From:To:Subject:Date:From; b=tNTVTGePy2ETvYe63x8zPiMQzlQKkONWfVBmNdB8CTIuCew+WrS5Lw2Zdk/nRAV+Z btT8quW5VX8qN8VQPKGHRdJYnU6C7VCU0POspxt9e9zKLZdwIrRYQ/SWVLO2AYwxgU J2dOXikxkXSl7HoaLGOjaxeERStvCTeI6xu2Vbmw= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 37E9354FE; Wed, 13 Sep 2023 13:07:26 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 04/13] comedi: comedi_8254: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:03 +0100 Message-Id: <20230913170712.111719-5-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-5-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:07:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776946618695955450 X-GMAIL-MSGID: 1776955360798081874 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 Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: N/A. v3: Add missing `---` divider before patch changelog. --- drivers/comedi/drivers/comedi_8254.c | 8 ++++++++ include/linux/comedi/comedi_8254.h | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/comedi/drivers/comedi_8254.c b/drivers/comedi/drivers/comedi_8254.c index 696596944506..6beca2a6d66e 100644 --- a/drivers/comedi/drivers/comedi_8254.c +++ b/drivers/comedi/drivers/comedi_8254.c @@ -122,6 +122,8 @@ #include #include +#ifdef CONFIG_HAS_IOPORT + static unsigned int i8254_io8_cb(struct comedi_8254 *i8254, int dir, unsigned int reg, unsigned int val) { @@ -164,6 +166,8 @@ static unsigned int i8254_io32_cb(struct comedi_8254 *i8254, int dir, } } +#endif /* CONFIG_HAS_IOPORT */ + static unsigned int i8254_mmio8_cb(struct comedi_8254 *i8254, int dir, unsigned int reg, unsigned int val) { @@ -648,6 +652,8 @@ static struct comedi_8254 *__i8254_init(comedi_8254_iocb_fn *iocb, 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 @@ -682,6 +688,8 @@ struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase, } 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 diff --git a/include/linux/comedi/comedi_8254.h b/include/linux/comedi/comedi_8254.h index 393ccb301028..d527f04400df 100644 --- a/include/linux/comedi/comedi_8254.h +++ b/include/linux/comedi/comedi_8254.h @@ -12,6 +12,8 @@ #define _COMEDI_8254_H #include +#include +#include struct comedi_device; struct comedi_insn; @@ -136,10 +138,21 @@ void comedi_8254_set_busy(struct comedi_8254 *i8254, 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, From patchwork Wed Sep 13 17:07:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp54829vqi; Wed, 13 Sep 2023 19:00:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9eicPpWgqSVH5tNWme80+6XyhZFZhPRnoQzopcEtMGOJEFYjxhZReaJ3UBkRnReo9HHra X-Received: by 2002:a05:6358:2909:b0:139:a45c:32b2 with SMTP id y9-20020a056358290900b00139a45c32b2mr4708605rwb.11.1694656840268; Wed, 13 Sep 2023 19:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694656840; cv=none; d=google.com; s=arc-20160816; b=ql6b9IkrWpvWpd6JUZG0yVxChsa3haUtnXVFyLkATHPZUWlCI8V1+/zF5oo5KrwVk6 imrmELkcyIVluuoHY9TweulLFTsjgqnzu+6cHu4YCWhV+g9dySS1taHDQ6PFFZ23DBsz cUgr2CqCUyYrz998ga7+QCbI7EmtYLt0ztV9QB4PWdWxYqyibY4sOT0a2YON4ceIYE3K YVpZSYcFqXMxBTNFIUGRmXTt21zBO6MGKiMITHd4AHAqCxlAxvRHLoU/7nr2UtlRVNLn 2a0fHQ0wN5izuykyyYK8Dad8KqBQU+ONx5BB+zCdCuLjxeK/1cVXEFbDSU/nK6spVFF/ Px4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P8kk3Rv0LeKC6HnZWF/kc5g/eLZ9oDIfBSzXq+ESugw=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=tExqnFk+NBStWxFdEkJ6q7/EfOPjxR/ITpK9ycqDZE7SJFdr5ible3V80XaGtQvpB0 3QMCeYmEwsR6HdhrvsFtqGdaVsHWKVlYC8zqWbSSSqom5va3vUMbnDbyeQfkgDRh2SiS 47ffMEhvAiOpOfrMAwvR1pXv7f6hVIE8qYr/UyO7GYozcI0eSyWspMtpKHq3g+kvVFu2 6JG5M5KHzeGk9heYUQandwQ39miHz5iu4fqFrPup36WKkxJv5DhJ58CSsLLTvWZg4DWa ARLyb64nd5xShhYBDaD/seJg3pGVNAmQuJpwqvVh18epNmsGhx3xmqsErB7eW8uNSyUq khyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=euoGXdmZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00564bdf6958fsi413217pgb.649.2023.09.13.19.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:00:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=euoGXdmZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EB5498104F57; Wed, 13 Sep 2023 10:07:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbjIMRHj (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbjIMRHe (ORCPT ); Wed, 13 Sep 2023 13:07:34 -0400 Received: from smtp114.iad3a.emailsrvr.com (smtp114.iad3a.emailsrvr.com [173.203.187.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A2B1BD5 for ; Wed, 13 Sep 2023 10:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624848; bh=dVrJIAZcbd+bb9knKMwOHFZeLuXBdm4FYPm3ib1lttc=; h=From:To:Subject:Date:From; b=euoGXdmZoZ1nm3Gl4VH/8p5Orrc11KSByRDx/T6UT39Hr15SLot/BKPOm+kBxS7q9 yZ4xZSfKEwGZ7ITb9wQIy0iHhV3ciQbxvwWhxvuXjzdhQOgH7BZcPbOGt8ZKDZBtJ+ BDqTNmXzdk4vqFNYebe5w5PorGt869Jku+keNMZU= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 8D8F654C7; Wed, 13 Sep 2023 13:07:27 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 05/13] comedi: 8255_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 18:07:04 +0100 Message-Id: <20230913170712.111719-6-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-6-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:07:58 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776928783538727497 X-GMAIL-MSGID: 1776976491004284678 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 Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT`. v3: N/A. --- drivers/comedi/drivers/8255_pci.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/comedi/drivers/8255_pci.c b/drivers/comedi/drivers/8255_pci.c index 0fec048e3a53..9ad52e9f5427 100644 --- a/drivers/comedi/drivers/8255_pci.c +++ b/drivers/comedi/drivers/8255_pci.c @@ -57,6 +57,7 @@ #include enum pci_8255_boardid { +#ifdef CONFIG_HAS_IOPORT BOARD_ADLINK_PCI7224, BOARD_ADLINK_PCI7248, BOARD_ADLINK_PCI7296, @@ -65,6 +66,7 @@ enum pci_8255_boardid { BOARD_CB_PCIDIO48H_OLD, BOARD_CB_PCIDIO48H_NEW, BOARD_CB_PCIDIO96H, +#endif /* CONFIG_HAS_IOPORT */ BOARD_NI_PCIDIO96, BOARD_NI_PCIDIO96B, BOARD_NI_PXI6508, @@ -82,6 +84,7 @@ struct pci_8255_boardinfo { }; static const struct pci_8255_boardinfo pci_8255_boards[] = { +#ifdef CONFIG_HAS_IOPORT [BOARD_ADLINK_PCI7224] = { .name = "adl_pci-7224", .dio_badr = 2, @@ -122,6 +125,7 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = { .dio_badr = 2, .n_8255 = 4, }, +#endif /* CONFIG_HAS_IOPORT */ [BOARD_NI_PCIDIO96] = { .name = "ni_pci-dio-96", .dio_badr = 1, @@ -219,8 +223,11 @@ static int pci_8255_auto_attach(struct comedi_device *dev, dev->mmio = pci_ioremap_bar(pcidev, board->dio_badr); if (!dev->mmio) return -ENOMEM; - } else { + } else if (IS_ENABLED(CONFIG_HAS_IOPORT)) { dev->iobase = pci_resource_start(pcidev, board->dio_badr); + } else { + dev_err(dev->class_dev, "error! need I/O port support\n"); + return -ENXIO; } /* @@ -259,6 +266,7 @@ static int pci_8255_pci_probe(struct pci_dev *dev, } static const struct pci_device_id pci_8255_pci_table[] = { +#ifdef CONFIG_HAS_IOPORT { PCI_VDEVICE(ADLINK, 0x7224), BOARD_ADLINK_PCI7224 }, { PCI_VDEVICE(ADLINK, 0x7248), BOARD_ADLINK_PCI7248 }, { PCI_VDEVICE(ADLINK, 0x7296), BOARD_ADLINK_PCI7296 }, @@ -269,6 +277,7 @@ static const struct pci_device_id pci_8255_pci_table[] = { { PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, PCI_VENDOR_ID_CB, 0x000b), .driver_data = BOARD_CB_PCIDIO48H_NEW }, { PCI_VDEVICE(CB, 0x0017), BOARD_CB_PCIDIO96H }, +#endif /* CONFIG_HAS_IOPORT */ { PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 }, { PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B }, { PCI_VDEVICE(NI, 0x13c0), BOARD_NI_PXI6508 }, From patchwork Wed Sep 13 17:07:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp37655vqi; Wed, 13 Sep 2023 18:09:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF60wicSZMZzO4Ch8+z+wIISpRqENseh3omwZBfp83iuG5KcLt/zht0z89KBROsU/IScaaO X-Received: by 2002:a17:90b:11d4:b0:269:46d7:f1db with SMTP id gv20-20020a17090b11d400b0026946d7f1dbmr4125440pjb.32.1694653761824; Wed, 13 Sep 2023 18:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694653761; cv=none; d=google.com; s=arc-20160816; b=JXv9CMwIWKOT9+i0WV2IehLb3wfJU++LBIFhZ7J/L7iOND/lErYpXhmIbwwQxHj3D7 M39BRUZIKSEoDIBmf5kJhKH+1Qj4cph/PoUZskAzobbAOI7dFQ2GOSijG2c9TRJ7sEVU a4KSdzhT4WXtvsplAnlP4yNqPvF/PpesdY9x/kDgV8ogFm/rKsXs0pVAvGSJSp0ldpwO Yd4HkWQ4H+Nl63NWR5x7C1YplFfgFjFd8F7NLKCLAL57CrAJuG4+4Hqp+g1XWFRRDmsp m+pGDxkmxBiEQUqbiJdUy4DP4P8RSAf9uSzvGyg51OPXzDB0Gn0NdFK2A6HS9pgu+jNY yznw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eYR+S5x/2zz/Q4T6E2EKClt5XD1KgFycBqspydJkQLA=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=GyKgpafx9b2zA/iaylaFVoY10/dalgY7JNKdqyD93dO668EfR66U20KwYDB7xu2AmD oD/k+Yf3+xtKq7gV001pO8x8Pfb6M748gv1MzWukI51hxzUpnLtZQfyFO/GS3UjGUi0T QCAgYxph0aUz413SUZsGWLWqbalGzeD2sHOv67ljHT0JyvowvYRmTHc88F7ttlE7xvLN J5osmauYf5oSkPPJVwNCBZk8yPj7eVjmtvZJut+wzwjAxjW9nmkYRmETkgKZz5ZdHSgK gn5S7Y876JGV4TP2njwnwo0f6Jq5xXEM1Hi3+0GuVe6La2Uv6DKJ720YFDwjEgUKJRsL J6Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=xAuMsoez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l3-20020a17090a72c300b002735abbfab0si2689169pjk.11.2023.09.13.18.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=xAuMsoez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 058F880C7ADB; Wed, 13 Sep 2023 10:07:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbjIMRHo (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbjIMRHf (ORCPT ); Wed, 13 Sep 2023 13:07:35 -0400 Received: from smtp113.iad3a.emailsrvr.com (smtp113.iad3a.emailsrvr.com [173.203.187.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D07A21BCB for ; Wed, 13 Sep 2023 10:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624850; bh=fzKqq7khPjdSdidKUzby8wxdacPUUZ23EwNC56Jh8oQ=; h=From:To:Subject:Date:From; b=xAuMsoezPVZNR32rXUXWEu1mVGi3ytw544sBweupTTgyPf6XDhUWd6PCdutUSSXAu Yod9eGu6n1bDWOyzVK5Z8E4lp2EnTErDIoIP8f1PU8GFhqocAFUa0aoV42Svn56wL1 82azd/VVI6w9dZGYO3cClWUQ/gOeBJSMWTUwnqw4= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id E656B55CE; Wed, 13 Sep 2023 13:07:28 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 06/13] comedi: comedi_8255: Rework subdevice initialization functions Date: Wed, 13 Sep 2023 18:07:05 +0100 Message-Id: <20230913170712.111719-7-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-7-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:07:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776933302940156618 X-GMAIL-MSGID: 1776973263013774006 Comedi drivers can initialize an 8255 subdevice in I/O space by calling `subdev_8255_init()`, or in memory-mapped I/O space by calling `subdev_8255_mm_init()`, or by supplying a call-back function pointer and context to either of those functions. Change it so that a new function `subdev_8255_cb_init()` shall be called instead when supplying a callback function and context, and remove the call-back function parameter from `subdev_8255_init()` and `subdev_8255_mm_init()`. Also rename `subdev_8255_init()` to `subdev_8255_io_init()`. The parameters are changing, so might as well rename it at the same time. Also rename the `regbase` member of `struct subdev_8255_private` to `context` since this holds the context for the call-back function call. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: N/A. v3: Add missing `---` divider before patch changelog. --- drivers/comedi/drivers/8255.c | 2 +- drivers/comedi/drivers/8255_pci.c | 4 +- drivers/comedi/drivers/adv_pci_dio.c | 4 +- drivers/comedi/drivers/aio_aio12_8.c | 2 +- drivers/comedi/drivers/amplc_pc236_common.c | 2 +- drivers/comedi/drivers/amplc_pci230.c | 2 +- drivers/comedi/drivers/cb_pcidas.c | 2 +- drivers/comedi/drivers/cb_pcidas64.c | 7 +- drivers/comedi/drivers/cb_pcidda.c | 2 +- drivers/comedi/drivers/cb_pcimdas.c | 2 +- drivers/comedi/drivers/cb_pcimdda.c | 2 +- drivers/comedi/drivers/comedi_8255.c | 115 +++++++++----------- drivers/comedi/drivers/daqboard2000.c | 4 +- drivers/comedi/drivers/das08.c | 2 +- drivers/comedi/drivers/das16.c | 2 +- drivers/comedi/drivers/das16m1.c | 2 +- drivers/comedi/drivers/dmm32at.c | 3 +- drivers/comedi/drivers/ni_atmio16d.c | 2 +- drivers/comedi/drivers/ni_daq_dio24.c | 2 +- drivers/comedi/drivers/ni_labpc_common.c | 4 +- drivers/comedi/drivers/ni_mio_common.c | 4 +- drivers/comedi/drivers/pcl724.c | 6 +- drivers/comedi/drivers/pcm3724.c | 2 +- include/linux/comedi/comedi_8255.h | 13 ++- 24 files changed, 92 insertions(+), 100 deletions(-) diff --git a/drivers/comedi/drivers/8255.c b/drivers/comedi/drivers/8255.c index ced8ea09d4fa..f45f7bd1c61a 100644 --- a/drivers/comedi/drivers/8255.c +++ b/drivers/comedi/drivers/8255.c @@ -80,7 +80,7 @@ static int dev_8255_attach(struct comedi_device *dev, if (ret) { s->type = COMEDI_SUBD_UNUSED; } else { - ret = subdev_8255_init(dev, s, NULL, iobase); + ret = subdev_8255_io_init(dev, s, iobase); if (ret) { /* * Release the I/O port region here, as the diff --git a/drivers/comedi/drivers/8255_pci.c b/drivers/comedi/drivers/8255_pci.c index 9ad52e9f5427..8498cabe4d91 100644 --- a/drivers/comedi/drivers/8255_pci.c +++ b/drivers/comedi/drivers/8255_pci.c @@ -242,9 +242,9 @@ static int pci_8255_auto_attach(struct comedi_device *dev, for (i = 0; i < board->n_8255; i++) { s = &dev->subdevices[i]; if (dev->mmio) - ret = subdev_8255_mm_init(dev, s, NULL, i * I8255_SIZE); + ret = subdev_8255_mm_init(dev, s, i * I8255_SIZE); else - ret = subdev_8255_init(dev, s, NULL, i * I8255_SIZE); + ret = subdev_8255_io_init(dev, s, i * I8255_SIZE); if (ret) return ret; } diff --git a/drivers/comedi/drivers/adv_pci_dio.c b/drivers/comedi/drivers/adv_pci_dio.c index 0319d8c7ee47..ca8054504760 100644 --- a/drivers/comedi/drivers/adv_pci_dio.c +++ b/drivers/comedi/drivers/adv_pci_dio.c @@ -642,8 +642,8 @@ static int pci_dio_auto_attach(struct comedi_device *dev, for (j = 0; j < d->chans; j++) { s = &dev->subdevices[subdev++]; - ret = subdev_8255_init(dev, s, NULL, - d->addr + j * I8255_SIZE); + ret = subdev_8255_io_init(dev, s, + d->addr + j * I8255_SIZE); if (ret) return ret; } diff --git a/drivers/comedi/drivers/aio_aio12_8.c b/drivers/comedi/drivers/aio_aio12_8.c index f9d40fa3d3a9..227a86a3a760 100644 --- a/drivers/comedi/drivers/aio_aio12_8.c +++ b/drivers/comedi/drivers/aio_aio12_8.c @@ -247,7 +247,7 @@ static int aio_aio12_8_attach(struct comedi_device *dev, /* Digital I/O subdevice (8255) */ s = &dev->subdevices[2]; - ret = subdev_8255_init(dev, s, NULL, AIO12_8_8255_BASE_REG); + ret = subdev_8255_io_init(dev, s, AIO12_8_8255_BASE_REG); if (ret) return ret; diff --git a/drivers/comedi/drivers/amplc_pc236_common.c b/drivers/comedi/drivers/amplc_pc236_common.c index 9f4f89b1ef23..326ca72c24ec 100644 --- a/drivers/comedi/drivers/amplc_pc236_common.c +++ b/drivers/comedi/drivers/amplc_pc236_common.c @@ -147,7 +147,7 @@ int amplc_pc236_common_attach(struct comedi_device *dev, unsigned long iobase, s = &dev->subdevices[0]; /* digital i/o subdevice (8255) */ - ret = subdev_8255_init(dev, s, NULL, 0x00); + ret = subdev_8255_io_init(dev, s, 0x00); if (ret) return ret; diff --git a/drivers/comedi/drivers/amplc_pci230.c b/drivers/comedi/drivers/amplc_pci230.c index 783da73877b9..c74209c2e83a 100644 --- a/drivers/comedi/drivers/amplc_pci230.c +++ b/drivers/comedi/drivers/amplc_pci230.c @@ -2529,7 +2529,7 @@ static int pci230_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; /* digital i/o subdevice */ if (board->have_dio) { - rc = subdev_8255_init(dev, s, NULL, PCI230_PPI_X_BASE); + rc = subdev_8255_io_init(dev, s, PCI230_PPI_X_BASE); if (rc) return rc; } else { diff --git a/drivers/comedi/drivers/cb_pcidas.c b/drivers/comedi/drivers/cb_pcidas.c index 7a6cd681e932..8bb9b0623869 100644 --- a/drivers/comedi/drivers/cb_pcidas.c +++ b/drivers/comedi/drivers/cb_pcidas.c @@ -1352,7 +1352,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, /* 8255 */ s = &dev->subdevices[2]; - ret = subdev_8255_init(dev, s, NULL, PCIDAS_8255_BASE); + ret = subdev_8255_io_init(dev, s, PCIDAS_8255_BASE); if (ret) return ret; diff --git a/drivers/comedi/drivers/cb_pcidas64.c b/drivers/comedi/drivers/cb_pcidas64.c index ca6038a25f26..ff19fc3859e4 100644 --- a/drivers/comedi/drivers/cb_pcidas64.c +++ b/drivers/comedi/drivers/cb_pcidas64.c @@ -3877,11 +3877,10 @@ static int setup_subdevices(struct comedi_device *dev) s = &dev->subdevices[4]; if (board->has_8255) { if (board->layout == LAYOUT_4020) { - ret = subdev_8255_init(dev, s, dio_callback_4020, - I8255_4020_REG); + ret = subdev_8255_cb_init(dev, s, dio_callback_4020, + I8255_4020_REG); } else { - ret = subdev_8255_mm_init(dev, s, NULL, - DIO_8255_OFFSET); + ret = subdev_8255_mm_init(dev, s, DIO_8255_OFFSET); } if (ret) return ret; diff --git a/drivers/comedi/drivers/cb_pcidda.c b/drivers/comedi/drivers/cb_pcidda.c index c52204a6bda4..c353d0f87da9 100644 --- a/drivers/comedi/drivers/cb_pcidda.c +++ b/drivers/comedi/drivers/cb_pcidda.c @@ -365,7 +365,7 @@ static int cb_pcidda_auto_attach(struct comedi_device *dev, /* two 8255 digital io subdevices */ for (i = 0; i < 2; i++) { s = &dev->subdevices[1 + i]; - ret = subdev_8255_init(dev, s, NULL, i * I8255_SIZE); + ret = subdev_8255_io_init(dev, s, i * I8255_SIZE); if (ret) return ret; } diff --git a/drivers/comedi/drivers/cb_pcimdas.c b/drivers/comedi/drivers/cb_pcimdas.c index 5816ef65ed5f..641c30df392e 100644 --- a/drivers/comedi/drivers/cb_pcimdas.c +++ b/drivers/comedi/drivers/cb_pcimdas.c @@ -405,7 +405,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, /* Digital I/O subdevice */ s = &dev->subdevices[2]; - ret = subdev_8255_init(dev, s, NULL, PCIMDAS_8255_BASE); + ret = subdev_8255_io_init(dev, s, PCIMDAS_8255_BASE); if (ret) return ret; diff --git a/drivers/comedi/drivers/cb_pcimdda.c b/drivers/comedi/drivers/cb_pcimdda.c index bf8093a10315..541b5742bb1b 100644 --- a/drivers/comedi/drivers/cb_pcimdda.c +++ b/drivers/comedi/drivers/cb_pcimdda.c @@ -154,7 +154,7 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, s = &dev->subdevices[1]; /* digital i/o subdevice */ - return subdev_8255_init(dev, s, NULL, PCIMDDA_8255_BASE_REG); + return subdev_8255_io_init(dev, s, PCIMDDA_8255_BASE_REG); } static struct comedi_driver cb_pcimdda_driver = { diff --git a/drivers/comedi/drivers/comedi_8255.c b/drivers/comedi/drivers/comedi_8255.c index 5562b9cd0a17..28fd9d8c95cc 100644 --- a/drivers/comedi/drivers/comedi_8255.c +++ b/drivers/comedi/drivers/comedi_8255.c @@ -33,9 +33,9 @@ #include struct subdev_8255_private { - unsigned long regbase; + unsigned long context; int (*io)(struct comedi_device *dev, int dir, int port, int data, - unsigned long regbase); + unsigned long context); }; static int subdev_8255_io(struct comedi_device *dev, @@ -64,7 +64,7 @@ static int subdev_8255_insn(struct comedi_device *dev, unsigned int *data) { struct subdev_8255_private *spriv = s->private; - unsigned long regbase = spriv->regbase; + unsigned long context = spriv->context; unsigned int mask; unsigned int v; @@ -72,18 +72,18 @@ static int subdev_8255_insn(struct comedi_device *dev, if (mask) { if (mask & 0xff) spriv->io(dev, 1, I8255_DATA_A_REG, - s->state & 0xff, regbase); + s->state & 0xff, context); if (mask & 0xff00) spriv->io(dev, 1, I8255_DATA_B_REG, - (s->state >> 8) & 0xff, regbase); + (s->state >> 8) & 0xff, context); if (mask & 0xff0000) spriv->io(dev, 1, I8255_DATA_C_REG, - (s->state >> 16) & 0xff, regbase); + (s->state >> 16) & 0xff, context); } - v = spriv->io(dev, 0, I8255_DATA_A_REG, 0, regbase); - v |= (spriv->io(dev, 0, I8255_DATA_B_REG, 0, regbase) << 8); - v |= (spriv->io(dev, 0, I8255_DATA_C_REG, 0, regbase) << 16); + v = spriv->io(dev, 0, I8255_DATA_A_REG, 0, context); + v |= (spriv->io(dev, 0, I8255_DATA_B_REG, 0, context) << 8); + v |= (spriv->io(dev, 0, I8255_DATA_C_REG, 0, context) << 16); data[1] = v; @@ -94,7 +94,7 @@ static void subdev_8255_do_config(struct comedi_device *dev, struct comedi_subdevice *s) { struct subdev_8255_private *spriv = s->private; - unsigned long regbase = spriv->regbase; + unsigned long context = spriv->context; int config; config = I8255_CTRL_CW; @@ -108,7 +108,7 @@ static void subdev_8255_do_config(struct comedi_device *dev, if (!(s->io_bits & 0xf00000)) config |= I8255_CTRL_C_HI_IO; - spriv->io(dev, 1, I8255_CTRL_REG, config, regbase); + spriv->io(dev, 1, I8255_CTRL_REG, config, context); } static int subdev_8255_insn_config(struct comedi_device *dev, @@ -142,23 +142,19 @@ static int __subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, int (*io)(struct comedi_device *dev, int dir, int port, int data, - unsigned long regbase), - unsigned long regbase, - bool is_mmio) + unsigned long context), + unsigned long context) { struct subdev_8255_private *spriv; + if (!io) + return -EINVAL; + spriv = comedi_alloc_spriv(s, sizeof(*spriv)); if (!spriv) return -ENOMEM; - if (io) - spriv->io = io; - else if (is_mmio) - spriv->io = subdev_8255_mmio; - else - spriv->io = subdev_8255_io; - spriv->regbase = regbase; + spriv->context = context; s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; @@ -174,88 +170,83 @@ static int __subdev_8255_init(struct comedi_device *dev, } /** - * subdev_8255_init - initialize DIO subdevice for driving I/O mapped 8255 + * subdev_8255_io_init - initialize DIO subdevice for driving I/O mapped 8255 * @dev: comedi device owning subdevice * @s: comedi subdevice to initialize - * @io: (optional) register I/O call-back function - * @regbase: offset of 8255 registers from dev->iobase, or call-back context + * @regbase: offset of 8255 registers from dev->iobase * * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. * - * If the optional I/O call-back function is provided, its prototype is of - * the following form: - * - * int my_8255_callback(struct comedi_device *dev, int dir, int port, - * int data, unsigned long regbase); - * - * where 'dev', and 'regbase' match the values passed to this function, - * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' - * is the direction (0 for read, 1 for write) and 'data' is the value to be - * written. It should return 0 if writing or the value read if reading. - * - * If the optional I/O call-back function is not provided, an internal - * call-back function is used which uses consecutive I/O port addresses - * starting at dev->iobase + regbase. - * * Return: -ENOMEM if failed to allocate memory, zero on success. */ -int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *dev, int dir, int port, - int data, unsigned long regbase), +int subdev_8255_io_init(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long regbase) { - return __subdev_8255_init(dev, s, io, regbase, false); + return __subdev_8255_init(dev, s, subdev_8255_io, regbase); } -EXPORT_SYMBOL_GPL(subdev_8255_init); +EXPORT_SYMBOL_GPL(subdev_8255_io_init); /** * subdev_8255_mm_init - initialize DIO subdevice for driving mmio-mapped 8255 * @dev: comedi device owning subdevice * @s: comedi subdevice to initialize - * @io: (optional) register I/O call-back function - * @regbase: offset of 8255 registers from dev->mmio, or call-back context + * @regbase: offset of 8255 registers from dev->mmio * * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. * - * If the optional I/O call-back function is provided, its prototype is of - * the following form: + * Return: -ENOMEM if failed to allocate memory, zero on success. + */ +int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned long regbase) +{ + return __subdev_8255_init(dev, s, subdev_8255_mmio, regbase); +} +EXPORT_SYMBOL_GPL(subdev_8255_mm_init); + +/** + * subdev_8255_cb_init - initialize DIO subdevice for driving callback-mapped 8255 + * @dev: comedi device owning subdevice + * @s: comedi subdevice to initialize + * @io: register I/O call-back function + * @context: call-back context + * + * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip. + * + * The prototype of the I/O call-back function is of the following form: * * int my_8255_callback(struct comedi_device *dev, int dir, int port, - * int data, unsigned long regbase); + * int data, unsigned long context); * - * where 'dev', and 'regbase' match the values passed to this function, + * where 'dev', and 'context' match the values passed to this function, * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir' * is the direction (0 for read, 1 for write) and 'data' is the value to be * written. It should return 0 if writing or the value read if reading. * - * If the optional I/O call-back function is not provided, an internal - * call-back function is used which uses consecutive MMIO virtual addresses - * starting at dev->mmio + regbase. * * Return: -ENOMEM if failed to allocate memory, zero on success. */ -int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, +int subdev_8255_cb_init(struct comedi_device *dev, struct comedi_subdevice *s, int (*io)(struct comedi_device *dev, int dir, int port, - int data, unsigned long regbase), - unsigned long regbase) + int data, unsigned long context), + unsigned long context) { - return __subdev_8255_init(dev, s, io, regbase, true); + return __subdev_8255_init(dev, s, io, context); } -EXPORT_SYMBOL_GPL(subdev_8255_mm_init); +EXPORT_SYMBOL_GPL(subdev_8255_cb_init); /** * subdev_8255_regbase - get offset of 8255 registers or call-back context * @s: comedi subdevice * - * Returns the 'regbase' parameter that was previously passed to - * subdev_8255_init() or subdev_8255_mm_init() to set up the subdevice. - * Only valid if the subdevice was set up successfully. + * Returns the 'regbase' or 'context' parameter that was previously passed to + * subdev_8255_io_init(), subdev_8255_mm_init(), or subdev_8255_cb_init() to + * set up the subdevice. Only valid if the subdevice was set up successfully. */ unsigned long subdev_8255_regbase(struct comedi_subdevice *s) { struct subdev_8255_private *spriv = s->private; - return spriv->regbase; + return spriv->context; } EXPORT_SYMBOL_GPL(subdev_8255_regbase); diff --git a/drivers/comedi/drivers/daqboard2000.c b/drivers/comedi/drivers/daqboard2000.c index c0a4e1b06fb3..897bf46b95ee 100644 --- a/drivers/comedi/drivers/daqboard2000.c +++ b/drivers/comedi/drivers/daqboard2000.c @@ -738,8 +738,8 @@ static int db2k_auto_attach(struct comedi_device *dev, unsigned long context) return result; s = &dev->subdevices[2]; - return subdev_8255_init(dev, s, db2k_8255_cb, - DB2K_REG_DIO_P2_EXP_IO_8_BIT); + return subdev_8255_cb_init(dev, s, db2k_8255_cb, + DB2K_REG_DIO_P2_EXP_IO_8_BIT); } static void db2k_detach(struct comedi_device *dev) diff --git a/drivers/comedi/drivers/das08.c b/drivers/comedi/drivers/das08.c index 6a3b5411aa90..5d5b9174f88a 100644 --- a/drivers/comedi/drivers/das08.c +++ b/drivers/comedi/drivers/das08.c @@ -429,7 +429,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s = &dev->subdevices[4]; /* 8255 */ if (board->i8255_offset != 0) { - ret = subdev_8255_init(dev, s, NULL, board->i8255_offset); + ret = subdev_8255_io_init(dev, s, board->i8255_offset); if (ret) return ret; } else { diff --git a/drivers/comedi/drivers/das16.c b/drivers/comedi/drivers/das16.c index bfe8811be1b5..4ed56a02150e 100644 --- a/drivers/comedi/drivers/das16.c +++ b/drivers/comedi/drivers/das16.c @@ -1145,7 +1145,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* 8255 Digital I/O subdevice */ if (board->has_8255) { s = &dev->subdevices[4]; - ret = subdev_8255_init(dev, s, NULL, board->i8255_offset); + ret = subdev_8255_io_init(dev, s, board->i8255_offset); if (ret) return ret; } diff --git a/drivers/comedi/drivers/das16m1.c b/drivers/comedi/drivers/das16m1.c index ff9c5a8897bd..b8ea737ad3d1 100644 --- a/drivers/comedi/drivers/das16m1.c +++ b/drivers/comedi/drivers/das16m1.c @@ -583,7 +583,7 @@ static int das16m1_attach(struct comedi_device *dev, /* Digital I/O subdevice (8255) */ s = &dev->subdevices[3]; - ret = subdev_8255_init(dev, s, NULL, DAS16M1_8255_IOBASE); + ret = subdev_8255_io_init(dev, s, DAS16M1_8255_IOBASE); if (ret) return ret; diff --git a/drivers/comedi/drivers/dmm32at.c b/drivers/comedi/drivers/dmm32at.c index fe023c722aa3..644e3b643c79 100644 --- a/drivers/comedi/drivers/dmm32at.c +++ b/drivers/comedi/drivers/dmm32at.c @@ -599,7 +599,8 @@ static int dmm32at_attach(struct comedi_device *dev, /* Digital I/O subdevice */ s = &dev->subdevices[2]; - return subdev_8255_init(dev, s, dmm32at_8255_io, DMM32AT_8255_IOBASE); + return subdev_8255_cb_init(dev, s, dmm32at_8255_io, + DMM32AT_8255_IOBASE); } static struct comedi_driver dmm32at_driver = { diff --git a/drivers/comedi/drivers/ni_atmio16d.c b/drivers/comedi/drivers/ni_atmio16d.c index 9fa902529a8e..e5e7cc423c87 100644 --- a/drivers/comedi/drivers/ni_atmio16d.c +++ b/drivers/comedi/drivers/ni_atmio16d.c @@ -677,7 +677,7 @@ static int atmio16d_attach(struct comedi_device *dev, /* 8255 subdevice */ s = &dev->subdevices[3]; if (board->has_8255) { - ret = subdev_8255_init(dev, s, NULL, 0x00); + ret = subdev_8255_io_init(dev, s, 0x00); if (ret) return ret; } else { diff --git a/drivers/comedi/drivers/ni_daq_dio24.c b/drivers/comedi/drivers/ni_daq_dio24.c index 487733111023..9419caf02edc 100644 --- a/drivers/comedi/drivers/ni_daq_dio24.c +++ b/drivers/comedi/drivers/ni_daq_dio24.c @@ -45,7 +45,7 @@ static int dio24_auto_attach(struct comedi_device *dev, /* 8255 dio */ s = &dev->subdevices[0]; - return subdev_8255_init(dev, s, NULL, 0x00); + return subdev_8255_io_init(dev, s, 0x00); } static struct comedi_driver driver_dio24 = { diff --git a/drivers/comedi/drivers/ni_labpc_common.c b/drivers/comedi/drivers/ni_labpc_common.c index eb8f6431276a..5d5c1d0e9cb6 100644 --- a/drivers/comedi/drivers/ni_labpc_common.c +++ b/drivers/comedi/drivers/ni_labpc_common.c @@ -1287,9 +1287,9 @@ int labpc_common_attach(struct comedi_device *dev, /* 8255 dio */ s = &dev->subdevices[2]; if (dev->mmio) - ret = subdev_8255_mm_init(dev, s, NULL, DIO_BASE_REG); + ret = subdev_8255_mm_init(dev, s, DIO_BASE_REG); else - ret = subdev_8255_init(dev, s, NULL, DIO_BASE_REG); + ret = subdev_8255_io_init(dev, s, DIO_BASE_REG); if (ret) return ret; diff --git a/drivers/comedi/drivers/ni_mio_common.c b/drivers/comedi/drivers/ni_mio_common.c index d39998565808..638be08b43e4 100644 --- a/drivers/comedi/drivers/ni_mio_common.c +++ b/drivers/comedi/drivers/ni_mio_common.c @@ -6137,8 +6137,8 @@ static int ni_E_init(struct comedi_device *dev, /* 8255 device */ s = &dev->subdevices[NI_8255_DIO_SUBDEV]; if (board->has_8255) { - ret = subdev_8255_init(dev, s, ni_8255_callback, - NI_E_8255_BASE); + ret = subdev_8255_cb_init(dev, s, ni_8255_callback, + NI_E_8255_BASE); if (ret) return ret; } else { diff --git a/drivers/comedi/drivers/pcl724.c b/drivers/comedi/drivers/pcl724.c index 948a0576c9ef..00474710b81f 100644 --- a/drivers/comedi/drivers/pcl724.c +++ b/drivers/comedi/drivers/pcl724.c @@ -124,10 +124,10 @@ static int pcl724_attach(struct comedi_device *dev, s = &dev->subdevices[i]; if (board->is_pet48) { iobase = dev->iobase + (i * 0x1000); - ret = subdev_8255_init(dev, s, pcl724_8255mapped_io, - iobase); + ret = subdev_8255_cb_init(dev, s, pcl724_8255mapped_io, + iobase); } else { - ret = subdev_8255_init(dev, s, NULL, i * I8255_SIZE); + ret = subdev_8255_io_init(dev, s, i * I8255_SIZE); } if (ret) return ret; diff --git a/drivers/comedi/drivers/pcm3724.c b/drivers/comedi/drivers/pcm3724.c index ca8bef54dacc..fb41de3baef8 100644 --- a/drivers/comedi/drivers/pcm3724.c +++ b/drivers/comedi/drivers/pcm3724.c @@ -204,7 +204,7 @@ static int pcm3724_attach(struct comedi_device *dev, for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; - ret = subdev_8255_init(dev, s, NULL, i * I8255_SIZE); + ret = subdev_8255_io_init(dev, s, i * I8255_SIZE); if (ret) return ret; s->insn_config = subdev_3724_insn_config; diff --git a/include/linux/comedi/comedi_8255.h b/include/linux/comedi/comedi_8255.h index b2a5bc6b3a49..b396fcfbf8b0 100644 --- a/include/linux/comedi/comedi_8255.h +++ b/include/linux/comedi/comedi_8255.h @@ -27,16 +27,17 @@ struct comedi_device; struct comedi_subdevice; -int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *dev, int dir, int port, - int data, unsigned long regbase), - unsigned long regbase); +int subdev_8255_io_init(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned long regbase); int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io)(struct comedi_device *dev, int dir, int port, - int data, unsigned long regbase), unsigned long regbase); +int subdev_8255_cb_init(struct comedi_device *dev, struct comedi_subdevice *s, + int (*io)(struct comedi_device *dev, int dir, int port, + int data, unsigned long context), + unsigned long context); + unsigned long subdev_8255_regbase(struct comedi_subdevice *s); #endif From patchwork Wed Sep 13 17:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp151287vqi; Wed, 13 Sep 2023 23:37:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTBQTb5Ex5OqWs96mVocLZ7UvzCdM546/731KKAshbjJf7cGnRTvjKthX0JUMQMLrnVtbc X-Received: by 2002:a17:90b:4b4e:b0:26b:49de:13bd with SMTP id mi14-20020a17090b4b4e00b0026b49de13bdmr4456469pjb.36.1694673467169; Wed, 13 Sep 2023 23:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694673467; cv=none; d=google.com; s=arc-20160816; b=AuDdXUCHiHYx41KTtrenKofPhnAlP4X00lOEyszcmIsEdltL4MF0eBnE56LqGZd6yM 85uxiBgXspIHtsnvV6k19dbASui+2BLmqZ3nrZjXLJZVi+EnlJ2b0wGWhcc/XaDiCtIq KLxdbvoER9eDUpJIyWVR1shriZbawFrde3z8t4kJpLzD1EKqTd053BdLg36BNshbf8qc R2ehMlfxxY37TkRvrDOcAPvsYmoVBTfTOpUrWHNpDuc7cGsmP8KT80WxgtEI87NKciAx mzjbW81OU2C6qRNlYYJbAei67YCeWdwskAfXpwIq/2EjQQ4WyDd+d/kP562j1ez58UWG 5OyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=evpAjqvtyBJWvQfvCbwJ99VA8XTPGtvFYmQ6sHd6BAU=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=jI3geqNwX3wFkD/w2pVOtGp2xGziOUsFabbosynLEYlQ1sP43SIwrlndz9cLitGnzR NT8JLtUCMR3D4K0jsbTXVnhOOAy5stEhQ7lzzBR+ViTPZaYcLM9AzPw5GqE5YssQtolk EF01rk/MZ8nCNdURyMcCjVqWJIKsBtKfqv0lp6fnLHbiLvX87Uiw314CIQZqU/UAfjzF sUbM0G78fKL5FdeE0Qhg4p+kGf3DnggmF72IrMSlvTmCUmuytjd1Tvj7vi7s9r2XvNA2 EC4CrhlRW7rhc57hy3JYnkoFqFVs7HXM5FyywJ0/NZGNQBesyklt8pGPzwaOe7YPnsmZ zNgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=pig1GM0c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e5-20020a17090a804500b002681dc4472esi3046343pjw.134.2023.09.13.23.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 23:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=pig1GM0c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B1E778104F6D; Wed, 13 Sep 2023 10:08:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbjIMRHw (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbjIMRHh (ORCPT ); Wed, 13 Sep 2023 13:07:37 -0400 Received: from smtp112.iad3a.emailsrvr.com (smtp112.iad3a.emailsrvr.com [173.203.187.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB351BD6 for ; Wed, 13 Sep 2023 10:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624852; bh=T1VSgJgZFQT7hlTIaOmx6j9S8YLzd9tknmB5plLkuJo=; h=From:To:Subject:Date:From; b=pig1GM0ccDUY3HoHYwxFALB8TnQ32akaeK3N2QXhG6XND9sgKDydSUY+Y59cdE4Kb IPwx+DQqfVlNPbODwoX5ECXrxVFhVjk1AoZZfI6O+DRErouuahl64gRSmWDTKBoBo7 jxcHvi4iiZlPoT8roUEZ2rdGFomrRAEVxMHIBwkw= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id D0458425E; Wed, 13 Sep 2023 13:07:31 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 08/13] comedi: ni_labpc_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:07 +0100 Message-Id: <20230913170712.111719-9-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-9-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:08 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941559609477941 X-GMAIL-MSGID: 1776993925724217187 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 ni_labpc_common module is used by the ni_labpc module (for ISA cards), the ni_labpc_cs module (for PCMCIA cards), and the ni_labpc_pci module (for PCI cards). The ISA and PCMCIA cards use port I/O and the PCI cards use memory-mapped I/O. Conditionally compile the parts of the module that use the port I/O functions so they are compiled if and only if the `CONFIG_HAS_IOPORT` macro is defined, so that the module can be built if the port I/O functions have not been declared. Add a run-time check in the `labpc_common_attach()` to return an error if the comedi device wants to use port I/O when the `CONFIG_HAS_IOPORT` macro is undefined. The changes allow the module to be built even if the port I/O functions have not been declared. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT`. Edit commit message to describe run-time check in `labpc_common_attach()`, and to mention that the changes allow the module to be built even if the port I/O functions have not been declared. v3: N/A. --- drivers/comedi/drivers/ni_labpc_common.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/comedi/drivers/ni_labpc_common.c b/drivers/comedi/drivers/ni_labpc_common.c index 5d5c1d0e9cb6..7e0ce0ce0adf 100644 --- a/drivers/comedi/drivers/ni_labpc_common.c +++ b/drivers/comedi/drivers/ni_labpc_common.c @@ -78,6 +78,9 @@ static const struct comedi_lrange range_labpc_ao = { * functions that do inb/outb and readb/writeb so we can use * function pointers to decide which to use */ + +#ifdef CONFIG_HAS_IOPORT + static unsigned int labpc_inb(struct comedi_device *dev, unsigned long reg) { return inb(dev->iobase + reg); @@ -89,6 +92,8 @@ static void labpc_outb(struct comedi_device *dev, outb(byte, dev->iobase + reg); } +#endif /* CONFIG_HAS_IOPORT */ + static unsigned int labpc_readb(struct comedi_device *dev, unsigned long reg) { return readb(dev->mmio + reg); @@ -1200,8 +1205,12 @@ int labpc_common_attach(struct comedi_device *dev, devpriv->read_byte = labpc_readb; devpriv->write_byte = labpc_writeb; } else { +#ifdef CONFIG_HAS_IOPORT devpriv->read_byte = labpc_inb; devpriv->write_byte = labpc_outb; +#else + return -ENXIO; +#endif } /* initialize board's command registers */ From patchwork Wed Sep 13 17:07:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139085 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp81105vqb; Wed, 13 Sep 2023 13:56:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdb7OC+cqrP5SQHEwT/WZgVmgsTjGWrQZ1E9+z1d8wkQ/lwxudeXaLdf32tQl5V9705hgU X-Received: by 2002:a05:6a00:1a14:b0:68a:31b2:5219 with SMTP id g20-20020a056a001a1400b0068a31b25219mr4129959pfv.22.1694638576610; Wed, 13 Sep 2023 13:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694638576; cv=none; d=google.com; s=arc-20160816; b=yIq4j1zMlK+kFENpiTtk+bPW2Id546XGddX10jOfrFBEc4JTAIRuMgLyOM6lBJLG5v K3exwi8C5OUU6Gc0fT2nNsCzTiCQzi7o8qh1/ATt4kEB5NCrlQ1OpeNNVlILYuIRnGVv VMS7uLwSJTM37TXxpR2kv6vSVonPfQPQqbS+wZDbl4gGClr+KL6l4lPuR8F2xFsS+Knu yUjS8P1f1lJ7iOdPlPNHEJqqulRw3JNv//PNbqFRqEwmRh237r6Y9IFRkNq4CBkzdlbn DgQmf7Lhl2733wljIN90jSaMyxts9Q9P4lCu9KnfpPEtpFM+9fUvlL1Gtyh9kpfo25B3 WTog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jLIpLJ60BvEh8SAPBLAA/u5DGkIlTq0S8iTBGlhGXPg=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=wBdY/LF/WkN4i5X5TgsikAiZ67yL7JAhxcfyAWNF3TiPU6Yu0O7bw3elSNNyGqO4lF JF+GjCHhUzFSLxidMgb8F0dCjXSNpFltTSftNrGOg090LPjDqN2+rtIwlx8HNgtmuNEc SWERcLDQm8EYfZTF5o2WuTjOhZgIXCf1sT8J+j03zB20SdTXUFTWCu3SB34thqom+o0c 7OonpZzsXMt45fwnOGUrha0lSSVLs2+2IZStA8Op9ij36oOxuUXCbXL/EGyz4F35aPWb Hg6duV7kpcwrHGPf93QXiASyaXLtm16oATIi4v3uvPftECFgn52s3HkHaK2KFqn2T83b 9dGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=A2Og4qbn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j22-20020a056a00235600b00687008df88dsi46789pfj.52.2023.09.13.13.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=A2Og4qbn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 25EA281129B7; Wed, 13 Sep 2023 10:08:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbjIMRH6 (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjIMRHp (ORCPT ); Wed, 13 Sep 2023 13:07:45 -0400 Received: from smtp115.iad3a.emailsrvr.com (smtp115.iad3a.emailsrvr.com [173.203.187.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 234811BE4 for ; Wed, 13 Sep 2023 10:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624854; bh=JgtIYmwmV6xYy/QUX+4Tkq/fmp98+9vB4JgNe0IQwNA=; h=From:To:Subject:Date:From; b=A2Og4qbnBND7NV5B9mvFsrIz/09mMXpRlPFsbcoOSb6iR+HXm5ano8s9YpoW5182M t5P63jFv8mcbooqgWOFlKvCvcwaoR8/niSdeaZylNJCG6vGtp3XQIQ+8yF1nVQ985h UAbbaEieNfGbHnr7Vwqh8LHGFZuXxoFOnafK9vD8= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 3270C54E5; Wed, 13 Sep 2023 13:07:33 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 09/13] comedi: ni_mio_common: Conditionally use I/O port or MMIO Date: Wed, 13 Sep 2023 18:07:08 +0100 Message-Id: <20230913170712.111719-10-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-10-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776943405693878580 X-GMAIL-MSGID: 1776957339817268085 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 "ni_mio_common.c" file contains calls to both port I/O functions and memory-mapped I/O functions. The file is `#include`d by "ni_atmio.c", "ni_mio_cs.c", and "ni_pcimio.c" for the ni_atmio, ni_mio_cs, and ni_pcimio modules, respectively. Only "ni_pcimio.c" defines the `PCIDMA` macro before including "ni_mio_common.c" and various bits of code in "ni_mio_common.c" is conditionally compiled according to whether that macro is defined or not. Currently, the port I/O function calls are compiled in regardless of whether the `PCIDMA` macro is defined or not. However, the fact is that the ni_atmio and ni_mio_cs modules will never call the memory-mapped I/O functions, and the ni_pcimio module will never call the port I/O functions. Calls to the port I/O and memory-mapped I/O functions is confined to the `ni_writel()`, `ni_writew()`, `ni_writeb()`, `ni_readl()`, `ni_readw()`, and `ni_readb()` functions which do a run-time test to decide whether to call the port I/O functions or the memory-mapped I/O functions. Conditionally compile two variants of the functions so they only call the port I/O functions if the `PCIDMA` macro is undefined (for the ni_atmio and ni_mio_cs modules), and only call the memory-mapped I/O functions if the `PCIDMA` macro is defined (for the ni_pcimio module). Add a run-time check in the `ni_E_init()` function to return an error if the comedi device has been set up to use port I/O if `PCIDMA` is defined, or has been set up to use memory-mapped I/O if `PCIDMA` is not defined. The changes make it possible to build the ni_pcimio module even if the port I/O functions have not been declared. (The ni_atmio and ni_mio_cs modules do still require the port I/O functions to be declared.) Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: N/A. v3: Add missing `---` divider before patch changelog. --- drivers/comedi/drivers/ni_mio_common.c | 70 ++++++++++++++++++-------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/drivers/comedi/drivers/ni_mio_common.c b/drivers/comedi/drivers/ni_mio_common.c index 638be08b43e4..980f309d6de7 100644 --- a/drivers/comedi/drivers/ni_mio_common.c +++ b/drivers/comedi/drivers/ni_mio_common.c @@ -46,6 +46,12 @@ #include #include "mite.h" +#ifdef PCIDMA +#define IS_PCIMIO 1 +#else +#define IS_PCIMIO 0 +#endif + /* A timeout count */ #define NI_TIMEOUT 1000 @@ -219,54 +225,72 @@ enum timebase_nanoseconds { static const int num_adc_stages_611x = 3; +#ifdef PCIDMA + static void ni_writel(struct comedi_device *dev, unsigned int data, int reg) { - if (dev->mmio) - writel(data, dev->mmio + reg); - else - outl(data, dev->iobase + reg); + writel(data, dev->mmio + reg); } static void ni_writew(struct comedi_device *dev, unsigned int data, int reg) { - if (dev->mmio) - writew(data, dev->mmio + reg); - else - outw(data, dev->iobase + reg); + writew(data, dev->mmio + reg); } static void ni_writeb(struct comedi_device *dev, unsigned int data, int reg) { - if (dev->mmio) - writeb(data, dev->mmio + reg); - else - outb(data, dev->iobase + reg); + writeb(data, dev->mmio + reg); } static unsigned int ni_readl(struct comedi_device *dev, int reg) { - if (dev->mmio) - return readl(dev->mmio + reg); + return readl(dev->mmio + reg); +} + +static unsigned int ni_readw(struct comedi_device *dev, int reg) +{ + return readw(dev->mmio + reg); +} + +static unsigned int ni_readb(struct comedi_device *dev, int reg) +{ + return readb(dev->mmio + reg); +} +#else /* PCIDMA */ + +static void ni_writel(struct comedi_device *dev, unsigned int data, int reg) +{ + outl(data, dev->iobase + reg); +} + +static void ni_writew(struct comedi_device *dev, unsigned int data, int reg) +{ + outw(data, dev->iobase + reg); +} + +static void ni_writeb(struct comedi_device *dev, unsigned int data, int reg) +{ + outb(data, dev->iobase + reg); +} + +static unsigned int ni_readl(struct comedi_device *dev, int reg) +{ return inl(dev->iobase + reg); } static unsigned int ni_readw(struct comedi_device *dev, int reg) { - if (dev->mmio) - return readw(dev->mmio + reg); - return inw(dev->iobase + reg); } static unsigned int ni_readb(struct comedi_device *dev, int reg) { - if (dev->mmio) - return readb(dev->mmio + reg); - return inb(dev->iobase + reg); } +#endif /* PCIDMA */ + /* * We automatically take advantage of STC registers that can be * read/written directly in the I/O space of the board. @@ -5977,6 +6001,12 @@ static int ni_E_init(struct comedi_device *dev, int i; const char *dev_family = devpriv->is_m_series ? "ni_mseries" : "ni_eseries"; + if (!IS_PCIMIO != !dev->mmio) { + dev_err(dev->class_dev, + "%s: bug! %s device not supported.\n", + KBUILD_MODNAME, board->name); + return -ENXIO; + } /* prepare the device for globally-named routes. */ if (ni_assign_device_routes(dev_family, board->name, From patchwork Wed Sep 13 17:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp142898vqb; Wed, 13 Sep 2023 16:12:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4oW+72bPLVWmc2IQ9Dx08cZws3Zoq0Vym12THMOReV8dHP16lU3ltWA/pByrxameIrZ5F X-Received: by 2002:a05:6a20:258c:b0:132:2f7d:29ca with SMTP id k12-20020a056a20258c00b001322f7d29camr4587506pzd.24.1694646733892; Wed, 13 Sep 2023 16:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694646733; cv=none; d=google.com; s=arc-20160816; b=dQwHXVrygSUfWP7bE6InLBX+EkiGu9E2/zEyHdhzKfz4nxH4kJvvO9COlBqss6HId1 Nn+XUPhTEwB458B/M4RM/XqBjjJpCp/VxueS7fpvoDxopnzRE1R3GThabzxYi9mdiJPa WxO40xdIL4RafgTNG48sLz1ZxPh/fQ9stGXumhG5nHQGrNREhY1jIHamVwAJPgROrUWA L6/wAZb+qJGegVb3AXPSD392jDOR+K41eoqdDrIULdwDmHDBh15NLUWx2EzzqNZXe989 uvnDDoCssLhv4oDwYlOfn3Wz8bqSY0YffGr8PUoaHwyPgWStwQR5y1atThnSu2tThAs3 9a7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iJSN1iZa7hdgh5d8m9t2mMc2bey6fDHRoR/BHz2cYLA=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=g5DhjTETC42vuar+UwGpMKkteITqw0KtCyy5O+7N6MJBks2/V1kgF+VVrFjHE5Gsm2 a+zdYItR27T+Bp9TxuDTwNgvqDkZGhYbIQKSAsCgLRjTz8EDaUbl844Pb2AsiWX2/zgL SNOOsdosP/lcKZZufAZ7xUuxvFSfi0BfDCeGNegQKowAFgMpT4cPMM+070CPCb1rRxhD VByt8i7SS/hPSzf1JCmemwf9spKGRqo3W4VLfwmag+t0WMoKRLcEpA2xaIkAnf2npcNH F/1DGkEvRJNy5Neg2Z4SW5aXvvax7CiwPdcuDWrgIbPYRX4albkf/FCKuMZTO4sd9O+o 3KOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=rAuxQDym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id dc14-20020a056a0035ce00b0068fc7938a28si218621pfb.397.2023.09.13.16.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:12:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=rAuxQDym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 377618320DE9; Wed, 13 Sep 2023 10:08:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231559AbjIMRIB (ORCPT + 35 others); Wed, 13 Sep 2023 13:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjIMRHr (ORCPT ); Wed, 13 Sep 2023 13:07:47 -0400 Received: from smtp113.iad3a.emailsrvr.com (smtp113.iad3a.emailsrvr.com [173.203.187.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49D631BF7 for ; Wed, 13 Sep 2023 10:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624855; bh=EjhvuulNlVaLF3hxEmMYJQOlca3ygkvwLuUu4uXCAWc=; h=From:To:Subject:Date:From; b=rAuxQDymRMZ2c2G9vHeAf5R7LOUvhrWa5FwutAjN5CHWGZh9THPdL4875kuoi4+AH 3VYFrmg/7IjPs/QKdbHgPlx3mDzMSAbKxLDvHkqXbspy57Ebc0ssGjvYuPbrwHbfj+ yvBYZYozngh6McFNLY/BDlVr4O4/qgHACmTl0Cl8= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 85C655531; Wed, 13 Sep 2023 13:07:34 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 10/13] comedi: amplc_dio200_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 18:07:09 +0100 Message-Id: <20230913170712.111719-11-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-11-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776945764194109354 X-GMAIL-MSGID: 1776965893900290090 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 amplc_dio200_pci module supports various Amplicon PCI and PCI Express devices. Some of the supported devices (the PCI ones) use port I/O, and some of them (the PCIe ones) 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. Add a run-time check in `dio200_pci_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 option is not enabled. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT` in commit description. v3: N/A. --- drivers/comedi/drivers/amplc_dio200_pci.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/comedi/drivers/amplc_dio200_pci.c b/drivers/comedi/drivers/amplc_dio200_pci.c index 527994d82a1f..cb5b328a28e3 100644 --- a/drivers/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/comedi/drivers/amplc_dio200_pci.c @@ -223,14 +223,17 @@ */ enum dio200_pci_model { +#ifdef CONFIG_HAS_IOPORT pci215_model, pci272_model, +#endif /* CONFIG_HAS_IOPORT */ pcie215_model, pcie236_model, pcie296_model }; static const struct dio200_board dio200_pci_boards[] = { +#ifdef CONFIG_HAS_IOPORT [pci215_model] = { .name = "pci215", .mainbar = 2, @@ -252,6 +255,7 @@ static const struct dio200_board dio200_pci_boards[] = { .sdinfo = { 0x00, 0x08, 0x10, 0x3f }, .has_int_sce = true, }, +#endif /* CONFIG_HAS_IOPORT */ [pcie215_model] = { .name = "pcie215", .mainbar = 1, @@ -364,8 +368,12 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, "error! cannot remap registers\n"); return -ENOMEM; } - } else { + } else if (IS_ENABLED(CONFIG_HAS_IOPORT)) { dev->iobase = pci_resource_start(pci_dev, bar); + } else { + dev_err(dev->class_dev, + "error! need I/O port support\n"); + return -ENXIO; } if (board->is_pcie) { @@ -385,8 +393,10 @@ static struct comedi_driver dio200_pci_comedi_driver = { }; static const struct pci_device_id dio200_pci_table[] = { +#ifdef CONFIG_HAS_IOPORT { PCI_VDEVICE(AMPLICON, 0x000b), pci215_model }, { PCI_VDEVICE(AMPLICON, 0x000a), pci272_model }, +#endif /* CONFIG_HAS_IOPORT */ { PCI_VDEVICE(AMPLICON, 0x0011), pcie236_model }, { PCI_VDEVICE(AMPLICON, 0x0012), pcie215_model }, { PCI_VDEVICE(AMPLICON, 0x0014), pcie296_model }, From patchwork Wed Sep 13 17:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp178391vqi; Thu, 14 Sep 2023 00:46:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEfMMFjsAf+zz3vlaKlKY+qTdDg0LYbDWENCOWvUnRXDhtD6j7omEcm1LRISu6eVYYoN0q X-Received: by 2002:a17:90b:4acf:b0:263:f4cc:a988 with SMTP id mh15-20020a17090b4acf00b00263f4cca988mr4552722pjb.5.1694677598236; Thu, 14 Sep 2023 00:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694677598; cv=none; d=google.com; s=arc-20160816; b=KbhwY5/Z/TKFXyh+5/7ZwE85dME9V4H+BfGMGJ7Lnn+G7b7lra1QOJYGGXDW16sa2e 2Dt+aIRdWrcXDyg9WmVDV+86ece9srIDk9qikuVy4qtjaYpM86YsVebr0uga0kRSc+Ol vkeVDlHis1lODVIkGrtp/S/ErrOFsBETc47FmBg35GD1Cq/q3P48ZR2GQvHepcdZTZ4u oD0KZ0l70mRH53EIUpPeQHJFtIpnZiHjB29UKWVNDXXgWvH0YNVk0VBseZx0nLOlOXLn yaktLwsY5MFSA86zr1v9sr255NFaKtHz05dMPAfa+V59vRZwFLrQJ68Y/2RzYYpmDsSn Bi7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zovre+NnhUMGhOe7jQl9tW++eT//p/nK1ciGC0rd9Tk=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=Ax0oTzXs41zkzwQ0PKyg2kfrq5n3q4z2mbpTl4w0MKrKrqM2n0oyxd+DxJMHTAgoIK roczFo4Peepq8XhpGYJSLcC2uZFYd6SyofAYCNlFWZ51b41a/uQXeuKNBigNHpnY4/q3 chnU0zDNKs3p5txsSI8tYtG1GPXYwWtgONYlthgT4rw628pvCSEtO6UG+RhTqlEzrFqb u7ylKe9U+gOrlYeK3U4V6nkGl5h4/DRkzxQiVpS8sXPxe4lJBCSuaZi4mkGa+vdJONYL YKwY8Ml6vaeU0Zp8GRtQU3fzDwSEyZMTzgPo2zNuciM7KVxw35ebpYQnCEuGg7XLBQs0 58Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=lOBme9cQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v21-20020a17090a521500b0026f4d1e6940si372852pjh.160.2023.09.14.00.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 00:46:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=lOBme9cQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 85809809248D; Wed, 13 Sep 2023 10:08:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231715AbjIMRIK (ORCPT + 35 others); Wed, 13 Sep 2023 13:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbjIMRHt (ORCPT ); Wed, 13 Sep 2023 13:07:49 -0400 Received: from smtp112.iad3a.emailsrvr.com (smtp112.iad3a.emailsrvr.com [173.203.187.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDABF1FD4 for ; Wed, 13 Sep 2023 10:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624856; bh=LVG4pa4at5j33GVC1eLu+Pgx6Tm/UOqR60TbS2+ntqk=; h=From:To:Subject:Date:From; b=lOBme9cQepKZx5EK+P5udqI7NWj0IAWTfbVQAXdrL8Fp+qKHdd2GeMj5/OzkgGHuL jRZJ2NvkGfdjsKjbB2k4HY2rjyWsl7vEA+qnlf0Tjf1nOGCTtFxYqW95STaHgXKax0 XTYZjPLo+XBNeDE1quFQh1195vhg47Yoois/90Dw= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id D746E4277; Wed, 13 Sep 2023 13:07:35 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 11/13] comedi: amplc_dio200_common: Refactor register access functions Date: Wed, 13 Sep 2023 18:07:10 +0100 Message-Id: <20230913170712.111719-12-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-12-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:22 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776946490385212652 X-GMAIL-MSGID: 1776998257393434495 The `dio200_read8()`, `dio200_write8()`, `dio200_read32()` and `dio200_write32()` functions apply a right-shift to the register offset for some devices and then perform the actual register access. Factor the register access part out to new functions `dio200___read8()`, `dio200___write8()`, `dio200___read32()`, and `dio200___write32()`. This will reduce duplicated code in a subsequent patch that will conditionally compile support for port I/O as part of the `HAS_IOPORT` changes. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `HAS_PORTIO` to `HAS_IOPORT` in commit description. v3: N/A. --- drivers/comedi/drivers/amplc_dio200_common.c | 52 ++++++++++++++------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/comedi/drivers/amplc_dio200_common.c b/drivers/comedi/drivers/amplc_dio200_common.c index 19166cb26f5e..e6d63e89e7bf 100644 --- a/drivers/comedi/drivers/amplc_dio200_common.c +++ b/drivers/comedi/drivers/amplc_dio200_common.c @@ -86,6 +86,40 @@ struct dio200_subdev_intr { unsigned int active:1; }; +static unsigned char dio200___read8(struct comedi_device *dev, + unsigned int offset) +{ + if (dev->mmio) + return readb(dev->mmio + offset); + return inb(dev->iobase + offset); +} + +static void dio200___write8(struct comedi_device *dev, + unsigned int offset, unsigned char val) +{ + if (dev->mmio) + writeb(val, dev->mmio + offset); + else + outb(val, dev->iobase + offset); +} + +static unsigned int dio200___read32(struct comedi_device *dev, + unsigned int offset) +{ + if (dev->mmio) + return readl(dev->mmio + offset); + return inl(dev->iobase + offset); +} + +static void dio200___write32(struct comedi_device *dev, + unsigned int offset, unsigned int val) +{ + if (dev->mmio) + writel(val, dev->mmio + offset); + else + outl(val, dev->iobase + offset); +} + static unsigned char dio200_read8(struct comedi_device *dev, unsigned int offset) { @@ -94,9 +128,7 @@ static unsigned char dio200_read8(struct comedi_device *dev, if (board->is_pcie) offset <<= 3; - if (dev->mmio) - return readb(dev->mmio + offset); - return inb(dev->iobase + offset); + return dio200___read8(dev, offset); } static void dio200_write8(struct comedi_device *dev, @@ -107,10 +139,7 @@ static void dio200_write8(struct comedi_device *dev, if (board->is_pcie) offset <<= 3; - if (dev->mmio) - writeb(val, dev->mmio + offset); - else - outb(val, dev->iobase + offset); + dio200___write8(dev, offset, val); } static unsigned int dio200_read32(struct comedi_device *dev, @@ -121,9 +150,7 @@ static unsigned int dio200_read32(struct comedi_device *dev, if (board->is_pcie) offset <<= 3; - if (dev->mmio) - return readl(dev->mmio + offset); - return inl(dev->iobase + offset); + return dio200___read32(dev, offset); } static void dio200_write32(struct comedi_device *dev, @@ -134,10 +161,7 @@ static void dio200_write32(struct comedi_device *dev, if (board->is_pcie) offset <<= 3; - if (dev->mmio) - writel(val, dev->mmio + offset); - else - outl(val, dev->iobase + offset); + dio200___write32(dev, offset, val); } static unsigned int dio200_subdev_8254_offset(struct comedi_device *dev, From patchwork Wed Sep 13 17:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp192439vqi; Thu, 14 Sep 2023 01:20:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZtzW49VYc87KNIP4rgkAEn4qoOYigpibhR6W5kYKTA8cRGQM3i7ZPwtkA5VXSwzO/L1B4 X-Received: by 2002:a05:6358:16cf:b0:134:d282:92e9 with SMTP id r15-20020a05635816cf00b00134d28292e9mr3275662rwl.29.1694679606124; Thu, 14 Sep 2023 01:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694679606; cv=none; d=google.com; s=arc-20160816; b=yCqUWxW0k3f6aYRv1CsIFvOeHa6ykvaefNyEtPjotr0UZsOPvO2PseyGCAZZxFtoId bdx7An71+j4G4s+p5mzujZZlC/grcJIn5o01N3ewebbZpxCWbM9Hp+n5mMxQl1T2vkAr M5SyKVrY4KQjowbp3wo5uBha4SwZjWeJs6axNcwzrl6bqjuptcubG9Vcl2zZcfTKVeD+ Wf0yvqkT4PgQxBDMjqbjZkN3e7W7f0nGOWDZUk6jsUmRJ0qGvcow2zIGTMyrIJAUEXWf 0WA619r2U4FtKcPnAO6DkmzjOq/5dGcSsAYPfikYT9SearS4PKD3gOniOgfPsTBS072Y dvOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=amwFXyodDrTJg6ZBC1M+yBTzllIDRwvGr/ZccLbTzDE=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=ZSDzqUYNwa4TMtUEyumn7E4jkYF/b8llEdaEb+kvDx8V9zQ8v0YQeG4348I2p8Jlbz rsduXOMzpGcYPzUVfb0Kk+AYMlS/laDXs+vuLDuKqPTXbVKvKik9qSk6P/M3t9A4/rpM jhcY+5sApfJ3SVcK3C57TvsImQwzvLn051W0eI8t8lIj9WrzIY4QThok9mlg6W0wzMCO DiDrkB6aLN+LbexUj1MiAQrFtEsOwx8By7xu1AExsB2Ei5F/HjI2IVJdzk/Pia64rwsD S6FasazynVnq5KIQXx1/wEdsXGtaN3eQB9Gkbrwm2xoTldY5dHOcmquBTWtz4/vn3dwz Jusw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=wJeRn3el; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id x9-20020a654149000000b005659b757791si1026877pgp.384.2023.09.14.01.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 01:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=wJeRn3el; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C017D8514B14; Wed, 13 Sep 2023 10:08:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbjIMRIO (ORCPT + 35 others); Wed, 13 Sep 2023 13:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjIMRHz (ORCPT ); Wed, 13 Sep 2023 13:07:55 -0400 Received: from smtp116.iad3a.emailsrvr.com (smtp116.iad3a.emailsrvr.com [173.203.187.116]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A52B2101 for ; Wed, 13 Sep 2023 10:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624858; bh=6ZFcgRAEUSCWaH0d5A84bNr1FKTGpaMbxStcDrGLGaU=; h=From:To:Subject:Date:From; b=wJeRn3elyNGCOqnk1kBqsKLIFFkWbjwKjLa7l9nQqMghiwJ5AY12yABh0bzfX46s0 Z75nSGsAWhb+SH4DkNZN2kCmcK1vH9oW16CyqHKJYwGVrsyqIv+RiXJGvg3Eg6KVEW +swTRVZDl/pjZTirXLCZybrOd173p6+cre3lVaTk= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 373F554A5; Wed, 13 Sep 2023 13:07:37 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 12/13] comedi: amplc_dio200_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:11 +0100 Message-Id: <20230913170712.111719-13-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-13-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776937908624338410 X-GMAIL-MSGID: 1777000362815765349 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 amplc_dio200_common module is used by the amplc_dio200 module (for ISA cards) and the amplc_dio200_pci module (for PCI and PCI Express cards). It supports both port I/O and memory-mapped I/O. Port I/O and memory-mapped I/O is confined to the `dio200___read8()`, `dio200___read32()`, `dio200___write8()` and `dio200___write32()` functions. Conditionally compile two versions of those functions. If the `CONFIG_HAS_IOPORT` macro is defined, call either the port I/O or memory mapped I/O functions depending on the `mmio` member of the `struct comedi_device`. If the `CONFIG_HAS_IOPORT` macro is undefined only call the memory-mapped I/O functions. Add a run-time check to `amplc_dio200_common_attach()` to return an error if the device wants to use port I/O when the `CONFIG_HAS_IOPORT` macro is undefined. The changes allow the module to be built even if the port I/O functions have not been declared. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT` in commit description. v3: N/A. --- drivers/comedi/drivers/amplc_dio200_common.c | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/comedi/drivers/amplc_dio200_common.c b/drivers/comedi/drivers/amplc_dio200_common.c index e6d63e89e7bf..b1a9b4c4a185 100644 --- a/drivers/comedi/drivers/amplc_dio200_common.c +++ b/drivers/comedi/drivers/amplc_dio200_common.c @@ -86,6 +86,8 @@ struct dio200_subdev_intr { unsigned int active:1; }; +#ifdef CONFIG_HAS_IOPORT + static unsigned char dio200___read8(struct comedi_device *dev, unsigned int offset) { @@ -120,6 +122,34 @@ static void dio200___write32(struct comedi_device *dev, outl(val, dev->iobase + offset); } +#else /* CONFIG_HAS_IOPORT */ + +static unsigned char dio200___read8(struct comedi_device *dev, + unsigned int offset) +{ + return readb(dev->mmio + offset); +} + +static void dio200___write8(struct comedi_device *dev, + unsigned int offset, unsigned char val) +{ + writeb(val, dev->mmio + offset); +} + +static unsigned int dio200___read32(struct comedi_device *dev, + unsigned int offset) +{ + return readl(dev->mmio + offset); +} + +static void dio200___write32(struct comedi_device *dev, + unsigned int offset, unsigned int val) +{ + writel(val, dev->mmio + offset); +} + +#endif /* CONFIG_HAS_IOPORT */ + static unsigned char dio200_read8(struct comedi_device *dev, unsigned int offset) { @@ -803,6 +833,12 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, unsigned int n; int ret; + if (!IS_ENABLED(CONFIG_HAS_IOPORT) && !dev->mmio) { + dev_err(dev->class_dev, + "error! need I/O port support\n"); + return -ENXIO; + } + ret = comedi_alloc_subdevices(dev, board->n_subdevs); if (ret) return ret; From patchwork Wed Sep 13 17:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp153835vqi; Wed, 13 Sep 2023 23:44:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtct2/ksRRAipJBZ+RTQI57hw+1WyYYwDXleChwYUUm0w9DKjFHTa6Zui9eLV/3QW6mPou X-Received: by 2002:a17:90a:a40d:b0:269:7f88:6b13 with SMTP id y13-20020a17090aa40d00b002697f886b13mr4339150pjp.0.1694673878659; Wed, 13 Sep 2023 23:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694673878; cv=none; d=google.com; s=arc-20160816; b=SWwtsZclg77Kj/z7rAV0tm2XIebBxls3bpfHLXCE4hisVwXZmyJbrwJj2lqgWe6LZv tZx1TA8TlpStvDjKAg1xewZWIq3WrJko7xzbXdoQvW1gX1fqSWUzRlZqkLPcGUYzM0pr 1lK5kjjmOagttTJ2ISZgY/JXY8jn63UKSbu7Lx3Ar1B6NC7ldBsls2zILrQshUxWN6R1 oU+Lioc3s6JilHu78SAaGR2bfFjkScs0x61qls8jiMmd7PvpZmU43vXjSzqcCD/X8GM0 ma1g0g/Gw5hH0mpro76pVbiHbgM5pkSvCTSNWGm3nzzq3s0OwdqLrlT6cjwDvh4esiPi zHRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=K4epXitrNterZDkdfrazGMUQbN2wBnDb9eCjDCM0x4Y=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=PyHAkMzrkQ6jwhmR8W4PtA6nW9dLgQSZzREcmGMvpFvYrb/yaUg66+Z4zUHqtVmtXp LddSeVlmWLFIMIPyiYC48IwKGoXa1POFUNjdIDDCEYgNeg+hVqPg8VIaalMn7hnDD6d/ vesYYlk2upCZYXQLLja2/KS0saIViqB7SiZmr8WgwBVlOxxmbCLvaYsM8ZxlRR6sdxZu p0UGfSZoMyriW+O1ee4Np6xkCmYogd43/x4Q0HkSm3MuDoiJF6eI1ordgNneXGrmOPH0 3KoH3qLVOMR67cUZFKOFOy40CaIqUoxojbF96nEcza4Vw0tRLXivV97SFiqVbQa4JFT8 d0qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=ps89mwf8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ls5-20020a17090b350500b0026963a00ab0si1124013pjb.122.2023.09.13.23.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 23:44:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=ps89mwf8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C10FF8514B1C; Wed, 13 Sep 2023 10:08:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbjIMRIR (ORCPT + 35 others); Wed, 13 Sep 2023 13:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjIMRIF (ORCPT ); Wed, 13 Sep 2023 13:08:05 -0400 Received: from smtp113.iad3a.emailsrvr.com (smtp113.iad3a.emailsrvr.com [173.203.187.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB531BFE for ; Wed, 13 Sep 2023 10:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624859; bh=HiudiX32knAM/0pSU87O1MShFDR2dFvDtUufk7ZQrR4=; h=From:To:Subject:Date:From; b=ps89mwf8LLKMa8hjvbCFIXoKnrKM4sawdCkKUCoZElgah1cly0edLXOyRhIcVSLwM 28PyUnI5oMfKSmPrSyW1dCROI7sKbP4L0va0PK/EjYrXlYqCfIN/qNQbdf+ig60x8B b7JinIDK1kBdf2NkvVWp7meJdzYWd7MewUOZyRNU= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 8C31154C7; Wed, 13 Sep 2023 13:07:38 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v3 13/13] comedi: add HAS_IOPORT dependencies again Date: Wed, 13 Sep 2023 18:07:12 +0100 Message-Id: <20230913170712.111719-14-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-14-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776966268434497362 X-GMAIL-MSGID: 1776994356878380913 In a future patch HAS_IOPORT=n will result in inb()/outb() and friends not being declared. We thus need to add HAS_IOPORT as dependency for those drivers using them. This was previously done in commit b5c75b68b7de ("comedi: add HAS_IOPORT dependencies"), but that has been reverted because it made it impossible to select configuration options for several comedi drivers. This is a do-over that avoids that. Since the original patch, modifications have been made to various comedi modules so that they can still be built even if the port I/O functions have not been declared, so the configuration options for building those modules no longer need to depend on HAS_IOPORT. Make the COMEDI_ISA_DRIVERS menu option (which allows configuration options for ISA and PC/104 drivers to be selected) depend on HAS_IOPORT, and also depend on ISA || ISA_BUS || PC104. Co-developed-by: Arnd Bergmann Signed-off-by: Arnd Bergmann Co-developed-by: Niklas Schnelle Signed-off-by: Niklas Schnelle Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: N/A. v3: N/A. --- drivers/comedi/Kconfig | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/comedi/Kconfig b/drivers/comedi/Kconfig index 536101f68e0f..93c68a40a17b 100644 --- a/drivers/comedi/Kconfig +++ b/drivers/comedi/Kconfig @@ -67,6 +67,7 @@ config COMEDI_TEST config COMEDI_PARPORT tristate "Parallel port support" + depends on HAS_IOPORT help Enable support for the standard parallel port. A cheap and easy way to get a few more digital I/O lines. Steal @@ -79,6 +80,7 @@ config COMEDI_PARPORT config COMEDI_SSV_DNP tristate "SSV Embedded Systems DIL/Net-PC support" depends on X86_32 || COMPILE_TEST + depends on HAS_IOPORT help Enable support for SSV Embedded Systems DIL/Net-PC @@ -89,6 +91,8 @@ endif # COMEDI_MISC_DRIVERS menuconfig COMEDI_ISA_DRIVERS bool "Comedi ISA and PC/104 drivers" + depends on ISA || ISA_BUS || PC104 + depends on HAS_IOPORT help Enable comedi ISA and PC/104 drivers to be built @@ -589,6 +593,7 @@ config COMEDI_8255_PCI config COMEDI_ADDI_WATCHDOG tristate + depends on HAS_IOPORT help Provides support for the watchdog subdevice found on many ADDI-DATA boards. This module will be automatically selected when needed. The @@ -596,6 +601,7 @@ config COMEDI_ADDI_WATCHDOG config COMEDI_ADDI_APCI_1032 tristate "ADDI-DATA APCI_1032 support" + depends on HAS_IOPORT help Enable support for ADDI-DATA APCI_1032 cards @@ -604,6 +610,7 @@ config COMEDI_ADDI_APCI_1032 config COMEDI_ADDI_APCI_1500 tristate "ADDI-DATA APCI_1500 support" + depends on HAS_IOPORT help Enable support for ADDI-DATA APCI_1500 cards @@ -612,6 +619,7 @@ config COMEDI_ADDI_APCI_1500 config COMEDI_ADDI_APCI_1516 tristate "ADDI-DATA APCI-1016/1516/2016 support" + depends on HAS_IOPORT select COMEDI_ADDI_WATCHDOG help Enable support for ADDI-DATA APCI-1016, APCI-1516 and APCI-2016 boards. @@ -623,6 +631,7 @@ config COMEDI_ADDI_APCI_1516 config COMEDI_ADDI_APCI_1564 tristate "ADDI-DATA APCI_1564 support" + depends on HAS_IOPORT select COMEDI_ADDI_WATCHDOG help Enable support for ADDI-DATA APCI_1564 cards @@ -632,6 +641,7 @@ config COMEDI_ADDI_APCI_1564 config COMEDI_ADDI_APCI_16XX tristate "ADDI-DATA APCI_16xx support" + depends on HAS_IOPORT help Enable support for ADDI-DATA APCI_16xx cards @@ -640,6 +650,7 @@ config COMEDI_ADDI_APCI_16XX config COMEDI_ADDI_APCI_2032 tristate "ADDI-DATA APCI_2032 support" + depends on HAS_IOPORT select COMEDI_ADDI_WATCHDOG help Enable support for ADDI-DATA APCI_2032 cards @@ -649,6 +660,7 @@ config COMEDI_ADDI_APCI_2032 config COMEDI_ADDI_APCI_2200 tristate "ADDI-DATA APCI_2200 support" + depends on HAS_IOPORT select COMEDI_ADDI_WATCHDOG help Enable support for ADDI-DATA APCI_2200 cards @@ -658,6 +670,7 @@ config COMEDI_ADDI_APCI_2200 config COMEDI_ADDI_APCI_3120 tristate "ADDI-DATA APCI_3120/3001 support" + depends on HAS_IOPORT depends on HAS_DMA help Enable support for ADDI-DATA APCI_3120/3001 cards @@ -667,6 +680,7 @@ config COMEDI_ADDI_APCI_3120 config COMEDI_ADDI_APCI_3501 tristate "ADDI-DATA APCI_3501 support" + depends on HAS_IOPORT help Enable support for ADDI-DATA APCI_3501 cards @@ -675,6 +689,7 @@ config COMEDI_ADDI_APCI_3501 config COMEDI_ADDI_APCI_3XXX tristate "ADDI-DATA APCI_3xxx support" + depends on HAS_IOPORT help Enable support for ADDI-DATA APCI_3xxx cards @@ -683,6 +698,7 @@ config COMEDI_ADDI_APCI_3XXX config COMEDI_ADL_PCI6208 tristate "ADLink PCI-6208A support" + depends on HAS_IOPORT help Enable support for ADLink PCI-6208A cards @@ -691,6 +707,7 @@ config COMEDI_ADL_PCI6208 config COMEDI_ADL_PCI7X3X tristate "ADLink PCI-723X/743X isolated digital i/o board support" + depends on HAS_IOPORT help Enable support for ADlink PCI-723X/743X isolated digital i/o boards. Supported boards include the 32-channel PCI-7230 (16 in/16 out), @@ -702,6 +719,7 @@ config COMEDI_ADL_PCI7X3X config COMEDI_ADL_PCI8164 tristate "ADLink PCI-8164 4 Axes Motion Control board support" + depends on HAS_IOPORT help Enable support for ADlink PCI-8164 4 Axes Motion Control board @@ -710,6 +728,7 @@ config COMEDI_ADL_PCI8164 config COMEDI_ADL_PCI9111 tristate "ADLink PCI-9111HR support" + depends on HAS_IOPORT select COMEDI_8254 help Enable support for ADlink PCI9111 cards @@ -719,6 +738,7 @@ config COMEDI_ADL_PCI9111 config COMEDI_ADL_PCI9118 tristate "ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support" + depends on HAS_IOPORT depends on HAS_DMA select COMEDI_8254 help @@ -729,6 +749,7 @@ config COMEDI_ADL_PCI9118 config COMEDI_ADV_PCI1710 tristate "Advantech PCI-171x and PCI-1731 support" + depends on HAS_IOPORT select COMEDI_8254 help Enable support for Advantech PCI-1710, PCI-1710HG, PCI-1711, @@ -739,6 +760,7 @@ config COMEDI_ADV_PCI1710 config COMEDI_ADV_PCI1720 tristate "Advantech PCI-1720 support" + depends on HAS_IOPORT help Enable support for Advantech PCI-1720 Analog Output board. @@ -747,6 +769,7 @@ config COMEDI_ADV_PCI1720 config COMEDI_ADV_PCI1723 tristate "Advantech PCI-1723 support" + depends on HAS_IOPORT help Enable support for Advantech PCI-1723 cards @@ -755,6 +778,7 @@ config COMEDI_ADV_PCI1723 config COMEDI_ADV_PCI1724 tristate "Advantech PCI-1724U support" + depends on HAS_IOPORT help Enable support for Advantech PCI-1724U cards. These are 32-channel analog output cards with voltage and current loop output ranges and @@ -765,6 +789,7 @@ config COMEDI_ADV_PCI1724 config COMEDI_ADV_PCI1760 tristate "Advantech PCI-1760 support" + depends on HAS_IOPORT help Enable support for Advantech PCI-1760 board. @@ -773,6 +798,7 @@ config COMEDI_ADV_PCI1760 config COMEDI_ADV_PCI_DIO tristate "Advantech PCI DIO card support" + depends on HAS_IOPORT select COMEDI_8254 select COMEDI_8255 help @@ -796,6 +822,7 @@ config COMEDI_AMPLC_DIO200_PCI config COMEDI_AMPLC_PC236_PCI tristate "Amplicon PCI236 DIO board support" + depends on HAS_IOPORT select COMEDI_AMPLC_PC236 help Enable support for Amplicon PCI236 DIO board. @@ -805,6 +832,7 @@ config COMEDI_AMPLC_PC236_PCI config COMEDI_AMPLC_PC263_PCI tristate "Amplicon PCI263 relay board support" + depends on HAS_IOPORT help Enable support for Amplicon PCI263 relay board. This is a PCI board with 16 reed relay output channels. @@ -814,6 +842,7 @@ config COMEDI_AMPLC_PC263_PCI config COMEDI_AMPLC_PCI224 tristate "Amplicon PCI224 and PCI234 support" + depends on HAS_IOPORT select COMEDI_8254 help Enable support for Amplicon PCI224 and PCI234 AO boards @@ -823,6 +852,7 @@ config COMEDI_AMPLC_PCI224 config COMEDI_AMPLC_PCI230 tristate "Amplicon PCI230 and PCI260 support" + depends on HAS_IOPORT select COMEDI_8254 select COMEDI_8255 help @@ -834,6 +864,7 @@ config COMEDI_AMPLC_PCI230 config COMEDI_CONTEC_PCI_DIO tristate "Contec PIO1616L digital I/O board support" + depends on HAS_IOPORT help Enable support for the Contec PIO1616L digital I/O board @@ -842,6 +873,7 @@ config COMEDI_CONTEC_PCI_DIO config COMEDI_DAS08_PCI tristate "DAS-08 PCI support" + depends on HAS_IOPORT select COMEDI_DAS08 help Enable support for PCI DAS-08 cards. @@ -861,6 +893,7 @@ config COMEDI_DT3000 config COMEDI_DYNA_PCI10XX tristate "Dynalog PCI DAQ series support" + depends on HAS_IOPORT help Enable support for Dynalog PCI DAQ series PCI-1050 @@ -911,6 +944,7 @@ config COMEDI_JR3_PCI config COMEDI_KE_COUNTER tristate "Kolter-Electronic PCI Counter 1 card support" + depends on HAS_IOPORT help Enable support for Kolter-Electronic PCI Counter 1 cards @@ -929,6 +963,7 @@ config COMEDI_CB_PCIDAS64 config COMEDI_CB_PCIDAS tristate "MeasurementComputing PCI-DAS support" + depends on HAS_IOPORT select COMEDI_8254 select COMEDI_8255 help @@ -942,6 +977,7 @@ config COMEDI_CB_PCIDAS config COMEDI_CB_PCIDDA tristate "MeasurementComputing PCI-DDA series support" + depends on HAS_IOPORT select COMEDI_8255 help Enable support for ComputerBoards/MeasurementComputing PCI-DDA @@ -953,6 +989,7 @@ config COMEDI_CB_PCIDDA config COMEDI_CB_PCIMDAS tristate "MeasurementComputing PCIM-DAS1602/16, PCIe-DAS1602/16 support" + depends on HAS_IOPORT select COMEDI_8254 select COMEDI_8255 help @@ -964,6 +1001,7 @@ config COMEDI_CB_PCIMDAS config COMEDI_CB_PCIMDDA tristate "MeasurementComputing PCIM-DDA06-16 support" + depends on HAS_IOPORT select COMEDI_8255 help Enable support for ComputerBoards/MeasurementComputing PCIM-DDA06-16 @@ -973,6 +1011,7 @@ config COMEDI_CB_PCIMDDA config COMEDI_ME4000 tristate "Meilhaus ME-4000 support" + depends on HAS_IOPORT select COMEDI_8254 help Enable support for Meilhaus PCI data acquisition cards @@ -1102,7 +1141,7 @@ endif # COMEDI_PCI_DRIVERS menuconfig COMEDI_PCMCIA_DRIVERS tristate "Comedi PCMCIA drivers" - depends on PCMCIA + depends on PCMCIA && HAS_IOPORT help Enable support for comedi PCMCIA drivers. @@ -1253,6 +1292,7 @@ config COMEDI_8255 config COMEDI_8255_SA tristate "Standalone 8255 support" + depends on HAS_IOPORT select COMEDI_8255 help Enable support for 8255 digital I/O as a standalone driver. @@ -1289,10 +1329,12 @@ config COMEDI_AMPLC_DIO200 config COMEDI_AMPLC_PC236 tristate + depends on HAS_IOPORT select COMEDI_8255 config COMEDI_DAS08 tristate + depends on HAS_IOPORT select COMEDI_8254 select COMEDI_8255