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 },