summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/stmicro/stmmac
diff options
context:
space:
mode:
authorJoachim Eastwood <manabian@gmail.com>2015-07-29 01:09:04 +0300
committerDavid S. Miller <davem@davemloft.net>2015-07-29 10:13:25 +0300
commit16b1adbb16c8a52b206092d875030b346b9ce50b (patch)
tree41999416a8c29e562c3c9716003952cf6f75dca2 /drivers/net/ethernet/stmicro/stmmac
parent75fee59550a9899fd9438ebc0a64c972829a8dd2 (diff)
downloadlinux-16b1adbb16c8a52b206092d875030b346b9ce50b.tar.xz
stmmac: dwmac-sti: refactor the init glue callbacks
Remove the two platform specific init callbacks and make them use a common one by creating a function member in the internal data structure. This allow us to remove the layer of indirection and simplify the code a bit. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index 83c501edb688..7f6f4a4fcc70 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -129,11 +129,11 @@ struct sti_dwmac {
struct device *dev;
struct regmap *regmap;
u32 speed;
+ void (*fix_retime_src)(void *priv, unsigned int speed);
};
struct sti_dwmac_of_data {
- void (*fix_mac_speed)(void *priv, unsigned int speed);
- int (*init)(struct platform_device *pdev, void *priv);
+ void (*fix_retime_src)(void *priv, unsigned int speed);
};
static u32 phy_intf_sels[] = {
@@ -228,8 +228,9 @@ static void stid127_fix_retime_src(void *priv, u32 spd)
regmap_update_bits(dwmac->regmap, reg, STID127_RETIME_SRC_MASK, val);
}
-static void sti_dwmac_ctrl_init(struct sti_dwmac *dwmac)
+static int sti_dwmac_init(struct platform_device *pdev, void *priv)
{
+ struct sti_dwmac *dwmac = priv;
struct regmap *regmap = dwmac->regmap;
int iface = dwmac->interface;
struct device *dev = dwmac->dev;
@@ -247,28 +248,8 @@ static void sti_dwmac_ctrl_init(struct sti_dwmac *dwmac)
val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
regmap_update_bits(regmap, reg, ENMII_MASK, val);
-}
-
-static int stix4xx_init(struct platform_device *pdev, void *priv)
-{
- struct sti_dwmac *dwmac = priv;
- u32 spd = dwmac->speed;
-
- sti_dwmac_ctrl_init(dwmac);
- stih4xx_fix_retime_src(priv, spd);
-
- return 0;
-}
-
-static int stid127_init(struct platform_device *pdev, void *priv)
-{
- struct sti_dwmac *dwmac = priv;
- u32 spd = dwmac->speed;
-
- sti_dwmac_ctrl_init(dwmac);
-
- stid127_fix_retime_src(priv, spd);
+ dwmac->fix_retime_src(priv, dwmac->speed);
return 0;
}
@@ -372,12 +353,14 @@ static int sti_dwmac_probe(struct platform_device *pdev)
return ret;
}
+ dwmac->fix_retime_src = data->fix_retime_src;
+
plat_dat->bsp_priv = dwmac;
- plat_dat->init = data->init;
+ plat_dat->init = sti_dwmac_init;
plat_dat->exit = sti_dwmac_exit;
- plat_dat->fix_mac_speed = data->fix_mac_speed;
+ plat_dat->fix_mac_speed = data->fix_retime_src;
- ret = plat_dat->init(pdev, plat_dat->bsp_priv);
+ ret = sti_dwmac_init(pdev, plat_dat->bsp_priv);
if (ret)
return ret;
@@ -385,13 +368,11 @@ static int sti_dwmac_probe(struct platform_device *pdev)
}
static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
- .fix_mac_speed = stih4xx_fix_retime_src,
- .init = stix4xx_init,
+ .fix_retime_src = stih4xx_fix_retime_src,
};
static const struct sti_dwmac_of_data stid127_dwmac_data = {
- .fix_mac_speed = stid127_fix_retime_src,
- .init = stid127_init,
+ .fix_retime_src = stid127_fix_retime_src,
};
static const struct of_device_id sti_dwmac_match[] = {