Skip to content

Commit a5ea265

Browse files
committed
Merge branch 'stmmac-devvm_stmmac_probe_config_dt-conversion'
Jisheng Zhang says: ==================== stmmac: convert to devm_stmmac_probe_config_dt Russell pointed out there's a new devm_stmmac_probe_config_dt() helper now when reviewing my starfive gmac error handling patch[1]. After greping the code, this nice helper was introduced by Bartosz in [2], I think it's time to convert all dwmac users to this helper and finally complete the TODO in [2] "but once all users of the old stmmac_pltfr_remove() are converted to the devres helper, it will be renamed back to stmmac_pltfr_remove() and the no_dt function removed." Link: https://lore.kernel.org/netdev/ZOtWmedBsa6wQQ6+@shell.armlinux.org.uk/ [1] Link: https://lore.kernel.org/all/20230623100417.93592-1-brgl@bgdev.pl/ [2] Since v1: - rebase on new net-next - add make stmmac_{probe|remove}_config_dt static as suggested by Russell. ==================== Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents e8535bf + b2504f6 commit a5ea265

22 files changed

Lines changed: 127 additions & 317 deletions

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int anarion_dwmac_probe(struct platform_device *pdev)
115115
if (IS_ERR(gmac))
116116
return PTR_ERR(gmac);
117117

118-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
118+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
119119
if (IS_ERR(plat_dat))
120120
return PTR_ERR(plat_dat);
121121

@@ -124,13 +124,7 @@ static int anarion_dwmac_probe(struct platform_device *pdev)
124124
anarion_gmac_init(pdev, gmac);
125125
plat_dat->bsp_priv = gmac;
126126

127-
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
128-
if (ret) {
129-
stmmac_remove_config_dt(pdev, plat_dat);
130-
return ret;
131-
}
132-
133-
return 0;
127+
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
134128
}
135129

136130
static const struct of_device_id anarion_dwmac_match[] = {

drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,14 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
435435
if (IS_ERR(stmmac_res.addr))
436436
return PTR_ERR(stmmac_res.addr);
437437

438-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
438+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
439439
if (IS_ERR(plat_dat))
440440
return PTR_ERR(plat_dat);
441441

442442
ret = data->probe(pdev, plat_dat, &stmmac_res);
443443
if (ret < 0) {
444444
dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");
445-
446-
goto remove_config;
445+
return ret;
447446
}
448447

449448
ret = dwc_eth_dwmac_config_dt(pdev, plat_dat);
@@ -458,25 +457,17 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
458457

459458
remove:
460459
data->remove(pdev);
461-
remove_config:
462-
stmmac_remove_config_dt(pdev, plat_dat);
463460

464461
return ret;
465462
}
466463

467464
static void dwc_eth_dwmac_remove(struct platform_device *pdev)
468465
{
469-
struct net_device *ndev = platform_get_drvdata(pdev);
470-
struct stmmac_priv *priv = netdev_priv(ndev);
471-
const struct dwc_eth_dwmac_data *data;
472-
473-
data = device_get_match_data(&pdev->dev);
466+
const struct dwc_eth_dwmac_data *data = device_get_match_data(&pdev->dev);
474467

475468
stmmac_dvr_remove(&pdev->dev);
476469

477470
data->remove(pdev);
478-
479-
stmmac_remove_config_dt(pdev, priv->plat);
480471
}
481472

482473
static const struct of_device_id dwc_eth_dwmac_match[] = {

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int dwmac_generic_probe(struct platform_device *pdev)
2727
return ret;
2828

2929
if (pdev->dev.of_node) {
30-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
30+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
3131
if (IS_ERR(plat_dat)) {
3232
dev_err(&pdev->dev, "dt configuration failed\n");
3333
return PTR_ERR(plat_dat);
@@ -46,17 +46,7 @@ static int dwmac_generic_probe(struct platform_device *pdev)
4646
plat_dat->unicast_filter_entries = 1;
4747
}
4848

49-
ret = stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
50-
if (ret)
51-
goto err_remove_config_dt;
52-
53-
return 0;
54-
55-
err_remove_config_dt:
56-
if (pdev->dev.of_node)
57-
stmmac_remove_config_dt(pdev, plat_dat);
58-
59-
return ret;
49+
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
6050
}
6151

6252
static const struct of_device_id dwmac_generic_match[] = {
@@ -77,7 +67,6 @@ MODULE_DEVICE_TABLE(of, dwmac_generic_match);
7767

7868
static struct platform_driver dwmac_generic_driver = {
7969
.probe = dwmac_generic_probe,
80-
.remove_new = stmmac_pltfr_remove,
8170
.driver = {
8271
.name = STMMAC_RESOURCE_NAME,
8372
.pm = &stmmac_pltfr_pm_ops,

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,14 @@ static int imx_dwmac_probe(struct platform_device *pdev)
331331
if (!dwmac)
332332
return -ENOMEM;
333333

334-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
334+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
335335
if (IS_ERR(plat_dat))
336336
return PTR_ERR(plat_dat);
337337

338338
data = of_device_get_match_data(&pdev->dev);
339339
if (!data) {
340340
dev_err(&pdev->dev, "failed to get match data\n");
341-
ret = -EINVAL;
342-
goto err_match_data;
341+
return -EINVAL;
343342
}
344343

345344
dwmac->ops = data;
@@ -348,7 +347,7 @@ static int imx_dwmac_probe(struct platform_device *pdev)
348347
ret = imx_dwmac_parse_dt(dwmac, &pdev->dev);
349348
if (ret) {
350349
dev_err(&pdev->dev, "failed to parse OF data\n");
351-
goto err_parse_dt;
350+
return ret;
352351
}
353352

354353
if (data->flags & STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY)
@@ -365,7 +364,7 @@ static int imx_dwmac_probe(struct platform_device *pdev)
365364

366365
ret = imx_dwmac_clks_config(dwmac, true);
367366
if (ret)
368-
goto err_clks_config;
367+
return ret;
369368

370369
ret = imx_dwmac_init(pdev, dwmac);
371370
if (ret)
@@ -385,10 +384,6 @@ static int imx_dwmac_probe(struct platform_device *pdev)
385384
imx_dwmac_exit(pdev, plat_dat->bsp_priv);
386385
err_dwmac_init:
387386
imx_dwmac_clks_config(dwmac, false);
388-
err_clks_config:
389-
err_parse_dt:
390-
err_match_data:
391-
stmmac_remove_config_dt(pdev, plat_dat);
392387
return ret;
393388
}
394389

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

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -241,29 +241,25 @@ static int ingenic_mac_probe(struct platform_device *pdev)
241241
if (ret)
242242
return ret;
243243

244-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
244+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
245245
if (IS_ERR(plat_dat))
246246
return PTR_ERR(plat_dat);
247247

248248
mac = devm_kzalloc(&pdev->dev, sizeof(*mac), GFP_KERNEL);
249-
if (!mac) {
250-
ret = -ENOMEM;
251-
goto err_remove_config_dt;
252-
}
249+
if (!mac)
250+
return -ENOMEM;
253251

254252
data = of_device_get_match_data(&pdev->dev);
255253
if (!data) {
256254
dev_err(&pdev->dev, "No of match data provided\n");
257-
ret = -EINVAL;
258-
goto err_remove_config_dt;
255+
return -EINVAL;
259256
}
260257

261258
/* Get MAC PHY control register */
262259
mac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "mode-reg");
263260
if (IS_ERR(mac->regmap)) {
264261
dev_err(&pdev->dev, "%s: Failed to get syscon regmap\n", __func__);
265-
ret = PTR_ERR(mac->regmap);
266-
goto err_remove_config_dt;
262+
return PTR_ERR(mac->regmap);
267263
}
268264

269265
if (!of_property_read_u32(pdev->dev.of_node, "tx-clk-delay-ps", &tx_delay_ps)) {
@@ -272,8 +268,7 @@ static int ingenic_mac_probe(struct platform_device *pdev)
272268
mac->tx_delay = tx_delay_ps * 1000;
273269
} else {
274270
dev_err(&pdev->dev, "Invalid TX clock delay: %dps\n", tx_delay_ps);
275-
ret = -EINVAL;
276-
goto err_remove_config_dt;
271+
return -EINVAL;
277272
}
278273
}
279274

@@ -283,8 +278,7 @@ static int ingenic_mac_probe(struct platform_device *pdev)
283278
mac->rx_delay = rx_delay_ps * 1000;
284279
} else {
285280
dev_err(&pdev->dev, "Invalid RX clock delay: %dps\n", rx_delay_ps);
286-
ret = -EINVAL;
287-
goto err_remove_config_dt;
281+
return -EINVAL;
288282
}
289283
}
290284

@@ -295,18 +289,9 @@ static int ingenic_mac_probe(struct platform_device *pdev)
295289

296290
ret = ingenic_mac_init(plat_dat);
297291
if (ret)
298-
goto err_remove_config_dt;
299-
300-
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
301-
if (ret)
302-
goto err_remove_config_dt;
303-
304-
return 0;
305-
306-
err_remove_config_dt:
307-
stmmac_remove_config_dt(pdev, plat_dat);
292+
return ret;
308293

309-
return ret;
294+
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
310295
}
311296

312297
#ifdef CONFIG_PM_SLEEP

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,15 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
8585
if (ret)
8686
return ret;
8787

88-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
88+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
8989
if (IS_ERR(plat_dat)) {
9090
dev_err(&pdev->dev, "dt configuration failed\n");
9191
return PTR_ERR(plat_dat);
9292
}
9393

9494
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
95-
if (!dwmac) {
96-
ret = -ENOMEM;
97-
goto err_remove_config_dt;
98-
}
95+
if (!dwmac)
96+
return -ENOMEM;
9997

10098
dwmac->dev = &pdev->dev;
10199
dwmac->tx_clk = NULL;
@@ -110,10 +108,8 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
110108
/* Enable TX clock */
111109
if (dwmac->data->tx_clk_en) {
112110
dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
113-
if (IS_ERR(dwmac->tx_clk)) {
114-
ret = PTR_ERR(dwmac->tx_clk);
115-
goto err_remove_config_dt;
116-
}
111+
if (IS_ERR(dwmac->tx_clk))
112+
return PTR_ERR(dwmac->tx_clk);
117113

118114
clk_prepare_enable(dwmac->tx_clk);
119115

@@ -126,7 +122,7 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
126122
if (ret) {
127123
dev_err(&pdev->dev,
128124
"Failed to set tx_clk\n");
129-
goto err_remove_config_dt;
125+
return ret;
130126
}
131127
}
132128
}
@@ -140,7 +136,7 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
140136
if (ret) {
141137
dev_err(&pdev->dev,
142138
"Failed to set clk_ptp_ref\n");
143-
goto err_remove_config_dt;
139+
return ret;
144140
}
145141
}
146142
}
@@ -158,15 +154,10 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
158154
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
159155
if (ret) {
160156
clk_disable_unprepare(dwmac->tx_clk);
161-
goto err_remove_config_dt;
157+
return ret;
162158
}
163159

164160
return 0;
165-
166-
err_remove_config_dt:
167-
stmmac_remove_config_dt(pdev, plat_dat);
168-
169-
return ret;
170161
}
171162

172163
static void intel_eth_plat_remove(struct platform_device *pdev)

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

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -384,22 +384,20 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
384384
if (val)
385385
return val;
386386

387-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
387+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
388388
if (IS_ERR(plat_dat))
389389
return PTR_ERR(plat_dat);
390390

391391
gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
392-
if (!gmac) {
393-
err = -ENOMEM;
394-
goto err_remove_config_dt;
395-
}
392+
if (!gmac)
393+
return -ENOMEM;
396394

397395
gmac->pdev = pdev;
398396

399397
err = ipq806x_gmac_of_parse(gmac);
400398
if (err) {
401399
dev_err(dev, "device tree parsing error\n");
402-
goto err_remove_config_dt;
400+
return err;
403401
}
404402

405403
regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL,
@@ -459,11 +457,11 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
459457
if (gmac->phy_mode == PHY_INTERFACE_MODE_SGMII) {
460458
err = ipq806x_gmac_configure_qsgmii_params(gmac);
461459
if (err)
462-
goto err_remove_config_dt;
460+
return err;
463461

464462
err = ipq806x_gmac_configure_qsgmii_pcs_speed(gmac);
465463
if (err)
466-
goto err_remove_config_dt;
464+
return err;
467465
}
468466

469467
plat_dat->has_gmac = true;
@@ -473,21 +471,12 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
473471
plat_dat->tx_fifo_size = 8192;
474472
plat_dat->rx_fifo_size = 8192;
475473

476-
err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
477-
if (err)
478-
goto err_remove_config_dt;
479-
480-
return 0;
474+
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
481475

482476
err_unsupported_phy:
483477
dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
484478
phy_modes(gmac->phy_mode));
485-
err = -EINVAL;
486-
487-
err_remove_config_dt:
488-
stmmac_remove_config_dt(pdev, plat_dat);
489-
490-
return err;
479+
return -EINVAL;
491480
}
492481

493482
static const struct of_device_id ipq806x_gmac_dwmac_match[] = {

0 commit comments

Comments
 (0)