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

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>

+9 -28
+9 -28
drivers/regulator/dummy.c
··· 13 13 14 14 #include <linux/err.h> 15 15 #include <linux/export.h> 16 - #include <linux/platform_device.h> 16 + #include <linux/device/faux.h> 17 17 #include <linux/regulator/driver.h> 18 18 #include <linux/regulator/machine.h> 19 19 ··· 37 37 .ops = &dummy_ops, 38 38 }; 39 39 40 - static int dummy_regulator_probe(struct platform_device *pdev) 40 + static int dummy_regulator_probe(struct faux_device *fdev) 41 41 { 42 42 struct regulator_config config = { }; 43 43 int ret; 44 44 45 - config.dev = &pdev->dev; 45 + config.dev = &fdev->dev; 46 46 config.init_data = &dummy_initdata; 47 47 48 - dummy_regulator_rdev = devm_regulator_register(&pdev->dev, &dummy_desc, 48 + dummy_regulator_rdev = devm_regulator_register(&fdev->dev, &dummy_desc, 49 49 &config); 50 50 if (IS_ERR(dummy_regulator_rdev)) { 51 51 ret = PTR_ERR(dummy_regulator_rdev); ··· 56 56 return 0; 57 57 } 58 58 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, 65 61 }; 66 62 67 - static struct platform_device *dummy_pdev; 63 + static struct faux_device *dummy_fdev; 68 64 69 65 void __init regulator_dummy_init(void) 70 66 { 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) { 75 69 pr_err("Failed to allocate dummy regulator device\n"); 76 70 return; 77 - } 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 71 } 91 72 }