From patchwork Wed Sep 13 11:20:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139134 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp132036vqb; Wed, 13 Sep 2023 15:51:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLHv4wbzt7lUDuLhi7NiNfNQ9SyxsoHNzJIfyeod8NtEHY0pHk3IpLWQxIIKTNjcF3FWZW X-Received: by 2002:a05:6a21:3d85:b0:154:c959:f157 with SMTP id bj5-20020a056a213d8500b00154c959f157mr3326040pzc.30.1694645470465; Wed, 13 Sep 2023 15:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694645470; cv=none; d=google.com; s=arc-20160816; b=LNq8Ll6JpItfWiR73KZluWtZajzfsvVhkf4YgCMBkb38Ru1pmmdLnvSU134nVre8HQ A3+Xif02N6kKWE8D+Ow9Gw4e1buhnjTmuGwE3Mf76jiOi0KegZvGnyVXAhuBJMlMup2e 76GHS4ipgXsruG8w766EteqZtvCsYuya62S5L8WXRkuxhEOyDiCz6dcQC5U+ZbY09e1E cbMHU+WMe/b1yLyLqb06YCOmpz32V7rTeH3Y7Q4xYu4mPiXOnLvUmx8BF5uTpsfqSleW wMgR7musheEH8SaTmwWPOKOmyvSmDUmnDWDOqng+0+1VYpODzy2bItHXuGTa+uT0MOpT nXCQ== 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 Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id w4-20020a170902e88400b001c4062a0e43si335642plg.169.2023.09.13.15.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 15:51:10 -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 08449842E81B; Wed, 13 Sep 2023 04:21:41 -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 S240013AbjIMLVg (ORCPT + 36 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 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:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776964568974738493 X-GMAIL-MSGID: 1776964568974738493 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 },