mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
gpio: devres: Use devres parent if undefined
If the user did not pass a parent in the struct gpio_chip then use the device used for devres as parent. This is quite intuitive and can help avoiding having to assign parent explicitly in every driver using devres to add the gpiochip. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://patch.msgid.link/20260427-gpio-mmio-more-v3-1-fe1882351424@kernel.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
be22c0f7f2
commit
575d985581
@@ -353,6 +353,13 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, vo
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* We are passing the devres device here so if the user did not pass
|
||||
* another parent, it's this one.
|
||||
*/
|
||||
if (!gc->parent)
|
||||
gc->parent = dev;
|
||||
|
||||
ret = gpiochip_add_data_with_key(gc, data, lock_key, request_key);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user