Re: [PATCH net-next 2/6] net: dsa: motorcomm: Rely on port isolation for CPU port

From: Andrew Lunn

Date: Wed Nov 04 2026 - 10:17:12 EST


On Wed, Nov 04, 2026 at 06:05:32PM +0800, David Yang wrote:
> On Wed, Nov 4, 2026 at 11:59 AM Andrew Lunn <andrew@xxxxxxx> wrote:
> >
> > > - ctrl = ~priv->cpu_ports_mask;
> > > - res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);
> > > - if (res)
> > > - return res;
> > > + if (!(BIT(port) & priv->cpu_ports_mask)) {
> >
> > if (!dsa_is_cpu_port(ds, port) ?
> >
>
> The next line is ctrl = ~priv->cpu_ports_mask, but could change both
> if you prefer.

The advantage of the dsa_is_cpu_port() is that is it very obvious what
it does. And anybody who has looked at any DSA driver knows these
functions and what they do. So maintenance is easier. The more you can
make the driver look like other DSA drivers, use the same constructs,
helpers, etc the better.

Andrew