From patchwork Wed Sep 13 16:40:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1257509vqx; Wed, 13 Sep 2023 10:52:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0zdrLDTQUrvAC6QVxaSeYjdTIMmgAzka+aCp7RKabVAnsvjGnZQCcanBDTWXDWMurV4ne X-Received: by 2002:a05:6a20:3d95:b0:13d:bf07:7444 with SMTP id s21-20020a056a203d9500b0013dbf077444mr3585831pzi.0.1694627537353; Wed, 13 Sep 2023 10:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694627537; cv=none; d=google.com; s=arc-20160816; b=SdIj+YgUGeB47Ap/ZNm+uZyXp1OH06CDMH+CVz5cQYhDT8MeUTziRZEIV8iuzVCUM3 ANoVgpu5Qi7BhxmagKCghovD/FhM1h5+9MBZBYM+OKDDo+afa34W8Bd05H+MjO+vKDW1 OrDspzzSJZH5ONWmYLH+q7iCAPnjA+xXNWEEEoLUHZKVmhtPxmi+Z+20LHudSLd7+Xpx UhVv+rH2815KCO6LMtMx8B8QGqbBykQqvjBOyHj8enTkyXomNlm17z5hZkNk86/OhI5b 3VXqWWCb90+J7XbUHqHc8Q9USY8jPQBEUA+V/4IYbck7yIIKN2tcLB2rBl6f1lidIOsO tLkg== 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=vxZle0T3MmOSIqcvqUjl9g3XXcYaC97gy1luecnq2Bw=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=elbYdNbQPd0BORwwCKpAkqmhez0HnIkdHCVaTxbYZw4OY5fdC74XslI9ZSyYvt0fp6 sYBid7deBe892aBLzeraK9l1q7XtXveFQgBYnDGtgH3RcWSUxC44Pnk3PLmjFdEYTsoV aVaWfKQEOhi/uN2PF09tIbkxjruAYYa8vKoPnxWVgQi+IiCCKyBJ9+eXbF5prybdSuLt vcGVQzswM1+hN/2Mw1U3eScZXU6Wjv7dF3ShUqoB+cgs1f8HRbkSBTadnKO4whj/uyLH waQNl1f43CbGP59J0DXH6cB5QUczXwSUVN9LWsCTbRUAg18kH+mlaLizoU3U/Z4b/Vvy pMKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=WUwaPRFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h63-20020a638342000000b0057776b67497si6153011pge.332.2023.09.13.10.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 10:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=WUwaPRFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id E929681D6BF0; Wed, 13 Sep 2023 09:44:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230410AbjIMQnl (ORCPT + 35 others); Wed, 13 Sep 2023 12:43:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231372AbjIMQnR (ORCPT ); Wed, 13 Sep 2023 12:43:17 -0400 Received: from smtp70.iad3a.emailsrvr.com (smtp70.iad3a.emailsrvr.com [173.203.187.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A326D421C for ; Wed, 13 Sep 2023 09:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694623241; bh=3DYoyucexyp3NqVzJwqSlUjI+W/qqxsbxRCtw8SQXNI=; h=From:To:Subject:Date:From; b=WUwaPRFnrEwUYx9OhkC9SGBLTd1kGg1IgqecM8VgkAZPsac33Zni09nRGXGkt8ZER gtmgyFYKq+PaxMvO/9C8iKCELS35GrbkTtzLZddobKH5T5FbsKB8oBOAdtzt/tqo7X +NKWRukLpJmuoFNBXS/a/8Nn7/+pQtb1iohBCpR8= X-Auth-ID: abbotti@mev.co.uk Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 0EF7E2391B; Wed, 13 Sep 2023 12:40:39 -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 v2 10/13] comedi: amplc_dio200_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 17:40:10 +0100 Message-Id: <20230913164013.107520-11-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913164013.107520-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: bb5231ff-a70f-4c9d-8b55-93f03f91465d-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 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:44:15 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776945764194109354 X-GMAIL-MSGID: 1776945764194109354 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. --- 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 },