drm/vc4: hdmi: Create destroy state implementation
authorMaxime Ripard <mripard@kernel.org>
Thu, 7 Dec 2023 15:49:41 +0000 (16:49 +0100)
committerMaxime Ripard <mripard@kernel.org>
Wed, 13 Dec 2023 15:19:01 +0000 (16:19 +0100)
Even though we were rolling our own custom state for the vc4 HDMI
controller driver, we were still using the generic helper to destroy
that state.

It was mostly working since the underlying state is the first member of
our state so the pointers are probably equal in all relevant cases, but
it's still fragile so let's fix this properly.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231207-kms-hdmi-connector-state-v5-18-6538e19d634d@kernel.org
drivers/gpu/drm/vc4/vc4_hdmi.c

index 25c9c71256d355944ed02f3dad976bb1b2b9c9bd..f05e2c95a60d7175d0fb4f1b13a195e6237c310e 100644 (file)
@@ -672,11 +672,21 @@ vc4_hdmi_connector_duplicate_state(struct drm_connector *connector)
        return &new_state->base;
 }
 
+static void vc4_hdmi_connector_destroy_state(struct drm_connector *connector,
+                                            struct drm_connector_state *state)
+{
+       struct vc4_hdmi_connector_state *vc4_state =
+               conn_state_to_vc4_hdmi_conn_state(state);
+
+       __drm_atomic_helper_connector_destroy_state(state);
+       kfree(vc4_state);
+}
+
 static const struct drm_connector_funcs vc4_hdmi_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .reset = vc4_hdmi_connector_reset,
        .atomic_duplicate_state = vc4_hdmi_connector_duplicate_state,
-       .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+       .atomic_destroy_state = vc4_hdmi_connector_destroy_state,
        .atomic_get_property = vc4_hdmi_connector_get_property,
        .atomic_set_property = vc4_hdmi_connector_set_property,
 };