Re: [PATCH net v3] net: dsa: mt7530: fix impossible MDIO address and issue warning

From: Florian Fainelli
Date: Thu Jul 04 2024 - 10:47:16 EST




On 7/3/2024 12:44 AM, Daniel Golle wrote:
The MDIO address of the MT7530 and MT7531 switch ICs can be configured
using bootstrap pins. However, there are only 4 possible options for the
switch itself: 7, 15, 23 and 31. As in MediaTek's SDK the address of the
switch is wrongly stated in the device tree as 0 (while in reality it is
31), warn the user about such broken device tree and make a good guess
what was actually intended.

This is imporant also to not break compatibility with older Device Trees
as with commit 868ff5f4944a ("net: dsa: mt7530-mdio: read PHY address of
switch from device tree") the address in device tree will be taken into
account, while before it was hard-coded to 0x1f.

Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
Only tested on BPi-R3 (with various deliberately broken DT) for now!

This seems like a whole lot of code just to auto-magically fix an issue that could be caught with a warning. I appreciate that most of these devices might be headless, and therefore having some attempt at getting functional networking goes a long way into allowing users to correct their mistakes.
--
Florian