From: Dariusz Marcinkiewicz <dar...@google.com>

Use the new cec_notifier_conn_(un)register() functions to
(un)register the notifier for the HDMI connector.

Signed-off-by: Dariusz Marcinkiewicz <dar...@google.com>
Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 84c6d4c91c65..8262b44b776e 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -82,6 +82,9 @@ struct tda998x_priv {
        u8 audio_port_enable[AUDIO_ROUTE_NUM];
        struct tda9950_glue cec_glue;
        struct gpio_desc *calib;
+
+       /* protect cec_notify */
+       struct mutex cec_notify_mutex;
        struct cec_notifier *cec_notify;
 };
 
@@ -805,8 +808,11 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data)
                                tda998x_edid_delay_start(priv);
                        } else {
                                schedule_work(&priv->detect_work);
-                               cec_notifier_set_phys_addr(priv->cec_notify,
-                                                  CEC_PHYS_ADDR_INVALID);
+
+                               mutex_lock(&priv->cec_notify_mutex);
+                               cec_notifier_phys_addr_invalidate(
+                                               priv->cec_notify);
+                               mutex_unlock(&priv->cec_notify_mutex);
                        }
 
                        handled = true;
@@ -1790,8 +1796,10 @@ static void tda998x_destroy(struct device *dev)
 
        i2c_unregister_device(priv->cec);
 
-       if (priv->cec_notify)
-               cec_notifier_put(priv->cec_notify);
+       mutex_lock(&priv->cec_notify_mutex);
+       cec_notifier_conn_unregister(priv->cec_notify);
+       priv->cec_notify = NULL;
+       mutex_unlock(&priv->cec_notify_mutex);
 }
 
 static int tda998x_create(struct device *dev)
@@ -1812,6 +1820,7 @@ static int tda998x_create(struct device *dev)
        mutex_init(&priv->mutex);       /* protect the page access */
        mutex_init(&priv->audio_mutex); /* protect access from audio thread */
        mutex_init(&priv->edid_mutex);
+       mutex_init(&priv->cec_notify_mutex);
        INIT_LIST_HEAD(&priv->bridge.list);
        init_waitqueue_head(&priv->edid_delay_waitq);
        timer_setup(&priv->edid_delay_timer, tda998x_edid_delay_done, 0);
@@ -1916,7 +1925,9 @@ static int tda998x_create(struct device *dev)
                cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD);
        }
 
-       priv->cec_notify = cec_notifier_get(dev);
+       mutex_lock(&priv->cec_notify_mutex);
+       priv->cec_notify = cec_notifier_conn_register(dev, NULL, NULL);
+       mutex_unlock(&priv->cec_notify_mutex);
        if (!priv->cec_notify) {
                ret = -ENOMEM;
                goto fail;
-- 
2.23.0

Reply via email to