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

reset: gpio: convert the driver to using the auxiliary bus

As the reset-gpio devices are purely virtual and never instantiated from
real firmware nodes, let's convert the driver to using the - more
fitting - auxiliary bus.

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
109ce747 46dae84a

+17 -17
+1
drivers/reset/Kconfig
··· 89 89 config RESET_GPIO 90 90 tristate "GPIO reset controller" 91 91 depends on GPIOLIB 92 + select AUXILIARY_BUS 92 93 help 93 94 This enables a generic reset controller for resets attached via 94 95 GPIOs. Typically for OF platforms this driver expects "reset-gpios"
+6 -8
drivers/reset/core.c
··· 7 7 8 8 #include <linux/acpi.h> 9 9 #include <linux/atomic.h> 10 + #include <linux/auxiliary_bus.h> 10 11 #include <linux/cleanup.h> 11 12 #include <linux/device.h> 12 13 #include <linux/err.h> ··· 19 18 #include <linux/kref.h> 20 19 #include <linux/module.h> 21 20 #include <linux/of.h> 22 - #include <linux/platform_device.h> 23 21 #include <linux/reset.h> 24 22 #include <linux/reset-controller.h> 25 23 #include <linux/slab.h> ··· 882 882 if (!lookup) 883 883 return -ENOMEM; 884 884 885 - lookup->dev_id = kasprintf(GFP_KERNEL, "reset-gpio.%d", id); 885 + lookup->dev_id = kasprintf(GFP_KERNEL, "reset.gpio.%d", id); 886 886 if (!lookup->dev_id) 887 887 return -ENOMEM; 888 888 ··· 903 903 static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) 904 904 { 905 905 struct reset_gpio_lookup *rgpio_dev; 906 - struct platform_device *pdev; 906 + struct auxiliary_device *adev; 907 907 int id, ret; 908 908 909 909 /* ··· 959 959 * Hold reference as long as rgpio_dev memory is valid. 960 960 */ 961 961 of_node_get(rgpio_dev->of_args.np); 962 - pdev = platform_device_register_data(gpio_device_to_device(gdev), 963 - "reset-gpio", id, 964 - &rgpio_dev->of_args, 965 - sizeof(rgpio_dev->of_args)); 966 - ret = PTR_ERR_OR_ZERO(pdev); 962 + adev = auxiliary_device_create(gpio_device_to_device(gdev), "reset", 963 + "gpio", &rgpio_dev->of_args, id); 964 + ret = PTR_ERR_OR_ZERO(adev); 967 965 if (ret) 968 966 goto err_put; 969 967
+10 -9
drivers/reset/reset-gpio.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 + #include <linux/auxiliary_bus.h> 3 4 #include <linux/gpio/consumer.h> 4 5 #include <linux/mod_devicetable.h> 5 6 #include <linux/module.h> 6 7 #include <linux/of.h> 7 - #include <linux/platform_device.h> 8 8 #include <linux/reset-controller.h> 9 9 10 10 struct reset_gpio_priv { ··· 61 61 of_node_put(data); 62 62 } 63 63 64 - static int reset_gpio_probe(struct platform_device *pdev) 64 + static int reset_gpio_probe(struct auxiliary_device *adev, 65 + const struct auxiliary_device_id *id) 65 66 { 66 - struct device *dev = &pdev->dev; 67 + struct device *dev = &adev->dev; 67 68 struct of_phandle_args *platdata = dev_get_platdata(dev); 68 69 struct reset_gpio_priv *priv; 69 70 int ret; ··· 76 75 if (!priv) 77 76 return -ENOMEM; 78 77 79 - platform_set_drvdata(pdev, &priv->rc); 78 + auxiliary_set_drvdata(adev, &priv->rc); 80 79 81 80 priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); 82 81 if (IS_ERR(priv->reset)) ··· 100 99 return devm_reset_controller_register(dev, &priv->rc); 101 100 } 102 101 103 - static const struct platform_device_id reset_gpio_ids[] = { 104 - { .name = "reset-gpio", }, 102 + static const struct auxiliary_device_id reset_gpio_ids[] = { 103 + { .name = "reset.gpio" }, 105 104 {} 106 105 }; 107 - MODULE_DEVICE_TABLE(platform, reset_gpio_ids); 106 + MODULE_DEVICE_TABLE(auxiliary, reset_gpio_ids); 108 107 109 - static struct platform_driver reset_gpio_driver = { 108 + static struct auxiliary_driver reset_gpio_driver = { 110 109 .probe = reset_gpio_probe, 111 110 .id_table = reset_gpio_ids, 112 111 .driver = { 113 112 .name = "reset-gpio", 114 113 }, 115 114 }; 116 - module_platform_driver(reset_gpio_driver); 115 + module_auxiliary_driver(reset_gpio_driver); 117 116 118 117 MODULE_AUTHOR("Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>"); 119 118 MODULE_DESCRIPTION("Generic GPIO reset driver");