Skip to content

Commit 0f21c53

Browse files
author
Bartosz Golaszewski
committed
gpio: of: replace gpiochip_find_* with gpio_device_find_*
We're porting all users of gpiochip_find() to using gpio_device_find(). Update the OF GPIO code. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Linus Walleij <[email protected]>
1 parent db54696 commit 0f21c53

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

drivers/gpio/gpiolib-of.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data)
127127
chip->of_xlate(chip, gpiospec, NULL) >= 0;
128128
}
129129

130-
static struct gpio_chip *of_find_gpiochip_by_xlate(
131-
struct of_phandle_args *gpiospec)
130+
static struct gpio_device *
131+
of_find_gpio_device_by_xlate(struct of_phandle_args *gpiospec)
132132
{
133-
return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate);
133+
return gpio_device_find(gpiospec, of_gpiochip_match_node_and_xlate);
134134
}
135135

136136
static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip,
@@ -372,7 +372,6 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np,
372372
const char *propname, int index, enum of_gpio_flags *flags)
373373
{
374374
struct of_phandle_args gpiospec;
375-
struct gpio_chip *chip;
376375
struct gpio_desc *desc;
377376
int ret;
378377

@@ -384,13 +383,15 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np,
384383
return ERR_PTR(ret);
385384
}
386385

387-
chip = of_find_gpiochip_by_xlate(&gpiospec);
388-
if (!chip) {
386+
struct gpio_device *gdev __free(gpio_device_put) =
387+
of_find_gpio_device_by_xlate(&gpiospec);
388+
if (!gdev) {
389389
desc = ERR_PTR(-EPROBE_DEFER);
390390
goto out;
391391
}
392392

393-
desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, flags);
393+
desc = of_xlate_and_get_gpiod_flags(gpio_device_get_chip(gdev),
394+
&gpiospec, flags);
394395
if (IS_ERR(desc))
395396
goto out;
396397

@@ -850,16 +851,16 @@ static int of_gpiochip_match_node(struct gpio_chip *chip, void *data)
850851
return device_match_of_node(&chip->gpiodev->dev, data);
851852
}
852853

853-
static struct gpio_chip *of_find_gpiochip_by_node(struct device_node *np)
854+
static struct gpio_device *of_find_gpio_device_by_node(struct device_node *np)
854855
{
855-
return gpiochip_find(np, of_gpiochip_match_node);
856+
return gpio_device_find(np, of_gpiochip_match_node);
856857
}
857858

858859
static int of_gpio_notify(struct notifier_block *nb, unsigned long action,
859860
void *arg)
860861
{
862+
struct gpio_device *gdev __free(gpio_device_put) = NULL;
861863
struct of_reconfig_data *rd = arg;
862-
struct gpio_chip *chip;
863864
int ret;
864865

865866
/*
@@ -876,11 +877,11 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action,
876877
if (of_node_test_and_set_flag(rd->dn, OF_POPULATED))
877878
return NOTIFY_DONE;
878879

879-
chip = of_find_gpiochip_by_node(rd->dn->parent);
880-
if (chip == NULL)
880+
gdev = of_find_gpio_device_by_node(rd->dn->parent);
881+
if (!gdev)
881882
return NOTIFY_DONE; /* not for us */
882883

883-
ret = of_gpiochip_add_hog(chip, rd->dn);
884+
ret = of_gpiochip_add_hog(gpio_device_get_chip(gdev), rd->dn);
884885
if (ret < 0) {
885886
pr_err("%s: failed to add hogs for %pOF\n", __func__,
886887
rd->dn);
@@ -893,11 +894,11 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action,
893894
if (!of_node_check_flag(rd->dn, OF_POPULATED))
894895
return NOTIFY_DONE; /* already depopulated */
895896

896-
chip = of_find_gpiochip_by_node(rd->dn->parent);
897-
if (chip == NULL)
897+
gdev = of_find_gpio_device_by_node(rd->dn->parent);
898+
if (!gdev)
898899
return NOTIFY_DONE; /* not for us */
899900

900-
of_gpiochip_remove_hog(chip, rd->dn);
901+
of_gpiochip_remove_hog(gpio_device_get_chip(gdev), rd->dn);
901902
of_node_clear_flag(rd->dn, OF_POPULATED);
902903
return NOTIFY_OK;
903904
}

0 commit comments

Comments
 (0)