From patchwork Wed Sep 13 11:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1133526vqx; Wed, 13 Sep 2023 07:40:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQbJ2g79F70FU5zusUqwWmC7n6Y/aW0Iy+3g8lcMZZFgzxIbGe2efG/E7PmlcY3YHqs7gV X-Received: by 2002:a05:6a20:552a:b0:14d:72e2:686a with SMTP id ko42-20020a056a20552a00b0014d72e2686amr2277953pzb.36.1694616029940; Wed, 13 Sep 2023 07:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694616029; cv=none; d=google.com; s=arc-20160816; b=cP+PDTRUEUZqMMTz39DEUUFnLfNON/G3blbS6UR6BBJQJaYzohkDG2fCr2S+zS+w5C KRFn5xFpgEUJ3tKc40tL//XL0DQH3qRRspbyUNeSTTIcZTUfDXQgR9c9ppnlD675m0Pu 7MGIWjV5hvQJF6Y3Fhf7vfuqa0WKQcE9DgLas/eTQOT+HpVotVgNnU0cWjVZTPuM+5As 0fW+rdJwih9aCZtpEpSwFCpuojre8pJQnoI40cb/kZhVG67P7BFFijWVbQAb/RrVVhBY EpADNjKBu8lXuGLvhAGwbrbQVQT4+89hVRhDRCEUFHjNJkG/wAZ4L+Yhp+WtyajqK3+N 8uoQ== 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=kwtD2hwqQlovK7ZFEo+a1+lZVyuMpHjK7AWAyN3Ssmk=; b=MfzftZUVCY67cyk3D/zFDct+S2j06e2Aglp/gobrOZqcVQyfG3OIkZjG4tKNTLED4m 2AYD2By/LxpfnzxqUzvH08R+XtubQVBxCo77XWby9PRrDQiDgCqIEJGIm4MNHEz5+scb 9Q9F5cO3EO6kZ8CHTY8nMh0Id9mBydyVJTqNW7saZ4Xiy+ptY4gTd827Tgvyn0lAJIf9 i73rdsZifKu28BV+L+uT5ObA+xfcGiK8ToZobg5TSAiQVjWLweNvn7f1OPiz5pF2JMXI F8HQpoRzaTsbO3a0VauFC1THeiQ742kysLs8C/CEKjLZOdsxZJ3i6rZJrXLx6UWojTw5 MyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=RegFVuA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 205-20020a6302d6000000b005694eb03d2dsi10068263pgc.713.2023.09.13.07.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 07:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=RegFVuA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 7673C81B17D8; Wed, 13 Sep 2023 04:21:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240048AbjIMLVJ (ORCPT + 36 others); Wed, 13 Sep 2023 07:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239982AbjIMLU7 (ORCPT ); Wed, 13 Sep 2023 07:20:59 -0400 Received: from smtp108.iad3b.emailsrvr.com (smtp108.iad3b.emailsrvr.com [146.20.161.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 685911BFE for ; Wed, 13 Sep 2023 04:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604054; bh=vGdISjzSsCl7AP5nEB0MZrEzyOvgK8VcBZUCftmqT4w=; h=From:To:Subject:Date:From; b=RegFVuA+9Dy4eSuo0TfwAyYMVg/x6QZd8ZGPpNLarZE4DAsP4ws/ARX9cb2RPwbk6 flgFAQCqCDJ+jkzmTN0TDyTnjaZbBPpK+dBp8d9kqBtZb6rw1reYEc4OiHtg1oAmb0 YzDELyI/P6O3wVK5bs2uVP7eG/pjwSVKv1/dC4QA= X-Auth-ID: abbotti@mev.co.uk Received: by smtp6.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 0C5AD200EF; Wed, 13 Sep 2023 07:20:53 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Niklas Schnelle , Ian Abbott Subject: [PATCH 05/13] comedi: 8255_pci: Conditionally remove devices that use port I/O Date: Wed, 13 Sep 2023 12:20:24 +0100 Message-Id: <20230913112032.90618-6-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-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 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:21:49 -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 pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776924661256906542 X-GMAIL-MSGID: 1776933697964257906 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 },