[PATCH 29/34] drm: zynqmp_dp: convert to devm_drm_bridge_alloc() API
Tomi Valkeinen
tomi.valkeinen at ideasonboard.com
Wed Apr 16 05:31:41 PDT 2025
Hi,
On 07/04/2025 17:23, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
>
> This driver has a peculiar structure. zynqmp_dpsub.c is the actual driver,
> which delegates to a submodule (zynqmp_dp.c) the allocation of a
> sub-structure embedding the drm_bridge and its initialization, however it
> does not delegate the drm_bridge_add(). Hence, following carefully the code
> flow, it is correct to change the allocation function and .funcs assignment
> in the submodule, while the drm_bridge_add() is not in that submodule.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli at bootlin.com>
>
> ---
>
> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Cc: Michal Simek <michal.simek at amd.com>
> Cc: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> ---
> drivers/gpu/drm/xlnx/zynqmp_dp.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> index 11d2415fb5a1f7fad03421898331289f2295d68b..de22b6457a78a7a2110f9f308d0b5a8700544010 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> @@ -2439,9 +2439,9 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
> struct zynqmp_dp *dp;
> int ret;
>
> - dp = kzalloc(sizeof(*dp), GFP_KERNEL);
> - if (!dp)
> - return -ENOMEM;
> + dp = devm_drm_bridge_alloc(&pdev->dev, struct zynqmp_dp, bridge, &zynqmp_dp_bridge_funcs);
> + if (IS_ERR(dp))
> + return PTR_ERR(dp);
>
> dp->dev = &pdev->dev;
> dp->dpsub = dpsub;
> @@ -2488,7 +2488,6 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
>
> /* Initialize the bridge. */
> bridge = &dp->bridge;
> - bridge->funcs = &zynqmp_dp_bridge_funcs;
> bridge->ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
> | DRM_BRIDGE_OP_HPD;
> bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
>
To add to my last mail, this clearly cannot be right, as it changes
kzalloc call to devm_* call, without removing the kfree()s...
Tomi
More information about the Linux-mediatek
mailing list