diff mbox series

[v2] extcon: usbc-tusb320: Call the Type-C IRQ handler only if a port is registered

Message ID 20221107153317.657803-1-y.oudjana@protonmail.com (mailing list archive)
State Accepted
Commit 341fd15e2e18c24d5c738496cfc3d7a272241201
Headers show
Series [v2] extcon: usbc-tusb320: Call the Type-C IRQ handler only if a port is registered | expand

Commit Message

Yassine Oudjana Nov. 7, 2022, 3:33 p.m. UTC
From: Yassine Oudjana <y.oudjana@protonmail.com>

Commit bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
added an optional Type-C interface to the driver but missed to check
if it is in use when calling the IRQ handler. This causes an oops on
devices currently using the old extcon interface. Check if a Type-C
port is registered before calling the Type-C IRQ handler.

Fixes: bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Reviewed-by: Marek Vasut <marex@denx.de>
---
Changes since v1:
- Drop "for backward compatibility" from comment to avoid confusion on
  whether Type-C is meant to be the old or new interface.

 drivers/extcon/extcon-usbc-tusb320.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Heikki Krogerus Nov. 7, 2022, 4:28 p.m. UTC | #1
On Mon, Nov 07, 2022 at 06:33:17PM +0300, Yassine Oudjana wrote:
> From: Yassine Oudjana <y.oudjana@protonmail.com>
> 
> Commit bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
> added an optional Type-C interface to the driver but missed to check
> if it is in use when calling the IRQ handler. This causes an oops on
> devices currently using the old extcon interface. Check if a Type-C
> port is registered before calling the Type-C IRQ handler.
> 
> Fixes: bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
> Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
> Reviewed-by: Marek Vasut <marex@denx.de>

Looks good to me. FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> Changes since v1:
> - Drop "for backward compatibility" from comment to avoid confusion on
>   whether Type-C is meant to be the old or new interface.
> 
>  drivers/extcon/extcon-usbc-tusb320.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
> index 41041ff0fadb..2a120d8d3c27 100644
> --- a/drivers/extcon/extcon-usbc-tusb320.c
> +++ b/drivers/extcon/extcon-usbc-tusb320.c
> @@ -327,7 +327,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
>  		return IRQ_NONE;
>  
>  	tusb320_extcon_irq_handler(priv, reg);
> -	tusb320_typec_irq_handler(priv, reg);
> +
> +	/*
> +	 * Type-C support is optional. Only call the Type-C handler if a
> +	 * port had been registered previously.
> +	 */
> +	if (priv->port)
> +		tusb320_typec_irq_handler(priv, reg);
>  
>  	regmap_write(priv->regmap, TUSB320_REG9, reg);
>  
> -- 
> 2.38.1

thanks,
Marek Vasut Nov. 7, 2022, 5:58 p.m. UTC | #2
On 11/7/22 17:28, Heikki Krogerus wrote:
> On Mon, Nov 07, 2022 at 06:33:17PM +0300, Yassine Oudjana wrote:
>> From: Yassine Oudjana <y.oudjana@protonmail.com>
>>
>> Commit bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
>> added an optional Type-C interface to the driver but missed to check
>> if it is in use when calling the IRQ handler. This causes an oops on
>> devices currently using the old extcon interface. Check if a Type-C
>> port is registered before calling the Type-C IRQ handler.
>>
>> Fixes: bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
>> Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
>> Reviewed-by: Marek Vasut <marex@denx.de>
> 
> Looks good to me. FWIW:
> 
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Likewise, looks good. You already have my RB. Thanks !
diff mbox series

Patch

diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
index 41041ff0fadb..2a120d8d3c27 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -327,7 +327,13 @@  static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	tusb320_extcon_irq_handler(priv, reg);
-	tusb320_typec_irq_handler(priv, reg);
+
+	/*
+	 * Type-C support is optional. Only call the Type-C handler if a
+	 * port had been registered previously.
+	 */
+	if (priv->port)
+		tusb320_typec_irq_handler(priv, reg);
 
 	regmap_write(priv->regmap, TUSB320_REG9, reg);