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

net: stmmac: platform: use optional clk/reset get APIs

Use the devm_reset_control_get_optional() and devm_clk_get_optional()
rather than open coding them.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Link: https://lore.kernel.org/r/20201112092606.5173aa6f@xhacker.debian
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jisheng Zhang and committed by
Jakub Kicinski
bb3222f7 ca1ab89c

+9 -13
+9 -13
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 399 399 struct device_node *np = pdev->dev.of_node; 400 400 struct plat_stmmacenet_data *plat; 401 401 struct stmmac_dma_cfg *dma_cfg; 402 + void *ret; 402 403 int rc; 403 404 404 405 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); ··· 577 576 clk_prepare_enable(plat->stmmac_clk); 578 577 } 579 578 580 - plat->pclk = devm_clk_get(&pdev->dev, "pclk"); 579 + plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); 581 580 if (IS_ERR(plat->pclk)) { 582 - if (PTR_ERR(plat->pclk) == -EPROBE_DEFER) 583 - goto error_pclk_get; 584 - 585 - plat->pclk = NULL; 581 + ret = plat->pclk; 582 + goto error_pclk_get; 586 583 } 587 584 clk_prepare_enable(plat->pclk); 588 585 ··· 595 596 dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate); 596 597 } 597 598 598 - plat->stmmac_rst = devm_reset_control_get(&pdev->dev, 599 - STMMAC_RESOURCE_NAME); 599 + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, 600 + STMMAC_RESOURCE_NAME); 600 601 if (IS_ERR(plat->stmmac_rst)) { 601 - if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER) 602 - goto error_hw_init; 603 - 604 - dev_info(&pdev->dev, "no reset control found\n"); 605 - plat->stmmac_rst = NULL; 602 + ret = plat->stmmac_rst; 603 + goto error_hw_init; 606 604 } 607 605 608 606 return plat; ··· 609 613 error_pclk_get: 610 614 clk_disable_unprepare(plat->stmmac_clk); 611 615 612 - return ERR_PTR(-EPROBE_DEFER); 616 + return ret; 613 617 } 614 618 615 619 /**