Skip to content

Commit

Permalink
thermal: tsens: switch from of_iomap() to devm_ioremap_resource()
Browse files Browse the repository at this point in the history
devm_ioremap_resources() automatically requests resources (so that the I/O
region shows up in /proc/iomem) and devm_ wrappers do better error handling
and unmapping of the I/O region when needed.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Amit Kucheria authored and Eduardo Valentin committed Jul 27, 2018
1 parent e0fe014 commit faa590b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/thermal/qcom/tsens-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@ static const struct regmap_config tsens_config = {
int __init init_common(struct tsens_device *tmdev)
{
void __iomem *base;
struct resource *res;
struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node);

if (!op)
return -EINVAL;
base = of_iomap(tmdev->dev->of_node, 0);
if (!base)
return -EINVAL;

/* The driver only uses the TM register address space for now */
if (op->num_resources > 1) {
Expand All @@ -143,11 +141,14 @@ int __init init_common(struct tsens_device *tmdev)
tmdev->tm_offset = 0x1000;
}

res = platform_get_resource(op, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&op->dev, res);
if (IS_ERR(base))
return PTR_ERR(base);

tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config);
if (IS_ERR(tmdev->map)) {
iounmap(base);
if (IS_ERR(tmdev->map))
return PTR_ERR(tmdev->map);
}

return 0;
}

0 comments on commit faa590b

Please sign in to comment.