Skip to contentSkip to conversation

counter: ftm-quaddec: use devm_platform_ioremap_resource

PATCH In review Rosen Penev 2 participants 2 messages Jul 14 – Aug 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 counter: ftm-quaddec: 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 DT nodes (counter@29d0000 / counter@29e0000 in ls1021a.dtsi) each have a single 0x10000 reg region, so the region reservation added by devm_ioremap_resource() is exclusive and does not introduce overlap failures.

Built for ARM (drivers/counter/ftm-quaddec.o) with LLVM=1.

Assisted-by opencode:hy3-free
---
 drivers/counter/ftm-quaddec.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/counter/ftm-quaddec.c +6 -12
index 8455f16d62cb..ed93f3621d2a 100644
@@ -262,28 +262,22 @@ static int ftm_quaddec_probe(struct platform_device *pdev)
 	struct ftm_quaddec *ftm;
 
 	struct device_node *node = pdev->dev.of_node;
-	struct resource *io;
+	void __iomem *ftm_base;
 	int ret;
 
+	ftm_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(ftm_base))
+		return PTR_ERR(ftm_base);
+
 	counter = devm_counter_alloc(&pdev->dev, sizeof(*ftm));
 	if (!counter)
 		return -ENOMEM;
 	ftm = counter_priv(counter);
 
-	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!io) {
-		dev_err(&pdev->dev, "Failed to get memory region\n");
-		return -ENODEV;
-	}
-
 	ftm->pdev = pdev;
 	ftm->big_endian = of_property_read_bool(node, "big-endian");
-	ftm->ftm_base = devm_ioremap(&pdev->dev, io->start, resource_size(io));
+	ftm->ftm_base = ftm_base;
 
-	if (!ftm->ftm_base) {
-		dev_err(&pdev->dev, "Failed to map memory region\n");
-		return -EINVAL;
-	}
 	counter->name = dev_name(&pdev->dev);
 	counter->parent = &pdev->dev;
 	counter->ops = &ftm_quaddec_cnt_ops;
Signature · 1 line
2.55.0
#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 DT nodes (counter@29d0000 / counter@29e0000 in ls1021a.dtsi) each have a single 0x10000 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/counter/ftm-quaddec.o) with LLVM=1.

Assisted-by opencode:hy3-free

Hi Rosen,

Patrick Havelange is stepping down from maintenance of this driver, so ftm-quaddec is currently considered to be in an Orphan status.[^1] If a new maintainer comes along in the future to maintain this driver, they will be able to assist the review of this patch.

Sincerely,

William Breathitt Gray

[^1]: https://lore.kernel.org/all/[email protected]/