lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXjirjOsc5IJFHfH@makrotopia.org>
Date: Tue, 27 Jan 2026 16:07:10 +0000
From: Daniel Golle <daniel@...rotopia.org>
To: Andrew Lunn <andrew@...n.ch>
Cc: Paolo Abeni <pabeni@...hat.com>, Vladimir Oltean <olteanv@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	Simon Horman <horms@...nel.org>, netdev@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	Frank Wunderlich <frankwu@....de>, Chad Monroe <chad@...roe.io>,
	Cezary Wilmanski <cezary.wilmanski@...ran.com>,
	Avinash Jayaraman <ajayaraman@...linear.com>,
	Bing tao Xu <bxu@...linear.com>, Liang Xu <lxu@...linear.com>,
	Juraj Povazanec <jpovazanec@...linear.com>,
	"Fanni (Fang-Yi) Chan" <fchan@...linear.com>,
	"Benny (Ying-Tsan) Weng" <yweng@...linear.com>,
	"Livia M. Rosu" <lrosu@...linear.com>,
	John Crispin <john@...ozen.org>
Subject: Re: [PATCH net-next v8 4/4] net: dsa: add basic initial driver for
 MxL862xx switches

On Tue, Jan 27, 2026 at 04:04:10PM +0100, Andrew Lunn wrote:
> > > int mxl862xx_to_zephyr_errno(u16 reg)
> > so that would then just be
> > 	return (s16)reg;
> > right?
> 
> Yes.

+1

Maybe better to check if bit 16~31 is actually zero as well, so
int mxl862xx_to_zephyr_errno(int reg)
{
	if (reg >= 0 && reg <= U16_MAX)
		return (s16)reg;

	return 0;
}

or

int mxl862xx_to_zephyr_errno(int reg)
{
	if (!(reg & GENMASK(31, 16))
		return (s16)reg;

	return 0;
}

or something like that. Let me know what you prefer.


> 
> > 
> > Or did you think to include the handling of the error __mdiodev_c45_read()
> > would return, ie.
> > int mxl862xx_to_zephyr_errno(int reg)
> > {
> > 	if (reg < 0)
> > 		return reg;
> 
> No, that mixes up real linux error codes and Zephyr OS error codes.

I thought of that 'int reg' to be the return value of
__mdiodev_c45_read(), so if that 32-bit signed int < 0 that means what
you get is the error returned from __mdiodev_c45_read().

> 
> If the MDIO operation fails, you have a real error code you can
> return. If the firmware fails, you will want to netdev_err() the
> Zephyr error code to aid debug, and then return -EIO.

+1


> 
> > Or actually translating the actual errno to a Linux error code?
> 
> Is it worth the effort? How many times have you seen the firmware
> fail? During debugging, it might be useful, but in production?

Some of the error values are useful, it *is* good to know whether eg. a
bridge cannot be allocated because (for what ever reason) of resource
exhaustion (-ENOMEM) or because of otherwise invalid settings (-EINVAL).
However, it is true that in production none of that should ever happen.
The driver will be able to predict and manage the resources of the
switch without ever hitting -ENOMEM, and make sure parameters are valid
before passing anything to the firmware. And even during development it
is good enough to see the error number in the netdev_err() output.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ