From patchwork Wed Sep 13 17:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp151287vqi; Wed, 13 Sep 2023 23:37:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTBQTb5Ex5OqWs96mVocLZ7UvzCdM546/731KKAshbjJf7cGnRTvjKthX0JUMQMLrnVtbc X-Received: by 2002:a17:90b:4b4e:b0:26b:49de:13bd with SMTP id mi14-20020a17090b4b4e00b0026b49de13bdmr4456469pjb.36.1694673467169; Wed, 13 Sep 2023 23:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694673467; cv=none; d=google.com; s=arc-20160816; b=AuDdXUCHiHYx41KTtrenKofPhnAlP4X00lOEyszcmIsEdltL4MF0eBnE56LqGZd6yM 85uxiBgXspIHtsnvV6k19dbASui+2BLmqZ3nrZjXLJZVi+EnlJ2b0wGWhcc/XaDiCtIq KLxdbvoER9eDUpJIyWVR1shriZbawFrde3z8t4kJpLzD1EKqTd053BdLg36BNshbf8qc R2ehMlfxxY37TkRvrDOcAPvsYmoVBTfTOpUrWHNpDuc7cGsmP8KT80WxgtEI87NKciAx mzjbW81OU2C6qRNlYYJbAei67YCeWdwskAfXpwIq/2EjQQ4WyDd+d/kP562j1ez58UWG 5OyQ== 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=evpAjqvtyBJWvQfvCbwJ99VA8XTPGtvFYmQ6sHd6BAU=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=jI3geqNwX3wFkD/w2pVOtGp2xGziOUsFabbosynLEYlQ1sP43SIwrlndz9cLitGnzR NT8JLtUCMR3D4K0jsbTXVnhOOAy5stEhQ7lzzBR+ViTPZaYcLM9AzPw5GqE5YssQtolk EF01rk/MZ8nCNdURyMcCjVqWJIKsBtKfqv0lp6fnLHbiLvX87Uiw314CIQZqU/UAfjzF sUbM0G78fKL5FdeE0Qhg4p+kGf3DnggmF72IrMSlvTmCUmuytjd1Tvj7vi7s9r2XvNA2 EC4CrhlRW7rhc57hy3JYnkoFqFVs7HXM5FyywJ0/NZGNQBesyklt8pGPzwaOe7YPnsmZ zNgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=pig1GM0c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e5-20020a17090a804500b002681dc4472esi3046343pjw.134.2023.09.13.23.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 23:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=pig1GM0c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id B1E778104F6D; Wed, 13 Sep 2023 10:08:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbjIMRHw (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbjIMRHh (ORCPT ); Wed, 13 Sep 2023 13:07:37 -0400 Received: from smtp112.iad3a.emailsrvr.com (smtp112.iad3a.emailsrvr.com [173.203.187.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB351BD6 for ; Wed, 13 Sep 2023 10:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624852; bh=T1VSgJgZFQT7hlTIaOmx6j9S8YLzd9tknmB5plLkuJo=; h=From:To:Subject:Date:From; b=pig1GM0ccDUY3HoHYwxFALB8TnQ32akaeK3N2QXhG6XND9sgKDydSUY+Y59cdE4Kb IPwx+DQqfVlNPbODwoX5ECXrxVFhVjk1AoZZfI6O+DRErouuahl64gRSmWDTKBoBo7 jxcHvi4iiZlPoT8roUEZ2rdGFomrRAEVxMHIBwkw= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id D0458425E; Wed, 13 Sep 2023 13:07:31 -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 v3 08/13] comedi: ni_labpc_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:07 +0100 Message-Id: <20230913170712.111719-9-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913170712.111719-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> <20230913170712.111719-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:08 -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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941559609477941 X-GMAIL-MSGID: 1776993925724217187 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. v3: N/A. --- 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 */