Commit fdc38d34 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

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: default avatarJakub Kicinski <kuba@kernel.org>
parents 4707191c 1a62894e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ static void gmac_write_reg(struct anarion_gmac *gmac, uint8_t reg, uint32_t val)
	writel(val, gmac->ctl_block + reg);
}

static int anarion_gmac_init(struct platform_device *pdev, void *priv)
static int anarion_gmac_init(struct device *dev, void *priv)
{
	uint32_t sw_config;
	struct anarion_gmac *gmac = priv;
@@ -52,7 +52,7 @@ static int anarion_gmac_init(struct platform_device *pdev, void *priv)
	return 0;
}

static void anarion_gmac_exit(struct platform_device *pdev, void *priv)
static void anarion_gmac_exit(struct device *dev, void *priv)
{
	struct anarion_gmac *gmac = priv;

+2 −2
Original line number Diff line number Diff line
@@ -58,14 +58,14 @@ static int eic7700_clks_config(void *priv, bool enabled)
	return ret;
}

static int eic7700_dwmac_init(struct platform_device *pdev, void *priv)
static int eic7700_dwmac_init(struct device *dev, void *priv)
{
	struct eic7700_qos_priv *dwc = priv;

	return eic7700_clks_config(dwc, true);
}

static void eic7700_dwmac_exit(struct platform_device *pdev, void *priv)
static void eic7700_dwmac_exit(struct device *dev, void *priv)
{
	struct eic7700_qos_priv *dwc = priv;

+6 −6
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ struct ls1x_dwmac {
struct ls1x_data {
	int (*setup)(struct platform_device *pdev,
		     struct plat_stmmacenet_data *plat_dat);
	int (*init)(struct platform_device *pdev, void *bsp_priv);
	int (*init)(struct device *dev, void *bsp_priv);
};

static int ls1b_dwmac_setup(struct platform_device *pdev,
@@ -79,7 +79,7 @@ static int ls1b_dwmac_setup(struct platform_device *pdev,
	return 0;
}

static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
static int ls1b_dwmac_syscon_init(struct device *dev, void *priv)
{
	struct ls1x_dwmac *dwmac = priv;
	struct plat_stmmacenet_data *plat = dwmac->plat_dat;
@@ -98,7 +98,7 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
					   GMAC0_USE_TXCLK | GMAC0_USE_PWM01);
			break;
		default:
			dev_err(&pdev->dev, "Unsupported PHY mode %u\n",
			dev_err(dev, "Unsupported PHY mode %u\n",
				plat->phy_interface);
			return -EOPNOTSUPP;
		}
@@ -122,7 +122,7 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
					   GMAC1_USE_TXCLK | GMAC1_USE_PWM23);
			break;
		default:
			dev_err(&pdev->dev, "Unsupported PHY mode %u\n",
			dev_err(dev, "Unsupported PHY mode %u\n",
				plat->phy_interface);
			return -EOPNOTSUPP;
		}
@@ -133,7 +133,7 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
	return 0;
}

static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
static int ls1c_dwmac_syscon_init(struct device *dev, void *priv)
{
	struct ls1x_dwmac *dwmac = priv;
	struct plat_stmmacenet_data *plat = dwmac->plat_dat;
@@ -143,7 +143,7 @@ static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
	phy_intf_sel = stmmac_get_phy_intf_sel(plat->phy_interface);
	if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
	    phy_intf_sel != PHY_INTF_SEL_RMII) {
		dev_err(&pdev->dev, "Unsupported PHY-mode %u\n",
		dev_err(dev, "Unsupported PHY-mode %u\n",
			plat->phy_interface);
		return -EOPNOTSUPP;
	}
+2 −2
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ static struct phylink_pcs *renesas_gmac_select_pcs(struct stmmac_priv *priv,
	return priv->hw->phylink_pcs;
}

static int renesas_gbeth_init(struct platform_device *pdev, void *priv)
static int renesas_gbeth_init(struct device *dev, void *priv)
{
	struct plat_stmmacenet_data *plat_dat;
	struct renesas_gbeth *gbeth = priv;
@@ -113,7 +113,7 @@ static int renesas_gbeth_init(struct platform_device *pdev, void *priv)
	return ret;
}

static void renesas_gbeth_exit(struct platform_device *pdev, void *priv)
static void renesas_gbeth_exit(struct device *dev, void *priv)
{
	struct plat_stmmacenet_data *plat_dat;
	struct renesas_gbeth *gbeth = priv;
+19 −28
Original line number Diff line number Diff line
@@ -1763,6 +1763,22 @@ static int rk_gmac_resume(struct device *dev, void *bsp_priv_)
	return 0;
}

static int rk_gmac_init(struct device *dev, void *bsp_priv)
{
	return rk_gmac_powerup(bsp_priv);
}

static void rk_gmac_exit(struct device *dev, void *bsp_priv_)
{
	struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dev));
	struct rk_priv_data *bsp_priv = bsp_priv_;

	rk_gmac_powerdown(bsp_priv);

	if (priv->plat->phy_node && bsp_priv->integrated_phy)
		clk_put(bsp_priv->clk_phy);
}

static int rk_gmac_probe(struct platform_device *pdev)
{
	struct plat_stmmacenet_data *plat_dat;
@@ -1795,6 +1811,8 @@ static int rk_gmac_probe(struct platform_device *pdev)

	plat_dat->get_interfaces = rk_get_interfaces;
	plat_dat->set_clk_tx_rate = rk_set_clk_tx_rate;
	plat_dat->init = rk_gmac_init;
	plat_dat->exit = rk_gmac_exit;
	plat_dat->suspend = rk_gmac_suspend;
	plat_dat->resume = rk_gmac_resume;

@@ -1806,33 +1824,7 @@ static int rk_gmac_probe(struct platform_device *pdev)
	if (ret)
		return ret;

	ret = rk_gmac_powerup(plat_dat->bsp_priv);
	if (ret)
		return ret;

	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
	if (ret)
		goto err_gmac_powerdown;

	return 0;

err_gmac_powerdown:
	rk_gmac_powerdown(plat_dat->bsp_priv);

	return ret;
}

static void rk_gmac_remove(struct platform_device *pdev)
{
	struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev));
	struct rk_priv_data *bsp_priv = priv->plat->bsp_priv;

	stmmac_dvr_remove(&pdev->dev);

	rk_gmac_powerdown(bsp_priv);

	if (priv->plat->phy_node && bsp_priv->integrated_phy)
		clk_put(bsp_priv->clk_phy);
	return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
}

static const struct of_device_id rk_gmac_dwmac_match[] = {
@@ -1858,7 +1850,6 @@ MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);

static struct platform_driver rk_gmac_dwmac_driver = {
	.probe  = rk_gmac_probe,
	.remove = rk_gmac_remove,
	.driver = {
		.name           = "rk_gmac-dwmac",
		.pm		= &stmmac_simple_pm_ops,
Loading