From patchwork Wed Sep 13 11:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1082503vqx; Wed, 13 Sep 2023 06:22:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG57/ixX3dBzTsnPx7FhaTK/XqhnNzJxzCpCgbIL2ybO6vhpwsDyhK0zBqC8mvozJTGUhv7 X-Received: by 2002:a05:6a20:54a1:b0:155:2c91:f8e5 with SMTP id i33-20020a056a2054a100b001552c91f8e5mr2594735pzk.14.1694611342917; Wed, 13 Sep 2023 06:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694611342; cv=none; d=google.com; s=arc-20160816; b=yadwzLJofitZ4JVtgrVUn0/MDuKc0w4CJpuXmJk/xq8kUPe12CLOLtVPMOGUjXRE8U dPlgR1cUS4ykrxKsHY7vLAKKsUeM4qFP2Sm4NAU/Gczmi5eS/w+HsliQ5mWa3jEOGgHj OTX+WXOrlWJgopD4W7ZeeMV6fUu0fqFQd7TIiGQqs1uZXe5sNUnSQmuH1BZJSeQIFpuu 2tM43y4lYTZN3UXTmcTdWqvUU+DAmYTUBraM9+tK6ddLl6Zq3EJ4uvdtyxca4a2FPm23 cUVIRA6a025yV5KZEk0Gb1UZH3GfzfjQvEXOOhAJ0g3Qt+dRx/R79eKJlHqrWRarkgsS V0Qw== 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=GIEefstpfx8j/BALTLEQ838UwiK0G8TqDoVkkk0pOyE=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=bMfuJ1/PsHCX4sOR5UdI9rwtSFJKqZtEcx4sWmGGzVl79XnHOfx0Y0OdTiWFH1WdN/ nsNBex+BMYSn42fAfJCi7TkHtWBldQ+UvwFqkFeVkUfRORbnQpVZWrE2nW2xZJKo1F6/ BV1Vy9ljBv/jKT6GSQgmkmsDOdLLRtjtqe37zTdwi+987XYnDv+d9/JLkBD4CuIhTHc7 ilsZmoFPEBVcwnENLusotW/ahdjgfGjLfS+B79X/uYShpLnRnyKj6VASEuSnrmSYvpdM d4/gSmvRXJBEARynR8LFL/pkeJ1LsCT8XKAp4OMdVaeFeBhS6kFhJwrtCTThwG1jxt5O r8fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=cbZ1PJzw; 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 cb6-20020a056a00430600b0068a62a4a176si4466983pfb.143.2023.09.13.06.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 06:22:22 -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=cbZ1PJzw; 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 CD05C831302F; Wed, 13 Sep 2023 04:33:28 -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 S240423AbjIMLdX (ORCPT + 36 others); Wed, 13 Sep 2023 07:33:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240374AbjIMLdS (ORCPT ); Wed, 13 Sep 2023 07:33:18 -0400 Received: from smtp73.iad3a.emailsrvr.com (smtp73.iad3a.emailsrvr.com [173.203.187.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E5319B6 for ; Wed, 13 Sep 2023 04:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604793; bh=vGdISjzSsCl7AP5nEB0MZrEzyOvgK8VcBZUCftmqT4w=; h=From:To:Subject:Date:From; b=cbZ1PJzwepFSc+uYiavikh96noulWZ1zwRBBFavSyYX67iqfpb2a8xvh3eB3hlN0q Ud4aBTppKfgkskTilS2pqW+tFROhPxnxNmy08Tn46aJgckSvz0Yrd4EW2DCicGXd+K h29oBU3h8cBimsSdyb2qYVUIJBgTf+380/gMx3a0= X-Auth-ID: abbotti@mev.co.uk Received: by smtp26.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 83B8B3B4D; Wed, 13 Sep 2023 07:33:12 -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 05/13] comedi: 8255_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 12:32:39 +0100 Message-Id: <20230913113247.91749-6-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913113247.91749-1-abbotti@mev.co.uk> References: <20230913113247.91749-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 007ec4bd-2574-475a-9bbd-5a4f93b29aec-6-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:33:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776928783538727497 X-GMAIL-MSGID: 1776928783538727497 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 8255_pci module supports PCI digital I/O devices from various manufacturers that consist of one or more 8255 Programmable Peripheral Interface chips (or equivalent hardware) to provide their digital I/O ports. Some of the devices use port I/O and some 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. Change `pci_8255_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 is not enabled. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- drivers/comedi/drivers/8255_pci.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/comedi/drivers/8255_pci.c b/drivers/comedi/drivers/8255_pci.c index 0fec048e3a53..4c4c0ef1db05 100644 --- a/drivers/comedi/drivers/8255_pci.c +++ b/drivers/comedi/drivers/8255_pci.c @@ -57,6 +57,7 @@ #include enum pci_8255_boardid { +#ifdef CONFIG_HAS_PORTIO BOARD_ADLINK_PCI7224, BOARD_ADLINK_PCI7248, BOARD_ADLINK_PCI7296, @@ -65,6 +66,7 @@ enum pci_8255_boardid { BOARD_CB_PCIDIO48H_OLD, BOARD_CB_PCIDIO48H_NEW, BOARD_CB_PCIDIO96H, +#endif /* CONFIG_HAS_PORTIO */ BOARD_NI_PCIDIO96, BOARD_NI_PCIDIO96B, BOARD_NI_PXI6508, @@ -82,6 +84,7 @@ struct pci_8255_boardinfo { }; static const struct pci_8255_boardinfo pci_8255_boards[] = { +#ifdef CONFIG_HAS_PORTIO [BOARD_ADLINK_PCI7224] = { .name = "adl_pci-7224", .dio_badr = 2, @@ -122,6 +125,7 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = { .dio_badr = 2, .n_8255 = 4, }, +#endif /* CONFIG_HAS_PORTIO */ [BOARD_NI_PCIDIO96] = { .name = "ni_pci-dio-96", .dio_badr = 1, @@ -219,8 +223,11 @@ static int pci_8255_auto_attach(struct comedi_device *dev, dev->mmio = pci_ioremap_bar(pcidev, board->dio_badr); if (!dev->mmio) return -ENOMEM; - } else { + } else if (IS_ENABLED(CONFIG_HAS_PORTIO)) { dev->iobase = pci_resource_start(pcidev, board->dio_badr); + } else { + dev_err(dev->class_dev, "error! need I/O port support\n"); + return -ENXIO; } /* @@ -259,6 +266,7 @@ static int pci_8255_pci_probe(struct pci_dev *dev, } static const struct pci_device_id pci_8255_pci_table[] = { +#ifdef CONFIG_HAS_PORTIO { PCI_VDEVICE(ADLINK, 0x7224), BOARD_ADLINK_PCI7224 }, { PCI_VDEVICE(ADLINK, 0x7248), BOARD_ADLINK_PCI7248 }, { PCI_VDEVICE(ADLINK, 0x7296), BOARD_ADLINK_PCI7296 }, @@ -269,6 +277,7 @@ static const struct pci_device_id pci_8255_pci_table[] = { { PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, PCI_VENDOR_ID_CB, 0x000b), .driver_data = BOARD_CB_PCIDIO48H_NEW }, { PCI_VDEVICE(CB, 0x0017), BOARD_CB_PCIDIO96H }, +#endif /* CONFIG_HAS_PORTIO */ { PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 }, { PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B }, { PCI_VDEVICE(NI, 0x13c0), BOARD_NI_PXI6508 },