From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, brgl@kernel.org,
linux-doc@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH v3 06/14] reset: fold ida_alloc() into reset_create_gpio_aux_device()
Date: Fri, 06 Mar 2026 18:22:50 +0100 [thread overview]
Message-ID: <20260306-reset-core-refactor-v3-6-599349522876@oss.qualcomm.com> (raw)
In-Reply-To: <20260306-reset-core-refactor-v3-0-599349522876@oss.qualcomm.com>
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>
---
drivers/reset/core.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 3e55f794d539e4edc99104cb5396cac72ba30618..025004989595ac60381804a7705a1eb584b63326 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 @@ static int __reset_add_reset_gpio_device(struct device_node *np,
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;
}
--
2.47.3
next prev parent reply other threads:[~2026-03-06 17:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 17:22 [PATCH v3 00/14] reset: major reset core refactoring Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 01/14] reset: gpio: remove unneeded OF-node put Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 02/14] reset: gpio: add a devlink between reset-gpio and its consumer Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 03/14] reset: gpio: simplify fallback device matching Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 04/14] reset: gpio: remove unneeded auxiliary_set_drvdata() Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 05/14] reset: warn on reset-gpio release Bartosz Golaszewski
2026-03-09 9:21 ` Philipp Zabel
2026-03-06 17:22 ` Bartosz Golaszewski [this message]
2026-03-09 7:47 ` [PATCH v3 06/14] reset: fold ida_alloc() into reset_create_gpio_aux_device() Philipp Zabel
2026-03-06 17:22 ` [PATCH v3 07/14] reset: use lock guards in reset core Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 08/14] reset: handle removing supplier before consumers Bartosz Golaszewski
2026-03-09 7:47 ` Philipp Zabel
2026-03-06 17:22 ` [PATCH v3 09/14] reset: protect struct reset_controller_dev with its own mutex Bartosz Golaszewski
2026-03-09 8:01 ` Philipp Zabel
2026-03-06 17:22 ` [PATCH v3 10/14] reset: protect struct reset_control " Bartosz Golaszewski
2026-03-09 8:01 ` Philipp Zabel
2026-03-06 17:22 ` [PATCH v3 11/14] reset: convert of_reset_control_get_count() to using firmware nodes Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 12/14] reset: convert the core API " Bartosz Golaszewski
2026-03-06 17:22 ` [PATCH v3 13/14] reset: convert reset core " Bartosz Golaszewski
2026-03-09 8:01 ` Philipp Zabel
2026-03-10 14:16 ` Mark Brown
2026-03-10 14:48 ` Philipp Zabel
2026-03-10 14:53 ` Bartosz Golaszewski
2026-03-10 15:00 ` Geert Uytterhoeven
2026-03-11 15:47 ` Tommaso Merciai
2026-03-11 15:54 ` Bartosz Golaszewski
2026-03-11 16:06 ` Tommaso Merciai
2026-03-06 17:22 ` [PATCH v3 14/14] reset: gpio: make the driver fwnode-agnostic Bartosz Golaszewski
2026-03-09 9:25 ` [PATCH v3 00/14] reset: major reset core refactoring Philipp Zabel
2026-03-09 9:34 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260306-reset-core-refactor-v3-6-599349522876@oss.qualcomm.com \
--to=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=corbet@lwn.net \
--cc=krzk@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®