Skip to content

Commit cc84d89

Browse files
vmordankuba-moo
authored andcommitted
stmmac: dwmac-intel-plat: remove redundant dwmac->data check in probe
The driver’s compatibility with devices is confirmed earlier in platform_match(). Since reaching probe means the device is valid, the extra check can be removed to simplify the code. Signed-off-by: Vitalii Mordan <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e867ed3 commit cc84d89

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,35 +97,38 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
9797
dwmac->dev = &pdev->dev;
9898
dwmac->tx_clk = NULL;
9999

100+
/*
101+
* This cannot return NULL at this point because the driver’s
102+
* compatibility with the device has already been validated in
103+
* platform_match().
104+
*/
100105
dwmac->data = device_get_match_data(&pdev->dev);
101-
if (dwmac->data) {
102-
if (dwmac->data->fix_mac_speed)
103-
plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed;
104-
105-
/* Enable TX clock */
106-
if (dwmac->data->tx_clk_en) {
107-
dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
108-
if (IS_ERR(dwmac->tx_clk))
109-
return PTR_ERR(dwmac->tx_clk);
106+
if (dwmac->data->fix_mac_speed)
107+
plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed;
108+
109+
/* Enable TX clock */
110+
if (dwmac->data->tx_clk_en) {
111+
dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
112+
if (IS_ERR(dwmac->tx_clk))
113+
return PTR_ERR(dwmac->tx_clk);
114+
115+
ret = clk_prepare_enable(dwmac->tx_clk);
116+
if (ret) {
117+
dev_err(&pdev->dev,
118+
"Failed to enable tx_clk\n");
119+
return ret;
120+
}
110121

111-
ret = clk_prepare_enable(dwmac->tx_clk);
122+
/* Check and configure TX clock rate */
123+
rate = clk_get_rate(dwmac->tx_clk);
124+
if (dwmac->data->tx_clk_rate &&
125+
rate != dwmac->data->tx_clk_rate) {
126+
rate = dwmac->data->tx_clk_rate;
127+
ret = clk_set_rate(dwmac->tx_clk, rate);
112128
if (ret) {
113129
dev_err(&pdev->dev,
114-
"Failed to enable tx_clk\n");
115-
return ret;
116-
}
117-
118-
/* Check and configure TX clock rate */
119-
rate = clk_get_rate(dwmac->tx_clk);
120-
if (dwmac->data->tx_clk_rate &&
121-
rate != dwmac->data->tx_clk_rate) {
122-
rate = dwmac->data->tx_clk_rate;
123-
ret = clk_set_rate(dwmac->tx_clk, rate);
124-
if (ret) {
125-
dev_err(&pdev->dev,
126-
"Failed to set tx_clk\n");
127-
goto err_tx_clk_disable;
128-
}
130+
"Failed to set tx_clk\n");
131+
goto err_tx_clk_disable;
129132
}
130133
}
131134

0 commit comments

Comments
 (0)