Hallo Andy, On Mon, 28 Apr 2025 20:44:03 +0800 (CST) "Andy Yan" <andys...@163.com> wrote:
> Hi , > > At 2025-04-25 02:59:08, "Luca Ceresoli" <luca.ceres...@bootlin.com> wrote: > >devm_drm_bridge_alloc() is the new API to be used for allocating (and > >partially initializing) a private driver struct embedding a struct > >drm_bridge. > > > >For many drivers having a simple code flow in the probe function, this > >commit does a mass conversion automatically with the following semantic > >patch. The changes have been reviewed manually for correctness as well as > >to find any false positives. > > > > @@ > > type T; > > identifier C; > > identifier BR; > > expression DEV; > > expression FUNCS; > > @@ > > -T *C; > > +T *C; > > ... > > ( > > -C = devm_kzalloc(DEV, ...); > > -if (!C) > > - return -ENOMEM; > > +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS); > > +if (IS_ERR(C)) > > + return PTR_ERR(C); > > | > > -C = devm_kzalloc(DEV, ...); > > -if (!C) > > - return ERR_PTR(-ENOMEM); > > +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS); > > +if (IS_ERR(C)) > > + return PTR_ERR(C); > > ) > > ... > > -C->BR.funcs = FUNCS; > > > >Signed-off-by: Luca Ceresoli <luca.ceres...@bootlin.com> [...] > >diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c > >b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c > >index > >5e5f8c2f95be1f5c4633f1093b17a00f9425bb37..9b1dfdb5e7ee528c876c01916c9821d550cad679 > > 100644 > >--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c > >+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c > >@@ -1045,9 +1045,10 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct > >platform_device *pdev, > > return ERR_PTR(-ENODEV); > > } > > > >- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); > >- if (!hdmi) > >- return ERR_PTR(-ENOMEM); > >+ hdmi = devm_drm_bridge_alloc(dev, struct dw_hdmi_qp, bridge, > >+ &dw_hdmi_qp_bridge_funcs); > >+ if (IS_ERR(hdmi)) > >+ return PTR_ERR(hdmi); > > This should return hdmi or ERR_CAST(hdmi); Indeed, thanks! My coccinelle patch is clearly not clever enough. I'll see whether I can fix it, otherwise I'll handle these 3 special cases manually, along with another similar one (imx/imx-legacy-bridge.c) I just spotted after your report. Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com