From patchwork Wed Sep 13 11:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp314378vqi; Thu, 14 Sep 2023 05:34:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKoiTXy1a97gudlsoRmuM4UX7W53DOqPWrnvtVQ8OzzoxgWimsOZKpHRv7aJO5Eb48Yjc4 X-Received: by 2002:a17:903:2284:b0:1bc:8fca:9d59 with SMTP id b4-20020a170903228400b001bc8fca9d59mr6169686plh.29.1694694879243; Thu, 14 Sep 2023 05:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694694879; cv=none; d=google.com; s=arc-20160816; b=D6eWUgHvcvR/iK583EK0hkMAvIRKMyL5i6Kraf7FBSUm1lYahSLkrSHObL0ZLvIwKz XfBvBYrSeuZZ2rEblD47ByfYJlh6an0p34DsHtIr+D7VqDJ4btAXf+w6vjIuitG2wHuy DRMyLXxkYf+80rP2LOWkzUp6G/q4FDR0l6bV9su/dkgtpbnvSEZtRmiQHFpff5Ph7Ihd +ZzhGfpLr9SfhHJCB1FSIE8Ht4Vajq/pyJz2IQbkWjFk9OUAJ2PjenAPEnN5bY1rIwPL PX3TyUTiID3/U9gLYoaixdCuQPwAOMcWiDc7rmrJ3k2YypoRhFEPLgTRuIH4MPcu/cpB ahsg== 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=JqtKvDcO8nWhPwd+KVwoQ+M2ZBhyN6lgCXNdQk9Gzmg=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=iVXNZb+nuhJf6TwEuSdIXJUoNWg1/7BhpD3ET0pyaoAp5O7eXYhlanjHFfhcwZdTTt UwoLOa9WTYikcAB8s9x6Xgz/hcdUBoKeQtjgGIAisOpnqMZ9ojgjjgZBRzwRPZGyrwrB rqweaGvLNj1GJOmYmo8NSJQHR9BwsyPp6OVm7SLq2hmzzWYViCVcLi5NO3fF5YPnXdh1 nau9KR2HOhaRR8gRzoapUc+pMaabRW8j3qEo/t/16bETOU4gLKwti/VpdG0gt7rtrY6I m5b2XdLMLalKaGCAM7D7QHs2GNcYhjCsS/XaXcHrYzeIZP/yVJJj6uY4qh1jzCaiGISt U0qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=bqG2GNIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id jx11-20020a170903138b00b001c20db2510asi1535499plb.53.2023.09.14.05.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 05:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=bqG2GNIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 97AB98213F06; Wed, 13 Sep 2023 04:33:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240542AbjIMLdr (ORCPT + 36 others); Wed, 13 Sep 2023 07:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240466AbjIMLdc (ORCPT ); Wed, 13 Sep 2023 07:33:32 -0400 Received: from smtp75.iad3a.emailsrvr.com (smtp75.iad3a.emailsrvr.com [173.203.187.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011D71BEB for ; Wed, 13 Sep 2023 04:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604800; bh=uLhfAgflV0leHcWKdgbLK0rcyQ0A5RWhfZPt2aW2IHY=; h=From:To:Subject:Date:From; b=bqG2GNImRQM2z8MHxGCv+JYgDdl/7k8XM36T9dme6/yTxbc33X3/B160dXMTose+5 93zW/q8w4ayokl73WwR+2SLCDCOjKVZ4ukab4/N3rOjgT8o/0gU+6bzF9tVfwtCEle 0aO1+MeihFZ0DbM5shI/8aRe7YWDPWL/N6YU748M= X-Auth-ID: abbotti@mev.co.uk Received: by smtp26.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 5A2C94227; Wed, 13 Sep 2023 07:33:19 -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 10/13] comedi: amplc_dio200_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 12:32:44 +0100 Message-Id: <20230913113247.91749-11-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913113247.91749-1-abbotti@mev.co.uk> References: <20230913113247.91749-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 007ec4bd-2574-475a-9bbd-5a4f93b29aec-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:33:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776945764194109354 X-GMAIL-MSGID: 1777016377673650686 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_PORTIO` 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 --- 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 },