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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-stmmac-dwc-qos-clean-up-clock-initialisation'

Russell King says:

====================
net: stmmac: dwc-qos: clean up clock initialisation

My single v1 patch has become two patches as a result of the build
error, as it appears this code uses "data" differently from others.
v2 still produced build warnings despite local builds being clean,
so v3 addresses those.

The first patch brings some consistency with other drivers, naming
local variables that refer to struct plat_stmmacenet_data as
"plat_dat", as is used elsewhere in this driver.
====================

Link: https://patch.msgid.link/Z7yj_BZa6yG02KcI@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+29 -24
+29 -24
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
··· 35 35 struct gpio_desc *reset; 36 36 }; 37 37 38 + static struct clk *dwc_eth_find_clk(struct plat_stmmacenet_data *plat_dat, 39 + const char *name) 40 + { 41 + for (int i = 0; i < plat_dat->num_clks; i++) 42 + if (strcmp(plat_dat->clks[i].id, name) == 0) 43 + return plat_dat->clks[i].clk; 44 + 45 + return NULL; 46 + } 47 + 38 48 static int dwc_eth_dwmac_config_dt(struct platform_device *pdev, 39 49 struct plat_stmmacenet_data *plat_dat) 40 50 { ··· 131 121 struct plat_stmmacenet_data *plat_dat, 132 122 struct stmmac_resources *stmmac_res) 133 123 { 134 - for (int i = 0; i < plat_dat->num_clks; i++) { 135 - if (strcmp(plat_dat->clks[i].id, "apb_pclk") == 0) 136 - plat_dat->stmmac_clk = plat_dat->clks[i].clk; 137 - else if (strcmp(plat_dat->clks[i].id, "phy_ref_clk") == 0) 138 - plat_dat->pclk = plat_dat->clks[i].clk; 139 - } 124 + plat_dat->pclk = dwc_eth_find_clk(plat_dat, "phy_ref_clk"); 140 125 141 126 return 0; 142 127 } ··· 229 224 } 230 225 231 226 static int tegra_eqos_probe(struct platform_device *pdev, 232 - struct plat_stmmacenet_data *data, 227 + struct plat_stmmacenet_data *plat_dat, 233 228 struct stmmac_resources *res) 234 229 { 235 230 struct device *dev = &pdev->dev; ··· 242 237 243 238 eqos->dev = &pdev->dev; 244 239 eqos->regs = res->addr; 240 + eqos->clk_slave = plat_dat->stmmac_clk; 245 241 246 242 if (!is_of_node(dev->fwnode)) 247 243 goto bypass_clk_reset_gpio; 248 244 249 - for (int i = 0; i < data->num_clks; i++) { 250 - if (strcmp(data->clks[i].id, "slave_bus") == 0) { 251 - eqos->clk_slave = data->clks[i].clk; 252 - data->stmmac_clk = eqos->clk_slave; 253 - } else if (strcmp(data->clks[i].id, "tx") == 0) { 254 - eqos->clk_tx = data->clks[i].clk; 255 - } 256 - } 245 + eqos->clk_tx = dwc_eth_find_clk(plat_dat, "tx"); 257 246 258 247 eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); 259 248 if (IS_ERR(eqos->reset)) { ··· 259 260 gpiod_set_value(eqos->reset, 0); 260 261 261 262 /* MDIO bus was already reset just above */ 262 - data->mdio_bus_data->needs_reset = false; 263 + plat_dat->mdio_bus_data->needs_reset = false; 263 264 264 265 eqos->rst = devm_reset_control_get(&pdev->dev, "eqos"); 265 266 if (IS_ERR(eqos->rst)) { ··· 280 281 usleep_range(2000, 4000); 281 282 282 283 bypass_clk_reset_gpio: 283 - data->fix_mac_speed = tegra_eqos_fix_speed; 284 - data->init = tegra_eqos_init; 285 - data->bsp_priv = eqos; 286 - data->flags |= STMMAC_FLAG_SPH_DISABLE; 284 + plat_dat->fix_mac_speed = tegra_eqos_fix_speed; 285 + plat_dat->init = tegra_eqos_init; 286 + plat_dat->bsp_priv = eqos; 287 + plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE; 287 288 288 289 err = tegra_eqos_init(pdev, eqos); 289 290 if (err < 0) ··· 308 309 309 310 struct dwc_eth_dwmac_data { 310 311 int (*probe)(struct platform_device *pdev, 311 - struct plat_stmmacenet_data *data, 312 + struct plat_stmmacenet_data *plat_dat, 312 313 struct stmmac_resources *res); 313 314 void (*remove)(struct platform_device *pdev); 315 + const char *stmmac_clk_name; 314 316 }; 315 317 316 318 static const struct dwc_eth_dwmac_data dwc_qos_data = { 317 319 .probe = dwc_qos_probe, 320 + .stmmac_clk_name = "apb_pclk", 318 321 }; 319 322 320 323 static const struct dwc_eth_dwmac_data tegra_eqos_data = { 321 324 .probe = tegra_eqos_probe, 322 325 .remove = tegra_eqos_remove, 326 + .stmmac_clk_name = "slave_bus", 323 327 }; 324 328 325 329 static int dwc_eth_dwmac_probe(struct platform_device *pdev) ··· 362 360 if (ret) 363 361 return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n"); 364 362 363 + plat_dat->stmmac_clk = dwc_eth_find_clk(plat_dat, 364 + data->stmmac_clk_name); 365 + 365 366 ret = data->probe(pdev, plat_dat, &stmmac_res); 366 367 if (ret < 0) { 367 368 dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n"); ··· 392 387 static void dwc_eth_dwmac_remove(struct platform_device *pdev) 393 388 { 394 389 const struct dwc_eth_dwmac_data *data = device_get_match_data(&pdev->dev); 395 - struct plat_stmmacenet_data *plat_data = dev_get_platdata(&pdev->dev); 390 + struct plat_stmmacenet_data *plat_dat = dev_get_platdata(&pdev->dev); 396 391 397 392 stmmac_dvr_remove(&pdev->dev); 398 393 399 394 if (data->remove) 400 395 data->remove(pdev); 401 396 402 - if (plat_data) 403 - clk_bulk_disable_unprepare(plat_data->num_clks, plat_data->clks); 397 + if (plat_dat) 398 + clk_bulk_disable_unprepare(plat_dat->num_clks, plat_dat->clks); 404 399 } 405 400 406 401 static const struct of_device_id dwc_eth_dwmac_match[] = {