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-pass-struct-device-to-init-exit'

Russell King says:

====================
net: stmmac: pass struct device to init/exit

Rather than passing the platform device to the ->init() and ->exit()
methods, make these methods useful for other devices by passing the
struct device instead. Update the implementations appropriately for
this change.

Move the calls for these methods into the core driver's probe and
remove methods from the stmmac_platform layer.

Convert dwmac-rk to use ->init() and ->exit().
====================

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

+94 -99
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
··· 34 34 writel(val, gmac->ctl_block + reg); 35 35 } 36 36 37 - static int anarion_gmac_init(struct platform_device *pdev, void *priv) 37 + static int anarion_gmac_init(struct device *dev, void *priv) 38 38 { 39 39 uint32_t sw_config; 40 40 struct anarion_gmac *gmac = priv; ··· 52 52 return 0; 53 53 } 54 54 55 - static void anarion_gmac_exit(struct platform_device *pdev, void *priv) 55 + static void anarion_gmac_exit(struct device *dev, void *priv) 56 56 { 57 57 struct anarion_gmac *gmac = priv; 58 58
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c
··· 58 58 return ret; 59 59 } 60 60 61 - static int eic7700_dwmac_init(struct platform_device *pdev, void *priv) 61 + static int eic7700_dwmac_init(struct device *dev, void *priv) 62 62 { 63 63 struct eic7700_qos_priv *dwc = priv; 64 64 65 65 return eic7700_clks_config(dwc, true); 66 66 } 67 67 68 - static void eic7700_dwmac_exit(struct platform_device *pdev, void *priv) 68 + static void eic7700_dwmac_exit(struct device *dev, void *priv) 69 69 { 70 70 struct eic7700_qos_priv *dwc = priv; 71 71
+6 -6
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
··· 48 48 struct ls1x_data { 49 49 int (*setup)(struct platform_device *pdev, 50 50 struct plat_stmmacenet_data *plat_dat); 51 - int (*init)(struct platform_device *pdev, void *bsp_priv); 51 + int (*init)(struct device *dev, void *bsp_priv); 52 52 }; 53 53 54 54 static int ls1b_dwmac_setup(struct platform_device *pdev, ··· 79 79 return 0; 80 80 } 81 81 82 - static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv) 82 + static int ls1b_dwmac_syscon_init(struct device *dev, void *priv) 83 83 { 84 84 struct ls1x_dwmac *dwmac = priv; 85 85 struct plat_stmmacenet_data *plat = dwmac->plat_dat; ··· 98 98 GMAC0_USE_TXCLK | GMAC0_USE_PWM01); 99 99 break; 100 100 default: 101 - dev_err(&pdev->dev, "Unsupported PHY mode %u\n", 101 + dev_err(dev, "Unsupported PHY mode %u\n", 102 102 plat->phy_interface); 103 103 return -EOPNOTSUPP; 104 104 } ··· 122 122 GMAC1_USE_TXCLK | GMAC1_USE_PWM23); 123 123 break; 124 124 default: 125 - dev_err(&pdev->dev, "Unsupported PHY mode %u\n", 125 + dev_err(dev, "Unsupported PHY mode %u\n", 126 126 plat->phy_interface); 127 127 return -EOPNOTSUPP; 128 128 } ··· 133 133 return 0; 134 134 } 135 135 136 - static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv) 136 + static int ls1c_dwmac_syscon_init(struct device *dev, void *priv) 137 137 { 138 138 struct ls1x_dwmac *dwmac = priv; 139 139 struct plat_stmmacenet_data *plat = dwmac->plat_dat; ··· 143 143 phy_intf_sel = stmmac_get_phy_intf_sel(plat->phy_interface); 144 144 if (phy_intf_sel != PHY_INTF_SEL_GMII_MII && 145 145 phy_intf_sel != PHY_INTF_SEL_RMII) { 146 - dev_err(&pdev->dev, "Unsupported PHY-mode %u\n", 146 + dev_err(dev, "Unsupported PHY-mode %u\n", 147 147 plat->phy_interface); 148 148 return -EOPNOTSUPP; 149 149 }
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-renesas-gbeth.c
··· 91 91 return priv->hw->phylink_pcs; 92 92 } 93 93 94 - static int renesas_gbeth_init(struct platform_device *pdev, void *priv) 94 + static int renesas_gbeth_init(struct device *dev, void *priv) 95 95 { 96 96 struct plat_stmmacenet_data *plat_dat; 97 97 struct renesas_gbeth *gbeth = priv; ··· 113 113 return ret; 114 114 } 115 115 116 - static void renesas_gbeth_exit(struct platform_device *pdev, void *priv) 116 + static void renesas_gbeth_exit(struct device *dev, void *priv) 117 117 { 118 118 struct plat_stmmacenet_data *plat_dat; 119 119 struct renesas_gbeth *gbeth = priv;
+19 -28
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
··· 1763 1763 return 0; 1764 1764 } 1765 1765 1766 + static int rk_gmac_init(struct device *dev, void *bsp_priv) 1767 + { 1768 + return rk_gmac_powerup(bsp_priv); 1769 + } 1770 + 1771 + static void rk_gmac_exit(struct device *dev, void *bsp_priv_) 1772 + { 1773 + struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dev)); 1774 + struct rk_priv_data *bsp_priv = bsp_priv_; 1775 + 1776 + rk_gmac_powerdown(bsp_priv); 1777 + 1778 + if (priv->plat->phy_node && bsp_priv->integrated_phy) 1779 + clk_put(bsp_priv->clk_phy); 1780 + } 1781 + 1766 1782 static int rk_gmac_probe(struct platform_device *pdev) 1767 1783 { 1768 1784 struct plat_stmmacenet_data *plat_dat; ··· 1811 1795 1812 1796 plat_dat->get_interfaces = rk_get_interfaces; 1813 1797 plat_dat->set_clk_tx_rate = rk_set_clk_tx_rate; 1798 + plat_dat->init = rk_gmac_init; 1799 + plat_dat->exit = rk_gmac_exit; 1814 1800 plat_dat->suspend = rk_gmac_suspend; 1815 1801 plat_dat->resume = rk_gmac_resume; 1816 1802 ··· 1824 1806 if (ret) 1825 1807 return ret; 1826 1808 1827 - ret = rk_gmac_powerup(plat_dat->bsp_priv); 1828 - if (ret) 1829 - return ret; 1830 - 1831 - ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 1832 - if (ret) 1833 - goto err_gmac_powerdown; 1834 - 1835 - return 0; 1836 - 1837 - err_gmac_powerdown: 1838 - rk_gmac_powerdown(plat_dat->bsp_priv); 1839 - 1840 - return ret; 1841 - } 1842 - 1843 - static void rk_gmac_remove(struct platform_device *pdev) 1844 - { 1845 - struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); 1846 - struct rk_priv_data *bsp_priv = priv->plat->bsp_priv; 1847 - 1848 - stmmac_dvr_remove(&pdev->dev); 1849 - 1850 - rk_gmac_powerdown(bsp_priv); 1851 - 1852 - if (priv->plat->phy_node && bsp_priv->integrated_phy) 1853 - clk_put(bsp_priv->clk_phy); 1809 + return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res); 1854 1810 } 1855 1811 1856 1812 static const struct of_device_id rk_gmac_dwmac_match[] = { ··· 1850 1858 1851 1859 static struct platform_driver rk_gmac_dwmac_driver = { 1852 1860 .probe = rk_gmac_probe, 1853 - .remove = rk_gmac_remove, 1854 1861 .driver = { 1855 1862 .name = "rk_gmac-dwmac", 1856 1863 .pm = &stmmac_simple_pm_ops,
+7 -7
drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
··· 47 47 return 0; 48 48 } 49 49 50 - static int s32_gmac_init(struct platform_device *pdev, void *priv) 50 + static int s32_gmac_init(struct device *dev, void *priv) 51 51 { 52 52 struct s32_priv_data *gmac = priv; 53 53 int ret; ··· 55 55 /* Set initial TX interface clock */ 56 56 ret = clk_prepare_enable(gmac->tx_clk); 57 57 if (ret) { 58 - dev_err(&pdev->dev, "Can't enable tx clock\n"); 58 + dev_err(dev, "Can't enable tx clock\n"); 59 59 return ret; 60 60 } 61 61 ret = clk_set_rate(gmac->tx_clk, GMAC_INTF_RATE_125M); 62 62 if (ret) { 63 - dev_err(&pdev->dev, "Can't set tx clock\n"); 63 + dev_err(dev, "Can't set tx clock\n"); 64 64 goto err_tx_disable; 65 65 } 66 66 67 67 /* Set initial RX interface clock */ 68 68 ret = clk_prepare_enable(gmac->rx_clk); 69 69 if (ret) { 70 - dev_err(&pdev->dev, "Can't enable rx clock\n"); 70 + dev_err(dev, "Can't enable rx clock\n"); 71 71 goto err_tx_disable; 72 72 } 73 73 ret = clk_set_rate(gmac->rx_clk, GMAC_INTF_RATE_125M); 74 74 if (ret) { 75 - dev_err(&pdev->dev, "Can't set rx clock\n"); 75 + dev_err(dev, "Can't set rx clock\n"); 76 76 goto err_txrx_disable; 77 77 } 78 78 79 79 /* Set interface mode */ 80 80 ret = s32_gmac_write_phy_intf_select(gmac); 81 81 if (ret) { 82 - dev_err(&pdev->dev, "Can't set PHY interface mode\n"); 82 + dev_err(dev, "Can't set PHY interface mode\n"); 83 83 goto err_txrx_disable; 84 84 } 85 85 ··· 92 92 return ret; 93 93 } 94 94 95 - static void s32_gmac_exit(struct platform_device *pdev, void *priv) 95 + static void s32_gmac_exit(struct device *dev, void *priv) 96 96 { 97 97 struct s32_priv_data *gmac = priv; 98 98
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
··· 551 551 return priv->hw->phylink_pcs; 552 552 } 553 553 554 - static int socfpga_dwmac_init(struct platform_device *pdev, void *bsp_priv) 554 + static int socfpga_dwmac_init(struct device *dev, void *bsp_priv) 555 555 { 556 556 struct socfpga_dwmac *dwmac = bsp_priv; 557 557
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 229 229 return 0; 230 230 } 231 231 232 - static int sti_dwmac_init(struct platform_device *pdev, void *bsp_priv) 232 + static int sti_dwmac_init(struct device *dev, void *bsp_priv) 233 233 { 234 234 struct sti_dwmac *dwmac = bsp_priv; 235 235 236 236 return clk_prepare_enable(dwmac->clk); 237 237 } 238 238 239 - static void sti_dwmac_exit(struct platform_device *pdev, void *bsp_priv) 239 + static void sti_dwmac_exit(struct device *dev, void *bsp_priv) 240 240 { 241 241 struct sti_dwmac *dwmac = bsp_priv; 242 242
+5 -5
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
··· 571 571 572 572 static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv); 573 573 574 - static int sun8i_dwmac_init(struct platform_device *pdev, void *priv) 574 + static int sun8i_dwmac_init(struct device *dev, void *priv) 575 575 { 576 - struct net_device *ndev = platform_get_drvdata(pdev); 576 + struct net_device *ndev = dev_get_drvdata(dev); 577 577 struct sunxi_priv_data *gmac = priv; 578 578 int ret; 579 579 580 580 if (gmac->regulator) { 581 581 ret = regulator_enable(gmac->regulator); 582 582 if (ret) { 583 - dev_err(&pdev->dev, "Fail to enable regulator\n"); 583 + dev_err(dev, "Fail to enable regulator\n"); 584 584 return ret; 585 585 } 586 586 } ··· 1005 1005 (H3_EPHY_SHUTDOWN | H3_EPHY_SELECT)); 1006 1006 } 1007 1007 1008 - static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv) 1008 + static void sun8i_dwmac_exit(struct device *dev, void *priv) 1009 1009 { 1010 1010 struct sunxi_priv_data *gmac = priv; 1011 1011 ··· 1265 1265 struct stmmac_priv *priv = netdev_priv(ndev); 1266 1266 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; 1267 1267 1268 - sun8i_dwmac_exit(pdev, gmac); 1268 + sun8i_dwmac_exit(&pdev->dev, gmac); 1269 1269 } 1270 1270 1271 1271 static const struct of_device_id sun8i_dwmac_match[] = {
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
··· 27 27 #define SUN7I_GMAC_GMII_RGMII_RATE 125000000 28 28 #define SUN7I_GMAC_MII_RATE 25000000 29 29 30 - static int sun7i_gmac_init(struct platform_device *pdev, void *priv) 30 + static int sun7i_gmac_init(struct device *dev, void *priv) 31 31 { 32 32 struct sunxi_priv_data *gmac = priv; 33 33 int ret = 0; ··· 58 58 return ret; 59 59 } 60 60 61 - static void sun7i_gmac_exit(struct platform_device *pdev, void *priv) 61 + static void sun7i_gmac_exit(struct device *dev, void *priv) 62 62 { 63 63 struct sunxi_priv_data *gmac = priv; 64 64
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
··· 186 186 return 0; 187 187 } 188 188 189 - static int thead_dwmac_init(struct platform_device *pdev, void *priv) 189 + static int thead_dwmac_init(struct device *dev, void *priv) 190 190 { 191 191 struct thead_dwmac *dwmac = priv; 192 192 unsigned int reg;
+34 -13
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 7593 7593 } 7594 7594 EXPORT_SYMBOL_GPL(stmmac_plat_dat_alloc); 7595 7595 7596 - /** 7597 - * stmmac_dvr_probe 7598 - * @device: device pointer 7599 - * @plat_dat: platform data pointer 7600 - * @res: stmmac resource pointer 7601 - * Description: this is the main probe function used to 7602 - * call the alloc_etherdev, allocate the priv structure. 7603 - * Return: 7604 - * returns 0 on success, otherwise errno. 7605 - */ 7606 - int stmmac_dvr_probe(struct device *device, 7607 - struct plat_stmmacenet_data *plat_dat, 7608 - struct stmmac_resources *res) 7596 + static int __stmmac_dvr_probe(struct device *device, 7597 + struct plat_stmmacenet_data *plat_dat, 7598 + struct stmmac_resources *res) 7609 7599 { 7610 7600 struct net_device *ndev = NULL; 7611 7601 struct stmmac_priv *priv; ··· 7896 7906 7897 7907 return ret; 7898 7908 } 7909 + 7910 + /** 7911 + * stmmac_dvr_probe 7912 + * @dev: device pointer 7913 + * @plat_dat: platform data pointer 7914 + * @res: stmmac resource pointer 7915 + * Description: this is the main probe function used to 7916 + * call the alloc_etherdev, allocate the priv structure. 7917 + * Return: 7918 + * returns 0 on success, otherwise errno. 7919 + */ 7920 + int stmmac_dvr_probe(struct device *dev, struct plat_stmmacenet_data *plat_dat, 7921 + struct stmmac_resources *res) 7922 + { 7923 + int ret; 7924 + 7925 + if (plat_dat->init) { 7926 + ret = plat_dat->init(dev, plat_dat->bsp_priv); 7927 + if (ret) 7928 + return ret; 7929 + } 7930 + 7931 + ret = __stmmac_dvr_probe(dev, plat_dat, res); 7932 + if (ret && plat_dat->exit) 7933 + plat_dat->exit(dev, plat_dat->bsp_priv); 7934 + 7935 + return ret; 7936 + } 7899 7937 EXPORT_SYMBOL_GPL(stmmac_dvr_probe); 7900 7938 7901 7939 /** ··· 7962 7944 7963 7945 pm_runtime_disable(dev); 7964 7946 pm_runtime_put_noidle(dev); 7947 + 7948 + if (priv->plat->exit) 7949 + priv->plat->exit(dev, priv->plat->bsp_priv); 7965 7950 } 7966 7951 EXPORT_SYMBOL_GPL(stmmac_dvr_remove); 7967 7952
+9 -26
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 747 747 748 748 /** 749 749 * stmmac_pltfr_init 750 - * @pdev: pointer to the platform device 750 + * @dev: pointer to the device structure 751 751 * @plat: driver data platform structure 752 752 * Description: Call the platform's init callback (if any) and propagate 753 753 * the return value. 754 754 */ 755 - static int stmmac_pltfr_init(struct platform_device *pdev, 755 + static int stmmac_pltfr_init(struct device *dev, 756 756 struct plat_stmmacenet_data *plat) 757 757 { 758 758 int ret = 0; 759 759 760 760 if (plat->init) 761 - ret = plat->init(pdev, plat->bsp_priv); 761 + ret = plat->init(dev, plat->bsp_priv); 762 762 763 763 return ret; 764 764 } 765 765 766 766 /** 767 767 * stmmac_pltfr_exit 768 - * @pdev: pointer to the platform device 768 + * @dev: pointer to the device structure 769 769 * @plat: driver data platform structure 770 770 * Description: Call the platform's exit callback (if any). 771 771 */ 772 - static void stmmac_pltfr_exit(struct platform_device *pdev, 772 + static void stmmac_pltfr_exit(struct device *dev, 773 773 struct plat_stmmacenet_data *plat) 774 774 { 775 775 if (plat->exit) 776 - plat->exit(pdev, plat->bsp_priv); 776 + plat->exit(dev, plat->bsp_priv); 777 777 } 778 778 779 779 static int stmmac_plat_suspend(struct device *dev, void *bsp_priv) 780 780 { 781 781 struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dev)); 782 782 783 - stmmac_pltfr_exit(to_platform_device(dev), priv->plat); 783 + stmmac_pltfr_exit(dev, priv->plat); 784 784 785 785 return 0; 786 786 } ··· 789 789 { 790 790 struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dev)); 791 791 792 - return stmmac_pltfr_init(to_platform_device(dev), priv->plat); 792 + return stmmac_pltfr_init(dev, priv->plat); 793 793 } 794 794 795 795 /** ··· 804 804 struct plat_stmmacenet_data *plat, 805 805 struct stmmac_resources *res) 806 806 { 807 - int ret; 808 - 809 807 if (!plat->suspend && plat->exit) 810 808 plat->suspend = stmmac_plat_suspend; 811 809 if (!plat->resume && plat->init) 812 810 plat->resume = stmmac_plat_resume; 813 811 814 - ret = stmmac_pltfr_init(pdev, plat); 815 - if (ret) 816 - return ret; 817 - 818 - ret = stmmac_dvr_probe(&pdev->dev, plat, res); 819 - if (ret) { 820 - stmmac_pltfr_exit(pdev, plat); 821 - return ret; 822 - } 823 - 824 - return ret; 812 + return stmmac_dvr_probe(&pdev->dev, plat, res); 825 813 } 826 814 EXPORT_SYMBOL_GPL(stmmac_pltfr_probe); 827 815 ··· 851 863 */ 852 864 void stmmac_pltfr_remove(struct platform_device *pdev) 853 865 { 854 - struct net_device *ndev = platform_get_drvdata(pdev); 855 - struct stmmac_priv *priv = netdev_priv(ndev); 856 - struct plat_stmmacenet_data *plat = priv->plat; 857 - 858 866 stmmac_dvr_remove(&pdev->dev); 859 - stmmac_pltfr_exit(pdev, plat); 860 867 } 861 868 EXPORT_SYMBOL_GPL(stmmac_pltfr_remove); 862 869
+2 -2
include/linux/stmmac.h
··· 264 264 unsigned int mode, 265 265 phy_interface_t interface); 266 266 void (*ptp_clk_freq_config)(struct stmmac_priv *priv); 267 - int (*init)(struct platform_device *pdev, void *priv); 268 - void (*exit)(struct platform_device *pdev, void *priv); 267 + int (*init)(struct device *dev, void *priv); 268 + void (*exit)(struct device *dev, void *priv); 269 269 int (*suspend)(struct device *dev, void *priv); 270 270 int (*resume)(struct device *dev, void *priv); 271 271 int (*mac_setup)(void *priv, struct mac_device_info *mac);