linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: anx7411: Call of_node_get() before of_find_xxx API
@ 2022-09-15  2:54 Liang He
  2022-09-15  6:53 ` Heikki Krogerus
  0 siblings, 1 reply; 3+ messages in thread
From: Liang He @ 2022-09-15  2:54 UTC (permalink / raw)
  To: heikki.krogerus, gregkh, linux-usb; +Cc: windhl

In anx7411_typec_switch_probe(), we should call of_node_get() before
of_find_node_by_name() which will automatically decrease the 'from'
argument.

Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/usb/typec/anx7411.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index c0f0842d443c..fe000bbf7183 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -1105,6 +1105,7 @@ static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
 	int ret;
 	struct device_node *node;
 
+	of_node_get(dev->of_node);
 	node = of_find_node_by_name(dev->of_node, "orientation_switch");
 	if (!node)
 		return 0;
@@ -1115,6 +1116,7 @@ static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
 		return ret;
 	}
 
+	of_node_get(dev->of_node);
 	node = of_find_node_by_name(dev->of_node, "mode_switch");
 	if (!node) {
 		dev_err(dev, "no typec mux exist");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: anx7411: Call of_node_get() before of_find_xxx API
  2022-09-15  2:54 [PATCH] usb: typec: anx7411: Call of_node_get() before of_find_xxx API Liang He
@ 2022-09-15  6:53 ` Heikki Krogerus
  2022-09-15  7:12   ` Liang He
  0 siblings, 1 reply; 3+ messages in thread
From: Heikki Krogerus @ 2022-09-15  6:53 UTC (permalink / raw)
  To: Liang He; +Cc: gregkh, linux-usb

On Thu, Sep 15, 2022 at 10:54:00AM +0800, Liang He wrote:
> In anx7411_typec_switch_probe(), we should call of_node_get() before
> of_find_node_by_name() which will automatically decrease the 'from'
> argument.

Just use of_get_child_by_name() instead of of_find_node_by_name(). If
you don't need recursion, then there is no point in using
of_find_node_by_name().

thanks,

> Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/usb/typec/anx7411.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
> index c0f0842d443c..fe000bbf7183 100644
> --- a/drivers/usb/typec/anx7411.c
> +++ b/drivers/usb/typec/anx7411.c
> @@ -1105,6 +1105,7 @@ static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
>  	int ret;
>  	struct device_node *node;
>  
> +	of_node_get(dev->of_node);
>  	node = of_find_node_by_name(dev->of_node, "orientation_switch");
>  	if (!node)
>  		return 0;
> @@ -1115,6 +1116,7 @@ static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
>  		return ret;
>  	}
>  
> +	of_node_get(dev->of_node);
>  	node = of_find_node_by_name(dev->of_node, "mode_switch");
>  	if (!node) {
>  		dev_err(dev, "no typec mux exist");
> -- 
> 2.25.1

-- 
heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re:Re: [PATCH] usb: typec: anx7411: Call of_node_get() before of_find_xxx API
  2022-09-15  6:53 ` Heikki Krogerus
@ 2022-09-15  7:12   ` Liang He
  0 siblings, 0 replies; 3+ messages in thread
From: Liang He @ 2022-09-15  7:12 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: gregkh, linux-usb




At 2022-09-15 14:53:51, "Heikki Krogerus" <heikki.krogerus@linux.intel.com> wrote:
>On Thu, Sep 15, 2022 at 10:54:00AM +0800, Liang He wrote:
>> In anx7411_typec_switch_probe(), we should call of_node_get() before
>> of_find_node_by_name() which will automatically decrease the 'from'
>> argument.
>
>Just use of_get_child_by_name() instead of of_find_node_by_name(). If
>you don't need recursion, then there is no point in using
>of_find_node_by_name().
>
>thanks,

Thanks, Heikki Krogerus,

I will send v2 patch based on your advices.

Liang

>
>> Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>>  drivers/usb/typec/anx7411.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
>> index c0f0842d443c..fe000bbf7183 100644
>> --- a/drivers/usb/typec/anx7411.c
>> +++ b/drivers/usb/typec/anx7411.c
>> @@ -1105,6 +1105,7 @@ static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
>>  	int ret;
>>  	struct device_node *node;
>>  
>> +	of_node_get(dev->of_node);
>>  	node = of_find_node_by_name(dev->of_node, "orientation_switch");
>>  	if (!node)
>>  		return 0;
>> @@ -1115,6 +1116,7 @@ static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
>>  		return ret;
>>  	}
>>  
>> +	of_node_get(dev->of_node);
>>  	node = of_find_node_by_name(dev->of_node, "mode_switch");
>>  	if (!node) {
>>  		dev_err(dev, "no typec mux exist");
>> -- 
>> 2.25.1
>
>-- 
>heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-15  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-15  2:54 [PATCH] usb: typec: anx7411: Call of_node_get() before of_find_xxx API Liang He
2022-09-15  6:53 ` Heikki Krogerus
2022-09-15  7:12   ` Liang He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).