Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3483561rdb; Wed, 13 Sep 2023 13:30:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHESgKDdCW7FHKpDAms6h4qflPn51vsfkmkoKZFwaUqLDFTrsaBP9SBTXyaE5I5xoL9DQFH X-Received: by 2002:a17:90b:11d1:b0:271:80f2:52c5 with SMTP id gv17-20020a17090b11d100b0027180f252c5mr3447447pjb.25.1694637049958; Wed, 13 Sep 2023 13:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694637049; cv=none; d=google.com; s=arc-20160816; b=cwRJo1eHVT4GrQbE9O+KFiN513okPjJJOYR/dn2E8qhVJQdHtF0HAmAAoC0yqVOGi8 fQpmoEiNFpQsGUuPUUBW77GZvuTdhCm9QY6/imcKw7AurXtCuBWF3xbscr5itM81BG/e bLFL8XsKPbvm1HNQYK2MHpFu0+fr9oDNX08U0Ei6HR8W3lE8c+q80dvndNkHpoj7FhIS K0RmWnXm62Ty3V2FuOm5WUqnj1s0nlBsNFVOW4a0MC7ckND98Dfn2E+aWyEIvw1+VECN OzJHkq9axNB306WlK8UZBXqRS7yZc9myS8IoUZ/RdDYLUzu28Rt3NmyerKKsUx2KmQ/J y+qA== 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 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 Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a19-20020a17090acb9300b00252d84b7af0si57099pju.181.2023.09.13.13.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:30:49 -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=rAuxQDym; 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 28968844BC6C; Wed, 13 Sep 2023 10:08:10 -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 S231549AbjIMRIB (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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:10 -0700 (PDT) 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 }, -- 2.40.1