From patchwork Wed Sep 13 11:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1271215vqx; Wed, 13 Sep 2023 11:13:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS9X6UqBOutoaPfTo/pEXBqdL4SOQ5h99PC4MzRaQ1oP8RqBfpFQqPw5GEmLFNUD/CjZxA X-Received: by 2002:a05:6a20:4283:b0:153:919e:18ce with SMTP id o3-20020a056a20428300b00153919e18cemr3536459pzj.48.1694628819546; Wed, 13 Sep 2023 11:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694628819; cv=none; d=google.com; s=arc-20160816; b=0gDT5PYqudedvHl52RNvcCAIXy0VEDl9m2bJrjx4qdSCv9QglvzV+GmS4T7QyeEiZf 4hvPWr2eZhiIYZne+XW63VAYlhNw0V0WAZwNAtzNHFNeAhtX/56a2mnt8VZwUTqGlUXN DL86QWsgbFZZQLxL3SKWSadAJE6ALmLV8edgkBsdZ37EW7rfpowsyvYSd5sBQATrsWjz kKElGX0h8BU0uwkVxWPKeJMuXi+CMJ75UX8/rZxo0C5IBLxCPP8b5VNbQPOEicT77cA+ 6xQQXZx73NwRa5cJu1TPR8n1YGmAsw7d0pQy27Xrs0v4073eNrhzMNapw+70EX5KiO8m YaNw== 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=kwtD2hwqQlovK7ZFEo+a1+lZVyuMpHjK7AWAyN3Ssmk=; b=Vdi8ZoFClyx5qxEXy0+9iygY3GHpCufTiMjBOxRc8gmsvotFhG5snV3XXv5zDE6h4O MJ63XnEUddB2dquhIVjqrdmcQp/R+5rWkIQthg7JbkdPcacJcXt/9ob9liIdbBK5XacZ 6u9IOPxaPCp4pIaqt2TqhSO9bX2BwefwFm1eRS87WPtNeqkTu3VqFWYqdVyMaI2ndX14 pmiZtA3t6akDkE4MbV8px3YgIcMzkHnd9U/57VO6ejLopC4XkbDu2OK0sUKlgZAIYYj1 HGyI/eKcXQNi5uXYSMcrxpRFTmvwzOwOcY1LJ8GdiAwCePxk1ZKdH93Ef4pmt3x0pBmM h3Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=cv7gORdk; 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 fa23-20020a056a002d1700b0068c01fba736si11006371pfb.301.2023.09.13.11.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:13:39 -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=cv7gORdk; 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 7B91381DC7AE; Wed, 13 Sep 2023 04:21:35 -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 S240140AbjIMLVM (ORCPT + 36 others); Wed, 13 Sep 2023 07:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240038AbjIMLVC (ORCPT ); Wed, 13 Sep 2023 07:21:02 -0400 Received: from smtp105.iad3b.emailsrvr.com (smtp105.iad3b.emailsrvr.com [146.20.161.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D26031BD1 for ; Wed, 13 Sep 2023 04:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604057; bh=Rcu+WRcF+p3jk6uJghybFBGg7QHs0LcO4lWUEsaEf5w=; h=From:To:Subject:Date:From; b=cv7gORdk2clgqp48dvwHFMnW9ZY736WWJ6r0YBoIQaxk83CFjoQJ9ZICg9nxNEy4p FNjRiRIMUFosEdfHFAMaW4GZaF781+koUPylTfKqKlcTBes0a7UlQ4yqm0LpR8VYC4 wxjPZj+okV4I6oxBL7OKTaoFPSYYAW+ERLrgA4ZE= X-Auth-ID: abbotti@mev.co.uk Received: by smtp6.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 6FA5D200F2; Wed, 13 Sep 2023 07:20:56 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Niklas Schnelle , Ian Abbott Subject: [PATCH 07/13] comedi: comedi_8255: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 12:20:26 +0100 Message-Id: <20230913112032.90618-8-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913112032.90618-1-abbotti@mev.co.uk> References: <20230913112032.90618-1-abbotti@mev.co.uk> MIME-Version: 1.0 X-Classification-ID: e346d63c-f057-4595-b974-8be9cf32e1c1-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:21:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776947109342899561 X-GMAIL-MSGID: 1776947109342899561 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);