Merge remote-tracking branch 'regulator/topic/list' into regulator-next
authorMark Brown <broonie@kernel.org>
Wed, 4 Nov 2015 11:19:36 +0000 (11:19 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 4 Nov 2015 11:19:36 +0000 (11:19 +0000)
1  2 
drivers/regulator/core.c

@@@ -1394,21 -1439,18 +1439,22 @@@ static int regulator_resolve_supply(str
                return 0;
  
        r = regulator_dev_lookup(dev, rdev->supply_name, &ret);
 -      if (ret == -ENODEV) {
 -              /*
 -               * No supply was specified for this regulator and
 -               * there will never be one.
 -               */
 -              return 0;
 -      }
 -
        if (!r) {
 +              if (ret == -ENODEV) {
 +                      /*
 +                       * No supply was specified for this regulator and
 +                       * there will never be one.
 +                       */
 +                      return 0;
 +              }
 +
 +              /* Did the lookup explicitly defer for us? */
 +              if (ret == -EPROBE_DEFER)
 +                      return ret;
 +
                if (have_full_constraints()) {
                        r = dummy_regulator_rdev;
+                       get_device(&r->dev);
                } else {
                        dev_err(dev, "Failed to resolve %s-supply for %s\n",
                                rdev->supply_name, rdev->desc->name);
  
        /* Recursively resolve the supply of the supply */
        ret = regulator_resolve_supply(r);
-       if (ret < 0)
+       if (ret < 0) {
+               put_device(&r->dev);
                return ret;
+       }
  
        ret = set_supply(rdev, r);
-       if (ret < 0)
+       if (ret < 0) {
+               put_device(&r->dev);
                return ret;
+       }
  
        /* Cascade always-on state to supply */
 -      if (_regulator_is_enabled(rdev)) {
 +      if (_regulator_is_enabled(rdev) && rdev->supply) {
                ret = regulator_enable(rdev->supply);
                if (ret < 0) {
 -                      if (rdev->supply)
 -                              _regulator_put(rdev->supply);
 +                      _regulator_put(rdev->supply);
                        return ret;
                }
        }