Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1222612lqe; Mon, 8 Apr 2024 02:29:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0CciZ7+yUU0q2dHzsW/EmaPQLAz2e1Y2l0ZpiyCrqHsEC2aVffIuD31cKfPLcRpKH8Swu2x8GVIVCpCG9WcKRKfUSI3Cno3jI2NqNMQ== X-Google-Smtp-Source: AGHT+IGNJxRQgBzxNSuPJg+UpqudegKkS68V/SASjIr4ZN72CefAD4KSb7Vm478u45/Bwq2XdHuz X-Received: by 2002:a50:cd9e:0:b0:56d:fc50:ec50 with SMTP id p30-20020a50cd9e000000b0056dfc50ec50mr7689113edi.13.1712568582279; Mon, 08 Apr 2024 02:29:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712568582; cv=pass; d=google.com; s=arc-20160816; b=PE+ehLBg0YpmiJMocaV4bDPUCakKMYFQ0RAIBRMZdKLVKqOXfwy84n4cWn0kXqF4fU ezPJ+LtJ7CfUeaxD2EXsLpNfQAdAAaRDlEGcIPGJRe5wmya2qhe9+JEXLpm7P8Pq3ADo hCnPK+/O83KroUI4IM/7E1AeYQzde7O2YMWKdbCLQPXgq+OfWAcafYM5YVxZMRxALoPy acQz+X2S52b7gQCf5j4JM7SNE9FlQuOahiv6K3UMzRNHtTBeFnh/frfD8gj6nG07jEW8 ztcSVlsP+9QKWUMAiL+/kaUByyZ0Cfd6pLvn0Sv7hGikEKgrVut5zUsRvuBkN67vbfL/ GcyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=lSkZ/qyheLDip88eoDXor99uDkWPNYWv/RDzvUiWGOI=; fh=4lFsFF7vQC87+wxbcn+d5E7fdaJQI8D7o4NIoHNWSUY=; b=cF3KN7R32OJ5YAjmEGwEKbZCChybd5hp3JDM21LAbtEQD2aKd3xuJ/6r4m9YL2Cl67 tsZYkRa83wnBVeCXTb22yca9qtgQDn6oAobsr8iek5fXqrTtymfT48UyNkVquICX2H69 46tKtWDUk/SLAeFcNTOkbj4sr3X0BTUNAL+fIznsuDfxG6SfKhgUB0fm3RsGi7Py0cdm 2RGMTwPPopCOoZA6OD4g95gFH8KBNxnPdCaado2p+xDw60dObeTFF47UWHfKXLuDWyLx bO8lpKMXFeIKPtYdcx5BAeUShLn6+bX5MJjauUgDqcFIPx21UWr/T+Y/QM2tch3XB42N 1iCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="F/5tfw9k"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135144-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h25-20020a50cdd9000000b0056e2e8a7b1bsi3587825edj.599.2024.04.08.02.29.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 02:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="F/5tfw9k"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135144-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 070BC1F21ECF for ; Mon, 8 Apr 2024 09:29:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15E6747F62; Mon, 8 Apr 2024 09:29:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F/5tfw9k" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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); -- 2.39.2