public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cwchoi00@gmail.com>
To: Peter Rosin <peda@axentia.se>, LKML <linux-kernel@vger.kernel.org>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Michael Auchter <michael.auchter@ni.com>
Subject: Re: [PATCH v2] extcon: usbc-tusb320: make sure the state is initialized on probe
Date: Tue, 10 Jan 2023 23:14:53 +0900	[thread overview]
Message-ID: <3e95cc81-bd58-2a4e-7605-d827610ccbf1@gmail.com> (raw)
In-Reply-To: <30cd9157-1850-b17f-bfd5-4c378990b81b@axentia.se>

Hi,

On 22. 12. 13. 07:36, Peter Rosin wrote:
> When the port is connected at boot, there is not necessarily
> an interrupt flagged in the interrupt status register, causing
> the IRQ handler to bail out early without reading the state when
> it is invoked directly from probe.
> 
> Add a flag that overrides the interrupt status register and reads
> the state regardless during probe.
> 
> Fixes: 06bc4ca115cd ("extcon: Add driver for TI TUSB320")
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/extcon/extcon-usbc-tusb320.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> Hi!
> 
> This is basically a resend of v1, the patch has simply been adapted
> to fit after the driver changes for type-c support.
> 
> Version 1 of the patch, with its brief "discussion", is here:
> https://lore.kernel.org/lkml/ab1ad93b-4d39-8863-9704-da779fc4c426@axentia.se/
> 
> I cannot see how the patch can possibly affect detection of connector
> changes *after* 'priv->initialized = true', so the comment from Chanwoo
> Choi is still a mystery to me. The patch is about what happens *before*
> 'priv->initialized = true', i.e. when the IRQ handler is called directly
> during probe. There is no change in behavior after the statement
> 'priv->initialized = true', and IRQs are handled exactly as before once
> past that point.
> 
> Please look at this patch again.
> 
> Cheers,
> Peter
> 
> diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
> index 2a120d8d3c27..dc586e5e3c65 100644
> --- a/drivers/extcon/extcon-usbc-tusb320.c
> +++ b/drivers/extcon/extcon-usbc-tusb320.c
> @@ -78,6 +78,7 @@ struct tusb320_priv {
>  	struct typec_capability	cap;
>  	enum typec_port_type port_type;
>  	enum typec_pwr_opmode pwr_opmode;
> +	bool initialized;
>  };
>  
>  static const char * const tusb_attached_states[] = {
> @@ -323,7 +324,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
>  		return IRQ_NONE;
>  	}
>  
> -	if (!(reg & TUSB320_REG9_INTERRUPT_STATUS))
> +	if (priv->initialized && !(reg & TUSB320_REG9_INTERRUPT_STATUS))
>  		return IRQ_NONE;
>  
>  	tusb320_extcon_irq_handler(priv, reg);
> @@ -479,6 +480,8 @@ static int tusb320_probe(struct i2c_client *client,
>  		 */
>  		tusb320_irq_handler(client->irq, priv);
>  
> +	priv->initialized = true;
> +
>  	ret = devm_request_threaded_irq(priv->dev, client->irq, NULL,
>  					tusb320_irq_handler,
>  					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,

I think that if priv->initialized=true on probe step,
tusb32_irq_handler return the always IRQ_NONE
because priv->initialized is never changed to false.

Is it right to keep the 'priv->initialized=true' always?

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi


  reply	other threads:[~2023-01-10 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 22:36 [PATCH v2] extcon: usbc-tusb320: make sure the state is initialized on probe Peter Rosin
2023-01-10 14:14 ` Chanwoo Choi [this message]
2023-01-10 15:01   ` Peter Rosin

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=3e95cc81-bd58-2a4e-7605-d827610ccbf1@gmail.com \
    --to=cwchoi00@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.auchter@ni.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=peda@axentia.se \
    /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