Skip to content

Commit 928d6fe

Browse files
ishikawa-yjrtdavem330
authored andcommitted
net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request.
Variable clk_sel_val is not initialized in the default case of the first switch statement. In that case, the function should return immediately without any changes to the hardware. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Fixes: b38dd98 ("net: stmmac: Add Toshiba Visconti SoCs glue driver") Signed-off-by: Yuji Ishikawa <[email protected]> Reviewed-by: Nobuhiro Iwamatsu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7674b7b commit 928d6fe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ struct visconti_eth {
4949
void __iomem *reg;
5050
u32 phy_intf_sel;
5151
struct clk *phy_ref_clk;
52+
struct device *dev;
5253
spinlock_t lock; /* lock to protect register update */
5354
};
5455

5556
static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed)
5657
{
5758
struct visconti_eth *dwmac = priv;
58-
unsigned int val, clk_sel_val;
59+
struct net_device *netdev = dev_get_drvdata(dwmac->dev);
60+
unsigned int val, clk_sel_val = 0;
5961
unsigned long flags;
6062

6163
spin_lock_irqsave(&dwmac->lock, flags);
@@ -85,7 +87,9 @@ static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed)
8587
break;
8688
default:
8789
/* No bit control */
88-
break;
90+
netdev_err(netdev, "Unsupported speed request (%d)", speed);
91+
spin_unlock_irqrestore(&dwmac->lock, flags);
92+
return;
8993
}
9094

9195
writel(val, dwmac->reg + MAC_CTRL_REG);
@@ -229,6 +233,7 @@ static int visconti_eth_dwmac_probe(struct platform_device *pdev)
229233

230234
spin_lock_init(&dwmac->lock);
231235
dwmac->reg = stmmac_res.addr;
236+
dwmac->dev = &pdev->dev;
232237
plat_dat->bsp_priv = dwmac;
233238
plat_dat->fix_mac_speed = visconti_eth_fix_mac_speed;
234239

0 commit comments

Comments
 (0)