Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3613256rdb; Wed, 13 Sep 2023 18:38:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHZqevcsNlELmmQQuvGTHX5yzLtyTVjNFJZB4YaJmA3CMhYxYaJTmp9QDv5gjzrh/PPkV9 X-Received: by 2002:a05:6359:a27:b0:13a:cd06:f631 with SMTP id el39-20020a0563590a2700b0013acd06f631mr3356513rwb.2.1694655528774; Wed, 13 Sep 2023 18:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694655528; cv=none; d=google.com; s=arc-20160816; b=zBPmjl6xi48A3cbOwgJbEmcvUGYclqpX87y/AM/N+xM2qEbO5YvZSCIAM+XGX0osvk aIw0AbP0+v4TPzCe8kDukHF/7iDV7WXLbsBldDWByN2LUCZ20X2UL/GBF5t65eF116sh V/9gAzbsozUBeui27UB4UmhWaCKiWB5/2VRhu7VSRm8/BBL7XcRK1frsRbfOajqjBBdw C7hgpSVoEqIwsN21HpeFX/uU0JDCqBZCEPLU1RWAlGb+Lbwg4DVwmTWGJNDxuyB8NE88 ogy3xIVADbPrYUTyuww69wuE9TrYO4U0+Pna87wUwBJEQX1zzzsHuPz0kL45rGnmvCyl 5c4g== 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=kwtD2hwqQlovK7ZFEo+a1+lZVyuMpHjK7AWAyN3Ssmk=; b=cdAUJq9MWWcYAqOcePwyAK8Iu3uH5yRHukjXbRhcayrQgptDS41XCKiebz6GWciVJg O+t7BZE94xhqrHhdxh+I91lDImeU6ocyQJ/GWHyDpW8eoOHYGChrPgti0p8SmFTbrKzE 6wifrbEAK6mRjBKcOhskmnXRf+fpGMD0z6yipneGpzKpWStwwWUNhP4h6C5EmR+faU5E m7xYZddjOA8VGNgimatTlyoQt/SGpRc42q/FpoFCSRDJ9pYZ3nIMBGBb18F2vl79cL2q TQWXCTABiefHARNqfJFOM/rHySHWw2QxpLLYWMvT7FgCpAvxH4ytdmeZpsaukZS9tgO2 eaww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=cmh089He; 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 y21-20020a634b15000000b00565f20a03f3si374224pga.774.2023.09.13.18.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:38: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=cmh089He; 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 AD622842AD32; Wed, 13 Sep 2023 04:21:35 -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 S240003AbjIMLVg (ORCPT + 99 others); Wed, 13 Sep 2023 07:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240017AbjIMLVF (ORCPT ); Wed, 13 Sep 2023 07:21:05 -0400 Received: from smtp105.iad3b.emailsrvr.com (smtp105.iad3b.emailsrvr.com [146.20.161.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22A87210B for ; Wed, 13 Sep 2023 04:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604060; bh=uLhfAgflV0leHcWKdgbLK0rcyQ0A5RWhfZPt2aW2IHY=; h=From:To:Subject:Date:From; b=cmh089HeyFx56EyimmAT4Z185FfAiSVDat1ZzQnP39bAoCThURqgo39pGodeIy4T9 QKYwPNoaxIzB9YKPPTPKwiur8k00LChb646p0q4prMjR6pdppX2mI6zqUJUCvIqlOZ vE4ubjRWaNEPme0xPe5aLTPqyV/bj5Hwl58yjHCk= X-Auth-ID: abbotti@mev.co.uk Received: by smtp6.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id B160C200CF; Wed, 13 Sep 2023 07:20:59 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Niklas Schnelle , Ian Abbott Subject: [PATCH 10/13] comedi: amplc_dio200_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 12:20:29 +0100 Message-Id: <20230913112032.90618-11-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913112032.90618-1-abbotti@mev.co.uk> References: <20230913112032.90618-1-abbotti@mev.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Classification-ID: e346d63c-f057-4595-b974-8be9cf32e1c1-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 04:21:35 -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_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 }, -- 2.40.1