From: Joachim Eastwood Date: Tue, 28 Jul 2015 22:08:58 +0000 (+0200) Subject: stmmac: let dwmac-* drivers handle their own match data X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=149adedd7696cbcf1d72d143ca181334000d0ee7;p=openwrt%2Fstaging%2Fblogic.git stmmac: let dwmac-* drivers handle their own match data Since only a few of the dwmac-* drivers actually need to use the OF match move handling into the dwmac-* drivers that need it. This will also allow dwmac-* drivers to use their own custom match data structure. Signed-off-by: Joachim Eastwood Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 21193a73acfc..65c1e1afe6a8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -580,8 +580,15 @@ static int rk_gmac_probe(struct platform_device *pdev) { struct plat_stmmacenet_data *plat_dat; struct stmmac_resources stmmac_res; + const struct stmmac_of_data *data; int ret; + data = of_device_get_match_data(&pdev->dev); + if (!data) { + dev_err(&pdev->dev, "no of match data provided\n"); + return -EINVAL; + } + ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) return ret; @@ -591,6 +598,7 @@ static int rk_gmac_probe(struct platform_device *pdev) return PTR_ERR(plat_dat); plat_dat->has_gmac = true; + plat_dat->setup = data->setup; plat_dat->init = rk_gmac_init; plat_dat->exit = rk_gmac_exit; plat_dat->fix_mac_speed = rk_fix_speed; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c index b17238aac791..8a977fde1a46 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "stmmac_platform.h" @@ -337,10 +338,17 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, static int sti_dwmac_probe(struct platform_device *pdev) { struct plat_stmmacenet_data *plat_dat; + const struct stmmac_of_data *data; struct stmmac_resources stmmac_res; struct sti_dwmac *dwmac; int ret; + data = of_device_get_match_data(&pdev->dev); + if (!data) { + dev_err(&pdev->dev, "No OF match data provided\n"); + return -EINVAL; + } + ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) return ret; @@ -360,7 +368,9 @@ static int sti_dwmac_probe(struct platform_device *pdev) } plat_dat->bsp_priv = dwmac; + plat_dat->init = data->init; plat_dat->exit = sti_dwmac_exit; + plat_dat->fix_mac_speed = data->fix_mac_speed; ret = plat_dat->init(pdev, plat_dat->bsp_priv); if (ret) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 9c49d95e529a..55e569b330b2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -109,30 +109,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) { struct device_node *np = pdev->dev.of_node; struct plat_stmmacenet_data *plat; - const struct stmmac_of_data *data; struct stmmac_dma_cfg *dma_cfg; plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); if (!plat) return ERR_PTR(-ENOMEM); - data = of_device_get_match_data(&pdev->dev); - if (data) { - plat->has_gmac = data->has_gmac; - plat->enh_desc = data->enh_desc; - plat->tx_coe = data->tx_coe; - plat->rx_coe = data->rx_coe; - plat->bugged_jumbo = data->bugged_jumbo; - plat->pmt = data->pmt; - plat->riwt_off = data->riwt_off; - plat->fix_mac_speed = data->fix_mac_speed; - plat->bus_setup = data->bus_setup; - plat->setup = data->setup; - plat->free = data->free; - plat->init = data->init; - plat->exit = data->exit; - } - *mac = of_get_mac_address(np); plat->interface = of_get_phy_mode(np);