Skip to content

Commit 46dae84

Browse files
Bartosz GolaszewskipH5
authored andcommitted
reset: make the provider of reset-gpios the parent of the reset device
Auxiliary devices really do need a parent so ahead of converting the reset-gpios driver to registering on the auxiliary bus, make the GPIO device that provides the reset GPIO the parent of the reset-gpio device. To that end move the lookup of the GPIO device by fwnode to the beginning of __reset_add_reset_gpio_device() which has the added benefit of bailing out earlier, before allocating resources for the virtual device, if the chip is not up yet. Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
1 parent 97d8532 commit 46dae84

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

drivers/reset/core.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,11 @@ static void __reset_control_put_internal(struct reset_control *rstc)
849849
kref_put(&rstc->refcnt, __reset_control_release);
850850
}
851851

852-
static int __reset_add_reset_gpio_lookup(int id, struct device_node *np,
852+
static int __reset_add_reset_gpio_lookup(struct gpio_device *gdev, int id,
853+
struct device_node *np,
853854
unsigned int gpio,
854855
unsigned int of_flags)
855856
{
856-
const struct fwnode_handle *fwnode = of_fwnode_handle(np);
857857
unsigned int lookup_flags;
858858
const char *label_tmp;
859859

@@ -868,10 +868,6 @@ static int __reset_add_reset_gpio_lookup(int id, struct device_node *np,
868868
return -EINVAL;
869869
}
870870

871-
struct gpio_device *gdev __free(gpio_device_put) = gpio_device_find_by_fwnode(fwnode);
872-
if (!gdev)
873-
return -EPROBE_DEFER;
874-
875871
label_tmp = gpio_device_get_label(gdev);
876872
if (!label_tmp)
877873
return -EINVAL;
@@ -926,6 +922,11 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
926922
*/
927923
lockdep_assert_not_held(&reset_list_mutex);
928924

925+
struct gpio_device *gdev __free(gpio_device_put) =
926+
gpio_device_find_by_fwnode(of_fwnode_handle(args->np));
927+
if (!gdev)
928+
return -EPROBE_DEFER;
929+
929930
guard(mutex)(&reset_gpio_lookup_mutex);
930931

931932
list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) {
@@ -946,7 +947,7 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
946947
goto err_ida_free;
947948
}
948949

949-
ret = __reset_add_reset_gpio_lookup(id, args->np, args->args[0],
950+
ret = __reset_add_reset_gpio_lookup(gdev, id, args->np, args->args[0],
950951
args->args[1]);
951952
if (ret < 0)
952953
goto err_kfree;
@@ -958,7 +959,8 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
958959
* Hold reference as long as rgpio_dev memory is valid.
959960
*/
960961
of_node_get(rgpio_dev->of_args.np);
961-
pdev = platform_device_register_data(NULL, "reset-gpio", id,
962+
pdev = platform_device_register_data(gpio_device_to_device(gdev),
963+
"reset-gpio", id,
962964
&rgpio_dev->of_args,
963965
sizeof(rgpio_dev->of_args));
964966
ret = PTR_ERR_OR_ZERO(pdev);

0 commit comments

Comments
 (0)