Microchip-Ethernet / EVB-KSZ9477

Repository for using Microchip EVB-KSZ9477 board. Product Supported: KSZ9477, KSZ9567, KSZ9897, KSZ9896, KSZ8567, KSZ8565, KSZ9893, KSZ9563, KSZ8563, LAN9646, Phys(KSZ9031/9131, LAN8770
76 stars 78 forks source link

static inline int of_get_phy_mode() is called with one too many argument #78

Open romatou18 opened 3 years ago

romatou18 commented 3 years ago

Hi, While patching an imx8 Zeus yocto Kernel v5.4.7, found that in fec_main.c in kernel/drivers/net/ethernet/freescale The following function has 2 arguments being passed instead of one: static inline int of_get_phy_mode()

fec_main.c call: https://github.com/Microchip-Ethernet/EVB-KSZ9477/blob/c9adfa73042758d643a2e26fc3f29b994d5c9b97/KSZ/linux-drivers/ksz9897/linux-5.4/drivers/net/ethernet/freescale/fec_main.c#L4875

Function definition in kernel 5.4.7: https://elixir.bootlin.com/linux/v5.4.70/source/include/linux/of_net.h#L13

I just fixed this by removing the extra argument, however this just shows that the v5.4 ksz9897 patch or the imx 5.4 patch (identical in this repo), are probably out of sync with kernel source v5.4.x.

Kind Regards

Romain Firmware Engineer

voodoo84 commented 3 years ago

In this specific case, older version of of_get_phy_mode() returned both error code (as negative value) or interface index (as positive value), while the new version returns strictly error code, and writes interface index into &interface address. So change it to:

interface = of_get_phy_mode(np); if (-ENODEV == interface) ... /* not found */

But obviously this patch is not based on mainline 5.4 so there are several occurrences of incompatibility which should be resolved manually.