From: Liang He <windhl@126.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com, windhl@126.com,
linux-scsi@vger.kernel.org
Subject: [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle()
Date: Thu, 14 Jul 2022 13:54:13 +0800 [thread overview]
Message-ID: <20220714055413.373449-1-windhl@126.com> (raw)
In ufshcd_populate_vreg(), we should hold the reference returned by
of_parse_phandle() and then use it to call of_node_put() for refcount
balance.
Fixes: aa4976130934 ("ufs: Add regulator enable support")
Signed-off-by: Liang He <windhl@126.com>
---
We add a helper to check the return value of_parse_phandle() as we
do not need the reference, otherwise we need to declare a device_node
in ufshcd_populate_vreg().
drivers/ufs/host/ufshcd-pltfrm.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
index e7332cc65b1f..2cb409d9ed3d 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.c
+++ b/drivers/ufs/host/ufshcd-pltfrm.c
@@ -108,6 +108,21 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
return ret;
}
+static bool is_of_parse_phandle(const struct device_node *np,
+ const char *phandle_name,
+ int index)
+{
+ struct device_node *parse_np = of_parse_phandle(np, phandle_name, index);
+ bool ret = false;
+
+ if (parse_np) {
+ ret = true;
+ of_node_put(parse_np);
+ }
+
+ return ret;
+}
+
#define MAX_PROP_SIZE 32
static int ufshcd_populate_vreg(struct device *dev, const char *name,
struct ufs_vreg **out_vreg)
@@ -122,7 +137,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 (!is_of_parse_phandle(np, prop_name, 0)) {
dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n",
__func__, prop_name);
goto out;
--
2.25.1
next reply other threads:[~2022-07-14 6:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-14 5:54 Liang He [this message]
2022-07-14 18:15 ` [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle() Bart Van Assche
2022-07-14 23:56 ` Liang He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220714055413.373449-1-windhl@126.com \
--to=windhl@126.com \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox