Skip to content

Commit

Permalink
Merge tag 'gpio-fixes-for-v6.5-rc3' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

 - fix initial value handling for output-only pins in gpio-tps68470

 - fix two resource leaks in gpio-mvebu

* tag 'gpio-fixes-for-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpio: mvebu: fix irq domain leak
  gpio: mvebu: Make use of devm_pwmchip_add
  gpio: tps68470: Make tps68470_gpio_output() always set the initial value
  • Loading branch information
Linus Torvalds committed Jul 22, 2023
2 parents d192f53 + 644ee70 commit c0842db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
26 changes: 15 additions & 11 deletions drivers/gpio/gpio-mvebu.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,

spin_lock_init(&mvpwm->lock);

return pwmchip_add(&mvpwm->chip);
return devm_pwmchip_add(dev, &mvpwm->chip);
}

#ifdef CONFIG_DEBUG_FS
Expand Down Expand Up @@ -1112,6 +1112,13 @@ static int mvebu_gpio_probe_syscon(struct platform_device *pdev,
return 0;
}

static void mvebu_gpio_remove_irq_domain(void *data)
{
struct irq_domain *domain = data;

irq_domain_remove(domain);
}

static int mvebu_gpio_probe(struct platform_device *pdev)
{
struct mvebu_gpio_chip *mvchip;
Expand Down Expand Up @@ -1243,17 +1250,21 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
if (!mvchip->domain) {
dev_err(&pdev->dev, "couldn't allocate irq domain %s (DT).\n",
mvchip->chip.label);
err = -ENODEV;
goto err_pwm;
return -ENODEV;
}

err = devm_add_action_or_reset(&pdev->dev, mvebu_gpio_remove_irq_domain,
mvchip->domain);
if (err)
return err;

err = irq_alloc_domain_generic_chips(
mvchip->domain, ngpios, 2, np->name, handle_level_irq,
IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_LEVEL, 0, 0);
if (err) {
dev_err(&pdev->dev, "couldn't allocate irq chips %s (DT).\n",
mvchip->chip.label);
goto err_domain;
return err;
}

/*
Expand Down Expand Up @@ -1293,13 +1304,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
}

return 0;

err_domain:
irq_domain_remove(mvchip->domain);
err_pwm:
pwmchip_remove(&mvchip->mvpwm->chip);

return err;
}

static struct platform_driver mvebu_gpio_driver = {
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpio/gpio-tps68470.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset,
struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
struct regmap *regmap = tps68470_gpio->tps68470_regmap;

/* Set the initial value */
tps68470_gpio_set(gc, offset, value);

/* rest are always outputs */
if (offset >= TPS68470_N_REGULAR_GPIO)
return 0;

/* Set the initial value */
tps68470_gpio_set(gc, offset, value);

return regmap_update_bits(regmap, TPS68470_GPIO_CTL_REG_A(offset),
TPS68470_GPIO_MODE_MASK,
TPS68470_GPIO_MODE_OUT_CMOS);
Expand Down

0 comments on commit c0842db

Please sign in to comment.