Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3561914rdb; Wed, 13 Sep 2023 16:29:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOXNupPAEjKrPf+sDQWnXLmplSp/5/4cVwnmbmL4MyYT53HrvLmaUtlvnJKeR4AMujJusV X-Received: by 2002:a05:6808:158c:b0:3a3:37dd:e052 with SMTP id t12-20020a056808158c00b003a337dde052mr4989411oiw.5.1694647746387; Wed, 13 Sep 2023 16:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694647746; cv=none; d=google.com; s=arc-20160816; b=BRQ1jHFUnzbBlu65EIcP059rzSXrHH1wrJE1SehZ9GGhp3EI6jSPlbgT3i77JqciWI eYP/Oy/KPSQwpsa+Xp1WnjTDRv6Hl+awdj7pmXKPunDmY4dHd+ieTM0UgZhBSKyWkbtx 8oVL4ngI32kRkwNbBJ1sAb04XkUyJdTndZWmolFp1P8WRz3ifKHIse/AcEgaEXPgB7Qi YqO9k9r/iQq09Q2AD6E0w2sRSuE6gE1H2ctN9VqqkeyscdbGj9T6kftUk5kpzQ2hUopK Wxhbq3ZDGLxy2qhv+pGiuYoA3zCouhvirMcUhdpNkGkLCxBJI0Dmxa5A/3TCMaFH8MMr lSSw== 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=JGadvbd7WW7v8H9e4fqyI41HdpAmopH30WkSwOV87H8=; fh=kwtD2hwqQlovK7ZFEo+a1+lZVyuMpHjK7AWAyN3Ssmk=; b=M/k+fcbQhmhhIpz2+MtDW/PKs3HPN4rkAG0hJy+rcNlwKZMzedWUUbVLvNRMohjc19 gmbPCnJ32VGHj7hNoWiAtHQPyecw6xN8bleyFf4ZNkx2FBNpObBzSlAOGnRSuBVO4H7k 114UnJcJ2T17F7XvVti8R4cRFIUfITU6AdpevsHboVMAjr2QSphwhpNSpKILrwJ7fp3K PxHPglPLfni5mXmQYH3UIIdC4xWlDFmWkzV01BqHISx9mwI2PIsdgZyraqr7qV+pmegK Ur56jxJZfhUTc2qumBP8NGXtVWJ/dWVdtkqpdb1AUsZdcgvuDJwAgrndufn/Es9/38Ji m8ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=sEl2+aLn; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z11-20020a6552cb000000b00564beb6145fsi158204pgp.765.2023.09.13.16.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:29:06 -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=sEl2+aLn; 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 D585E820DA3C; Wed, 13 Sep 2023 04:21:40 -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 S240042AbjIMLVl (ORCPT + 99 others); Wed, 13 Sep 2023 07:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240143AbjIMLVM (ORCPT ); Wed, 13 Sep 2023 07:21:12 -0400 Received: from smtp107.iad3b.emailsrvr.com (smtp107.iad3b.emailsrvr.com [146.20.161.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7B11FFA for ; Wed, 13 Sep 2023 04:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694604062; bh=jTD6S3A1Mblo08Ha6IHdDgLu3daAAvWNJ47NXzRPFbY=; h=From:To:Subject:Date:From; b=sEl2+aLn6Xc+W4/UAwUrBIoz//hn8cHie7Qub//h7gjId6fdYpfNlagJZ4SesJNeF 9lbYpxZpqanQlpGByKy5shOy4/weL4SmCLB1l+rsWikzy5uND+nG46eQx3vJVqZxBs d+GPqpS6WhTi6aVH/APWsO+ehRsGsTSgjCH7RRwE= X-Auth-ID: abbotti@mev.co.uk Received: by smtp6.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id E0A94200C1; Wed, 13 Sep 2023 07:21:01 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Niklas Schnelle , Ian Abbott Subject: [PATCH 12/13] comedi: amplc_dio200_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 12:20:31 +0100 Message-Id: <20230913112032.90618-13-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 Content-Transfer-Encoding: 8bit X-Classification-ID: e346d63c-f057-4595-b974-8be9cf32e1c1-13-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:41 -0700 (PDT) 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 amplc_dio200_common module is used by the amplc_dio200 module (for ISA cards) and the amplc_dio200_pci module (for PCI and PCI Express cards). It supports both port I/O and memory-mapped I/O. Port I/O and memory-mapped I/O is confined to the `dio200___read8()`, `dio200___read32()`, `dio200___write8()` and `dio200___write32()` functions. Conditionally compile two versions of those functions. If the `CONFIG_HAS_PORTIO` macro is defined, call either the port I/O or memory mapped I/O functions depending on the `mmio` member of the `struct comedi_device`. If the `CONFIG_HAS_PORTIO` macro is undefined only call the memory-mapped I/O functions. Add a run-time check to `amplc_dio200_common_attach()` to return an error if the device wants to use port I/O when the `CONFIG_HAS_PORTIO` macro is undefined. The changes allow the module to be built even if the port I/O functions have not been declared. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- drivers/comedi/drivers/amplc_dio200_common.c | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/comedi/drivers/amplc_dio200_common.c b/drivers/comedi/drivers/amplc_dio200_common.c index e6d63e89e7bf..b1a9b4c4a185 100644 --- a/drivers/comedi/drivers/amplc_dio200_common.c +++ b/drivers/comedi/drivers/amplc_dio200_common.c @@ -86,6 +86,8 @@ struct dio200_subdev_intr { unsigned int active:1; }; +#ifdef CONFIG_HAS_IOPORT + static unsigned char dio200___read8(struct comedi_device *dev, unsigned int offset) { @@ -120,6 +122,34 @@ static void dio200___write32(struct comedi_device *dev, outl(val, dev->iobase + offset); } +#else /* CONFIG_HAS_IOPORT */ + +static unsigned char dio200___read8(struct comedi_device *dev, + unsigned int offset) +{ + return readb(dev->mmio + offset); +} + +static void dio200___write8(struct comedi_device *dev, + unsigned int offset, unsigned char val) +{ + writeb(val, dev->mmio + offset); +} + +static unsigned int dio200___read32(struct comedi_device *dev, + unsigned int offset) +{ + return readl(dev->mmio + offset); +} + +static void dio200___write32(struct comedi_device *dev, + unsigned int offset, unsigned int val) +{ + writel(val, dev->mmio + offset); +} + +#endif /* CONFIG_HAS_IOPORT */ + static unsigned char dio200_read8(struct comedi_device *dev, unsigned int offset) { @@ -803,6 +833,12 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, unsigned int n; int ret; + if (!IS_ENABLED(CONFIG_HAS_IOPORT) && !dev->mmio) { + dev_err(dev->class_dev, + "error! need I/O port support\n"); + return -ENXIO; + } + ret = comedi_alloc_subdevices(dev, board->n_subdevs); if (ret) return ret; -- 2.40.1