Skip to content

Commit 109ce74

Browse files
Bartosz GolaszewskipH5
authored andcommitted
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>
1 parent 46dae84 commit 109ce74

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

drivers/reset/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ config RESET_EYEQ
8989
config RESET_GPIO
9090
tristate "GPIO reset controller"
9191
depends on GPIOLIB
92+
select AUXILIARY_BUS
9293
help
9394
This enables a generic reset controller for resets attached via
9495
GPIOs. Typically for OF platforms this driver expects "reset-gpios"

drivers/reset/core.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/acpi.h>
99
#include <linux/atomic.h>
10+
#include <linux/auxiliary_bus.h>
1011
#include <linux/cleanup.h>
1112
#include <linux/device.h>
1213
#include <linux/err.h>
@@ -18,7 +19,6 @@
1819
#include <linux/kref.h>
1920
#include <linux/module.h>
2021
#include <linux/of.h>
21-
#include <linux/platform_device.h>
2222
#include <linux/reset.h>
2323
#include <linux/reset-controller.h>
2424
#include <linux/slab.h>
@@ -882,7 +882,7 @@ static int __reset_add_reset_gpio_lookup(struct gpio_device *gdev, int id,
882882
if (!lookup)
883883
return -ENOMEM;
884884

885-
lookup->dev_id = kasprintf(GFP_KERNEL, "reset-gpio.%d", id);
885+
lookup->dev_id = kasprintf(GFP_KERNEL, "reset.gpio.%d", id);
886886
if (!lookup->dev_id)
887887
return -ENOMEM;
888888

@@ -903,7 +903,7 @@ static int __reset_add_reset_gpio_lookup(struct gpio_device *gdev, int id,
903903
static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
904904
{
905905
struct reset_gpio_lookup *rgpio_dev;
906-
struct platform_device *pdev;
906+
struct auxiliary_device *adev;
907907
int id, ret;
908908

909909
/*
@@ -959,11 +959,9 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
959959
* Hold reference as long as rgpio_dev memory is valid.
960960
*/
961961
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);
967965
if (ret)
968966
goto err_put;
969967

drivers/reset/reset-gpio.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3+
#include <linux/auxiliary_bus.h>
34
#include <linux/gpio/consumer.h>
45
#include <linux/mod_devicetable.h>
56
#include <linux/module.h>
67
#include <linux/of.h>
7-
#include <linux/platform_device.h>
88
#include <linux/reset-controller.h>
99

1010
struct reset_gpio_priv {
@@ -61,9 +61,10 @@ static void reset_gpio_of_node_put(void *data)
6161
of_node_put(data);
6262
}
6363

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)
6566
{
66-
struct device *dev = &pdev->dev;
67+
struct device *dev = &adev->dev;
6768
struct of_phandle_args *platdata = dev_get_platdata(dev);
6869
struct reset_gpio_priv *priv;
6970
int ret;
@@ -75,7 +76,7 @@ static int reset_gpio_probe(struct platform_device *pdev)
7576
if (!priv)
7677
return -ENOMEM;
7778

78-
platform_set_drvdata(pdev, &priv->rc);
79+
auxiliary_set_drvdata(adev, &priv->rc);
7980

8081
priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
8182
if (IS_ERR(priv->reset))
@@ -99,20 +100,20 @@ static int reset_gpio_probe(struct platform_device *pdev)
99100
return devm_reset_controller_register(dev, &priv->rc);
100101
}
101102

102-
static const struct platform_device_id reset_gpio_ids[] = {
103-
{ .name = "reset-gpio", },
103+
static const struct auxiliary_device_id reset_gpio_ids[] = {
104+
{ .name = "reset.gpio" },
104105
{}
105106
};
106-
MODULE_DEVICE_TABLE(platform, reset_gpio_ids);
107+
MODULE_DEVICE_TABLE(auxiliary, reset_gpio_ids);
107108

108-
static struct platform_driver reset_gpio_driver = {
109+
static struct auxiliary_driver reset_gpio_driver = {
109110
.probe = reset_gpio_probe,
110111
.id_table = reset_gpio_ids,
111112
.driver = {
112113
.name = "reset-gpio",
113114
},
114115
};
115-
module_platform_driver(reset_gpio_driver);
116+
module_auxiliary_driver(reset_gpio_driver);
116117

117118
MODULE_AUTHOR("Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>");
118119
MODULE_DESCRIPTION("Generic GPIO reset driver");

0 commit comments

Comments
 (0)