Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <mordan@ispras.ru>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vitalii Mordan and committed by
Jakub Kicinski
cc84d89a e867ed3a

+27 -24
+27 -24
drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
··· 97 97 dwmac->dev = &pdev->dev; 98 98 dwmac->tx_clk = NULL; 99 99 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 + */ 100 105 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; 106 + if (dwmac->data->fix_mac_speed) 107 + plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed; 104 108 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); 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); 110 114 111 - ret = clk_prepare_enable(dwmac->tx_clk); 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 + } 121 + 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); 112 128 if (ret) { 113 129 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; 129 132 } 130 133 } 131 134