Skip to content

Commit 331b8a9

Browse files
committed
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 <[email protected]> Acked-by: Vladimir Zapolskiy <[email protected]> Reviewed-by: Vladimir Zapolskiy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent 84d1078 commit 331b8a9

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

drivers/memory/pl172.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ static int pl172_parse_cs_config(struct amba_device *adev,
187187
return -EINVAL;
188188
}
189189

190+
static void pl172_amba_release_regions(void *data)
191+
{
192+
struct amba_device *adev = data;
193+
194+
amba_release_regions(adev);
195+
}
196+
190197
static const char * const pl172_revisions[] = {"r1", "r2", "r2p3", "r2p4"};
191198
static const char * const pl175_revisions[] = {"r1"};
192199
static const char * const pl176_revisions[] = {"r0"};
@@ -232,13 +239,14 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id)
232239
return ret;
233240
}
234241

242+
ret = devm_add_action_or_reset(dev, pl172_amba_release_regions, adev);
243+
if (ret)
244+
return ret;
245+
235246
pl172->base = devm_ioremap(dev, adev->res.start,
236247
resource_size(&adev->res));
237-
if (!pl172->base) {
238-
dev_err(dev, "ioremap failed\n");
239-
ret = -ENOMEM;
240-
goto err_no_ioremap;
241-
}
248+
if (!pl172->base)
249+
return dev_err_probe(dev, -ENOMEM, "ioremap failed\n");
242250

243251
amba_set_drvdata(adev, pl172);
244252

@@ -256,15 +264,6 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id)
256264
}
257265

258266
return 0;
259-
260-
err_no_ioremap:
261-
amba_release_regions(adev);
262-
return ret;
263-
}
264-
265-
static void pl172_remove(struct amba_device *adev)
266-
{
267-
amba_release_regions(adev);
268267
}
269268

270269
static const struct amba_id pl172_ids[] = {
@@ -292,7 +291,6 @@ static struct amba_driver pl172_driver = {
292291
.name = "memory-pl172",
293292
},
294293
.probe = pl172_probe,
295-
.remove = pl172_remove,
296294
.id_table = pl172_ids,
297295
};
298296
module_amba_driver(pl172_driver);

0 commit comments

Comments
 (0)