usb: typec: anx7411: Call of_node_get() before of_find_xxx API
Subsystems (2)
PATCH 1/1 usb: typec: anx7411: Call of_node_get() before of_find_xxx API
In anx7411_typec_switch_probe(), we should call of_node_get() before of_find_node_by_name() which will automatically decrease the 'from' argument.
--- drivers/usb/typec/anx7411.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/typec/anx7411.c +2 -0
@@ -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" );
Signature · 1 line
2.25.1
Heikki Krogerus
maintainerQuoted 3 lines · Liang He
In
anx7411_typec_switch_probe(), we should callof_node_get()beforeof_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,
Quoted 28 lines
Fixes fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")Signed-off-by Liang He <[email protected]>--- drivers/usb/typec/anx7411.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/typec/anx7411.c +2
-0@@ -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" );Signature · 1 line
2.25.1
Signature · 1 line
heikki
Quoted 10 lines · Heikki Krogerus
Quoted 3 lines · Liang He
In
anx7411_typec_switch_probe(), we should callof_node_get()beforeof_find_node_by_name()which will automatically decrease the 'from' argument.Just use
of_get_child_by_name()instead ofof_find_node_by_name(). If you don't need recursion, then there is no point in usingof_find_node_by_name().thanks,
Thanks, Heikki Krogerus,
I will send v2 patch based on your advices.
Liang
Quoted 32 lines
Quoted 29 lines
Fixes fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")Signed-off-by Liang He <[email protected]>--- drivers/usb/typec/anx7411.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/typec/anx7411.c +2
-0@@ -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" );Signature · 1 line
2.25.1Signature · 1 line
heikki