mbox series

[0/2] net: phy: Make phy_interface_is_sgmii|rgmii a switch statement

Message ID 20230413180713.2922524-1-nm@ti.com
Headers show
Series net: phy: Make phy_interface_is_sgmii|rgmii a switch statement | expand

Message

Nishanth Menon April 13, 2023, 6:07 p.m. UTC
Originally reported by Tom[1], turned out to be that recent commit
75d28899e3e9 ("net: phy: Synchronize PHY interface modes with Linux")
reordered the enum definitions which in turn broke the range checks.

we are left with two options:
a) check against explicit values to help reuse as much as possible and
let compiler optimize where applicable
or
b) be very explicit in phy drivers and drop these helpers.

I have chosen to go with (a) approach.

Tested on am64x, though the dp83867 is used elsewhere as well.

Nishanth Menon (2):
  net: phy: Make phy_interface_is_sgmii a switch statement
  net: phy: Make phy_interface_is_rgmii a switch statement

 include/phy.h | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

Comments

Nishanth Menon April 13, 2023, 6:08 p.m. UTC | #1
On 13:07-20230413, Nishanth Menon wrote:
> Originally reported by Tom[1], turned out to be that recent commit
> 75d28899e3e9 ("net: phy: Synchronize PHY interface modes with Linux")
> reordered the enum definitions which in turn broke the range checks.
> 
> we are left with two options:
> a) check against explicit values to help reuse as much as possible and
> let compiler optimize where applicable
> or
> b) be very explicit in phy drivers and drop these helpers.
> 
> I have chosen to go with (a) approach.
> 
> Tested on am64x, though the dp83867 is used elsewhere as well.
> 
> Nishanth Menon (2):
>   net: phy: Make phy_interface_is_sgmii a switch statement
>   net: phy: Make phy_interface_is_rgmii a switch statement
> 
>  include/phy.h | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> -- 
> 2.40.0
> 
Oops.. forgot to provide the link of the report:

[1] https://libera.irclog.whitequark.org/u-boot/2023-04-07#34130437;