aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBartosz Golaszewski2023-09-27 16:29:30 +0200
committerBartosz Golaszewski2023-10-04 13:36:23 +0200
commitb7b56e64a345e738eda17352f735f1e5af287862 (patch)
tree732dc4daa1dc07582281f7b823ed6d81888519be /drivers
parent3c9d5431b40701e35e8af470d6a3e9babe44ffef (diff)
gpio: swnode: replace gpiochip_find() with gpio_device_find_by_label()
We're porting all users of gpiochip_find() to using gpio_device_find(). Update the swnode GPIO code. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib-swnode.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index b5a6eaf3729b..fa52bdb1a29a 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -31,22 +31,17 @@ static void swnode_format_propname(const char *con_id, char *propname,
strscpy(propname, "gpios", max_size);
}
-static int swnode_gpiochip_match_name(struct gpio_chip *chip, void *data)
+static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
{
- return !strcmp(chip->label, data);
-}
-
-static struct gpio_chip *swnode_get_chip(struct fwnode_handle *fwnode)
-{
- const struct software_node *chip_node;
- struct gpio_chip *chip;
+ const struct software_node *gdev_node;
+ struct gpio_device *gdev;
- chip_node = to_software_node(fwnode);
- if (!chip_node || !chip_node->name)
+ gdev_node = to_software_node(fwnode);
+ if (!gdev_node || !gdev_node->name)
return ERR_PTR(-EINVAL);
- chip = gpiochip_find((void *)chip_node->name, swnode_gpiochip_match_name);
- return chip ?: ERR_PTR(-EPROBE_DEFER);
+ gdev = gpio_device_find_by_label(gdev_node->name);
+ return gdev ?: ERR_PTR(-EPROBE_DEFER);
}
struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
@@ -55,7 +50,6 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
{
const struct software_node *swnode;
struct fwnode_reference_args args;
- struct gpio_chip *chip;
struct gpio_desc *desc;
char propname[32]; /* 32 is max size of property name */
int error;
@@ -77,12 +71,17 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
return ERR_PTR(error);
}
- chip = swnode_get_chip(args.fwnode);
+ struct gpio_device *gdev __free(gpio_device_put) =
+ swnode_get_gpio_device(args.fwnode);
fwnode_handle_put(args.fwnode);
- if (IS_ERR(chip))
- return ERR_CAST(chip);
+ if (IS_ERR(gdev))
+ return ERR_CAST(gdev);
- desc = gpiochip_get_desc(chip, args.args[0]);
+ /*
+ * FIXME: The GPIO device reference is put at return but the descriptor
+ * is passed on. Find a proper solution.
+ */
+ desc = gpio_device_get_desc(gdev, args.args[0]);
*flags = args.args[1]; /* We expect native GPIO flags */
pr_debug("%s: parsed '%s' property of node '%pfwP[%d]' - status (%d)\n",