Skip to contentSkip to conversation

mfd: ti_am335x_tscadc: Use devm_ioremap_resource()

PATCH Applied Jingoo Han 2 participants 2 messages Feb 12, 2014 Multifunction devices (MFD)

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 mfd: ti_am335x_tscadc: Use devm_ioremap_resource()

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

---
 drivers/mfd/ti_am335x_tscadc.c |   23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/mfd/ti_am335x_tscadc.c +4 -19
index d4e8604..e0e081e 100644
@@ -184,12 +184,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no memory resource defined.\n");
-		return -EINVAL;
-	}
-
 	/* Allocate memory for device */
 	tscadc = devm_kzalloc(&pdev->dev,
 			sizeof(struct ti_tscadc_dev), GFP_KERNEL);
@@ -206,19 +200,10 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	} else
 		tscadc->irq = err;
 
-	res = devm_request_mem_region(&pdev->dev,
-			res->start, resource_size(res), pdev->name);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to reserve registers.\n");
-		return -EBUSY;
-	}
-
-	tscadc->tscadc_base = devm_ioremap(&pdev->dev,
-			res->start, resource_size(res));
-	if (!tscadc->tscadc_base) {
-		dev_err(&pdev->dev, "failed to map registers.\n");
-		return -ENOMEM;
-	}
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(tscadc->tscadc_base))
+		return PTR_ERR(tscadc->tscadc_base);
 
 	tscadc->regmap_tscadc = devm_regmap_init_mmio(&pdev->dev,
 			tscadc->tscadc_base, &tscadc_regmap_config);
Signature · 1 line
1.7.10.4
Applied
#1 lore raw
Quoted 8 lines

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

---
 drivers/mfd/ti_am335x_tscadc.c |   23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog