Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+13 -15
+13 -15
drivers/memory/pl172.c
··· 187 187 return -EINVAL; 188 188 } 189 189 190 + static void pl172_amba_release_regions(void *data) 191 + { 192 + struct amba_device *adev = data; 193 + 194 + amba_release_regions(adev); 195 + } 196 + 190 197 static const char * const pl172_revisions[] = {"r1", "r2", "r2p3", "r2p4"}; 191 198 static const char * const pl175_revisions[] = {"r1"}; 192 199 static const char * const pl176_revisions[] = {"r0"}; ··· 239 232 return ret; 240 233 } 241 234 235 + ret = devm_add_action_or_reset(dev, pl172_amba_release_regions, adev); 236 + if (ret) 237 + return ret; 238 + 242 239 pl172->base = devm_ioremap(dev, adev->res.start, 243 240 resource_size(&adev->res)); 244 - if (!pl172->base) { 245 - dev_err(dev, "ioremap failed\n"); 246 - ret = -ENOMEM; 247 - goto err_no_ioremap; 248 - } 241 + if (!pl172->base) 242 + return dev_err_probe(dev, -ENOMEM, "ioremap failed\n"); 249 243 250 244 amba_set_drvdata(adev, pl172); 251 245 ··· 264 256 } 265 257 266 258 return 0; 267 - 268 - err_no_ioremap: 269 - amba_release_regions(adev); 270 - return ret; 271 - } 272 - 273 - static void pl172_remove(struct amba_device *adev) 274 - { 275 - amba_release_regions(adev); 276 259 } 277 260 278 261 static const struct amba_id pl172_ids[] = { ··· 291 292 .name = "memory-pl172", 292 293 }, 293 294 .probe = pl172_probe, 294 - .remove = pl172_remove, 295 295 .id_table = pl172_ids, 296 296 }; 297 297 module_amba_driver(pl172_driver);