190-1-5-e1000e-Fix-error-path-in-link-detection.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From patchwork Fri Jul 21 18:36:23 2017
  2. Content-Type: text/plain; charset="utf-8"
  3. MIME-Version: 1.0
  4. Content-Transfer-Encoding: 7bit
  5. Subject: [1/5] e1000e: Fix error path in link detection
  6. From: Benjamin Poirier <[email protected]>
  7. X-Patchwork-Id: 9857487
  8. Message-Id: <[email protected]>
  9. To: Jeff Kirsher <[email protected]>
  10. Cc: Lennart Sorensen <[email protected]>,
  11. [email protected], [email protected],
  12. [email protected]
  13. Date: Fri, 21 Jul 2017 11:36:23 -0700
  14. In case of error from e1e_rphy(), the loop will exit early and "success"
  15. will be set to true erroneously.
  16. Signed-off-by: Benjamin Poirier <[email protected]>
  17. ---
  18. drivers/net/ethernet/intel/e1000e/phy.c | 7 ++++---
  19. 1 file changed, 4 insertions(+), 3 deletions(-)
  20. --- a/drivers/net/ethernet/intel/e1000e/phy.c
  21. +++ b/drivers/net/ethernet/intel/e1000e/phy.c
  22. @@ -1744,6 +1744,7 @@ s32 e1000e_phy_has_link_generic(struct e
  23. s32 ret_val = 0;
  24. u16 i, phy_status;
  25. + *success = false;
  26. for (i = 0; i < iterations; i++) {
  27. /* Some PHYs require the MII_BMSR register to be read
  28. * twice due to the link bit being sticky. No harm doing
  29. @@ -1763,16 +1764,16 @@ s32 e1000e_phy_has_link_generic(struct e
  30. ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
  31. if (ret_val)
  32. break;
  33. - if (phy_status & BMSR_LSTATUS)
  34. + if (phy_status & BMSR_LSTATUS) {
  35. + *success = true;
  36. break;
  37. + }
  38. if (usec_interval >= 1000)
  39. msleep(usec_interval / 1000);
  40. else
  41. udelay(usec_interval);
  42. }
  43. - *success = (i < iterations);
  44. -
  45. return ret_val;
  46. }