From patchwork Wed Sep 13 16:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1216402vqx; Wed, 13 Sep 2023 09:45:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzis1GSA1JTNRJtZRiKYrGLwLXDXa4atESwlfTQX4QFeBy43UFr/EVkHbY5EhvNwXLtm96 X-Received: by 2002:a05:6a20:a111:b0:135:38b5:7e58 with SMTP id q17-20020a056a20a11100b0013538b57e58mr3197498pzk.37.1694623527303; Wed, 13 Sep 2023 09:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623527; cv=none; d=google.com; s=arc-20160816; b=rr0QEY6E86LciUl0FWgp33IFg9JDwGFIygzFOomugCsIIvDqTJxxOjlm8/Wlr0JdV+ Z77P++iutlV6X7FzHEV7zltswZG06GD9VMMFlXoz2n5auM/N5WexmTA3mBHdhlndkIoI tzDfTurLygiJDraMLjg5lbwBUizpajRIPECo2jk8A9KVx0/ewW0Bh6izPU4BWPcMOLUU C8eMU3VkkwRwz++JxvCQ7okyMvJFrNHVd4sV1t9fmrYQPY9ucjYEkFyls8bUHLNhP38B 9yisHAK+iH3agvH7W3k+gTahL6OvM2sjyM33fH+n8tPGhFoVEleC7B7JmeMCeKEOoKgV oHEw== 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=puS1z46ywTGZGGw5WskNBCtyrSj7yANcVhU6cooKF/M=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=lYhjPEM0mscJAqDW8fWudW6XTDJQz6QHxzek6l5RkzVYQaXIwF74vepyRG9CC5+M0q eTRKjHt1tsYo6s5OCDWyRM6JdKsMkQ2wwnFNxNdgNcGtfSPLEA6wY5J1aX5GK6gqm7kj LHReRfR4ReeKHBKvXNucKBCwKAYuQ7Rl4GoLmezhriCaeVHjvRkaOEGkf9v0NaOzY0vO 6ABmNcFk5BewLOBIZ8f16bH9WiIg80Kq5PAXQ61Bymr+x0GkMhUG6a/oze6xymGswPZ0 X5xoJJHoD+b6eQn0xvf/xOX0D+ZQRWDcijSU1to4Tv/+2UO1iuGCdF64j3ZKGHN+doBz ByTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=Ua8tscvN; 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 cr9-20020a056a000f0900b0068e27a368f8si10173470pfb.115.2023.09.13.09.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:45:27 -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=Ua8tscvN; 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 9717E81E5D2D; Wed, 13 Sep 2023 09:44:52 -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 S229652AbjIMQng (ORCPT + 35 others); Wed, 13 Sep 2023 12:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231528AbjIMQnM (ORCPT ); Wed, 13 Sep 2023 12:43:12 -0400 Received: from smtp71.iad3a.emailsrvr.com (smtp71.iad3a.emailsrvr.com [173.203.187.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3DE3C3F for ; Wed, 13 Sep 2023 09:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694623238; bh=S6A0R8UwQZX2BpyXHgTGz+DwJ/QqgrKGsXty8EwurHc=; h=From:To:Subject:Date:From; b=Ua8tscvNtOwMDvvROGKnBNj8/ecADNUrDbauucEpinSLPAiinNJoguwYqRYQY3eHr D4WSuMlbjs2/zUHUjIesawnPCgduiUOyE8yZAftobUObwb5Sjwx+iiCJreZm1r1AHL i+t/zTj+ydzUkjZ/Rj0IWJSTEjP/CXVO/W6cNZdI= X-Auth-ID: abbotti@mev.co.uk Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 681A423049; Wed, 13 Sep 2023 12:40:37 -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 08/13] comedi: ni_labpc_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 17:40:08 +0100 Message-Id: <20230913164013.107520-9-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-9-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:52 -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: 1776941559609477941 X-GMAIL-MSGID: 1776941559609477941 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 ni_labpc_common module is used by the ni_labpc module (for ISA cards), the ni_labpc_cs module (for PCMCIA cards), and the ni_labpc_pci module (for PCI cards). The ISA and PCMCIA cards use port I/O and the PCI cards use memory-mapped I/O. Conditionally compile the parts of the module that use the port I/O functions so they are compiled if and only if the `CONFIG_HAS_IOPORT` macro is defined, so that the module can be built if the port I/O functions have not been declared. Add a run-time check in the `labpc_common_attach()` to return an error if the comedi device wants to use port I/O when the `CONFIG_HAS_IOPORT` macro is undefined. The changes allow the module to be built even if the port I/O functions have not been declared. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT`. Edit commit message to describe run-time check in `labpc_common_attach()`, and to mention that the changes allow the module to be built even if the port I/O functions have not been declared. --- drivers/comedi/drivers/ni_labpc_common.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/comedi/drivers/ni_labpc_common.c b/drivers/comedi/drivers/ni_labpc_common.c index 5d5c1d0e9cb6..7e0ce0ce0adf 100644 --- a/drivers/comedi/drivers/ni_labpc_common.c +++ b/drivers/comedi/drivers/ni_labpc_common.c @@ -78,6 +78,9 @@ static const struct comedi_lrange range_labpc_ao = { * functions that do inb/outb and readb/writeb so we can use * function pointers to decide which to use */ + +#ifdef CONFIG_HAS_IOPORT + static unsigned int labpc_inb(struct comedi_device *dev, unsigned long reg) { return inb(dev->iobase + reg); @@ -89,6 +92,8 @@ static void labpc_outb(struct comedi_device *dev, outb(byte, dev->iobase + reg); } +#endif /* CONFIG_HAS_IOPORT */ + static unsigned int labpc_readb(struct comedi_device *dev, unsigned long reg) { return readb(dev->mmio + reg); @@ -1200,8 +1205,12 @@ int labpc_common_attach(struct comedi_device *dev, devpriv->read_byte = labpc_readb; devpriv->write_byte = labpc_writeb; } else { +#ifdef CONFIG_HAS_IOPORT devpriv->read_byte = labpc_inb; devpriv->write_byte = labpc_outb; +#else + return -ENXIO; +#endif } /* initialize board's command registers */