[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <65d2682a.5d0a0220.3fef2.efe4@mx.google.com>
Date: Sun, 18 Feb 2024 21:27:22 +0100
From: Christian Marangi <ansuelsmth@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: "Russell King (Oracle)" <linux@...linux.org.uk>,
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>,
Florian Fainelli <florian.fainelli@...adcom.com>,
Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
Robert Marko <robimarko@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@....com>,
Nipun Gupta <nipun.gupta@....com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Puneet Gupta <puneet.gupta@....com>,
Abhijit Gangurde <abhijit.gangurde@....com>,
Umang Jain <umang.jain@...asonboard.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [net-next RFC PATCH 1/6] net: phy: add support for defining
multiple PHY IDs in PHY driver
On Sun, Feb 18, 2024 at 09:10:30PM +0100, Andrew Lunn wrote:
> > > > + phy_dev_id = (struct mdio_device_id *)&phydev->dev_id;
> > >
> > > Why this cast? Try to write code that doesn't need casts.
> > >
> >
> > This cast is needed to keep the dev_id const in the phy_device struct so
> > that other are warned to not modify it and should only be handled by
> > phy_probe since it's the one that fills it.
> >
> > Alternative is to drop const and drop the warning.
>
> Can you propagate the const. Make phy_dev_id point to a const?
>
Mhh not following, I tried changing to const struct mdio_device_id *phy_dev_id
but that results in memcpy complain (dest is void * not const) and
writing in read-only for the single PHY part (the else part)
An alternative might be to make dev_id a pointer in struct phy_device
and dynamically allocate a mdio_device_id for the case of single PHY
(else case). That effectively remove the need of this cast but I would
love to skip checking for -ENOMEM (this is why i made that local)
If it's OK to dynamically allocate for the else case then I will make
this change. I just tested this implementation and works correctly with
not warning.
--
Ansuel
Powered by blists - more mailing lists