From patchwork Wed Sep 13 11:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1179275vqx; Wed, 13 Sep 2023 08:49:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdqdyFuE+M66Xe71V4xqeNc1loJe4geVmcbsccPW9SdRUb2lY9cxPto7H3AsPGeUm76kCh X-Received: by 2002:a05:6a21:a588:b0:149:2149:9491 with SMTP id gd8-20020a056a21a58800b0014921499491mr3588026pzc.43.1694620197406; Wed, 13 Sep 2023 08:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694620197; cv=none; d=google.com; s=arc-20160816; b=mXKP4FEqW781xvxuRx6j4od4XfK7wKdIuy75kcfyDvF5El/DxqZ7g/W/9zDfwiSTyK 73gNbfLqDnI7a+Yuxondg7iUzTSPvwGFeEqm1ITQjQVyM6JvYt4o6RoPK1fWXBulE1o0 AGUBOdqMuALndhdGgyiLCuadtPJDclJ+ftA/AZKyrtrYHFFQZ7sE1sA5qKTiDBxyS0mR Yh9zINvLxIdZ1ZYTsdiV9mUz5gI9RevXf3h24O603dMP93K8LP+byzw+35OCGgyk1e37 IiiAZriTb/bz/0njuoEzNtTTl5QJmXiGbuCEGd5+Ga4iGEqW6fmyUeBFGXQa1mLpmJJ1 0g4A== 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=mLtZUZ/Q6ZMnaWjU5ZVq+IUI63hO4CLdCD/AHheyx5E=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=ZvhPkrFPVeu/wjzkRCHZPcK1WzlzDUMjziQiDfYCcXlYe3EDf677cRW2rG8sBinfs/ 2dVR47vnotaY3BpORdzFVvNT0IJTGDOsGv0mQusWzh36/FVyDyd3NFKAf4IaMOd+uvzg 5977x/3qv+lyJyGfxLg3GVuLs5hD50h2gjbMtEaap82f5YjJ6RbK/3OhKoBtSHi991cO XFkq6mffBfx/xaRemBCwG7jgN5PlADGk25U9GQGNnbns0uyMoNgyHxV52V+akaD3tqjK 62IkbrPywa3MQu7V84vZplVTXCE5EYpsIK5bWHIXBQrPTOZTnnnnWN+mqfjdkKyRYkpn t8Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=Q1xFkLoA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h190-20020a6383c7000000b0057777451a5csi5642234pge.374.2023.09.13.08.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 08:49:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=Q1xFkLoA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id EDEA88322708; Wed, 13 Sep 2023 04:33:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240477AbjIMLdd (ORCPT + 36 others); Wed, 13 Sep 2023 07:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240396AbjIMLdU (ORCPT ); Wed, 13 Sep 2023 07:33:20 -0400 Received: from smtp72.iad3a.emailsrvr.com (smtp72.iad3a.emailsrvr.com [173.203.187.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08AFB1BCA for ; Wed, 13 Sep 2023 04:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604796; bh=Rcu+WRcF+p3jk6uJghybFBGg7QHs0LcO4lWUEsaEf5w=; h=From:To:Subject:Date:From; b=Q1xFkLoA4DKTHWfX3qOkLBJvM+gz5LaqGDb+Gq0FEOdxq4g6JT/yjgfpbMcXbQAOg yYxcaqvTzqZPnSFyr3/mvkFo18k1OukqNWM1dYU8bGKg8VaBGk/KOa24JoVw0SXR1m zlL2q009PcfFgBuzSJ2gVc0brXcvBeoxyeCCiDn0= X-Auth-ID: abbotti@mev.co.uk Received: by smtp26.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 61228423D; Wed, 13 Sep 2023 07:33:15 -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 07/13] comedi: comedi_8255: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 12:32:41 +0100 Message-Id: <20230913113247.91749-8-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-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:33:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776938068335327333 X-GMAIL-MSGID: 1776938068335327333 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_PORTIO` 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 --- 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);