summaryrefslogtreecommitdiff
path: root/drivers/reset
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>2026-03-06 18:22:50 +0100
committerPhilipp Zabel <p.zabel@pengutronix.de>2026-03-09 10:20:03 +0100
commit6703784ab9a8039bd3f476db2643414c45690c68 (patch)
tree7e02db0a780d85ea3b013b1f90ff314708543f4b /drivers/reset
parent20adbf3b8f5c5787da29f8cdd7cfc4fa87854bd5 (diff)
downloadlinux-next-6703784ab9a8039bd3f476db2643414c45690c68.tar.gz
linux-next-6703784ab9a8039bd3f476db2643414c45690c68.zip
reset: fold ida_alloc() into reset_create_gpio_aux_device()
We don't need to know the IDA value outside of the function that creates the auxiliary reset-gpio device. Simplify error handling by folding it into reset_create_gpio_aux_device(). Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/reset')
-rw-r--r--drivers/reset/core.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 3fa0d49eb494..3b67e727c84e 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -824,10 +824,14 @@ static void reset_gpio_aux_device_release(struct device *dev)
}
static int reset_create_gpio_aux_device(struct reset_gpio_lookup *rgpio_dev,
- struct device *parent, int id)
+ struct device *parent)
{
struct auxiliary_device *adev = &rgpio_dev->adev;
- int ret;
+ int ret, id;
+
+ id = ida_alloc(&reset_gpio_ida, GFP_KERNEL);
+ if (id < 0)
+ return -ENOMEM;
adev->id = id;
adev->name = "gpio";
@@ -837,12 +841,15 @@ static int reset_create_gpio_aux_device(struct reset_gpio_lookup *rgpio_dev,
device_set_node(&adev->dev, rgpio_dev->swnode);
ret = auxiliary_device_init(adev);
- if (ret)
+ if (ret) {
+ ida_free(&reset_gpio_ida, id);
return ret;
+ }
ret = __auxiliary_device_add(adev, "reset");
if (ret) {
auxiliary_device_uninit(adev);
+ ida_free(&reset_gpio_ida, id);
return ret;
}
@@ -891,7 +898,7 @@ static int __reset_add_reset_gpio_device(struct device_node *np,
unsigned int offset, of_flags, lflags;
struct reset_gpio_lookup *rgpio_dev;
struct device *parent;
- int id, ret, prop = 0;
+ int ret, prop = 0;
/*
* Currently only #gpio-cells=2 is supported with the meaning of:
@@ -951,16 +958,10 @@ static int __reset_add_reset_gpio_device(struct device_node *np,
properties[prop++] = PROPERTY_ENTRY_STRING("compatible", "reset-gpio");
properties[prop++] = PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnode, offset, lflags);
- id = ida_alloc(&reset_gpio_ida, GFP_KERNEL);
- if (id < 0)
- return id;
-
/* Not freed on success, because it is persisent subsystem data. */
rgpio_dev = kzalloc_obj(*rgpio_dev);
- if (!rgpio_dev) {
- ret = -ENOMEM;
- goto err_ida_free;
- }
+ if (!rgpio_dev)
+ return -ENOMEM;
rgpio_dev->of_args = *args;
/*
@@ -976,7 +977,7 @@ static int __reset_add_reset_gpio_device(struct device_node *np,
goto err_put_of_node;
}
- ret = reset_create_gpio_aux_device(rgpio_dev, parent, id);
+ ret = reset_create_gpio_aux_device(rgpio_dev, parent);
if (ret)
goto err_del_swnode;
@@ -990,8 +991,6 @@ err_del_swnode:
err_put_of_node:
of_node_put(rgpio_dev->of_args.np);
kfree(rgpio_dev);
-err_ida_free:
- ida_free(&reset_gpio_ida, id);
return ret;
}