Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bartosz Golaszewski and committed by
Philipp Zabel
46dae84a 97d85328

+10 -8
+10 -8
drivers/reset/core.c
··· 849 849 kref_put(&rstc->refcnt, __reset_control_release); 850 850 } 851 851 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, 853 854 unsigned int gpio, 854 855 unsigned int of_flags) 855 856 { 856 - const struct fwnode_handle *fwnode = of_fwnode_handle(np); 857 857 unsigned int lookup_flags; 858 858 const char *label_tmp; 859 859 ··· 867 867 of_flags, gpio); 868 868 return -EINVAL; 869 869 } 870 - 871 - struct gpio_device *gdev __free(gpio_device_put) = gpio_device_find_by_fwnode(fwnode); 872 - if (!gdev) 873 - return -EPROBE_DEFER; 874 870 875 871 label_tmp = gpio_device_get_label(gdev); 876 872 if (!label_tmp) ··· 922 926 */ 923 927 lockdep_assert_not_held(&reset_list_mutex); 924 928 929 + struct gpio_device *gdev __free(gpio_device_put) = 930 + gpio_device_find_by_fwnode(of_fwnode_handle(args->np)); 931 + if (!gdev) 932 + return -EPROBE_DEFER; 933 + 925 934 guard(mutex)(&reset_gpio_lookup_mutex); 926 935 927 936 list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) { ··· 947 946 goto err_ida_free; 948 947 } 949 948 950 - ret = __reset_add_reset_gpio_lookup(id, args->np, args->args[0], 949 + ret = __reset_add_reset_gpio_lookup(gdev, id, args->np, args->args[0], 951 950 args->args[1]); 952 951 if (ret < 0) 953 952 goto err_kfree; ··· 959 958 * Hold reference as long as rgpio_dev memory is valid. 960 959 */ 961 960 of_node_get(rgpio_dev->of_args.np); 962 - pdev = platform_device_register_data(NULL, "reset-gpio", id, 961 + pdev = platform_device_register_data(gpio_device_to_device(gdev), 962 + "reset-gpio", id, 963 963 &rgpio_dev->of_args, 964 964 sizeof(rgpio_dev->of_args)); 965 965 ret = PTR_ERR_OR_ZERO(pdev);