Merge tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[sfrench/cifs-2.6.git] / drivers / ufs / host / ufshcd-pltfrm.c
index e7332cc65b1fecfaa1f62d683ea77391949a5c4e..173aea8e9997ce6ecb1bbba5a4f76d6a3dbd4d6d 100644 (file)
@@ -108,9 +108,20 @@ out:
        return ret;
 }
 
+static bool phandle_exists(const struct device_node *np,
+                          const char *phandle_name, int index)
+{
+       struct device_node *parse_np = of_parse_phandle(np, phandle_name, index);
+
+       if (parse_np)
+               of_node_put(parse_np);
+
+       return parse_np != NULL;
+}
+
 #define MAX_PROP_SIZE 32
 static int ufshcd_populate_vreg(struct device *dev, const char *name,
-               struct ufs_vreg **out_vreg)
+                               struct ufs_vreg **out_vreg)
 {
        char prop_name[MAX_PROP_SIZE];
        struct ufs_vreg *vreg = NULL;
@@ -122,7 +133,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
        }
 
        snprintf(prop_name, MAX_PROP_SIZE, "%s-supply", name);
-       if (!of_parse_phandle(np, prop_name, 0)) {
+       if (!phandle_exists(np, prop_name, 0)) {
                dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n",
                                __func__, prop_name);
                goto out;