Skip to content

Commit b7b56e6

Browse files
author
Bartosz Golaszewski
committed
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 <[email protected]> Reviewed-by: Linus Walleij <[email protected]>
1 parent 3c9d543 commit b7b56e6

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

drivers/gpio/gpiolib-swnode.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,17 @@ static void swnode_format_propname(const char *con_id, char *propname,
3131
strscpy(propname, "gpios", max_size);
3232
}
3333

34-
static int swnode_gpiochip_match_name(struct gpio_chip *chip, void *data)
34+
static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
3535
{
36-
return !strcmp(chip->label, data);
37-
}
38-
39-
static struct gpio_chip *swnode_get_chip(struct fwnode_handle *fwnode)
40-
{
41-
const struct software_node *chip_node;
42-
struct gpio_chip *chip;
36+
const struct software_node *gdev_node;
37+
struct gpio_device *gdev;
4338

44-
chip_node = to_software_node(fwnode);
45-
if (!chip_node || !chip_node->name)
39+
gdev_node = to_software_node(fwnode);
40+
if (!gdev_node || !gdev_node->name)
4641
return ERR_PTR(-EINVAL);
4742

48-
chip = gpiochip_find((void *)chip_node->name, swnode_gpiochip_match_name);
49-
return chip ?: ERR_PTR(-EPROBE_DEFER);
43+
gdev = gpio_device_find_by_label(gdev_node->name);
44+
return gdev ?: ERR_PTR(-EPROBE_DEFER);
5045
}
5146

5247
struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
@@ -55,7 +50,6 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
5550
{
5651
const struct software_node *swnode;
5752
struct fwnode_reference_args args;
58-
struct gpio_chip *chip;
5953
struct gpio_desc *desc;
6054
char propname[32]; /* 32 is max size of property name */
6155
int error;
@@ -77,12 +71,17 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
7771
return ERR_PTR(error);
7872
}
7973

80-
chip = swnode_get_chip(args.fwnode);
74+
struct gpio_device *gdev __free(gpio_device_put) =
75+
swnode_get_gpio_device(args.fwnode);
8176
fwnode_handle_put(args.fwnode);
82-
if (IS_ERR(chip))
83-
return ERR_CAST(chip);
77+
if (IS_ERR(gdev))
78+
return ERR_CAST(gdev);
8479

85-
desc = gpiochip_get_desc(chip, args.args[0]);
80+
/*
81+
* FIXME: The GPIO device reference is put at return but the descriptor
82+
* is passed on. Find a proper solution.
83+
*/
84+
desc = gpio_device_get_desc(gdev, args.args[0]);
8685
*flags = args.args[1]; /* We expect native GPIO flags */
8786

8887
pr_debug("%s: parsed '%s' property of node '%pfwP[%d]' - status (%d)\n",

0 commit comments

Comments
 (0)