[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZXuVsotg1DV596lV@shell.armlinux.org.uk>
Date: Thu, 14 Dec 2023 23:54:26 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: Florian Fainelli <florian.fainelli@...adcom.com>,
Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Vladimir Oltean <olteanv@...il.com>,
David Epping <david.epping@...singlinkelectronics.com>,
Harini Katakam <harini.katakam@....com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [net-next PATCH v7 2/4] net: phy: extend PHY package API to
support multiple global address
On Thu, Dec 14, 2023 at 05:54:51PM +0100, Christian Marangi wrote:
> What I don't like is the wrap check.
>
> But I wonder... Isn't it easier to have
>
> unsigned int addr = shared->base_addr + addr_offset;
>
> and check if >= PHY_MAC_ADDR?
>
> Everything is unsigned (so no negative case) and wrap is not possible as
> nothing is downcasted.
I'm afraid that I LOL'd at "wrap is not possible" ! Of course it's
possible. Here's an example:
shared->base_addr is 20
addr_offset is ~0 (or -1 casted to an unsigned int)
addr becomes 19
How about:
if (addr_offset >= PHY_MAX_ADDR)
return -EIO;
addr = shared->base_addr + addr_offset;
if (addr >= PHY_MAX_ADDR)
return -EIO;
and then we could keep 'addr' as u8.
Honestly, I have wondered why the mdio bus address is a signed int, but
never decided to do anything about it.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists