Re: [PATCH 7/8] usb: typec: fusb302: rework gpio_int_n_irq handling

From: Heikki Krogerus

Date: Tue Nov 17 2026 - 08:35:15 EST


On Fri, Nov 13, 2026 at 05:42:43PM +0100, Sebastian Reichel wrote:
> Improve the code readability, so that one does not need to jump
> into fusb302_init_irq() to understand that chip->gpio_int_n_irq
> is guranteed to be initialized.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
> ---
> drivers/usb/typec/tcpm/fusb302.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
> index 76851e2b9ce5..6105f09f96aa 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -1656,8 +1656,7 @@ static int fusb302_init_irq(struct fusb302_chip *chip)
> if (ret < 0)
> return dev_err_probe(dev, ret, "cannot request IRQ for GPIO\n");
>
> - chip->gpio_int_n_irq = ret;
> - return 0;
> + return ret;
> }
>
> #define PDO_FIXED_FLAGS \
> @@ -1752,13 +1751,13 @@ static int fusb302_probe(struct i2c_client *client)
> if (ret < 0)
> return ret;
>
> - if (client->irq) {
> + if (client->irq)
> chip->gpio_int_n_irq = client->irq;
> - } else {
> - ret = fusb302_init_irq(chip);
> - if (ret < 0)
> - return ret;
> - }
> + else
> + chip->gpio_int_n_irq = fusb302_init_irq(chip);
> +
> + if (chip->gpio_int_n_irq < 0)
> + return chip->gpio_int_n_irq;
>
> chip->tcpc_dev.fwnode = fusb302_fwnode_get(dev);
> if (IS_ERR(chip->tcpc_dev.fwnode)) {

I think this is okay, but I now think that gpio_int_n_irq should be
renamed. It's a bit confusing. The irq is not always gpio.

And that said, I'm now wondering if fusb302_init_irq should be
something else after all. Maybe fusb302_init_gpio_irq, or something
like that?

Thanks,

--
heikki