Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3401160rdb; Wed, 13 Sep 2023 10:50:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKM2Q56erxrSHecATx2TWiKtrEkof1gIgLE3UTfFl9B5wEEeJYqYxI3fXrxtkyDMScj/w+ X-Received: by 2002:a05:6358:279c:b0:139:c7cb:77d4 with SMTP id l28-20020a056358279c00b00139c7cb77d4mr3772001rwb.24.1694627442120; Wed, 13 Sep 2023 10:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694627442; cv=none; d=google.com; s=arc-20160816; b=xZJOnAFnOimfaD5PjauBO0bff1nuEDhLuXbJj3Cn0crrQgwmu3vzS8vxXRLTmLM3uP IUGxITBcriG5cFVDH0etrNNP6gC76THFmtmgqxCWzOYLqpfY3rkwrztsuUDe1/GHMW1T nP1VBrBgdIaNHtnnJ0TwXSOJ8DZlengs0hqWDLegPC3JpyP249m2XIvCOggorSYbu08W 9xW2Vcae2MKck75ROoNreOrcK7bUUdZquZULDpdd4CNP6CgwfZ2/duXfMZHLN4pIWJJx D3qOTy5QF2ghBNaSVi5ITXVGgzesHmitwOkaIaSP1/jltTYMZkY+n0FbTASlyeR3IOyg Vwew== 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 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u1-20020a637901000000b0057763b28f63si6946963pgc.506.2023.09.13.10.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 10:50:42 -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=Ua8tscvN; 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 9E9A981E5D11; Wed, 13 Sep 2023 09:44:00 -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 S231477AbjIMQnf (ORCPT + 99 others); Wed, 13 Sep 2023 12:43:35 -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 Content-Transfer-Encoding: 8bit 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:00 -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 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 */ -- 2.40.1