regulator: fix device unlinking
authorGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Fri, 8 Feb 2019 07:41:53 +0000 (08:41 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 8 Feb 2019 13:05:14 +0000 (13:05 +0000)
Device links are refcounted, device_link_remove() has to be called as
many times as device_link_add().

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index b9d7b45c7295459f0928e8436623b45897be23d1..2994ee023b40db1fa3ba2d6d6d10a960d364094f 100644 (file)
@@ -2058,15 +2058,7 @@ static void _regulator_put(struct regulator *regulator)
        debugfs_remove_recursive(regulator->debugfs);
 
        if (regulator->dev) {
-               int count = 0;
-               struct regulator *r;
-
-               list_for_each_entry(r, &rdev->consumer_list, list)
-                       if (r->dev == regulator->dev)
-                               count++;
-
-               if (count == 1)
-                       device_link_remove(regulator->dev, &rdev->dev);
+               device_link_remove(regulator->dev, &rdev->dev);
 
                /* remove any sysfs entries */
                sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);