[PATCH] counter: ftm-quaddec: use devm_platform_ioremap_resource

Rosen Penev <[email protected]>
Newsgroups dev.linux.lists.llvm,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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
Signed-off-by: Rosen Penev <[email protected]>
---
 drivers/counter/ftm-quaddec.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c
index 8455f16d62cb..ed93f3621d2a 100644
--- a/drivers/counter/ftm-quaddec.c
+++ b/drivers/counter/ftm-quaddec.c
@@ -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;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.