Re: [RFC PATCH 1/2] net: include: mii: Refactor: Define LPA_* in terms of ADVERTISE_*

From: Csókás Bence
Date: Wed Jun 05 2024 - 09:51:31 EST


Hi!

On 6/5/24 14:51, Andrew Lunn wrote:
On Wed, Jun 05, 2024 at 02:16:47PM +0200, Csókás, Bence wrote:
Ethernet specification mandates that these bits will be equal.
To reduce the amount of magix hex'es in the code, just define
them in terms of each other.

Are magic hexes in this context actually bad?

Yes, as if it ever needs to be changed (for instance in the 2/2 of the series, when I replaced them with BIT() macros), it needs to be changed twice in the file.

In .c files i would
agree. But what you have in effect done is force me into jump another
hoop to find the actual hex value so i can manually decode a register
value.

True. I expected this concern, hence why I tagged this as RFC. However, I believe that from a maintainability perspective, it's best to only have one definition, and since these #define's are right under one another, the "jumping around" is minimal anyways.

And you have made the compile slightly slower.

C'mon, that's negligible. The time it takes to load the header file from disk will probably take longer than it does to resolve an extra layer of simple #define's.

These defines have been like this since the beginning of the git
history. Is there a good reason to change them after all that time?

Just because something was "always like this" doesn't mean that it cannot be changed. Especially since this patch is 100% backwards-compatible, just maybe slightly more future-proof.

Andrew


Bence