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

drm/bridge: dw-hdmi: Always add the bridge in the global bridge list

It doesn't hurt to add the bridge in the global bridge list also for
platform specific dw-hdmi drivers which are based on the component
framework. This can be achieved by moving the drm_bridge_add() function
call from dw_hdmi_probe() to __dw_hdmi_probe(). A counterpart movement
for drm_bridge_remove() is also needed then. Moreover, since drm_bridge_add()
initializes &bridge->hpd_mutex, this may help those platform specific
dw-hdmi drivers(based on the component framework) avoid accessing the
uninitialized mutex in drm_bridge_hpd_notify() which is called in
dw_hdmi_irq(). Putting drm_bridge_add() in __dw_hdmi_probe() just before
it returns successfully should bring no logic change for platforms based
on the DRM bridge API, which is a good choice from safety point of view.
Also, __dw_hdmi_probe() is renamed to dw_hdmi_probe() since dw_hdmi_probe()
does nothing else but calling __dw_hdmi_probe(). Similar renaming applies
to the __dw_hdmi_remove()/dw_hdmi_remove() pair.

Fixes: ec971aaa6775 ("drm: bridge: dw-hdmi: Make connector creation optional")
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Dariusz Marcinkiewicz <darekm@google.com>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: dri-devel@lists.freedesktop.org
Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1594260156-8316-2-git-send-email-victor.liu@nxp.com

authored by

Liu Ying and committed by
Sam Ravnborg
0bf4f5b5 2ae53e79

+13 -31
+13 -31
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
··· 3179 3179 hdmi->phy.ops->setup_hpd(hdmi, hdmi->phy.data); 3180 3180 } 3181 3181 3182 - static struct dw_hdmi * 3183 - __dw_hdmi_probe(struct platform_device *pdev, 3184 - const struct dw_hdmi_plat_data *plat_data) 3182 + /* ----------------------------------------------------------------------------- 3183 + * Probe/remove API, used from platforms based on the DRM bridge API. 3184 + */ 3185 + struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, 3186 + const struct dw_hdmi_plat_data *plat_data) 3185 3187 { 3186 3188 struct device *dev = &pdev->dev; 3187 3189 struct device_node *np = dev->of_node; ··· 3440 3438 hdmi->cec = platform_device_register_full(&pdevinfo); 3441 3439 } 3442 3440 3441 + drm_bridge_add(&hdmi->bridge); 3442 + 3443 3443 return hdmi; 3444 3444 3445 3445 err_iahb: ··· 3455 3451 3456 3452 return ERR_PTR(ret); 3457 3453 } 3454 + EXPORT_SYMBOL_GPL(dw_hdmi_probe); 3458 3455 3459 - static void __dw_hdmi_remove(struct dw_hdmi *hdmi) 3456 + void dw_hdmi_remove(struct dw_hdmi *hdmi) 3460 3457 { 3458 + drm_bridge_remove(&hdmi->bridge); 3459 + 3461 3460 if (hdmi->audio && !IS_ERR(hdmi->audio)) 3462 3461 platform_device_unregister(hdmi->audio); 3463 3462 if (!IS_ERR(hdmi->cec)) ··· 3479 3472 else 3480 3473 i2c_put_adapter(hdmi->ddc); 3481 3474 } 3482 - 3483 - /* ----------------------------------------------------------------------------- 3484 - * Probe/remove API, used from platforms based on the DRM bridge API. 3485 - */ 3486 - struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, 3487 - const struct dw_hdmi_plat_data *plat_data) 3488 - { 3489 - struct dw_hdmi *hdmi; 3490 - 3491 - hdmi = __dw_hdmi_probe(pdev, plat_data); 3492 - if (IS_ERR(hdmi)) 3493 - return hdmi; 3494 - 3495 - drm_bridge_add(&hdmi->bridge); 3496 - 3497 - return hdmi; 3498 - } 3499 - EXPORT_SYMBOL_GPL(dw_hdmi_probe); 3500 - 3501 - void dw_hdmi_remove(struct dw_hdmi *hdmi) 3502 - { 3503 - drm_bridge_remove(&hdmi->bridge); 3504 - 3505 - __dw_hdmi_remove(hdmi); 3506 - } 3507 3475 EXPORT_SYMBOL_GPL(dw_hdmi_remove); 3508 3476 3509 3477 /* ----------------------------------------------------------------------------- ··· 3491 3509 struct dw_hdmi *hdmi; 3492 3510 int ret; 3493 3511 3494 - hdmi = __dw_hdmi_probe(pdev, plat_data); 3512 + hdmi = dw_hdmi_probe(pdev, plat_data); 3495 3513 if (IS_ERR(hdmi)) 3496 3514 return hdmi; 3497 3515 ··· 3508 3526 3509 3527 void dw_hdmi_unbind(struct dw_hdmi *hdmi) 3510 3528 { 3511 - __dw_hdmi_remove(hdmi); 3529 + dw_hdmi_remove(hdmi); 3512 3530 } 3513 3531 EXPORT_SYMBOL_GPL(dw_hdmi_unbind); 3514 3532