From patchwork Wed Sep 13 11:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 138887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1159775vqx; Wed, 13 Sep 2023 08:18:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9T4D7j3XCuScd3d/SLPfN9eKZEgDqAhFoPC07k+uUtW1zq6gZrjYdWFfKmEM5iua8wVIw X-Received: by 2002:a05:6a20:3ca9:b0:145:47af:57d8 with SMTP id b41-20020a056a203ca900b0014547af57d8mr3042791pzj.2.1694618339517; Wed, 13 Sep 2023 08:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694618339; cv=none; d=google.com; s=arc-20160816; b=FsEPPbyFRXanOUvTGV5ZCUzWWe/0SbDIhe4q3zx7cYof6JhosOxtQRtpOEmhMCAtKQ NtYAJakp3oBfhHHFDPktlGL94tTyby7PGtlG6jwbXIVIbti1gnwp2YmdfYxo7dpOu7sP JFXRWrfbOd45qXAi5lvMFr3m2KKMIGrGz3Hk24MXVPpPMSMIBfck3IWtCmN0Fp2/WeIQ 3FW2RX4DXPNWu/a7BQnzRmW0hQ7ZtRpVYFrDfdGh45dp1OcCXqsL4NGKfVKniwSxe7Au aCTp4YL8lEO/DC6e84LsqxbuBXY8WKKVlOqnP3sJgHaKpkaRWXQpNhDUtzn85/uUr/JP +yqQ== 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=rn3lnRs0HfxuJSGII4V8SY5vDHcdWSYatCJfM79XbDE=; fh=kwtD2hwqQlovK7ZFEo+a1+lZVyuMpHjK7AWAyN3Ssmk=; b=IXZ6wfuQ7JXlzjmegc/NThFfTgvXmXLY1A4JZqkEjjzDRgQgfXHkdCgjrxpBH4uJaK 3StJ3mo0HPL6n8pt9hoA3jxi/K8hj/vc9nL8j2SDbJ7GKtEiiBbkeDDRDug5/diwFwkQ go13apawJ9I30XQV4a5ksgODoXmiQ2kesJcPnFPXV7zduaYNYyRSqySHtipjclY1+PWq oiyvEE/6N3DZxJLdDC6LNL9/HylYT0pV+KWeqh5EclqfaiKn+qIhijtSEHp+aVPQLOmz JjAUdqcIn54T+mn9q2AgmWkzskIMTNvU4UeFYlGJ5GxEmSEDGt+ujRRRYePuTMYHK/z3 R3Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b="m/DGlLRu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id m9-20020a654389000000b0056535e2b751si10372858pgp.782.2023.09.13.08.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 08:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b="m/DGlLRu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 13FEA8087256; Wed, 13 Sep 2023 04:21:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239964AbjIMLVH (ORCPT + 36 others); Wed, 13 Sep 2023 07:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239981AbjIMLU6 (ORCPT ); Wed, 13 Sep 2023 07:20:58 -0400 Received: from smtp105.iad3b.emailsrvr.com (smtp105.iad3b.emailsrvr.com [146.20.161.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E8D1BF4 for ; Wed, 13 Sep 2023 04:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604053; bh=RUuuQK6RPlCA9X76BGMNc6q5fXGNjtOHgTDLxmsqyIk=; h=From:To:Subject:Date:From; b=m/DGlLRubMjTxPlyNkNAT/jCu8dPo1jZOq/18UXdT3t2qpSqnov8NKgPl+3aFfvNZ qnr3RwcXZ31dRlbhT0A2pY5mN2I/4WTv7KGUW50xvKHhteLgOS285TUZl2wL0tiR7F OPPtdbCgbb133+98xLvF5KnXxTem6i5jCYSTDe9c= X-Auth-ID: abbotti@mev.co.uk Received: by smtp6.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id EB4B0200E5; Wed, 13 Sep 2023 07:20:52 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Niklas Schnelle , Ian Abbott Subject: [PATCH 04/13] comedi: comedi_8254: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 12:20:23 +0100 Message-Id: <20230913112032.90618-5-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-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 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:21:44 -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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776936120105195101 X-GMAIL-MSGID: 1776936120105195101 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 --- 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,