Fix initialization failure when phy_mdio_port is 0 #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue I reproduced with my TRENDnet TEG-10GECTX v2.0R and the driver from branch
release/linux-6.7.y-1running on Linux 6.8.This card has Device ID 4027, Subsystem Device ID 3015.
With my card; the
forloop inbdx_mdio_scan_phy_idcompletes on the very first iteration, which means the resulting value ofiis0, which is then assigned topriv->phy_mdio_port.When the port is set to 0, the if condition
!priv->phy_mdio_portis true inbdx_phy_init, which results in an immediate return and failed detection of the PHY.If I understand correctly, there may be up to 32 MDIO ports, but these are represented as values 0 to 31 in
phy_mdio_port. Thus0is a valid port and should not result in a failure.I changed the if condition in question to use the return value of
bdx_mdio_scan_phy_idinstead. This value is0when the for loop has completed 32 iterations without finding a PHY.I also found that the call to
priv->phy_ops.mdio_reseton line 463 was hard-coded to use a port number of1rather than the detected port number stored inphy_mdio_port. Adjusted the same.The driver initialization completes successfully with these changes in my own testing.