From: Christian Marangi <ansuelsmth@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-arm-msm@vger.kernel.org
Subject: Re: [net-next PATCH 06/14] net: phy: at803x: move at8031 specific data out of generic at803x_priv
Date: Thu, 30 Nov 2023 21:24:05 +0100 [thread overview]
Message-ID: <6568ef67.050a0220.398ae.be77@mx.google.com> (raw)
In-Reply-To: <568f8b22-a7d2-46c3-a539-30ecf6a85b18@lunn.ch>
On Thu, Nov 30, 2023 at 09:14:00PM +0100, Andrew Lunn wrote:
> On Thu, Nov 30, 2023 at 08:38:17PM +0100, Christian Marangi wrote:
> > On Thu, Nov 30, 2023 at 04:21:50PM +0100, Andrew Lunn wrote:
> > > > +struct at8031_data {
> > > > + bool is_fiber;
> > > > + bool is_1000basex;
> > > > + struct regulator_dev *vddio_rdev;
> > > > + struct regulator_dev *vddh_rdev;
> > > > +};
> > > > +
> > > > struct at803x_priv {
> > > > int flags;
> > > > u16 clk_25m_reg;
> > > > u16 clk_25m_mask;
> > > > u8 smarteee_lpi_tw_1g;
> > > > u8 smarteee_lpi_tw_100m;
> > > > - bool is_fiber;
> > > > - bool is_1000basex;
> > > > - struct regulator_dev *vddio_rdev;
> > > > - struct regulator_dev *vddh_rdev;
> > > > +
> > > > + /* Specific data for at8031 PHYs */
> > > > + void *data;
> > > > };
> > >
> > > I don't really like this void *
> > >
> > > Go through at803x_priv and find out what is common to them all, and
> > > keep that in one structure. Add per family private structures which
> > > include the common as a member.
> >
> > As you notice later in the patches, only at803x have stuff in common
> > qca803xx and qca808x doesn't use the struct at all (aside from stats)
>
> The dangers here are taking a phydev->priv and casting it. You think
> it is X, but is actually Y, and bad things happen.
>
> The helpers you have in your common.c must never do this. You can have
> a at803x_priv only visible inside the at803x driver, and a
> qca808x_priv only visible inside the qca808x driver. Define a
> structure which is needed for the shared code in common.c, and pass it
> as a parameter to these helpers.
Tell me if the idea is crazy enough. Ideally common function should do
simple phy read/write and should not reference stuff using priv (as we
would have the problem you are pointing out)
But phy_read/write needs phydev...
Would be ok to have something like
struct qca_ethphy_common {
struct phy_device *phydev;
}
And pass this struct to the helper? Is it enough to desist devs from
starting introducing function in common.c, checking the ID there and
starting doing stuff with funny specific phydev priv?
>
> You have a reasonably good idea what your end goal is. The tricky part
> is getting there, in lots of easy to review, obviously correct steps.
>
--
Ansuel
next prev parent reply other threads:[~2023-11-30 20:24 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 2:12 [net-next PATCH 00/14] net: phy: at803x: cleanup + split Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 01/14] net: phy: at803x: fix passing the wrong reference for config_intr Christian Marangi
2023-11-30 14:50 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 02/14] net: phy: at803x: move disable WOL for 8031 from probe to config Christian Marangi
2023-11-29 9:24 ` Russell King (Oracle)
2023-11-29 9:36 ` Christian Marangi
2023-11-29 10:45 ` Russell King (Oracle)
2023-11-29 11:03 ` Christian Marangi
2023-11-29 11:09 ` Russell King (Oracle)
2023-11-30 14:58 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 03/14] net: phy: at803x: raname hw_stats functions to qca83xx specific name Christian Marangi
2023-11-30 14:59 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 04/14] net: phy: at803x: move qca83xx stats out of generic at803x_priv struct Christian Marangi
2023-11-29 9:29 ` Russell King (Oracle)
2023-11-29 9:38 ` Christian Marangi
2023-11-30 15:09 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 05/14] net: phy: at803x: move qca83xx specific check in dedicated functions Christian Marangi
2023-11-30 15:14 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 06/14] net: phy: at803x: move at8031 specific data out of generic at803x_priv Christian Marangi
2023-11-29 9:35 ` Russell King (Oracle)
2023-11-29 11:08 ` Christian Marangi
2023-11-29 11:31 ` Russell King (Oracle)
2023-11-30 15:21 ` Andrew Lunn
2023-11-30 19:38 ` Christian Marangi
2023-11-30 20:14 ` Andrew Lunn
2023-11-30 20:24 ` Christian Marangi [this message]
2023-11-29 2:12 ` [net-next PATCH 07/14] net: phy: at803x: move at8035 specific DT parse to dedicated probe Christian Marangi
2023-11-30 15:29 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 08/14] net: phy: at803x: drop specific PHY id check from cable test functions Christian Marangi
2023-11-29 9:38 ` Russell King (Oracle)
2023-11-29 9:47 ` Christian Marangi
2023-11-29 10:57 ` Russell King (Oracle)
2023-11-29 11:04 ` Christian Marangi
2023-11-29 11:07 ` Russell King (Oracle)
2023-11-29 2:12 ` [net-next PATCH 09/14] net: phy: at803x: remove specific qca808x check from at803x functions Christian Marangi
2023-11-29 9:43 ` Russell King (Oracle)
2023-11-29 9:49 ` Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 10/14] net: phy: at803x: drop usless probe for qca8081 PHY Christian Marangi
2023-11-29 9:44 ` Russell King (Oracle)
2023-11-29 9:51 ` Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 11/14] net: phy: at803x: make specific status mask more generic Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 12/14] net: phy: move at803x PHY driver to dedicated directory Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 13/14] net: phy: qcom: deatch qca83xx PHY driver from at803x Christian Marangi
2023-11-29 9:53 ` Russell King (Oracle)
2023-11-29 10:37 ` Christian Marangi
2023-11-29 11:20 ` Russell King (Oracle)
2023-11-29 11:21 ` Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 14/14] net: phy: qcom: detach qca808x " Christian Marangi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6568ef67.050a0220.398ae.be77@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=konrad.dybcio@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox