From patchwork Wed Sep 13 16:40:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp38563vqb; Wed, 13 Sep 2023 12:28:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6m9cMu6NEpx4PbFw06GAMk/sCCoMqItU6Ls6PrUBNLKQJAe8pOizAK23UhZ3015+jfrWN X-Received: by 2002:a17:90a:a82:b0:268:535f:7c15 with SMTP id 2-20020a17090a0a8200b00268535f7c15mr9110508pjw.0.1694633300503; Wed, 13 Sep 2023 12:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694633300; cv=none; d=google.com; s=arc-20160816; b=iTs/L7s7NDk1tpilyI3V1yORbJ+VkFeyUQ7rqczRLJ0tlK0R5f34dWFonC/lJf3J6d vIvqJVAQ2ij7u11/mVEVvHz/brJUKoDR27wN4Ai9NHHqP2Yvods4a1c7pY1oqmZtjMVI 5h0Wja5XRjn+pvKDDUh7wGHULm3fiwJCV/7sBKExFFZhgZHQvtRwX9dRBk5iZp4ObRLh pCjRGZi4Xo4/eETlse4uvq14Jeg2kb6RAPuMYXfKVLEuu8Nnl+wTsrcJZzWnC+jA7d0k JWJQdWHkOw8lm0IWC9XdkXT3g99ATJhZjN2vYEIe8SWktd1NxuGIKn4ux5rcy1TFjH3R 9vLg== 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=TRs0B9LV+BvcpBGEqQv3iJ1ECSp0uDfGtjBz3iX+MUU=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=N2mUHReIsp7IsoO1lPjL3Xqrot70CbbJEIzOkT5vHQGJEDeKZY8INaPe5TWHkvExgm oJgbu+xtRoFwbBP4jw49ZgreAP9KKc/eziZTpkjEI1R/mymJplMBnAzUlgrDCwAyMQhf 0T02V8Dkd3MkbggckLMK14wNBf0hTtbGxj0QOYX5F81t2Z+PVVs122xZOFUVt4v4xwc1 IXjHhOOyhcznWVVx7UyiOZa0yigf8DN2RDaAtrnk1NH4SerAxoCB1BsHa+6Ve+X4gXxG Qw+nggJ+pPRH/rGpHhkkuW8OQczaw1GzT46LqnXk7+2/VC3zxTRp64N7dMrqs3C8zwx0 8VxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b="ebVks/cn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id pi10-20020a17090b1e4a00b002632a1243dbsi2248973pjb.104.2023.09.13.12.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 12:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b="ebVks/cn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 4A53F81E5CF7; Wed, 13 Sep 2023 09:43:45 -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 S231425AbjIMQnW (ORCPT + 35 others); Wed, 13 Sep 2023 12:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjIMQnA (ORCPT ); Wed, 13 Sep 2023 12:43:00 -0400 Received: from smtp69.iad3a.emailsrvr.com (smtp69.iad3a.emailsrvr.com [173.203.187.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED196213B for ; Wed, 13 Sep 2023 09:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694623234; bh=hHxiEopWROF+8PsakHWEqJ4Jd7zZSusKaY9f4Eppu3U=; h=From:To:Subject:Date:From; b=ebVks/cnyQXd8qpSOHpEStNAYrIF7xydsZZndJQb6KojwrXGfKhDJLFjQb2MZs+Z7 NHNb4zJjEYG9UYkY6f4YIeCEAhF809vSblMH42nnS6v1TnRfHn2I+BYc92RSoaXK3+ El9RKKrNV8Bws6uGYTZKyaniO9Kb0lsPZWE1x7G4= X-Auth-ID: abbotti@mev.co.uk Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 4469F2525C; Wed, 13 Sep 2023 12:40:33 -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 05/13] comedi: 8255_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 17:40:05 +0100 Message-Id: <20230913164013.107520-6-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-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 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:43:45 -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: 1776928783538727497 X-GMAIL-MSGID: 1776951808141097728 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_IOPORT` 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 --- v2: correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT`. --- 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..9ad52e9f5427 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_IOPORT 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_IOPORT */ 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_IOPORT [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_IOPORT */ [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_IOPORT)) { 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_IOPORT { 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_IOPORT */ { PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 }, { PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B }, { PCI_VDEVICE(NI, 0x13c0), BOARD_NI_PXI6508 },