Skip to contentSkip to conversation

gpio: mockup: initialize a managed pointer in place

PATCH New Bartosz Golaszewski 1 participant 1 message Nov 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: mockup: initialize a managed pointer in place

From: Bartosz Golaszewski <[email protected]>

The preferred pattern for autopointers is to initialize them when they're declared unless it doesn't make sense. Move the declaration of the managed device pointer to where it's initialized.

---
 drivers/gpio/gpio-mockup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-mockup.c +1 -2
index 4870e267a402..455eecf6380e 100644
@@ -354,7 +354,6 @@ static const struct file_operations gpio_mockup_debugfs_ops = {
 static void gpio_mockup_debugfs_setup(struct device *dev,
 				      struct gpio_mockup_chip *chip)
 {
-	struct device *child __free(put_device) = NULL;
 	struct gpio_mockup_dbgfs_private *priv;
 	struct gpio_chip *gc;
 	const char *devname;
@@ -367,7 +366,7 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
 	 * There can only be a single GPIO device per platform device in
 	 * gpio-mockup so using device_find_any_child() is OK.
 	 */
-	child = device_find_any_child(dev);
+	struct device *child __free(put_device) = device_find_any_child(dev);
 	if (!child)
 		return;
 
Signature · 1 line
2.40.1