Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp282474ybm; Thu, 28 May 2020 02:37:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0fNwwx+GGatRzWHjZntCET0G0K7jA+u2lacyFAPrWPRQWvWS9iEmXYapZnLNWuAK5Zo80 X-Received: by 2002:a50:e711:: with SMTP id a17mr2100934edn.369.1590658654495; Thu, 28 May 2020 02:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590658654; cv=none; d=google.com; s=arc-20160816; b=PgoYkPbUUel38kHs5HdelV6KrEv2SngUngf2QdiQ7/RoFq8igbySPEPSYn+/8w1CNa 5M9rC7R7o+UtzpL5vegP0NmnLmJqzmAWDz6GtuHpSjQ9hlTw2xfBglof9xGcweA+ZXzM /GoE94gzZzM8K3ou/iUlRctMMtxLx1y23kR4u+u5Tux7yHgwSB+Ugm0eiPWd5B5BY57a YKzcAhXT6zrge8zizd5Gf3EXyYalAoJP4qMrCPOXTYBtjlUULyf24zNBTB28xHz2BByP mHi5/DOpZKCUGDl2zdzjQY+J1n45UQfcjLMeT6ZmXZ2so6L8sh0H277lRnhSAS36beN6 d7Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8A1iedUpKrjhenzDkw4URsp6mjKkL8IQqtETFkNEWYE=; b=srNqIk7E43ECDwIQZLv+Lf9yEMIoL5b8radFyy8hD2m2qDXKr7vUBvOvCEHMfnCIYD 83vCX5+gwua5Ov2fHd6sgiFq1vO+Jid9v9DpvuNdTrfOs5dMsyU+kC8TNcQqgIGOEs5P kAbVXGYzg5wIAHKex9tCKxz7ocLCDo4nJwgXbM0Qo5tyoGu2vAyKdH4Gf0PcXh63LHEe 3TPUaJMCiqN1b/d8byVBvVDX9A9qMZO5RDZkg9D7yUT8RZbaFJfCuy3TyJ/ye4pVmv3Z 8gYk8mjPtplf/UipsCzio9toLWtanbBaHERHf9HpmEr32XcS9Kd4YqshpfD0oqliIbZP ctXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l22si3222797eds.197.2020.05.28.02.37.12; Thu, 28 May 2020 02:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387538AbgE1JeE (ORCPT + 99 others); Thu, 28 May 2020 05:34:04 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:40618 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387440AbgE1Jdi (ORCPT ); Thu, 28 May 2020 05:33:38 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 19AD1803083A; Thu, 28 May 2020 09:33:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Og9TnaDgPqFS; Thu, 28 May 2020 12:33:34 +0300 (MSK) From: Serge Semin To: Jarkko Nikula , Wolfram Sang , Andy Shevchenko , Mika Westerberg CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Rob Herring , , , , Subject: [PATCH v6 10/11] i2c: designware: Move reg-space remapping into a dedicated function Date: Thu, 28 May 2020 12:33:20 +0300 Message-ID: <20200528093322.23553-11-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200528093322.23553-1-Sergey.Semin@baikalelectronics.ru> References: <20200528093322.23553-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a preparation patch before adding a quirk with custom registers map creation required for the Baikal-T1 System I2C support. Signed-off-by: Serge Semin Reviewed-by: Andy Shevchenko Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Rob Herring Cc: linux-mips@vger.kernel.org Cc: devicetree@vger.kernel.org --- Changelog v3: - This is a new patch, which has been created due to declining the glue-layer approach. Changelog v4: - Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() method. - Discard devm_platform_get_and_ioremap_resource() utilization. --- drivers/i2c/busses/i2c-designware-platdrv.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 38657d821c72..9d467fa0e163 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -108,6 +108,15 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev) pm_runtime_put_noidle(dev->dev); } +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) +{ + struct platform_device *pdev = to_platform_device(dev->dev); + + dev->base = devm_platform_ioremap_resource(pdev, 0); + + return PTR_ERR_OR_ZERO(dev->base); +} + static int dw_i2c_plat_probe(struct platform_device *pdev) { struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -125,15 +134,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) return -ENOMEM; dev->flags = (uintptr_t)device_get_match_data(&pdev->dev); - - dev->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(dev->base)) - return PTR_ERR(dev->base); - dev->dev = &pdev->dev; dev->irq = irq; platform_set_drvdata(pdev, dev); + ret = dw_i2c_plat_request_regs(dev); + if (ret) + return ret; + dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); if (IS_ERR(dev->rst)) return PTR_ERR(dev->rst); -- 2.26.2