[PATCH v8 4/8] net: dsa: allow rcv() and xmit() to be optional

Vladimir Oltean vladimir.oltean at nxp.com
Wed Nov 30 18:25:40 CET 2022


On Tue, Nov 29, 2022 at 04:58:33PM -0800, Tim Harvey wrote:
> Yes, it makes sense. How about the following patch instead:
> 
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index 211a991cdd0d..1ae9adc66eda 100644
> --- a/net/dsa-uclass.c
> +++ b/net/dsa-uclass.c
> @@ -142,6 +142,9 @@ static int dsa_port_send(struct udevice *pdev,
> void *packet, int length)
>         struct dsa_port_pdata *port_pdata;
>         int err;
> 
> +       if (!ops->xmit)
> +               return eth_get_ops(master)->send(master, packet, length);

My 2 cents, I would avoid calling eth_get_ops(master)->send() twice.
Either keep the mangling inside the "if" block, or pass the length
argument by reference to your function, or use a goto skip_mangling.

> +
>         if (length + head + tail > PKTSIZE_ALIGN)
>                 return -EINVAL;
> 
> @@ -172,7 +175,7 @@ static int dsa_port_recv(struct udevice *pdev, int
> flags, uchar **packetp)
>         int length, port_index, err;
> 
>         length = eth_get_ops(master)->recv(master, flags, packetp);
> -       if (length <= 0)
> +       if (length <= 0 || !ops->rcv)
>                 return length;
> 
>         /*
> 
> Perhaps it's more elegant to wrap the bulk of dsa_port_send with an
> 'if (ops->xmit)' but changing the indentation makes the patch more
> difficult to follow.
> 
> Best Regards,
> 
> Tim


More information about the U-Boot mailing list