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-sti-cleanups'

Russell King says:

====================
net: stmmac: sti cleanups

Clean up the STI platform glue code.

- IS_PHY_IF_MODE_RGMII() is just a duplicate for
phy_interface_mode_is_rgmii(), so use the generic version that we
already have.

- add init/exit functions that call clk_prepare_enable(),
sti_dwmac_set_mode() and clk_disable_unprepare() as appropriate,
converting to devm_stmmac_pltfr_probe().

- the custom suspend/resume ops do basically what the generic ones
do with init/exit functions populated, but also add runtime and
noirq ops. Update STI to use the generic ops.
====================

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

+29 -59
+29 -59
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 23 23 24 24 #define DWMAC_50MHZ 50000000 25 25 26 - #define IS_PHY_IF_MODE_RGMII(iface) (iface == PHY_INTERFACE_MODE_RGMII || \ 27 - iface == PHY_INTERFACE_MODE_RGMII_ID || \ 28 - iface == PHY_INTERFACE_MODE_RGMII_RXID || \ 29 - iface == PHY_INTERFACE_MODE_RGMII_TXID) 30 - 31 - #define IS_PHY_IF_MODE_GBIT(iface) (IS_PHY_IF_MODE_RGMII(iface) || \ 26 + #define IS_PHY_IF_MODE_GBIT(iface) (phy_interface_mode_is_rgmii(iface) || \ 32 27 iface == PHY_INTERFACE_MODE_GMII) 33 28 34 29 /* STiH4xx register definitions (STiH407/STiH410 families) ··· 143 148 src = TX_RETIME_SRC_CLKGEN; 144 149 freq = DWMAC_50MHZ; 145 150 } 146 - } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { 151 + } else if (phy_interface_mode_is_rgmii(dwmac->interface)) { 147 152 /* On GiGa clk source can be either ext or from clkgen */ 148 153 freq = rgmii_clock(spd); 149 154 ··· 233 238 return 0; 234 239 } 235 240 241 + static int sti_dwmac_init(struct platform_device *pdev, void *bsp_priv) 242 + { 243 + struct sti_dwmac *dwmac = bsp_priv; 244 + int ret; 245 + 246 + ret = clk_prepare_enable(dwmac->clk); 247 + if (ret) 248 + return ret; 249 + 250 + ret = sti_dwmac_set_mode(dwmac); 251 + if (ret) 252 + clk_disable_unprepare(dwmac->clk); 253 + 254 + return ret; 255 + } 256 + 257 + static void sti_dwmac_exit(struct platform_device *pdev, void *bsp_priv) 258 + { 259 + struct sti_dwmac *dwmac = bsp_priv; 260 + 261 + clk_disable_unprepare(dwmac->clk); 262 + } 263 + 236 264 static int sti_dwmac_probe(struct platform_device *pdev) 237 265 { 238 266 struct plat_stmmacenet_data *plat_dat; ··· 292 274 293 275 plat_dat->bsp_priv = dwmac; 294 276 plat_dat->fix_mac_speed = data->fix_retime_src; 277 + plat_dat->init = sti_dwmac_init; 278 + plat_dat->exit = sti_dwmac_exit; 295 279 296 - ret = clk_prepare_enable(dwmac->clk); 297 - if (ret) 298 - return ret; 299 - 300 - ret = sti_dwmac_set_mode(dwmac); 301 - if (ret) 302 - goto disable_clk; 303 - 304 - ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 305 - if (ret) 306 - goto disable_clk; 307 - 308 - return 0; 309 - 310 - disable_clk: 311 - clk_disable_unprepare(dwmac->clk); 312 - 313 - return ret; 280 + return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res); 314 281 } 315 - 316 - static void sti_dwmac_remove(struct platform_device *pdev) 317 - { 318 - struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); 319 - 320 - stmmac_dvr_remove(&pdev->dev); 321 - 322 - clk_disable_unprepare(dwmac->clk); 323 - } 324 - 325 - static int sti_dwmac_suspend(struct device *dev) 326 - { 327 - struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); 328 - int ret = stmmac_suspend(dev); 329 - 330 - clk_disable_unprepare(dwmac->clk); 331 - 332 - return ret; 333 - } 334 - 335 - static int sti_dwmac_resume(struct device *dev) 336 - { 337 - struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); 338 - 339 - clk_prepare_enable(dwmac->clk); 340 - sti_dwmac_set_mode(dwmac); 341 - 342 - return stmmac_resume(dev); 343 - } 344 - 345 - static DEFINE_SIMPLE_DEV_PM_OPS(sti_dwmac_pm_ops, sti_dwmac_suspend, 346 - sti_dwmac_resume); 347 282 348 283 static const struct sti_dwmac_of_data stih4xx_dwmac_data = { 349 284 .fix_retime_src = stih4xx_fix_retime_src, ··· 310 339 311 340 static struct platform_driver sti_dwmac_driver = { 312 341 .probe = sti_dwmac_probe, 313 - .remove = sti_dwmac_remove, 314 342 .driver = { 315 343 .name = "sti-dwmac", 316 - .pm = pm_sleep_ptr(&sti_dwmac_pm_ops), 344 + .pm = &stmmac_pltfr_pm_ops, 317 345 .of_match_table = sti_dwmac_match, 318 346 }, 319 347 };