[PATCH 6/8] usb: typec: fusb302: move gpio_int_n into function local scope

From: Sebastian Reichel

Date: Fri Nov 13 2026 - 19:04:35 EST


The driver only cares about the interrupt and the GPIO itself is
device managed, so drop the reference from the device structure
and only keep it in the function scope. While at it cleanup the
error handling by using dev_err_probe.

Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
---
drivers/usb/typec/tcpm/fusb302.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index 1b3ee5715a74..76851e2b9ce5 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -86,7 +86,6 @@ struct fusb302_chip {
struct work_struct irq_work;
bool irq_suspended;
bool irq_while_suspended;
- struct gpio_desc *gpio_int_n;
int gpio_int_n_irq;
struct extcon_dev *extcon;

@@ -1646,19 +1645,17 @@ static void fusb302_irq_work(struct work_struct *work)
static int fusb302_init_irq(struct fusb302_chip *chip)
{
struct device *dev = chip->dev;
+ struct gpio_desc *int_gpio;
int ret = 0;

- chip->gpio_int_n = devm_gpiod_get(dev, "fcs,int_n", GPIOD_IN);
- if (IS_ERR(chip->gpio_int_n)) {
- dev_err(dev, "failed to request gpio_int_n\n");
- return PTR_ERR(chip->gpio_int_n);
- }
- ret = gpiod_to_irq(chip->gpio_int_n);
- if (ret < 0) {
- dev_err(dev,
- "cannot request IRQ for GPIO Int_N, ret=%d", ret);
- return ret;
- }
+ int_gpio = devm_gpiod_get(dev, "fcs,int_n", GPIOD_IN);
+ if (IS_ERR(int_gpio))
+ return dev_err_probe(dev, PTR_ERR(int_gpio), "failed to request interrupt GPIO\n");
+
+ ret = gpiod_to_irq(int_gpio);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "cannot request IRQ for GPIO\n");
+
chip->gpio_int_n_irq = ret;
return 0;
}

--
2.53.0