From patchwork Mon Apr 8 09:28:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 787298 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 336D844C94; Mon, 8 Apr 2024 09:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712568574; cv=none; b=nrBTKebsWyan1Pa5HHDlV4jWYe+jWes3U3N4UqhjbacB0jh2+rW2ygtkd82uvurGxEaHJRIG33+yiecgZ1jNC7Eho6WrARbO0/VYpn9vlpBlaFX3o+IX0egjyOBLLGo/VUFzC35xx7y0/x3EOCLo/fbPTZ8j8pAelQxH1o4FMxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712568574; c=relaxed/simple; bh=rBe98hJNY8XuRDecuH4PlMK9Yxww2sRXOAuYjPRlaSo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FjwqbiPfk898reaieovxhcnA+S/TTiYn+0K8t6o/YPof5FEloo7+mOefr5retlMEG2LwS96zg8xMb/+KVsMlVWmGx2+pJhHDJ9ig3THazx33+xFxdadDXMV3LkTP7NQHRJ85EjcWZkYOJqjHEbu1RvH6KUlUT9ufqNjGqX0JkB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F/5tfw9k; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F/5tfw9k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53DB5C433F1; Mon, 8 Apr 2024 09:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712568574; bh=rBe98hJNY8XuRDecuH4PlMK9Yxww2sRXOAuYjPRlaSo=; h=From:To:Cc:Subject:Date:From; b=F/5tfw9k/x4622llVirTzKRAmTFIFVEW9tt360apuDlDTQ9eGswCsqVW5y9GwqngK dMcgm1UeYSkA+sPdVRHJ+0i/fiWliU5R3hHxJy73wWJClqR27AqTGk5Mn2GEIJUJiV oYP4PyAUaSgLaxlXGgav7sKDlrsWYvEwa/o+fIs/PrbIBtM+0z/RseVXehWb4s3bUt uB7iOqmEaiuExGwCgrhIN0CB2zQhBpDddZVM0L8qC9LDcLr0oyrnjTW2NvzxlKhuFV fmXmYim5kTYd4kBg7hslAnPwQpmshGG863YD+COo1SFOe3g1Sxo5atQZkeBpw0RqiV ljAlL/QZOfO2g== From: Arnd Bergmann To: Andi Shyti , Peter Korsgaard , Andrew Lunn Cc: Arnd Bergmann , Geert Uytterhoeven , Wolfram Sang , Jarkko Nikula , Geert Uytterhoeven , Niklas Schnelle , Samuel Holland , Gregor Herburger , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO Date: Mon, 8 Apr 2024 11:28:36 +0200 Message-Id: <20240408092923.2816928-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann There is at least one machine that uses this driver but does not have support for inb()/outb() instructions. Convert this to using ioport_map() so it can build on architectures that don't provide these but work correctly on machines that require using port I/O. Fixes: 53f44c1005ba ("i2c: add HAS_IOPORT dependencies") Reported-by: Geert Uytterhoeven Link: https://lore.kernel.org/lkml/CAMuHMdVUQ2WgtpYPYfO2T=itMmZ7w=geREqDtsP8Q3ODh9rxdw@mail.gmail.com/ Signed-off-by: Arnd Bergmann Acked-by: Peter Korsgaard --- drivers/i2c/busses/Kconfig | 1 - drivers/i2c/busses/i2c-ocores.c | 21 +++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 2d5e74ac9ea0..64c985ec0fae 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -886,7 +886,6 @@ config I2C_NPCM config I2C_OCORES tristate "OpenCores I2C Controller" - depends on HAS_IOPORT help If you say yes to this option, support will be included for the OpenCores I2C controller. For details see diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index e106af83cef4..56a4dabf5a38 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c @@ -32,7 +32,6 @@ */ struct ocores_i2c { void __iomem *base; - int iobase; u32 reg_shift; u32 reg_io_width; unsigned long flags; @@ -136,16 +135,6 @@ static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg) return ioread32be(i2c->base + (reg << i2c->reg_shift)); } -static void oc_setreg_io_8(struct ocores_i2c *i2c, int reg, u8 value) -{ - outb(value, i2c->iobase + reg); -} - -static inline u8 oc_getreg_io_8(struct ocores_i2c *i2c, int reg) -{ - return inb(i2c->iobase + reg); -} - static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) { i2c->setreg(i2c, reg, value); @@ -618,15 +607,19 @@ static int ocores_i2c_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) return -EINVAL; - i2c->iobase = res->start; if (!devm_request_region(&pdev->dev, res->start, resource_size(res), pdev->name)) { dev_err(&pdev->dev, "Can't get I/O resource.\n"); return -EBUSY; } - i2c->setreg = oc_setreg_io_8; - i2c->getreg = oc_getreg_io_8; + i2c->base = devm_ioport_map(&pdev->dev, res->start, + resource_size(res)); + if (!i2c->base) { + dev_err(&pdev->dev, "Can't map I/O resource.\n"); + return -EBUSY; + } + i2c->reg_io_width = 1; } pdata = dev_get_platdata(&pdev->dev);