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

drm: zynqmp_dp: convert to devm_drm_bridge_alloc() API

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.

Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20250509-drm-bridge-convert-to-alloc-api-v3-17-b8bc1f16d7aa@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

+11 -21
+11 -20
drivers/gpu/drm/xlnx/zynqmp_dp.c
··· 2439 2439 struct zynqmp_dp *dp; 2440 2440 int ret; 2441 2441 2442 - dp = kzalloc(sizeof(*dp), GFP_KERNEL); 2443 - if (!dp) 2444 - return -ENOMEM; 2442 + dp = devm_drm_bridge_alloc(&pdev->dev, struct zynqmp_dp, bridge, &zynqmp_dp_bridge_funcs); 2443 + if (IS_ERR(dp)) 2444 + return PTR_ERR(dp); 2445 2445 2446 2446 dp->dev = &pdev->dev; 2447 2447 dp->dpsub = dpsub; ··· 2454 2454 2455 2455 /* Acquire all resources (IOMEM, IRQ and PHYs). */ 2456 2456 dp->iomem = devm_platform_ioremap_resource_byname(pdev, "dp"); 2457 - if (IS_ERR(dp->iomem)) { 2458 - ret = PTR_ERR(dp->iomem); 2459 - goto err_free; 2460 - } 2457 + if (IS_ERR(dp->iomem)) 2458 + return PTR_ERR(dp->iomem); 2461 2459 2462 2460 dp->irq = platform_get_irq(pdev, 0); 2463 - if (dp->irq < 0) { 2464 - ret = dp->irq; 2465 - goto err_free; 2466 - } 2461 + if (dp->irq < 0) 2462 + return dp->irq; 2467 2463 2468 2464 dp->reset = devm_reset_control_get(dp->dev, NULL); 2469 - if (IS_ERR(dp->reset)) { 2470 - ret = dev_err_probe(dp->dev, PTR_ERR(dp->reset), 2465 + if (IS_ERR(dp->reset)) 2466 + return dev_err_probe(dp->dev, PTR_ERR(dp->reset), 2471 2467 "failed to get reset\n"); 2472 - goto err_free; 2473 - } 2474 2468 2475 2469 ret = zynqmp_dp_reset(dp, true); 2476 2470 if (ret < 0) 2477 - goto err_free; 2471 + return ret; 2478 2472 2479 2473 ret = zynqmp_dp_reset(dp, false); 2480 2474 if (ret < 0) 2481 - goto err_free; 2475 + return ret; 2482 2476 2483 2477 ret = zynqmp_dp_phy_probe(dp); 2484 2478 if (ret) ··· 2480 2486 2481 2487 /* Initialize the bridge. */ 2482 2488 bridge = &dp->bridge; 2483 - bridge->funcs = &zynqmp_dp_bridge_funcs; 2484 2489 bridge->ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID 2485 2490 | DRM_BRIDGE_OP_HPD; 2486 2491 bridge->type = DRM_MODE_CONNECTOR_DisplayPort; ··· 2532 2539 zynqmp_dp_phy_exit(dp); 2533 2540 err_reset: 2534 2541 zynqmp_dp_reset(dp, true); 2535 - err_free: 2536 - kfree(dp); 2537 2542 return ret; 2538 2543 } 2539 2544
-1
drivers/gpu/drm/xlnx/zynqmp_dpsub.c
··· 180 180 void zynqmp_dpsub_release(struct zynqmp_dpsub *dpsub) 181 181 { 182 182 kfree(dpsub->disp); 183 - kfree(dpsub->dp); 184 183 kfree(dpsub); 185 184 } 186 185