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

Configure Feed

Select the types of activity you want to include in your feed.

remoteproc: wkup_m3: Use devm_rproc_alloc() helper

Use the device lifecycle managed allocation function. This helps prevent
mistakes like freeing out of order in cleanup functions and forgetting to
free on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250814153940.670564-3-afd@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

authored by

Andrew Davis and committed by
Mathieu Poirier
9b84eec6 642f8c01

+8 -20
+8 -20
drivers/remoteproc/wkup_m3_rproc.c
··· 165 165 if (ret) 166 166 return dev_err_probe(dev, ret, "failed to add disable pm devm action\n"); 167 167 168 - rproc = rproc_alloc(dev, "wkup_m3", &wkup_m3_rproc_ops, 169 - fw_name, sizeof(*wkupm3)); 168 + rproc = devm_rproc_alloc(dev, "wkup_m3", &wkup_m3_rproc_ops, 169 + fw_name, sizeof(*wkupm3)); 170 170 if (!rproc) 171 171 return -ENOMEM; 172 172 ··· 183 183 if (!wkupm3->rsts) { 184 184 if (!(pdata && pdata->deassert_reset && pdata->assert_reset && 185 185 pdata->reset_name)) { 186 - dev_err(dev, "Platform data missing!\n"); 187 - ret = -ENODEV; 188 - goto err_put_rproc; 186 + return dev_err_probe(dev, -ENODEV, "Platform data missing!\n"); 189 187 } 190 188 } 191 189 ··· 191 193 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 192 194 mem_names[i]); 193 195 wkupm3->mem[i].cpu_addr = devm_ioremap_resource(dev, res); 194 - if (IS_ERR(wkupm3->mem[i].cpu_addr)) { 195 - dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n", 196 - i); 197 - ret = PTR_ERR(wkupm3->mem[i].cpu_addr); 198 - goto err_put_rproc; 199 - } 196 + if (IS_ERR(wkupm3->mem[i].cpu_addr)) 197 + return dev_err_probe(dev, PTR_ERR(wkupm3->mem[i].cpu_addr), 198 + "devm_ioremap_resource failed for resource %d\n", i); 200 199 wkupm3->mem[i].bus_addr = res->start; 201 200 wkupm3->mem[i].size = resource_size(res); 202 201 addrp = of_get_address(dev->of_node, i, &size, NULL); ··· 211 216 dev_set_drvdata(dev, rproc); 212 217 213 218 ret = rproc_add(rproc); 214 - if (ret) { 215 - dev_err(dev, "rproc_add failed\n"); 216 - goto err_put_rproc; 217 - } 219 + if (ret) 220 + return dev_err_probe(dev, ret, "rproc_add failed\n"); 218 221 219 222 return 0; 220 - 221 - err_put_rproc: 222 - rproc_free(rproc); 223 - return ret; 224 223 } 225 224 226 225 static void wkup_m3_rproc_remove(struct platform_device *pdev) ··· 222 233 struct rproc *rproc = platform_get_drvdata(pdev); 223 234 224 235 rproc_del(rproc); 225 - rproc_free(rproc); 226 236 } 227 237 228 238 #ifdef CONFIG_PM