Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3534025rdb; Wed, 13 Sep 2023 15:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZ3vJrQ70rdRDbHet+l5vZZ38SWuldXxImAD99+DkzqtuJuvvH4hgkmbIGJynWeO+Odh2C X-Received: by 2002:a0d:d651:0:b0:592:2a17:9d64 with SMTP id y78-20020a0dd651000000b005922a179d64mr3705311ywd.20.1694643790678; Wed, 13 Sep 2023 15:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694643790; cv=none; d=google.com; s=arc-20160816; b=fCuFt54nEbredrdkzAV9cjQPzB8b2TXlqXp+pCiQEWxoNkVZ1g402sGmJPsgrLATuT 4ebnUDpyi358ju4Pyudrn+Z8TmB94rrqsq0CG0LqmDX8hk5F78Lcf4H4LweKgDXoTZUj ZqyFZ+jcfBs1MUNVgMMbj07M7dLi6LeahEw96SlgzKRFX1M/Upv0A99Srs2SBAw05tGa a92ZCXhTV13YVgEnK7oOl20lucpMGbbnUHPEZLiJrUP4XBdSRUB4RmdMjlTf4Fbslf2i +k+BFeZU2DCj+13Gww9CekcFeILzuo3dV6oT7dEkoqOYGyM7hIUF76zyIMqaSozJkk+q L6SQ== 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:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id m4-20020a633f04000000b00565f90b5ae1si66514pga.812.2023.09.13.15.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 15:23:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; 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:5 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 groat.vger.email (Postfix) with ESMTP id ECCC68235796; Wed, 13 Sep 2023 10:08:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231449AbjIMRHw (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:30 -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 groat.vger.email 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 */ -- 2.40.1