regulator: dummy: Use devm_regulator_register()
authorZenghui Yu <yuzenghui@huawei.com>
Sat, 25 Sep 2021 03:55:07 +0000 (11:55 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 27 Sep 2021 12:01:20 +0000 (13:01 +0100)
debugfs code complained at boot time that

  debugfs: Directory 'reg-dummy-regulator-dummy' with parent 'regulator'
  already present!

if we compile kernel with DEBUG_TEST_DRIVER_REMOVE. The problem is that we
don't provide .remove() method for dummy_regulator_driver, which should
invoke regulator_unregister() on device teardown to properly free things.

Though it's harmless as dummy_pdev never gets unbound in practice, let's
use devm_regulator_register() to get rid of the inconsistency.

Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Link: https://lore.kernel.org/r/20210925035507.1904-1-yuzenghui@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/dummy.c

index d8059f596391f60aa1a3488256e4d30620a070dd..24e586f938554515b7fc1d33b444137d15fc9f2c 100644 (file)
@@ -45,7 +45,8 @@ static int dummy_regulator_probe(struct platform_device *pdev)
        config.dev = &pdev->dev;
        config.init_data = &dummy_initdata;
 
-       dummy_regulator_rdev = regulator_register(&dummy_desc, &config);
+       dummy_regulator_rdev = devm_regulator_register(&pdev->dev, &dummy_desc,
+                                                      &config);
        if (IS_ERR(dummy_regulator_rdev)) {
                ret = PTR_ERR(dummy_regulator_rdev);
                pr_err("Failed to register regulator: %d\n", ret);