* [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle()
@ 2022-07-14 5:54 Liang He
2022-07-14 18:15 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Liang He @ 2022-07-14 5:54 UTC (permalink / raw)
To: jejb, martin.petersen, windhl, linux-scsi
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle()
2022-07-14 5:54 [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle() Liang He
@ 2022-07-14 18:15 ` Bart Van Assche
2022-07-14 23:56 ` Liang He
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2022-07-14 18:15 UTC (permalink / raw)
To: Liang He, jejb, martin.petersen, linux-scsi
On 7/13/22 22:54, Liang He wrote:
> +static bool is_of_parse_phandle(const struct device_node *np,
> + const char *phandle_name,
> + int index)
> +{
The function name sounds weird to me. Would phandle_exists() perhaps be
a better name?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re:Re: [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle()
2022-07-14 18:15 ` Bart Van Assche
@ 2022-07-14 23:56 ` Liang He
0 siblings, 0 replies; 3+ messages in thread
From: Liang He @ 2022-07-14 23:56 UTC (permalink / raw)
To: Bart Van Assche; +Cc: jejb, martin.petersen, linux-scsi
At 2022-07-15 02:15:12, "Bart Van Assche" <bvanassche@acm.org> wrote:
>On 7/13/22 22:54, Liang He wrote:
>> +static bool is_of_parse_phandle(const struct device_node *np,
>> + const char *phandle_name,
>> + int index)
>> +{
>
>The function name sounds weird to me. Would phandle_exists() perhaps be
>a better name?
>
>Thanks,
>
>Bart.
Thanks, Bart
I will send a new version with above name.
Thanks again,
Liang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-14 23:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14 5:54 [PATCH] ufs: host: ufschd-pltfrm: Hold reference returned by of_parse_phandle() Liang He
2022-07-14 18:15 ` Bart Van Assche
2022-07-14 23:56 ` Liang He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox