| Message ID | 20260902200703.2016410-6-mukesh.ojha@oss.qualcomm.com |
|---|---|
| State | New |
| Headers | show |
| Series | media: Use devm_of_reserved_mem_device_init() | expand |
On Thu, Sep 3, 2026 at 4:08 AM Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> wrote: > > Use the devres-managed devm_of_reserved_mem_device_init() instead of > the manual of_reserved_mem_device_init()/of_reserved_mem_device_release() > pair, letting the device resource manager handle cleanup automatically. > > Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> > --- > drivers/media/platform/mediatek/vpu/mtk_vpu.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.c b/drivers/media/platform/mediatek/vpu/mtk_vpu.c > index 8d8319f0cd22..557bffb2c2f1 100644 > --- a/drivers/media/platform/mediatek/vpu/mtk_vpu.c > +++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.c > @@ -888,7 +888,7 @@ static int mtk_vpu_probe(struct platform_device *pdev) > dev_info(dev, "4GB mode %u\n", vpu->enable_4GB); > > if (vpu->enable_4GB) { > - ret = of_reserved_mem_device_init(dev); > + ret = devm_of_reserved_mem_device_init(dev); There are non-devm calls before this. Inserting a devm call in here messes up the unwind order and leads to confusion. In other words this is a bad idea. OOTH, the remove function is missing a release call. > if (ret) > dev_info(dev, "init reserved memory failed\n"); > /* continue to use dynamic allocation if failed */ > @@ -930,7 +930,6 @@ static int mtk_vpu_probe(struct platform_device *pdev) > free_d_mem: > vpu_free_ext_mem(vpu, D_FW); > remove_debugfs: > - of_reserved_mem_device_release(dev); > #ifdef CONFIG_DEBUG_FS > debugfs_remove(vpu_debugfs); > #endif > -- > 2.55.0 > >
diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.c b/drivers/media/platform/mediatek/vpu/mtk_vpu.c index 8d8319f0cd22..557bffb2c2f1 100644 --- a/drivers/media/platform/mediatek/vpu/mtk_vpu.c +++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.c @@ -888,7 +888,7 @@ static int mtk_vpu_probe(struct platform_device *pdev) dev_info(dev, "4GB mode %u\n", vpu->enable_4GB); if (vpu->enable_4GB) { - ret = of_reserved_mem_device_init(dev); + ret = devm_of_reserved_mem_device_init(dev); if (ret) dev_info(dev, "init reserved memory failed\n"); /* continue to use dynamic allocation if failed */ @@ -930,7 +930,6 @@ static int mtk_vpu_probe(struct platform_device *pdev) free_d_mem: vpu_free_ext_mem(vpu, D_FW); remove_debugfs: - of_reserved_mem_device_release(dev); #ifdef CONFIG_DEBUG_FS debugfs_remove(vpu_debugfs); #endif
Use the devres-managed devm_of_reserved_mem_device_init() instead of the manual of_reserved_mem_device_init()/of_reserved_mem_device_release() pair, letting the device resource manager handle cleanup automatically. Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> --- drivers/media/platform/mediatek/vpu/mtk_vpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)