Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH v1 1/1] gpiolib: shared: Don't define variable in the middle of the code
@ 2026-10-13  9:44 Andy Shevchenko
  2026-10-13 10:04 ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-10-13  9:44 UTC (permalink / raw)
  To: Bartosz Golaszewski, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jiri Slaby, Andy Shevchenko

While the C11 allows us to define variables in the code, we do not
do this style (see more at [1]). Move the declaration to the top of
the function.

Link: https://lore.kernel.org/lkml/58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com/ [1]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-shared.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 5f9623e40b0f..40c08f1ae5f0 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -196,6 +196,7 @@ static int gpio_shared_of_traverse(struct device_node *curr)
 		for (i = 0; i < count; i++) {
 			struct device_node *np __free(device_node) = NULL;
 			char *con_id __free(kfree) = NULL;
+			struct fwnode_handle *curr_fwnode;
 
 			ret = of_parse_phandle_with_args(curr, prop->name,
 							 "#gpio-cells", i,
@@ -261,8 +262,7 @@ static int gpio_shared_of_traverse(struct device_node *curr)
 				con_id[con_id_len - suffix_len] = '\0';
 			}
 
-			struct fwnode_handle *curr_fwnode =
-				fwnode_handle_get(of_fwnode_handle(curr));
+			curr_fwnode = fwnode_handle_get(of_fwnode_handle(curr));
 			ref = gpio_shared_make_ref(curr_fwnode, con_id, args.args[1]);
 			if (!ref) {
 				fwnode_handle_put(curr_fwnode);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-13 13:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13  9:44 [PATCH v1 1/1] gpiolib: shared: Don't define variable in the middle of the code Andy Shevchenko
2026-10-13 10:04 ` Jiri Slaby
2026-10-13 11:42   ` Bartosz Golaszewski
2026-10-13 13:31     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox