mirror of https://github.com/torvalds/linux.git
memory: pl172: simplify releasing AMBA regions with devm
Use devm_add_action_or_reset() and dev_err_probe() to make the probe() error handling simpler around amba_release_regions() cleanup. This allows to drop the remove() callback entirely. Suggested-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com> Acked-by: Vladimir Zapolskiy <vz@mleia.com> Reviewed-by: Vladimir Zapolskiy <vz@mleia.com> Link: https://lore.kernel.org/r/20240825135001.48963-1-krzysztof.kozlowski@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
This commit is contained in:
parent
84d1078af5
commit
331b8a9631
|
|
@ -187,6 +187,13 @@ static int pl172_parse_cs_config(struct amba_device *adev,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pl172_amba_release_regions(void *data)
|
||||||
|
{
|
||||||
|
struct amba_device *adev = data;
|
||||||
|
|
||||||
|
amba_release_regions(adev);
|
||||||
|
}
|
||||||
|
|
||||||
static const char * const pl172_revisions[] = {"r1", "r2", "r2p3", "r2p4"};
|
static const char * const pl172_revisions[] = {"r1", "r2", "r2p3", "r2p4"};
|
||||||
static const char * const pl175_revisions[] = {"r1"};
|
static const char * const pl175_revisions[] = {"r1"};
|
||||||
static const char * const pl176_revisions[] = {"r0"};
|
static const char * const pl176_revisions[] = {"r0"};
|
||||||
|
|
@ -232,13 +239,14 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = devm_add_action_or_reset(dev, pl172_amba_release_regions, adev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
pl172->base = devm_ioremap(dev, adev->res.start,
|
pl172->base = devm_ioremap(dev, adev->res.start,
|
||||||
resource_size(&adev->res));
|
resource_size(&adev->res));
|
||||||
if (!pl172->base) {
|
if (!pl172->base)
|
||||||
dev_err(dev, "ioremap failed\n");
|
return dev_err_probe(dev, -ENOMEM, "ioremap failed\n");
|
||||||
ret = -ENOMEM;
|
|
||||||
goto err_no_ioremap;
|
|
||||||
}
|
|
||||||
|
|
||||||
amba_set_drvdata(adev, pl172);
|
amba_set_drvdata(adev, pl172);
|
||||||
|
|
||||||
|
|
@ -256,15 +264,6 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_no_ioremap:
|
|
||||||
amba_release_regions(adev);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pl172_remove(struct amba_device *adev)
|
|
||||||
{
|
|
||||||
amba_release_regions(adev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct amba_id pl172_ids[] = {
|
static const struct amba_id pl172_ids[] = {
|
||||||
|
|
@ -292,7 +291,6 @@ static struct amba_driver pl172_driver = {
|
||||||
.name = "memory-pl172",
|
.name = "memory-pl172",
|
||||||
},
|
},
|
||||||
.probe = pl172_probe,
|
.probe = pl172_probe,
|
||||||
.remove = pl172_remove,
|
|
||||||
.id_table = pl172_ids,
|
.id_table = pl172_ids,
|
||||||
};
|
};
|
||||||
module_amba_driver(pl172_driver);
|
module_amba_driver(pl172_driver);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue