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(). Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
bcb5a7d335
commit
924ff918ad
|
@ -183,12 +183,6 @@ static int ti_tscadc_probe(struct platform_device *pdev)
|
||||||
return -EINVAL;
|
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 */
|
/* Allocate memory for device */
|
||||||
tscadc = devm_kzalloc(&pdev->dev,
|
tscadc = devm_kzalloc(&pdev->dev,
|
||||||
sizeof(struct ti_tscadc_dev), GFP_KERNEL);
|
sizeof(struct ti_tscadc_dev), GFP_KERNEL);
|
||||||
|
@ -205,19 +199,10 @@ static int ti_tscadc_probe(struct platform_device *pdev)
|
||||||
} else
|
} else
|
||||||
tscadc->irq = err;
|
tscadc->irq = err;
|
||||||
|
|
||||||
res = devm_request_mem_region(&pdev->dev,
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
res->start, resource_size(res), pdev->name);
|
tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res);
|
||||||
if (!res) {
|
if (IS_ERR(tscadc->tscadc_base))
|
||||||
dev_err(&pdev->dev, "failed to reserve registers.\n");
|
return PTR_ERR(tscadc->tscadc_base);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
tscadc->regmap_tscadc = devm_regmap_init_mmio(&pdev->dev,
|
tscadc->regmap_tscadc = devm_regmap_init_mmio(&pdev->dev,
|
||||||
tscadc->tscadc_base, &tscadc_regmap_config);
|
tscadc->tscadc_base, &tscadc_regmap_config);
|
||||||
|
|
Loading…
Reference in New Issue