Re: [PATCH net] net: pse-pd: pd692x0: Fix power limit retrieval

From: Jakub Kicinski
Date: Tue Feb 18 2025 - 21:33:16 EST


On Mon, 17 Feb 2025 17:15:00 +0100 Kory Maincent wrote:
> > > - return pd692x0_pi_get_pw_from_table(buf.data[2], buf.data[3]);
> > > + return pd692x0_pi_get_pw_from_table(buf.data[0], buf.data[1]);
> >
> > Would the issue of been more obvious if some #defines were used,
> > rather than magic numbers?
>
> We would need lots of defines as the offset of the useful data can
> change between each command. Don't know if it would have been better.
>
> On my current patch priority series.
> git grep "buf\." drivers/net/pse-pd/pd692x0.c | wc -l
> 29

I guess it'd take a bigger rewrite, so I'll apply.
But I fully agree with Andrew that the current coding is very error
prone :( If you ever need to add more message you should start from
refactoring this code..