From patchwork Wed Sep 13 17:07:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 139073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp67166vqb; Wed, 13 Sep 2023 13:24:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcBI0Y3hsO3qcuAC41ticexKKyiGNpOde6TA1jo4cbNqfo1/ABwZzPibrIo2ajOZRG1mLw X-Received: by 2002:a17:902:eb46:b0:1bc:6266:d0e4 with SMTP id i6-20020a170902eb4600b001bc6266d0e4mr3423522pli.69.1694636689016; Wed, 13 Sep 2023 13:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694636689; cv=none; d=google.com; s=arc-20160816; b=Vni/m+6Xd9fFUwUZD++DrxyRl9CncNnnWOlcLnBK0Cic8bO6RouA/XyD1yh2kwa4Cm 1qIaluZb1dIqeKPmbyem8EyyQ92l08clQkx/XvtbZA30MVMtNt5bdjsnAxSaEF/Tbrwh daZRFE1AUVvhafgERny3Uu+UoIbXoy3S4jjIYKhyJfrSeWlV1RMu3qIBei7z5E0mCcS8 Fxo311trqGCLppctPEhis3VKu2s57ldiHmkzP0+zQBlk05hPkNPUvFGlCsjmGa98jWtR eA3pLsDiP32eyxPCZ57p+qQYw6CNd+Hjqdp4IQnXn5SdWBCjE1u7rFO8cp/Kj9gvAeLM x6Cw== 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=hyan7kXKjxJXLwE+OGZbVRXctv+F1SfwhSVKkiN0d1E=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=kjc7HhZ6lvuIzIB0XbJFW9M4qKburyUQiuvVyE2XmSi/HDcRSntplOyC0lFCrRbkCS Lr9+qZW4ZxL0HJyFVnzWoT51DpllQzwRW1EdW7eAl1gMx7FtrX7PL6dkrcika5WaRjiN ri60vZTVu/iBvRZUZWDKCPYJSD0tuA0aSKscqsEw0teZZPHuZzWL4gc+lfSQZ53MNGvd CA2o31LG2kxwxfHNHWBtd7AuZfbD/Ky9ZCmixjjHCONFdE8pFCZ+UURWMYX4WIqXPta0 zEK3Q5pRM05b+eLRdtHeRMQM4ydOHGksIsMmwOIRXwqFrHlxot5zh93ZWg11MKBJfbl3 dUtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=tNTVTGeP; 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 cp2-20020a170902e78200b001b8c824e826si46122plb.533.2023.09.13.13.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:24:48 -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=tNTVTGeP; 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 879AB8051908; Wed, 13 Sep 2023 10:07:46 -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 S230461AbjIMRHg (ORCPT + 35 others); Wed, 13 Sep 2023 13:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbjIMRHb (ORCPT ); Wed, 13 Sep 2023 13:07:31 -0400 Received: from smtp112.iad3a.emailsrvr.com (smtp112.iad3a.emailsrvr.com [173.203.187.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD1A51BCB for ; Wed, 13 Sep 2023 10:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624847; bh=I/tHvGfvIq4pfoyP88Yoc/G05xULJ8fWaIvY9vzRiPo=; h=From:To:Subject:Date:From; b=tNTVTGePy2ETvYe63x8zPiMQzlQKkONWfVBmNdB8CTIuCew+WrS5Lw2Zdk/nRAV+Z btT8quW5VX8qN8VQPKGHRdJYnU6C7VCU0POspxt9e9zKLZdwIrRYQ/SWVLO2AYwxgU J2dOXikxkXSl7HoaLGOjaxeERStvCTeI6xu2Vbmw= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 37E9354FE; Wed, 13 Sep 2023 13:07:26 -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 04/13] comedi: comedi_8254: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:03 +0100 Message-Id: <20230913170712.111719-5-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-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:07:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776946618695955450 X-GMAIL-MSGID: 1776955360798081874 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. v3: Add missing `---` divider before patch changelog. --- 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,