From: Andrew Lunn <andrew@lunn.ch>
To: David Yang <mmyangfl@gmail.com>
Cc: netdev@vger.kernel.org, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC net-next 3/4] net: dsa: motorcomm: Dynamically allocate port structures
Date: Sat, 20 Jun 2026 10:03:52 +0200 [thread overview]
Message-ID: <fc82aaa6-ff6b-4d17-beb2-e6f156e64059@lunn.ch> (raw)
In-Reply-To: <CAAXyoMN9a6nncr-C1UDuUQMf4i5FR-9s-sfhSpYLYs5nmh9Uhg@mail.gmail.com>
On Fri, Jun 19, 2026 at 02:46:24PM +0800, David Yang wrote:
> On Fri, Jun 19, 2026 at 2:06 PM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > On Fri, Jun 19, 2026 at 04:26:31AM +0800, David Yang wrote:
> > > With support for LED introduced later, struct yt921x_priv will be 17k
> > > which is not very good for a single kmalloc(). Convert the ports array
> > > to a array of pointers to stop bloating the priv struct.
> > >
> > > Signed-off-by: David Yang <mmyangfl@gmail.com>
> > > ---
> > > drivers/net/dsa/motorcomm/chip.c | 95 ++++++++++++++++++++++++--------
> > > drivers/net/dsa/motorcomm/chip.h | 3 +-
> > > 2 files changed, 75 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> > > index 6dee25b6754a..d44f7749de02 100644
> > > --- a/drivers/net/dsa/motorcomm/chip.c
> > > +++ b/drivers/net/dsa/motorcomm/chip.c
> > > @@ -548,11 +548,14 @@ yt921x_mbus_ext_init(struct yt921x_priv *priv, struct device_node *mnp)
> > > /* Read and handle overflow of 32bit MIBs. MIB buffer must be zeroed before. */
> > > static int yt921x_read_mib(struct yt921x_priv *priv, int port)
> > > {
> > > - struct yt921x_port *pp = &priv->ports[port];
> > > + struct yt921x_port *pp = priv->ports[port];
> > > struct device *dev = to_device(priv);
> > > struct yt921x_mib *mib = &pp->mib;
> > > int res = 0;
> > >
> > > + if (!pp)
> > > + return -ENODEV;
> > > +
> >
> > Are all these tests actually needed? If you cannot allocate the
> > memory, i would expect the probe to fail, so you can never get here.
> >
> > Andrew
>
> Dummy ports are no longer assigned control blocks (in yt921x_dsa_setup).
This seems pretty error prone. A missing check will result in an
opps. At least it will be obvious. How big is each port structure? Is
the memory saving worth it?
Andrew
next prev parent reply other threads:[~2026-06-20 8:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 20:26 [RFC net-next 0/4] net: dsa: motorcomm: Add LED support David Yang
2026-06-18 20:26 ` [RFC net-next 1/4] net: dsa: motorcomm: Move to subdirectory David Yang
2026-06-18 20:26 ` [RFC net-next 2/4] net: dsa: motorcomm: Split SMI module David Yang
2026-06-18 20:26 ` [RFC net-next 3/4] net: dsa: motorcomm: Dynamically allocate port structures David Yang
2026-06-19 6:06 ` Andrew Lunn
2026-06-19 6:46 ` David Yang
2026-06-20 8:03 ` Andrew Lunn [this message]
2026-06-20 16:13 ` David Yang
2026-06-21 9:06 ` Andrew Lunn
2026-06-18 20:26 ` [RFC net-next 4/4] net: dsa: motorcomm: Add LED support David Yang
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=fc82aaa6-ff6b-4d17-beb2-e6f156e64059@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmyangfl@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--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