@@ -7,6 +7,7 @@
#define pr_fmt(fmt) "gpiolib: swnode: " fmt
+#include <linux/cleanup.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/export.h>
@@ -26,23 +27,20 @@
static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
{
- const struct software_node *gdev_node;
- struct gpio_device *gdev;
-
- gdev_node = to_software_node(fwnode);
- if (!gdev_node || !gdev_node->name)
- return ERR_PTR(-EINVAL);
+ struct gpio_device *gdev __free(gpio_device_put) =
+ gpio_device_find_by_fwnode(fwnode);
+ if (!gdev)
+ return ERR_PTR(-EPROBE_DEFER);
/*
* Check for a special node that identifies undefined GPIOs, this is
* primarily used as a key for internal chip selects in SPI bindings.
*/
if (IS_ENABLED(CONFIG_GPIO_SWNODE_UNDEFINED) &&
- !strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME))
+ !strcmp(fwnode_get_name(fwnode), GPIOLIB_SWNODE_UNDEFINED_NAME))
return ERR_PTR(-ENOENT);
- gdev = gpio_device_find_by_label(gdev_node->name);
- return gdev ?: ERR_PTR(-EPROBE_DEFER);
+ return no_free_ptr(gdev);
}
static int swnode_gpio_get_reference(const struct fwnode_handle *fwnode,