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

index 455732c2e8437c79e7a49e252f91de0e76f5d9c8,57a5deb6a9497d677a4ed25acf0e98a525dfbe59..e9b94d7be7c919531a41d33285915b2837310932
@@@ -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;
                }
        }