linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Dariusz Marcinkiewicz <darekm@google.com>,
	linux-media@vger.kernel.org, hverkuil@xs4all.nl
Subject: Re: [PATCH v2 1/5] drm: tda998x: use cec_notifier_conn_(un)register
Date: Mon, 15 Jul 2019 12:47:16 +0200	[thread overview]
Message-ID: <ee8a2464-0b23-9cfe-1a56-19da8cf36fdc@xs4all.nl> (raw)
In-Reply-To: <20190701145944.214098-2-darekm@google.com>

On 7/1/19 4:59 PM, Dariusz Marcinkiewicz wrote:
> 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 v1:
> 	Add memory barrier to make sure that the notifier
> 	becomes visible to the irq thread once it is
> 	fully constructed.
> 
> Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 32 ++++++++++++++++++++++---------
>  1 file changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 7f34601bb5155..7844f4113a839 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -794,9 +794,14 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data)
>  			if (lvl & CEC_RXSHPDLEV_HPD) {
>  				tda998x_edid_delay_start(priv);
>  			} else {
> +				struct cec_notifier *notify;
> +
>  				schedule_work(&priv->detect_work);
> -				cec_notifier_set_phys_addr(priv->cec_notify,
> -						   CEC_PHYS_ADDR_INVALID);
> +
> +				notify = READ_ONCE(priv->cec_notify);
> +				if (notify)
> +					cec_notifier_set_phys_addr(notify,
> +							CEC_PHYS_ADDR_INVALID);

Can you replace this with cec_notifier_phys_addr_invalidate()?

>  			}
>  
>  			handled = true;
> @@ -1253,6 +1258,8 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
>  				  struct drm_device *drm)
>  {
>  	struct drm_connector *connector = &priv->connector;
> +	struct cec_connector_info conn_info;
> +	struct cec_notifier *notifier;
>  	int ret;
>  
>  	connector->interlace_allowed = 1;
> @@ -1269,6 +1276,19 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
>  	if (ret)
>  		return ret;
>  
> +	cec_fill_conn_info_from_drm(&conn_info, connector);
> +
> +	notifier = cec_notifier_conn_register(priv->cec_glue.parent,
> +					      NULL, &conn_info);
> +	if (!notifier)
> +		return -ENOMEM;
> +	/*
> +	 * Make sure that tda998x_irq_thread does see the notifier
> +	 * when it fully constructed.
> +	 */
> +	smp_wmb();
> +	priv->cec_notify = notifier;
> +
>  	drm_connector_attach_encoder(&priv->connector,
>  				     priv->bridge.encoder);
>  
> @@ -1651,7 +1671,7 @@ static void tda998x_destroy(struct device *dev)
>  	i2c_unregister_device(priv->cec);
>  
>  	if (priv->cec_notify)
> -		cec_notifier_put(priv->cec_notify);
> +		cec_notifier_conn_unregister(priv->cec_notify);

You can drop the 'if': cec_notifier_conn_unregister() does nothing if
the notifier is NULL.

>  }
>  
>  static int tda998x_create(struct device *dev)
> @@ -1776,12 +1796,6 @@ static int tda998x_create(struct device *dev)
>  		cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD);
>  	}
>  
> -	priv->cec_notify = cec_notifier_get(dev);
> -	if (!priv->cec_notify) {
> -		ret = -ENOMEM;
> -		goto fail;
> -	}
> -
>  	priv->cec_glue.parent = dev;
>  	priv->cec_glue.data = priv;
>  	priv->cec_glue.init = tda998x_cec_hook_init;
> 

Regards,

	Hans

  reply	other threads:[~2019-07-15 10:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 14:59 [PATCH v2 0/5] cec: convert remaining drivers to the new notifier API Dariusz Marcinkiewicz
2019-07-01 14:59 ` [PATCH v2 1/5] drm: tda998x: use cec_notifier_conn_(un)register Dariusz Marcinkiewicz
2019-07-15 10:47   ` Hans Verkuil [this message]
2019-07-01 14:59 ` [PATCH v2 2/5] drm: sti: " Dariusz Marcinkiewicz
2019-07-15 10:49   ` Hans Verkuil
2019-07-01 14:59 ` [PATCH v2 3/5] drm: tegra: " Dariusz Marcinkiewicz
2019-07-15 10:51   ` Hans Verkuil
2019-07-01 14:59 ` [PATCH v2 4/5] drm: dw-hdmi: " Dariusz Marcinkiewicz
2019-07-15 10:52   ` Hans Verkuil
2019-07-01 14:59 ` [PATCH v2 5/5] drm: exynos: exynos_hdmi: " Dariusz Marcinkiewicz
2019-07-15 10:53   ` Hans Verkuil
2019-07-15 11:18 ` [PATCH v2 0/5] cec: convert remaining drivers to the new notifier API Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee8a2464-0b23-9cfe-1a56-19da8cf36fdc@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=darekm@google.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).