Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3571601rdb; Wed, 13 Sep 2023 16:53:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhz6OBY1a+g8QYcn7Aua8fyLTweZE7MpFVy7sYp6vFqNCx4LkV9g/aasxbhK/KwY67qbjK X-Received: by 2002:a17:903:4d7:b0:1c0:b17a:7554 with SMTP id jm23-20020a17090304d700b001c0b17a7554mr3790440plb.64.1694649217188; Wed, 13 Sep 2023 16:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694649217; cv=none; d=google.com; s=arc-20160816; b=W2UOrTGW70sLzGD4hv1fDVW+pzhQ/JlFf65Z+13tvmTSb+ucz4n1r7tXAhMLZqASOM gEhxCklIETVtx6icd5+aF4J6A6YoQkp+mdSaOYJqdXDdifi81VXMgdvJ8BZ3Fkq6yhH1 jv2zawQ9J6YQ7a691pdvNy2yAa9GVoLkzPDnwWdr1RYAgmkWCq8t2DZc52L0Gksu8ri8 OtmQpjYkWvcCyRWIHDKlQL7pkdcdGbdyMrZpZQ1YCNXk6JSulpBBxcBAq7AVEZoiEcyO ZNaRKACmJABgWzwdIvPbomkbtSuxESKsjs9Jg6WqkgX3DN/m/uqI30jF5StYC/XknOCH DIJw== 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=amwFXyodDrTJg6ZBC1M+yBTzllIDRwvGr/ZccLbTzDE=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=ZSDzqUYNwa4TMtUEyumn7E4jkYF/b8llEdaEb+kvDx8V9zQ8v0YQeG4348I2p8Jlbz rsduXOMzpGcYPzUVfb0Kk+AYMlS/laDXs+vuLDuKqPTXbVKvKik9qSk6P/M3t9A4/rpM jhcY+5sApfJ3SVcK3C57TvsImQwzvLn051W0eI8t8lIj9WrzIY4QThok9mlg6W0wzMCO DiDrkB6aLN+LbexUj1MiAQrFtEsOwx8By7xu1AExsB2Ei5F/HjI2IVJdzk/Pia64rwsD S6FasazynVnq5KIQXx1/wEdsXGtaN3eQB9Gkbrwm2xoTldY5dHOcmquBTWtz4/vn3dwz Jusw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=wJeRn3el; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id jx11-20020a170903138b00b001c20db2510asi380800plb.53.2023.09.13.16.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=wJeRn3el; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 A52448514B10; Wed, 13 Sep 2023 10:08:20 -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 S231309AbjIMRIN (ORCPT + 99 others); Wed, 13 Sep 2023 13:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjIMRHz (ORCPT ); Wed, 13 Sep 2023 13:07:55 -0400 Received: from smtp116.iad3a.emailsrvr.com (smtp116.iad3a.emailsrvr.com [173.203.187.116]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A52B2101 for ; Wed, 13 Sep 2023 10:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694624858; bh=6ZFcgRAEUSCWaH0d5A84bNr1FKTGpaMbxStcDrGLGaU=; h=From:To:Subject:Date:From; b=wJeRn3elyNGCOqnk1kBqsKLIFFkWbjwKjLa7l9nQqMghiwJ5AY12yABh0bzfX46s0 Z75nSGsAWhb+SH4DkNZN2kCmcK1vH9oW16CyqHKJYwGVrsyqIv+RiXJGvg3Eg6KVEW +swTRVZDl/pjZTirXLCZybrOd173p6+cre3lVaTk= X-Auth-ID: abbotti@mev.co.uk Received: by smtp39.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 373F554A5; Wed, 13 Sep 2023 13:07:37 -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 12/13] comedi: amplc_dio200_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 18:07:11 +0100 Message-Id: <20230913170712.111719-13-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 Content-Transfer-Encoding: 8bit X-Classification-ID: 19793052-af61-4898-a406-82596fa230be-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:08:20 -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_IOPORT` 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_IOPORT` 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_IOPORT` 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 --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT` in commit description. v3: N/A. --- 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