diff mbox series

can: rcar_canfd: Use of_get_available_child_by_name()

Message ID 20250201094642.16243-1-biju.das.jz@bp.renesas.com (mailing list archive)
State New
Delegated to: Geert Uytterhoeven
Headers show
Series can: rcar_canfd: Use of_get_available_child_by_name() | expand

Commit Message

Biju Das Feb. 1, 2025, 9:46 a.m. UTC
Simplify rcar_canfd_probe() using of_get_available_child_by_name().

Simplify rcar_canfd_probe() using of_get_available_child_by_name().

While at it, move of_node_put(child) inside the if block to avoid
additional check if of_child is NULL.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
This patch is only compile tested and depend upon[1]
[1] https://lore.kernel.org/all/20250201093126.7322-1-biju.das.jz@bp.renesas.com/
---
 drivers/net/can/rcar/rcar_canfd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Sergey Shtylyov Feb. 1, 2025, 6:52 p.m. UTC | #1
On 2/1/25 12:46 PM, Biju Das wrote:

> Simplify rcar_canfd_probe() using of_get_available_child_by_name().
> 
> Simplify rcar_canfd_probe() using of_get_available_child_by_name().

   Twice? :-)

> While at it, move of_node_put(child) inside the if block to avoid
> additional check if of_child is NULL.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
[...]

MBR, Sergey
Vincent Mailhol Feb. 2, 2025, 8:40 a.m. UTC | #2
On 02/02/2025 at 03:52, Sergey Shtylyov wrote:
> On 2/1/25 12:46 PM, Biju Das wrote:
> 
>> Simplify rcar_canfd_probe() using of_get_available_child_by_name().
>>
>> Simplify rcar_canfd_probe() using of_get_available_child_by_name().
> 
>    Twice? :-)

+1

>> While at it, move of_node_put(child) inside the if block to avoid
>> additional check if of_child is NULL.
>>
>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> [...]

Please remove the repetition. Aside from that, the patch is good.

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>


Yours sincerely,
Vincent Mailhol
Biju Das Feb. 2, 2025, 10:21 a.m. UTC | #3
Hi Vincent and Sergey,

Thanks for the feedback.

> -----Original Message-----
> From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> Sent: 02 February 2025 08:41
> Subject: Re: [PATCH] can: rcar_canfd: Use of_get_available_child_by_name()
> 
> On 02/02/2025 at 03:52, Sergey Shtylyov wrote:
> > On 2/1/25 12:46 PM, Biju Das wrote:
> >
> >> Simplify rcar_canfd_probe() using of_get_available_child_by_name().
> >>
> >> Simplify rcar_canfd_probe() using of_get_available_child_by_name().
> >
> >    Twice? :-)
> 
> +1

Oops.

> 
> >> While at it, move of_node_put(child) inside the if block to avoid
> >> additional check if of_child is NULL.
> >>
> >> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > [...]
> 
> Please remove the repetition. Aside from that, the patch is good.

OK, Will fix and send the next version, when dependency patch hits on
net-next.

Cheers,
Biju
diff mbox series

Patch

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index df1a5d0b37b2..619a21d68d82 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1862,13 +1862,13 @@  static int rcar_canfd_probe(struct platform_device *pdev)
 
 	for (i = 0; i < info->max_channels; ++i) {
 		name[7] = '0' + i;
-		of_child = of_get_child_by_name(dev->of_node, name);
-		if (of_child && of_device_is_available(of_child)) {
+		of_child = of_get_available_child_by_name(dev->of_node, name);
+		if (of_child) {
 			channels_mask |= BIT(i);
 			transceivers[i] = devm_of_phy_optional_get(dev,
 							of_child, NULL);
+			of_node_put(of_child);
 		}
-		of_node_put(of_child);
 		if (IS_ERR(transceivers[i]))
 			return PTR_ERR(transceivers[i]);
 	}