[PATCH RFC v3 04/31] drm/display: hdmi-cec-notifier-helper: add non-drmm API variant

From: Luca Ceresoli

Date: Wed Nov 18 2026 - 11:52:20 EST


For bridge hotplug drmm allocations are not suitable because a connector
may have to be added and removed multiple times in the lifetime of a card.

In preparation to support hotpluggable HDMI bridges (and the
drm_bridge_connector) add a non-drmm variant of the CEC notifier
(de)registration API, with an explicit unregister API.

Signed-off-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>

---

New patch in v3.
---
.../gpu/drm/display/drm_hdmi_cec_notifier_helper.c | 30 ++++++++++++++++++----
include/drm/display/drm_hdmi_cec_helper.h | 15 +++++++++++
2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_hdmi_cec_notifier_helper.c b/drivers/gpu/drm/display/drm_hdmi_cec_notifier_helper.c
index 47662bdc5d08..2f30844fcdad 100644
--- a/drivers/gpu/drm/display/drm_hdmi_cec_notifier_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_cec_notifier_helper.c
@@ -29,8 +29,7 @@ static void drmm_connector_hdmi_cec_notifier_unregister(struct drm_device *dev,
{
struct drm_connector *connector = res;

- cec_notifier_conn_unregister(connector->cec.data);
- connector->cec.data = NULL;
+ drm_connector_hdmi_cec_notifier_unregister(connector);
}

static const struct drm_connector_cec_funcs drm_connector_cec_notifier_funcs = {
@@ -38,9 +37,9 @@ static const struct drm_connector_cec_funcs drm_connector_cec_notifier_funcs = {
.phys_addr_set = drm_connector_hdmi_cec_notifier_phys_addr_set,
};

-int drmm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
- const char *port_name,
- struct device *dev)
+int drm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
+ const char *port_name,
+ struct device *dev)
{
struct cec_connector_info conn_info;
struct cec_notifier *notifier;
@@ -58,6 +57,27 @@ int drmm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,

mutex_unlock(&connector->cec.mutex);

+ return 0;
+}
+EXPORT_SYMBOL(drm_connector_hdmi_cec_notifier_register);
+
+void drm_connector_hdmi_cec_notifier_unregister(struct drm_connector *connector)
+{
+ cec_notifier_conn_unregister(connector->cec.data);
+ connector->cec.data = NULL;
+}
+EXPORT_SYMBOL(drm_connector_hdmi_cec_notifier_unregister);
+
+int drmm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
+ const char *port_name,
+ struct device *dev)
+{
+ int ret;
+
+ ret = drm_connector_hdmi_cec_notifier_register(connector, port_name, dev);
+ if (ret)
+ return ret;
+
return drmm_add_action_or_reset(connector->dev,
drmm_connector_hdmi_cec_notifier_unregister,
connector);
diff --git a/include/drm/display/drm_hdmi_cec_helper.h b/include/drm/display/drm_hdmi_cec_helper.h
index 7e76a163e3a5..8d648532eeb7 100644
--- a/include/drm/display/drm_hdmi_cec_helper.h
+++ b/include/drm/display/drm_hdmi_cec_helper.h
@@ -63,10 +63,25 @@ void drm_connector_hdmi_cec_transmit_attempt_done(struct drm_connector *connecto
u8 status);

#if IS_ENABLED(CONFIG_DRM_DISPLAY_HDMI_CEC_NOTIFIER_HELPER)
+int drm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
+ const char *port_name,
+ struct device *dev);
+void drm_connector_hdmi_cec_notifier_unregister(struct drm_connector *connector);
int drmm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
const char *port_name,
struct device *dev);
#else
+static inline int drm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
+ const char *port_name,
+ struct device *dev)
+{
+ return 0;
+}
+
+static inline void drm_connector_hdmi_cec_notifier_unregister(struct drm_connector *connector)
+{
+}
+
static inline int drmm_connector_hdmi_cec_notifier_register(struct drm_connector *connector,
const char *port_name,
struct device *dev)

--
2.56.1