[PATCH 2/6] ASoC: wm8903: Use devm_gpiochip_add_data() to add the GPIO chip

Charles Keepax ckeepax at opensource.cirrus.com
Wed Dec 2 09:42:40 PST 2026


On Tue, Dec 01, 2026 at 11:23:33PM +0400, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova at mbzuai.ac.ae>
> 
> wm8903_i2c_probe() adds the GPIO chip and can still fail after that,
> when the interrupt cannot be requested or the component cannot be
> registered. The error path only disables the regulators, so the chip
> stays registered while devres frees the wm8903_priv structure that
> contains it.
> 
> wm8903_init_gpio() also only logs a failure of gpiochip_add_data(), and
> wm8903_i2c_remove() calls gpiochip_remove() regardless.
> 
> Add the chip with devm_gpiochip_add_data(). It is then removed on probe
> failure and on unbind, before the regmap and the driver data are
> released, and only if it was added.
> 
> Fixes: 0bf79ef2c303 ("ASoC: wm8903: init GPIOs during I2C probe not codec probe")
> Fixes: 7cfe56172ac1 ("ASoC: wm8903: Expose GPIOs through gpiolib")
> Signed-off-by: Arina Kharlamova <arina.kharlamova at mbzuai.ac.ae>
> ---

Reviewed-by: Charles Keepax <ckeepax at opensource.cirrus.com>

Thanks,
Charles



More information about the linux-arm-kernel mailing list