mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chunyan Zhang <zhang.chunyan@linaro.org>
To: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	Orson Zhai <orsonzhai@gmail.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Baolin Wang <baolin.wang@linaro.org>
Subject: [PATCH v2 1/3] clk: sprd: Switch from of_iomap() to devm_ioremap_resource()
Date: Wed, 22 May 2019 09:15:01 +0800	[thread overview]
Message-ID: <20190522011504.19342-2-zhang.chunyan@linaro.org> (raw)
In-Reply-To: <20190522011504.19342-1-zhang.chunyan@linaro.org>

devm_ioremap_resources() automatically requests resources and devm_ wrappers
do better error handling and unmapping of the I/O region when needed,
that would make drivers more clean and simple.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 drivers/clk/sprd/common.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c
index e038b0447206..9ce690999eaa 100644
--- a/drivers/clk/sprd/common.c
+++ b/drivers/clk/sprd/common.c
@@ -42,6 +42,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
 	void __iomem *base;
 	struct device_node *node = pdev->dev.of_node;
 	struct regmap *regmap;
+	struct resource *res;
 
 	if (of_find_property(node, "sprd,syscon", NULL)) {
 		regmap = syscon_regmap_lookup_by_phandle(node, "sprd,syscon");
@@ -50,7 +51,11 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
 			return PTR_ERR(regmap);
 		}
 	} else {
-		base = of_iomap(node, 0);
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(base))
+			return PTR_ERR(base);
+
 		regmap = devm_regmap_init_mmio(&pdev->dev, base,
 					       &sprdclk_regmap_config);
 		if (IS_ERR_OR_NULL(regmap)) {
-- 
2.17.1


  reply	other threads:[~2019-05-22  1:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  1:15 [PATCH v2 0/3] Return immediately if sprd_clk_regmap_init() fails Chunyan Zhang
2019-05-22  1:15 ` Chunyan Zhang [this message]
2019-05-22  2:07   ` [PATCH v2 1/3] clk: sprd: Switch from of_iomap() to devm_ioremap_resource() Baolin Wang
2019-06-26 18:16   ` Stephen Boyd
2019-06-27  7:52     ` Chunyan Zhang
2019-05-22  1:15 ` [PATCH v2 2/3] clk: sprd: Check error only for devm_regmap_init_mmio() Chunyan Zhang
2019-05-22  2:08   ` Baolin Wang
2019-06-26 18:16   ` Stephen Boyd
2019-05-22  1:15 ` [PATCH v2 3/3] clk: sprd: Add check for return value of sprd_clk_regmap_init() Chunyan Zhang
2019-06-26 18:16   ` Stephen Boyd
2019-05-22  1:15 ` [PATCH v2 3/3] clk: sprd: Add check the " Chunyan Zhang
2019-05-22  1:26 ` [PATCH v2 0/3] Return immediately if sprd_clk_regmap_init() fails Chunyan Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522011504.19342-2-zhang.chunyan@linaro.org \
    --to=zhang.chunyan@linaro.org \
    --cc=baolin.wang@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®