Messages in this thread | | | Date | Sat, 4 Feb 2023 18:13:42 +0100 | From | Andrew Lunn <> | Subject | Re: [PATCH 9/9] net: dsa: mt7530: use external PCS driver |
| |
> The SerDes PCS units are only available for port 5 and 6. The code > should make sure that the corresponding interface modes are only used > on these two ports, so a BUG_ON(!mt753x_is_mac_port(port)) would also > do the trick, I guess. However, as dsa_port_phylink_mac_select_pcs may > also return ERR_PTR(-EOPNOTSUPP), returning ERR_PTR(-EINVAL) felt like > the right thing to do in that case. > Are you suggesting to use BUG_ON() instead or rather return > ERR_PTR(-EOPNOTSUPP)?
BUG_ON() is considered to mean something which you cannot recover from has happened, and going further will only cause more file system corruption, memory corruption, etc. WARN_ON() is better, since it gives the user a chance to perform a controlled shutdown, so potentially not loosing files etc.
But even a WARN_ON() seems a bit extreme. If -EINVAL is sufficient to cause either the whole device, or the port to fail to probe, that should be enough to get the DT developers attention. Then either a dev_err() or a dev_dbg() to help narrow down which check failed.
Andrew
| |