Skip to contentSkip to conversation

scsi: ufs: fix error return code of ufshcd_populate_vreg()

PATCH In review Jia-Ju Bai 2 participants 2 messages Mar 5, 2021 – Mar 7, 2021 SCSI

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 scsi: ufs: fix error return code of ufshcd_populate_vreg()

When np is NULL or of_parse_phandle() returns NULL, no error return code of ufshcd_populate_vreg() is assigned.
To fix this bug, ret is assigned with -EINVAL or -ENOENT as error return code.

---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +2 -0
index 1a69949a4ea1..9f11c416a919 100644
@@ -113,6 +113,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 
 	if (!np) {
 		dev_err(dev, "%s: non DT initialization\n", __func__);
+		ret = -EINVAL;
 		goto out;
 	}
 
@@ -120,6 +121,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 	if (!of_parse_phandle(np, prop_name, 0)) {
 		dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n",
 				__func__, prop_name);
+		ret = -ENOENT;
 		goto out;
 	}
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines

When np is NULL or of_parse_phandle() returns NULL, no error return code of ufshcd_populate_vreg() is assigned.
To fix this bug, ret is assigned with -EINVAL or -ENOENT as error return code.

This changes the flow of ufshcd_parse_regulator_info so you need to:
a) get a tested-by tag and indicate which platform & devices you used, and
b) explain further why ufshcd_parse_regulator_info doesn't no longer allow some of the regulators not to be set via DT, which is the current state.

Thanks,
Avri

Quoted 31 lines
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +2 -1
index 1a69949a4ea1..9f11c416a919 100644
@@ -113,6 +113,7 @@ static int ufshcd_populate_vreg(struct device *dev,
 const char *name,
 
        if (!np) {
                dev_err(dev, "%s: non DT initialization\n", __func__);
+               ret = -EINVAL;
                goto out;
        }
@@ -120,6 +121,7 @@ static int ufshcd_populate_vreg(struct device *dev,
 const char *name,
        if (!of_parse_phandle(np, prop_name, 0)) {
                dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n",
                                __func__, prop_name);
+               ret = -ENOENT;
                goto out;
        }
 
--

2.17.1