From patchwork Wed Sep 13 16:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139072 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp67063vqb; Wed, 13 Sep 2023 13:24:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNWKkUp/n8Cszvn8uMD4YD2WnaEl56yEc6ZQFBPnhree3ecbqYiKiWbBw/b+u53BO8vM6Q X-Received: by 2002:a05:6a20:e105:b0:141:69d:8041 with SMTP id kr5-20020a056a20e10500b00141069d8041mr4272829pzb.48.1694636673806; Wed, 13 Sep 2023 13:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694636673; cv=none; d=google.com; s=arc-20160816; b=O89qtqsfL8hdEikHxcoJxbBbr6uucCVNnsrIGegr013S49c1csps6a8l7dOsvP5Dy6 eYfi5M/02eWZjcA6oPQuSeTZ2/SVZoXaRoM0pU00wv5nCmtv8ch9OFcACcWcidnDm4mj nZe/Bq7pzsDnoM+Aa8LdYJeh8l7yIsPFKwaQOrOWkuiFOYX43Fz/gT/tM/0BJkZxeAxX mGHum/Poz2hSHrdGIjhMYku+v92Rj2uaqT4HpA9leSte2IRDjZg61Qw4YRoBYg537+CI ciMmXVlx7fII0jrsXHIZ+/xSFQmifXAzkVrz3rC+EWV+kBfeAUBPQxGVwd4o/uInbTYq e3Ig== 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=usaZj24iEuVm9tuv3wNoHbj+6WihG1DYcfHrQ9l5DWA=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=ntaVkFTiusimfSYosRPBw+jxRNhJsfZDQbHfmmo2vCISM0JdyYXePdAY2oQJ5e+JNp ThOS5OEXcW1Ci/zoW7waNcPTf6IS8F5zA1sD+ajzH1ZNYVifZm/lYLhZytS9H+OszBw6 w6ur7aaJCwifQR9JTg8OgAhNBSxl5wTg+BYwLoXDVQj7OZbwTDxQFDq7ZJDwxHOSPUoE DZzyCaCQNBVQB4fcbX+lHFOm7tj0CN4z0aIxZCzdNFyBQ8i0lGSBMejYZfYblq3NFfrI zUjyqohkYQ22qAOD5SnbZMLKw2EeQ1mv91MMhcvH9f07T2NMK10IuDXqmx1Nrau2S2/J 8lGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=QCsrn44S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z11-20020a6552cb000000b00565336a3cf5si10789878pgp.491.2023.09.13.13.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:24:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=QCsrn44S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id BD8388057D9F; Wed, 13 Sep 2023 09:43:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbjIMQnc (ORCPT + 35 others); Wed, 13 Sep 2023 12:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbjIMQnE (ORCPT ); Wed, 13 Sep 2023 12:43:04 -0400 Received: from smtp67.iad3a.emailsrvr.com (smtp67.iad3a.emailsrvr.com [173.203.187.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB31D3C2A for ; Wed, 13 Sep 2023 09:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694623237; bh=ElEo1fCXb3ElxGwXpE5dWw47teDAV9y9nmpqAtCla2A=; h=From:To:Subject:Date:From; b=QCsrn44SnttXfaaAwl3CRT/tv0fIOhZbUec8fSmFxZek4sifelFt4dGaNTm2uaR5V X31oKLoOSZkCIX2VrF1EdvXzblJxcWINDGkqPDdvIUgyqilPe/zCPTAV07hbJt2f3D eyjtJD060IjVeJy80QF7wEIiW/0jMa6RSWH95GAc= X-Auth-ID: abbotti@mev.co.uk Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 1F45725299; Wed, 13 Sep 2023 12:40:36 -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 07/13] comedi: comedi_8255: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 17:40:07 +0100 Message-Id: <20230913164013.107520-8-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 X-Classification-ID: bb5231ff-a70f-4c9d-8b55-93f03f91465d-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 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:43:59 -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 lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776945692580360641 X-GMAIL-MSGID: 1776955344892338611 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. --- 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);