drm: sti: use cec_notifier_conn_(un)register
authorDariusz Marcinkiewicz <darekm@google.com>
Wed, 14 Aug 2019 10:45:04 +0000 (12:45 +0200)
committerBenjamin Gaignard <benjamin.gaignard@linaro.org>
Mon, 2 Sep 2019 13:09:13 +0000 (15:09 +0200)
Use the new cec_notifier_conn_(un)register() functions to
(un)register the notifier for the HDMI connector, and fill
in the cec_connector_info.

Changes since v2:
Don't invalidate physical address before unregistering the
notifier.

Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190814104520.6001-7-darekm@google.com
drivers/gpu/drm/sti/sti_hdmi.c

index 84318d0832a01e1ae7daa31405a5005929f516d5..5f457bb6fa2df1a04672301675318f363165bce2 100644 (file)
@@ -1257,6 +1257,7 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
        struct drm_device *drm_dev = data;
        struct drm_encoder *encoder;
        struct sti_hdmi_connector *connector;
+       struct cec_connector_info conn_info;
        struct drm_connector *drm_connector;
        struct drm_bridge *bridge;
        int err;
@@ -1319,6 +1320,14 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
                goto err_sysfs;
        }
 
+       cec_fill_conn_info_from_drm(&conn_info, drm_connector);
+       hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL,
+                                                   &conn_info);
+       if (!hdmi->notifier) {
+               hdmi->drm_connector = NULL;
+               return -ENOMEM;
+       }
+
        /* Enable default interrupts */
        hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN);
 
@@ -1332,6 +1341,9 @@ err_sysfs:
 static void sti_hdmi_unbind(struct device *dev,
                struct device *master, void *data)
 {
+       struct sti_hdmi *hdmi = dev_get_drvdata(dev);
+
+       cec_notifier_conn_unregister(hdmi->notifier);
 }
 
 static const struct component_ops sti_hdmi_ops = {
@@ -1437,10 +1449,6 @@ static int sti_hdmi_probe(struct platform_device *pdev)
                goto release_adapter;
        }
 
-       hdmi->notifier = cec_notifier_get(&pdev->dev);
-       if (!hdmi->notifier)
-               goto release_adapter;
-
        hdmi->reset = devm_reset_control_get(dev, "hdmi");
        /* Take hdmi out of reset */
        if (!IS_ERR(hdmi->reset))
@@ -1460,14 +1468,11 @@ static int sti_hdmi_remove(struct platform_device *pdev)
 {
        struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
 
-       cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID);
-
        i2c_put_adapter(hdmi->ddc_adapt);
        if (hdmi->audio_pdev)
                platform_device_unregister(hdmi->audio_pdev);
        component_del(&pdev->dev, &sti_hdmi_ops);
 
-       cec_notifier_put(hdmi->notifier);
        return 0;
 }