From patchwork Wed Sep 13 11:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp42724vqi; Wed, 13 Sep 2023 18:23:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjocP8th9RMTxyBPRbol8mWPvtAH7AamyqqpK6PSWK7pxnQbGpyCTCQmrVsrlFO4/xXvgS X-Received: by 2002:a81:8887:0:b0:594:ea4f:f5a7 with SMTP id y129-20020a818887000000b00594ea4ff5a7mr4409092ywf.31.1694654579800; Wed, 13 Sep 2023 18:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694654579; cv=none; d=google.com; s=arc-20160816; b=VqNxNdSOqm/CHodFRJqLmsrj3kQK9L1tSH5LgeNtD60ZrwBoZ8Y5tV9yQq8Go9QwEQ 9RzrdEVoY8URngFoivJXmcrBxqjyPZSoeQTXQW7/0AjBYGjXKpuRnzNmx/sbzwru/H7Q Y06oosWN4PKZlXQvLROf4FDFNAKEy/avZ1S2OTxpmMVekpJGbnR+t2C2dtR1+Lc+V8Kv Kr96NdUx089EM+386nNGBU27ZCFA93DTQJX9cySlg3qwy91DqDkhOc5Nxju9DuwCSKOL 3JPWgMB1CfrKfDOf2KbEMcE+/MWdnb079cmmRPoAdjI0F+cahw07gY92X3jkJUjCMM0O vQQA== 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=rn3lnRs0HfxuJSGII4V8SY5vDHcdWSYatCJfM79XbDE=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=o4ghybmJ9Ai3mGp7OGwkZLCYeeBITV4q0LpqjGx/TaFP7Vzd1njwP8dtL3UfarukEw 8xEVRoIE1NY007CFXwTmkC+6cuEKb9mG2uTignOPm45We5RYuMTwcxPuT95jOKnUiN1I d8HnJgq1w3JaUmy0g7uY5wdJmKOU5SsIzQUvBRw8NjM+YTbV2lFWG93bAG2FUARcwYsh KhWj149hZ70kXdms8g+z/IYKKSyBWm1zRXoseYFih6iyULSoLFgVueeJHsyD57j2HYvZ tGr8k0j1pO2RDwKcfJEgxmdldmPsZyImdEdD/bLm3EkNzdjshcr8Ha1D8VvuC39C9ZGm x2uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b="rWz9SU/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d9-20020a056a0010c900b0068255c2b8a8si470556pfu.151.2023.09.13.18.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b="rWz9SU/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 1B21081BDF28; Wed, 13 Sep 2023 04:33:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240381AbjIMLdV (ORCPT + 36 others); Wed, 13 Sep 2023 07:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240349AbjIMLdR (ORCPT ); Wed, 13 Sep 2023 07:33:17 -0400 Received: from smtp77.iad3a.emailsrvr.com (smtp77.iad3a.emailsrvr.com [173.203.187.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E0A719BE for ; Wed, 13 Sep 2023 04:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604792; bh=RUuuQK6RPlCA9X76BGMNc6q5fXGNjtOHgTDLxmsqyIk=; h=From:To:Subject:Date:From; b=rWz9SU/dWPotibTL3gb26T5xPmJL0Y0fdL1SHEvnjwhvEpCmN5Bei1C1EiSVhIjZw 8AZWatJNHiamLuspl7COXznnhoHt2vyI4VSuby8TWv1Sqi/7sUiGQBGK1quThkTj7N 8j0k5sBhm0/GJlneGj3oBfk7SbUCncH84XG+4gmM= X-Auth-ID: abbotti@mev.co.uk Received: by smtp26.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 3906F3FBC; Wed, 13 Sep 2023 07:33:11 -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 04/13] comedi: comedi_8254: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 12:32:38 +0100 Message-Id: <20230913113247.91749-5-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913113247.91749-1-abbotti@mev.co.uk> References: <20230913113247.91749-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: 007ec4bd-2574-475a-9bbd-5a4f93b29aec-5-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:33:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776946618695955450 X-GMAIL-MSGID: 1776974120630265052 The comedi_8254 module supports both port I/O and memory-mapped I/O. In a future patch, the port I/O functions (`inb()`, `outb()`, and friends) will only be declared if the `HAS_IOPORT` configuration option is enabled. Conditionally compile the parts of the module that use port I/O so they are compiled if and only if the `CONFIG_HAS_IOPORT` macro is defined, so that it can still be built if the port I/O functions have not been declared. If `CONFIG_HAS_IOPORT` is undefined, replace the GPL-exported `comedi_8254_io_alloc()` function with a dummy static inline version that just returns `ERR_PTR(-ENXIO)`. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- drivers/comedi/drivers/comedi_8254.c | 8 ++++++++ include/linux/comedi/comedi_8254.h | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/comedi/drivers/comedi_8254.c b/drivers/comedi/drivers/comedi_8254.c index 696596944506..6beca2a6d66e 100644 --- a/drivers/comedi/drivers/comedi_8254.c +++ b/drivers/comedi/drivers/comedi_8254.c @@ -122,6 +122,8 @@ #include #include +#ifdef CONFIG_HAS_IOPORT + static unsigned int i8254_io8_cb(struct comedi_8254 *i8254, int dir, unsigned int reg, unsigned int val) { @@ -164,6 +166,8 @@ static unsigned int i8254_io32_cb(struct comedi_8254 *i8254, int dir, } } +#endif /* CONFIG_HAS_IOPORT */ + static unsigned int i8254_mmio8_cb(struct comedi_8254 *i8254, int dir, unsigned int reg, unsigned int val) { @@ -648,6 +652,8 @@ static struct comedi_8254 *__i8254_init(comedi_8254_iocb_fn *iocb, return i8254; } +#ifdef CONFIG_HAS_IOPORT + /** * comedi_8254_io_alloc - allocate and initialize the 8254 device for pio access * @iobase: port I/O base address @@ -682,6 +688,8 @@ struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase, } EXPORT_SYMBOL_GPL(comedi_8254_io_alloc); +#endif /* CONFIG_HAS_IOPORT */ + /** * comedi_8254_mm_alloc - allocate and initialize the 8254 device for mmio access * @mmio: memory mapped I/O base address diff --git a/include/linux/comedi/comedi_8254.h b/include/linux/comedi/comedi_8254.h index 393ccb301028..d527f04400df 100644 --- a/include/linux/comedi/comedi_8254.h +++ b/include/linux/comedi/comedi_8254.h @@ -12,6 +12,8 @@ #define _COMEDI_8254_H #include +#include +#include struct comedi_device; struct comedi_insn; @@ -136,10 +138,21 @@ void comedi_8254_set_busy(struct comedi_8254 *i8254, void comedi_8254_subdevice_init(struct comedi_subdevice *s, struct comedi_8254 *i8254); +#ifdef CONFIG_HAS_IOPORT struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase, unsigned int osc_base, unsigned int iosize, unsigned int regshift); +#else +static inline struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase, + unsigned int osc_base, + unsigned int iosize, + unsigned int regshift) +{ + return ERR_PTR(-ENXIO); +} +#endif + struct comedi_8254 *comedi_8254_mm_alloc(void __iomem *mmio, unsigned int osc_base, unsigned int iosize,