From patchwork Wed Sep 13 16:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1266282vqx; Wed, 13 Sep 2023 11:05:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkjM2anGxomTzqgQ6nqbl9k24fxq6DO1wH3Hg0VOt9r+PAB3f9fpY83IXvEXdZkKAdSPYx X-Received: by 2002:a05:6870:420b:b0:1b7:27cf:9709 with SMTP id u11-20020a056870420b00b001b727cf9709mr3918492oac.43.1694628351689; Wed, 13 Sep 2023 11:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694628351; cv=none; d=google.com; s=arc-20160816; b=XS6d8sh1MHJjGHFv2CndVA/ogptOJk1PV1+EBaHoJZtKjDkzgAWzFg/7ZIoHqPZOaj E5/H269mtbm1Chif6pDGyQwpqd4JdUMJPkIeD1vgRVYX2eR1ZjBrwc2prUBA07SYyx2E dOXHW0HC29bqXPuu3K3Lj/ParEU+XNd1DoO9mGXYjwZZfp1F040f4s/CKFnC+fw80UwP cNJKJnRefV5gPO7vDNtILgzVWsr+oFfGXSOQaxKHz2Apt3mbnyOP0yAtTQ030xA4XOAf HOnfuebM4gKUMNBMFJMAw8BLcImN8egdIOkcl6VMoMtciyrvZ1RDRB4jYcIWyeym36C3 gXow== 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=6GnX7Pyv5+D1uUD+lFKnm3UY8PgZvnbsCWapHD7q0pE=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=dZ8+kgXIg+5vxnHjxyqRf7gWx7TZZU5D2NPl5EngzTZDhalzZ48fGoDQXcFN+5457O 5r7fa6TuY8az1Sah/iFUYhebEIQy55kVBTu5bkMxVi5qvHe6jVXTTD/bW0B8SRA1noeX 04O2EpP1KR9Jn98O6aBkNWvlvFDGalgHgphi+OrGUGg8tRw5dalK3HkZPTfyTFudDqoX fgScf2GswzbnlJyo52g3Cr2AhSHFvQl0c9Of8DrjWC8UOzhsDFSuUifWs9RDaAohTnFQ FOmbnqiRFsw7E7QNOF1jibAfcwf7lYXO8p4akw1yzVF6ZaoP4i/mdPfVSs3tYVn23/+h NMxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=frMUcwRK; 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 g132-20020a636b8a000000b0057017abe776si3703768pgc.677.2023.09.13.11.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:05:51 -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=frMUcwRK; 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 938D9820E523; Wed, 13 Sep 2023 09:43:21 -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 S231603AbjIMQnS (ORCPT + 35 others); Wed, 13 Sep 2023 12:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231563AbjIMQm7 (ORCPT ); Wed, 13 Sep 2023 12:42:59 -0400 Received: from smtp70.iad3a.emailsrvr.com (smtp70.iad3a.emailsrvr.com [173.203.187.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9BC2132 for ; Wed, 13 Sep 2023 09:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694623232; bh=+4AgmgDMxTC/EiiXefByr+6i6BcmD06W5cWppuDQ1Tw=; h=From:To:Subject:Date:From; b=frMUcwRKtmJs8c3w37Jx8oERSTC4OqS5cudZ6Kr6mViGfesTSxtyVcNQiqQIZr2O1 3WD+ikI0Zwx+Db6ZDt+U6Ml4orVJELS7fchyc/Bp6BhDxbD3b88nkVv9VxGwEEbHZo CWT8pkHuLrRRFsHeXAH6qyf+f0xqMUFoqs3Hbgik= X-Auth-ID: abbotti@mev.co.uk Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id E2FE025292; Wed, 13 Sep 2023 12:40:31 -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 04/13] comedi: comedi_8254: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 17:40:04 +0100 Message-Id: <20230913164013.107520-5-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-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 09:43:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776946618695955450 X-GMAIL-MSGID: 1776946618695955450 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 v2: N/A --- 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,