cec: add cec_adapter to cec_notifier_cec_adap_unregister()
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 4 Oct 2019 11:04:24 +0000 (13:04 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 7 Oct 2019 10:47:43 +0000 (12:47 +0200)
It is possible for one HDMI connector to have multiple CEC adapters. The
typical real-world scenario is that where one adapter is used when the
device is in standby, and one that's better/smarter when the device is
powered up.

The cec-notifier changes were made with that in mind, but I missed that in
order to support this you need to tell cec_notifier_cec_adap_unregister()
which adapter you are unregistering from the notifier.

Add this additional argument. It is currently unused, but once all drivers
use this, the CEC core will be adapted for these use-cases.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/e9fc8740-6be6-43a7-beee-ce2d7b54936e@xs4all.nl
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
drivers/gpu/drm/i2c/tda9950.c
drivers/media/cec/cec-notifier.c
drivers/media/platform/cros-ec-cec/cros-ec-cec.c
drivers/media/platform/meson/ao-cec-g12a.c
drivers/media/platform/meson/ao-cec.c
drivers/media/platform/s5p-cec/s5p_cec.c
drivers/media/platform/seco-cec/seco-cec.c
drivers/media/platform/sti/cec/stih-cec.c
drivers/media/platform/tegra-cec/tegra_cec.c
include/media/cec-notifier.h

index ac1e001d0882901c1e04db96364f29d6e28ede9e..70ab4fbdc23ed421cbd0baef43fb74d529be948b 100644 (file)
@@ -285,7 +285,7 @@ static int dw_hdmi_cec_probe(struct platform_device *pdev)
 
        ret = cec_register_adapter(cec->adap, pdev->dev.parent);
        if (ret < 0) {
-               cec_notifier_cec_adap_unregister(cec->notify);
+               cec_notifier_cec_adap_unregister(cec->notify, cec->adap);
                return ret;
        }
 
@@ -302,7 +302,7 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)
 {
        struct dw_hdmi_cec *cec = platform_get_drvdata(pdev);
 
-       cec_notifier_cec_adap_unregister(cec->notify);
+       cec_notifier_cec_adap_unregister(cec->notify, cec->adap);
        cec_unregister_adapter(cec->adap);
 
        return 0;
index a5a75bdeb7a5fa4462993829a88a753eb6cdc6a4..5b03fdd1eaa4057a20103a1093e6ba6691b0d27c 100644 (file)
@@ -465,7 +465,7 @@ static int tda9950_probe(struct i2c_client *client,
 
        ret = cec_register_adapter(priv->adap, priv->hdmi);
        if (ret < 0) {
-               cec_notifier_cec_adap_unregister(priv->notify);
+               cec_notifier_cec_adap_unregister(priv->notify, priv->adap);
                return ret;
        }
 
@@ -482,7 +482,7 @@ static int tda9950_remove(struct i2c_client *client)
 {
        struct tda9950_priv *priv = i2c_get_clientdata(client);
 
-       cec_notifier_cec_adap_unregister(priv->notify);
+       cec_notifier_cec_adap_unregister(priv->notify, priv->adap);
        cec_unregister_adapter(priv->adap);
 
        return 0;
index 4d82a5522072e16bac6410f65194115b01047d77..7cf42b133dbc1702ff4c16796f094416574642fa 100644 (file)
@@ -153,13 +153,14 @@ cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name,
 }
 EXPORT_SYMBOL_GPL(cec_notifier_cec_adap_register);
 
-void cec_notifier_cec_adap_unregister(struct cec_notifier *n)
+void cec_notifier_cec_adap_unregister(struct cec_notifier *n,
+                                     struct cec_adapter *adap)
 {
        if (!n)
                return;
 
        mutex_lock(&n->lock);
-       n->cec_adap->notifier = NULL;
+       adap->notifier = NULL;
        n->cec_adap = NULL;
        n->callback = NULL;
        mutex_unlock(&n->lock);
index 4a3b3810fd895691488e1c97c329944306189669..f048e89947850e3389b09d222cd9a99d7695cc17 100644 (file)
@@ -314,7 +314,8 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
        return 0;
 
 out_probe_notify:
-       cec_notifier_cec_adap_unregister(cros_ec_cec->notify);
+       cec_notifier_cec_adap_unregister(cros_ec_cec->notify,
+                                        cros_ec_cec->adap);
 out_probe_adapter:
        cec_delete_adapter(cros_ec_cec->adap);
        return ret;
@@ -335,7 +336,8 @@ static int cros_ec_cec_remove(struct platform_device *pdev)
                return ret;
        }
 
-       cec_notifier_cec_adap_unregister(cros_ec_cec->notify);
+       cec_notifier_cec_adap_unregister(cros_ec_cec->notify,
+                                        cros_ec_cec->adap);
        cec_unregister_adapter(cros_ec_cec->adap);
 
        return 0;
index 3b39e875292e46e485a7f9635f17fcc167ddfeac..70f875b4a01e0528ffea9985a3d7eef5136add21 100644 (file)
@@ -736,7 +736,7 @@ out_probe_core_clk:
        clk_disable_unprepare(ao_cec->core);
 
 out_probe_notify:
-       cec_notifier_cec_adap_unregister(ao_cec->notify);
+       cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap);
 
 out_probe_adapter:
        cec_delete_adapter(ao_cec->adap);
@@ -752,7 +752,7 @@ static int meson_ao_cec_g12a_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(ao_cec->core);
 
-       cec_notifier_cec_adap_unregister(ao_cec->notify);
+       cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap);
 
        cec_unregister_adapter(ao_cec->adap);
 
index 64ed549bf0120bde4bd8868864e3f4d8730dce8b..92859a6d006f81b8bafe66097a1af77d01bfa0ea 100644 (file)
@@ -688,7 +688,7 @@ out_probe_clk:
        clk_disable_unprepare(ao_cec->core);
 
 out_probe_notify:
-       cec_notifier_cec_adap_unregister(ao_cec->notify);
+       cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap);
 
 out_probe_adapter:
        cec_delete_adapter(ao_cec->adap);
@@ -704,7 +704,7 @@ static int meson_ao_cec_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(ao_cec->core);
 
-       cec_notifier_cec_adap_unregister(ao_cec->notify);
+       cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap);
        cec_unregister_adapter(ao_cec->adap);
 
        return 0;
index 6ddcc35b0bbda16e588066b3d94ed4f9ef0619a3..2a3e7ffefe0a21b7b953ea3321bf4db04357376b 100644 (file)
@@ -239,7 +239,7 @@ static int s5p_cec_probe(struct platform_device *pdev)
        return 0;
 
 err_notifier:
-       cec_notifier_cec_adap_unregister(cec->notifier);
+       cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
 
 err_delete_adapter:
        cec_delete_adapter(cec->adap);
@@ -250,7 +250,7 @@ static int s5p_cec_remove(struct platform_device *pdev)
 {
        struct s5p_cec_dev *cec = platform_get_drvdata(pdev);
 
-       cec_notifier_cec_adap_unregister(cec->notifier);
+       cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
        cec_unregister_adapter(cec->adap);
        pm_runtime_disable(&pdev->dev);
        return 0;
index 9cd60fe1867c9a1c368d9a465cbdbb7bf3f7090c..54b0d51e9c55346b84f55bb5116c64b877422955 100644 (file)
@@ -671,7 +671,7 @@ static int secocec_probe(struct platform_device *pdev)
        return ret;
 
 err_notifier:
-       cec_notifier_cec_adap_unregister(secocec->notifier);
+       cec_notifier_cec_adap_unregister(secocec->notifier, secocec->cec_adap);
 err_delete_adapter:
        cec_delete_adapter(secocec->cec_adap);
 err:
@@ -692,7 +692,7 @@ static int secocec_remove(struct platform_device *pdev)
 
                dev_dbg(&pdev->dev, "IR disabled");
        }
-       cec_notifier_cec_adap_unregister(secocec->notifier);
+       cec_notifier_cec_adap_unregister(secocec->notifier, secocec->cec_adap);
        cec_unregister_adapter(secocec->cec_adap);
 
        release_region(BRA_SMB_BASE_ADDR, 7);
index 8118c7365d3f31879e8f9034d54687b1ed361c44..f0c73e64b586ec989530cc3e43a94e1ae54d4e19 100644 (file)
@@ -359,7 +359,7 @@ static int stih_cec_probe(struct platform_device *pdev)
        return 0;
 
 err_notifier:
-       cec_notifier_cec_adap_unregister(cec->notifier);
+       cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
 
 err_delete_adapter:
        cec_delete_adapter(cec->adap);
@@ -370,7 +370,7 @@ static int stih_cec_remove(struct platform_device *pdev)
 {
        struct stih_cec *cec = platform_get_drvdata(pdev);
 
-       cec_notifier_cec_adap_unregister(cec->notifier);
+       cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
        cec_unregister_adapter(cec->adap);
 
        return 0;
index a632602131f210f02a81163e66569cf6c559becf..a99caac59f444081a64bc6e96f2b6e8fa2f7e720 100644 (file)
@@ -409,7 +409,7 @@ static int tegra_cec_probe(struct platform_device *pdev)
        return 0;
 
 err_notifier:
-       cec_notifier_cec_adap_unregister(cec->notifier);
+       cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
 err_adapter:
        cec_delete_adapter(cec->adap);
 err_clk:
@@ -423,7 +423,7 @@ static int tegra_cec_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(cec->clk);
 
-       cec_notifier_cec_adap_unregister(cec->notifier);
+       cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
        cec_unregister_adapter(cec->adap);
 
        return 0;
index f161f8a493aca6b4d3d09cc2457515a078543c69..985afea1ee3625779265499fbee7f5275657a324 100644 (file)
@@ -93,8 +93,10 @@ cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name,
  * cec_notifier_cec_adap_unregister - decrease refcount and delete when the
  * refcount reaches 0.
  * @n: notifier. If NULL, then this function does nothing.
+ * @adap: the cec adapter that registered this notifier.
  */
-void cec_notifier_cec_adap_unregister(struct cec_notifier *n);
+void cec_notifier_cec_adap_unregister(struct cec_notifier *n,
+                                     struct cec_adapter *adap);
 
 /**
  * cec_notifier_set_phys_addr - set a new physical address.
@@ -160,7 +162,8 @@ cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name,
        return (struct cec_notifier *)0xdeadfeed;
 }
 
-static inline void cec_notifier_cec_adap_unregister(struct cec_notifier *n)
+static inline void cec_notifier_cec_adap_unregister(struct cec_notifier *n,
+                                                   struct cec_adapter *adap)
 {
 }