Skip to content

Commit

Permalink
Merge branch 'fixes-for-yt8511-phy-driver'
Browse files Browse the repository at this point in the history
Peter Geis says:

====================
fixes for yt8511 phy driver

The Intel clang bot caught a few uninitialized variables in the new
Motorcomm driver. While investigating the issue, it was found that the
driver would have unintended effects when used in an unsupported mode.

Fixed the uninitialized ret variable and abort loading the driver in
unsupported modes.
====================

Link: https://lore.kernel.org/r/20210529110556.202531-1-pgwipeout@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed May 30, 2021
2 parents 8b97f36 + 0cc8bdd commit a729b8e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/net/phy/motorcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,13 @@ static int yt8511_write_page(struct phy_device *phydev, int page)

static int yt8511_config_init(struct phy_device *phydev)
{
int oldpage, ret = 0;
unsigned int ge, fe;
int ret, oldpage;

/* set clock mode to 125mhz */
oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE);
if (oldpage < 0)
goto err_restore_page;

ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M);
if (ret < 0)
goto err_restore_page;

/* set rgmii delay mode */
switch (phydev->interface) {
case PHY_INTERFACE_MODE_RGMII:
Expand All @@ -80,14 +75,20 @@ static int yt8511_config_init(struct phy_device *phydev)
ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN;
fe = YT8511_DELAY_FE_TX_EN;
break;
default: /* leave everything alone in other modes */
break;
default: /* do not support other modes */
ret = -EOPNOTSUPP;
goto err_restore_page;
}

ret = __phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
if (ret < 0)
goto err_restore_page;

/* set clock mode to 125mhz */
ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M);
if (ret < 0)
goto err_restore_page;

/* fast ethernet delay is in a separate page */
ret = __phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE);
if (ret < 0)
Expand Down

0 comments on commit a729b8e

Please sign in to comment.