Re: [net-next PATCH 1/3] net: phy: extend PHY package API to support multiple global address

From: Christian Marangi
Date: Sun Nov 26 2023 - 13:23:12 EST


On Sun, Nov 26, 2023 at 07:19:16PM +0100, Andrew Lunn wrote:
> > > static inline int phy_package_read(struct phy_device *phydev,
> > > unsigned int addr_offset, u32 regnum)
> > > {
> > > struct phy_package_shared *shared = phydev->shared;
> > > int addr = shared->base_addr + addr_offset;
> >
> > Isn't this problematic if shared is NULL?
>
> Duh! Yes, it is. But why should shared be NULL? The driver is doing a
> read on the package before the package is created. That is a bug. So
> an Opps is O.K, it helps find the bug. So i would drop the test for
> !shared.

Well yes I think we should assume those API to be called only in
config_once context or in package context. But is it Panic ok? I would
at least use something like BUG() to give descriptive warning instead of
NULL pointer exception. What do you think?

--
Ansuel