Since this is a bridge, we don't start out with a respective DRM device. Likewise this means we don't have a connector, which also means that we should be following drm_dp_aux_register()'s documentation advice and not call drm_dp_aux_register() until we have a matching connector. Instead, call drm_dp_aux_init() in tc_probe() and wait until tc_bridge_attach() to register our AUX channel. We also add tc_bridge_detach() to handle unregistering the AUX adapter once the bridge has been disconnected. Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx> --- drivers/gpu/drm/bridge/tc358767.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 34a3e4e9f717..da89922721ed 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -1414,11 +1414,15 @@ static int tc_bridge_attach(struct drm_bridge *bridge, if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) return 0; + ret = drm_dp_aux_register(&tc->aux); + if (ret < 0) + return ret; + /* Create DP/eDP connector */ drm_connector_helper_add(&tc->connector, &tc_connector_helper_funcs); ret = drm_connector_init(drm, &tc->connector, &tc_connector_funcs, tc->bridge.type); if (ret) - return ret; + goto aux_unregister; /* Don't poll if don't have HPD connected */ if (tc->hpd_pin >= 0) { @@ -1438,10 +1442,19 @@ static int tc_bridge_attach(struct drm_bridge *bridge, drm_connector_attach_encoder(&tc->connector, tc->bridge.encoder); return 0; +aux_unregister: + drm_dp_aux_unregister(&tc->aux); + return ret; +} + +static void tc_bridge_detach(struct drm_bridge *bridge) +{ + drm_dp_aux_unregister(&bridge_to_tc(bridge)->aux); } static const struct drm_bridge_funcs tc_bridge_funcs = { .attach = tc_bridge_attach, + .detach = tc_bridge_detach, .mode_valid = tc_mode_valid, .mode_set = tc_bridge_mode_set, .enable = tc_bridge_enable, @@ -1680,9 +1693,7 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) tc->aux.name = "TC358767 AUX i2c adapter"; tc->aux.dev = tc->dev; tc->aux.transfer = tc_aux_transfer; - ret = drm_dp_aux_register(&tc->aux); - if (ret) - return ret; + drm_dp_aux_init(&tc->aux); tc->bridge.funcs = &tc_bridge_funcs; if (tc->hpd_pin >= 0) @@ -1702,7 +1713,6 @@ static int tc_remove(struct i2c_client *client) struct tc_data *tc = i2c_get_clientdata(client); drm_bridge_remove(&tc->bridge); - drm_dp_aux_unregister(&tc->aux); return 0; } -- 2.29.2 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx