Re: [PATCH RFC net-next 3/3] net: dsa: add basic initial driver for MxL862xx switches

From: Daniel Golle

Date: Fri Dec 12 2025 - 11:50:05 EST


Hi Andrew,

On Wed, Dec 10, 2025 at 07:56:13PM +0100, Andrew Lunn wrote:
> > > > + if (result < 0) {
> > > > + ret = result;
> > > > + goto out;
> > > > + }
> > >
> > > If i'm reading mxl862xx_send_cmd() correct, result is the value of a
> > > register. It seems unlikely this is a Linux error code?
> >
> > Only someone with insights into the use of error codes by the uC
> > firmware can really answer that. However, as also Russell pointed out,
> > the whole use of s16 here with negative values being interpreted as
> > errors is fishy here, because in the end this is also used to read
> > registers from external MDIO connected PHYs which may return arbitrary
> > 16-bit values...
> > Someone in MaxLinear will need to clarify here.
>
> It looks wrong, and since different architectures use different error
> code values, it is hard to get right. I would suggest you just return
> EPROTO or EIO and add a netdev_err() to print the value of result.

MaxLinear folks got back to me. So the error codes returned by the firmware
are basically based on Zephyr's errno.h which seems to be a copy of a BSD
header, see

https://github.com/zephyrproject-rtos/zephyr/blob/main/lib/libc/minimal/include/errno.h

So the best would probably be to modify and include that header with the
driver, together with a function translating the error codes to what ever
is defined in uapi/asm/errno.h for the architecture we are building for.

They also told me that (obviously) not all error codes are currently
used by the firmware, but the best would be to just catch all the possible
error codes and translate Zephyr libc -> Linux kernel.