Skip to contentSkip to conversation

clk: hisilicon: hi3660-stub: use devm_platform_ioremap_resource

PATCH In review Rosen Penev 2 participants 2 messages Jul 19 – Jul 20 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: hisilicon: hi3660-stub: use devm_platform_ioremap_resource

Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with devm_platform_ioremap_resource(), which fetches the resource, requests the region and maps it in one call. Switch the error check to IS_ERR()/PTR_ERR() and drop the now-unused struct resource pointer.

The only in-tree user (stub_clock@e896b500 in hi3660.dtsi) has a single 0x100-byte reg region, so the region reservation added by devm_ioremap_resource() is exclusive and does not introduce overlap failures.

Built for ARM (drivers/clk/hisilicon/clk-hi3660-stub.o) with LLVM=1.

Assisted-by opencode:hy3-free
---
 drivers/clk/hisilicon/clk-hi3660-stub.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clk/hisilicon/clk-hi3660-stub.c +3 -7
index 7c8b00ee6019..1b81f26670ed 100644
@@ -124,7 +124,6 @@ static struct clk_hw *hi3660_stub_clk_hw_get(struct of_phandle_args *clkspec,
 static int hi3660_stub_clk_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	unsigned int i;
 	int ret;
 
@@ -139,12 +138,9 @@ static int hi3660_stub_clk_probe(struct platform_device *pdev)
 	if (IS_ERR(stub_clk_chan.mbox))
 		return PTR_ERR(stub_clk_chan.mbox);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-	freq_reg = devm_ioremap(dev, res->start, resource_size(res));
-	if (!freq_reg)
-		return -ENOMEM;
+	freq_reg = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(freq_reg))
+		return PTR_ERR(freq_reg);
 
 	freq_reg += HI3660_STUB_CLOCK_DATA;
 
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Rosen Penev

Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with devm_platform_ioremap_resource(), which fetches the resource, requests the region and maps it in one call. Switch the error check to IS_ERR()/PTR_ERR() and drop the now-unused struct resource pointer.

The only in-tree user (stub_clock@e896b500 in hi3660.dtsi) has a single 0x100-byte reg region, so the region reservation added by devm_ioremap_resource() is exclusive and does not introduce overlap failures.

Quoted 4 lines

Built for ARM (drivers/clk/hisilicon/clk-hi3660-stub.o) with LLVM=1.

Assisted-by opencode:hy3-free