From patchwork Wed Sep 13 17:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1256928vqx; Wed, 13 Sep 2023 10:51:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOPtMxP0WdtrdGhRqhZWTKfRL0LISp0TZIbsCqW/XnYP/FxN2j1rWZ9l77A0fANkJbdimx X-Received: by 2002:a05:6a00:1487:b0:68c:1004:1feb with SMTP id v7-20020a056a00148700b0068c10041febmr3455675pfu.32.1694627468659; Wed, 13 Sep 2023 10:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694627468; cv=none; d=google.com; s=arc-20160816; b=zf4AdLT/ciwoO4X4Hi7wmYvn6u4jpc6CEJDwQO0Uvw9rOwCM+iTPS9y3LUkh4EeNC4 5FsmNzPqKyIMwnQXMVImt63fDo3M94HYcmscGR6yGZCq223Wpc8A8FRB0RPLxXACMdrX wOL1GZqgsRW3kfN2qqemrH/uOQN7S9U0cLlsLPlIZvvN3TwYZJmGGCjhHH78BKL45uMK eZFeZ+TbKv5+qu5dK9PBmhwTuVu6RXKgIH2s7RGSBi/f1aaMJL9SZyeUd7kBwShDCAFL dxHM9PYi7Dv4mPFrJJ5HZY312FTTsB8XKUV8CjG25Or1MO5qBNM0FdWiNzIJjj9+EtVV M8PA== 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=8cncSteSYfpn8PzFS0tTBJQWJ8tFWMnKEgts89lCqG8=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=Z0jKA+arrmnYwsXcVPIoxBLwNzuXiRiBoN6gf5Ty1WFMOmLcbWPkYpNDdurmFzW76+ c2Ea//SmsT2ACzoPRwIb7my2q+ftaebBMjDRYbrLxqT6QzATrL6jI76xCp1pFzFihkR7 ShrT7jdQqrRME85dPFfhZZuRHji1gCJft5NlHOdoOUltYhv6DKgcV/KVwHbBSgrkzgQR /LmGVffnX/NGZOzWyckItf0hZN0Y+Fv5IYC9ww5hpJE4FVR6LJH/tdS+DLIOwgfgK/AD zOkZCa/ooh7dPOO+n8lkBO+cmWBV7m0v19qmkUR6bsIC5BEQeaERYCBbf2ghHQIgd8lV 0uZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=X2F0PpcQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z20-20020a62d114000000b0068e37843a1bsi1450789pfg.162.2023.09.13.10.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 10:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=X2F0PpcQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1B3FB801CFF0; Wed, 13 Sep 2023 10:08:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbjIMRHu (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbjIMRHg (ORCPT ); Wed, 13 Sep 2023 13:07:36 -0400 Received: from smtp119.iad3a.emailsrvr.com (smtp119.iad3a.emailsrvr.com [173.203.187.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 438491BD1 for ; Wed, 13 Sep 2023 10:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624851; bh=pK0cMMnR27s2hNteQP+Jk6qnFAGNVa+UnJLFRlW2bbQ=; h=From:To:Subject:Date:From; b=X2F0PpcQyf9d+yJmjVIKgOd1R8pvEUcaAwRLJM4o5whx+dSDw0oBTbV9kZr7di/ix HfSXVyiXoZQCxGVK3J9yTPIWlFl1JNjf5rhJMHd+aCeWcwWBTg5smFsO85FYLOwL4j miL2Wd3QN9vq7r3kEJXYeQjhASQHa4hCGprnfLFg= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 7C35E551C; Wed, 13 Sep 2023 13:07:30 -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 07/13] comedi: comedi_8255: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:06 +0100 Message-Id: <20230913170712.111719-8-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-8-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 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:10 -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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776945692580360641 X-GMAIL-MSGID: 1776945692580360641 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 comedi_8255 module supports both port I/O and memory-mapped I/O. Conditionally compile the parts of the module that use port I/O 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 the `CONFIG_HAS_IOPORT` macro is undefined, replace the GPL-exported `subdev_8255_io_init()` function with a dummy static inline version that just returns `-ENXIO`. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT` in commit description. v3: N/A. --- drivers/comedi/drivers/comedi_8255.c | 8 ++++++++ include/linux/comedi/comedi_8255.h | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/comedi/drivers/comedi_8255.c b/drivers/comedi/drivers/comedi_8255.c index 28fd9d8c95cc..e4974b508328 100644 --- a/drivers/comedi/drivers/comedi_8255.c +++ b/drivers/comedi/drivers/comedi_8255.c @@ -38,6 +38,8 @@ struct subdev_8255_private { unsigned long context); }; +#ifdef CONFIG_HAS_IOPORT + static int subdev_8255_io(struct comedi_device *dev, int dir, int port, int data, unsigned long regbase) { @@ -48,6 +50,8 @@ static int subdev_8255_io(struct comedi_device *dev, return inb(dev->iobase + regbase + port); } +#endif /* CONFIG_HAS_IOPORT */ + static int subdev_8255_mmio(struct comedi_device *dev, int dir, int port, int data, unsigned long regbase) { @@ -169,6 +173,8 @@ static int __subdev_8255_init(struct comedi_device *dev, return 0; } +#ifdef CONFIG_HAS_IOPORT + /** * subdev_8255_io_init - initialize DIO subdevice for driving I/O mapped 8255 * @dev: comedi device owning subdevice @@ -186,6 +192,8 @@ int subdev_8255_io_init(struct comedi_device *dev, struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(subdev_8255_io_init); +#endif /* CONFIG_HAS_IOPORT */ + /** * subdev_8255_mm_init - initialize DIO subdevice for driving mmio-mapped 8255 * @dev: comedi device owning subdevice diff --git a/include/linux/comedi/comedi_8255.h b/include/linux/comedi/comedi_8255.h index b396fcfbf8b0..d24a69da389b 100644 --- a/include/linux/comedi/comedi_8255.h +++ b/include/linux/comedi/comedi_8255.h @@ -10,6 +10,8 @@ #ifndef _COMEDI_8255_H #define _COMEDI_8255_H +#include + #define I8255_SIZE 0x04 #define I8255_DATA_A_REG 0x00 @@ -27,8 +29,17 @@ struct comedi_device; struct comedi_subdevice; +#ifdef CONFIG_HAS_IOPORT int subdev_8255_io_init(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long regbase); +#else +static inline int subdev_8255_io_init(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned long regbase) +{ + return -ENXIO; +} +#endif int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long regbase);