]> git.ipfire.org Git - thirdparty/linux.git/commit
drm/bridge: tc358767: convert to devm_drm_bridge_alloc() API
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 28 May 2025 09:29:36 +0000 (11:29 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Thu, 19 Jun 2025 12:56:19 +0000 (14:56 +0200)
commita59a271769149f0b8258507276f3d2a24370cbdb
tree0a06cf538bb66d9532db2732c1085d0b96cda7fc
parent1a45ef022f0364186d4fb2f4e5255dcae1ff638a
drm/bridge: tc358767: convert to devm_drm_bridge_alloc() API

This is the new API for allocating DRM bridges.

Converting this driver is a bit complex because the drm_bridge funcs
pointer differs based on the bridge mode. So the current code does:

 * tc_probe()
   * devm_kzalloc() private struct embedding drm_bridge
   * call tc_probe_bridge_endpoint() which
     * parses DT description into struct fields
     * computes the mode
     * calls different bridge init functions based on the mode
       * each sets a different bridge.funcs pointer

The new API expects the funcs pointer to be known at alloc time, which does
not fit in the current code structure.

Solve this by splitting tc_probe_bridge_endpoint() in two functions:

 * tc_probe_get_mode(), computing the mode without needing the private
   driver structure
 * tc_probe_bridge_endpoint(), only initializing the endpoints

So now the mode is known before allocation and so
is the funcs pointer, while all other operations are still happening after
allocation, directly into the private struct data, as they used to.

The new code flow is:

 * tc_probe()
   * tc_probe_get_mode()
     * parses DT description
     * computes and returns the mode
   * based onf the mode, pick the funcs pointer
   * devm_drm_bridfge_alloc(..., funcs)
   * call tc_probe_bridge_endpoint() which
     * calls different bridge init functions based on the mode
       * these don't set the funcs pointer, it was done by _alloc

This solution is chosen to minimize the changes in the driver logical code
flow. The drawback is we now iterate twice over the endpoints during probe.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250528-drm-bridge-convert-to-alloc-api-v4-1-f04e698c9a77@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/bridge/tc358767.c