Skip to content

Commit dcd2a9a

Browse files
committed
regulator: dummy: convert to use the faux device interface
The dummy regulator driver does not need to create a platform device, it only did so because it was simple to do. Change it over to use the faux bus instead as this is NOT a real platform device, and it makes the code even smaller than before. Reviewed-by: Mark Brown <broonie@kernel.org> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/2025021027-outclass-stress-59dd@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6f119e3 commit dcd2a9a

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

drivers/regulator/dummy.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <linux/err.h>
1515
#include <linux/export.h>
16-
#include <linux/platform_device.h>
16+
#include <linux/device/faux.h>
1717
#include <linux/regulator/driver.h>
1818
#include <linux/regulator/machine.h>
1919

@@ -37,15 +37,15 @@ static const struct regulator_desc dummy_desc = {
3737
.ops = &dummy_ops,
3838
};
3939

40-
static int dummy_regulator_probe(struct platform_device *pdev)
40+
static int dummy_regulator_probe(struct faux_device *fdev)
4141
{
4242
struct regulator_config config = { };
4343
int ret;
4444

45-
config.dev = &pdev->dev;
45+
config.dev = &fdev->dev;
4646
config.init_data = &dummy_initdata;
4747

48-
dummy_regulator_rdev = devm_regulator_register(&pdev->dev, &dummy_desc,
48+
dummy_regulator_rdev = devm_regulator_register(&fdev->dev, &dummy_desc,
4949
&config);
5050
if (IS_ERR(dummy_regulator_rdev)) {
5151
ret = PTR_ERR(dummy_regulator_rdev);
@@ -56,36 +56,17 @@ static int dummy_regulator_probe(struct platform_device *pdev)
5656
return 0;
5757
}
5858

59-
static struct platform_driver dummy_regulator_driver = {
60-
.probe = dummy_regulator_probe,
61-
.driver = {
62-
.name = "reg-dummy",
63-
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
64-
},
59+
struct faux_device_ops dummy_regulator_driver = {
60+
.probe = dummy_regulator_probe,
6561
};
6662

67-
static struct platform_device *dummy_pdev;
63+
static struct faux_device *dummy_fdev;
6864

6965
void __init regulator_dummy_init(void)
7066
{
71-
int ret;
72-
73-
dummy_pdev = platform_device_alloc("reg-dummy", -1);
74-
if (!dummy_pdev) {
67+
dummy_fdev = faux_device_create("reg-dummy", NULL, &dummy_regulator_driver);
68+
if (!dummy_fdev) {
7569
pr_err("Failed to allocate dummy regulator device\n");
7670
return;
7771
}
78-
79-
ret = platform_device_add(dummy_pdev);
80-
if (ret != 0) {
81-
pr_err("Failed to register dummy regulator device: %d\n", ret);
82-
platform_device_put(dummy_pdev);
83-
return;
84-
}
85-
86-
ret = platform_driver_register(&dummy_regulator_driver);
87-
if (ret != 0) {
88-
pr_err("Failed to register dummy regulator driver: %d\n", ret);
89-
platform_device_unregister(dummy_pdev);
90-
}
9172
}

0 commit comments

Comments
 (0)