Skip to content

Commit 5f109d4

Browse files
commododavem330
authored andcommitted
net: stmmac: socfpga: re-use the interface parameter from platform data
The socfpga sub-driver defines an `interface` field in the `socfpga_dwmac` struct and parses it on init. The shared `stmmac_probe_config_dt()` function also parses this from the device-tree and makes it available on the returned `plat_data` (which is the same data available via `netdev_priv()`). All that's needed now is to dig that information out, via some `dev_get_drvdata()` && `netdev_priv()` calls and re-use it. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 95cf667 commit 5f109d4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct socfpga_dwmac_ops {
4646
};
4747

4848
struct socfpga_dwmac {
49-
int interface;
5049
u32 reg_offset;
5150
u32 reg_shift;
5251
struct device *dev;
@@ -110,8 +109,6 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
110109
struct resource res_tse_pcs;
111110
struct resource res_sgmii_adapter;
112111

113-
dwmac->interface = of_get_phy_mode(np);
114-
115112
sys_mgr_base_addr =
116113
altr_sysmgr_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon");
117114
if (IS_ERR(sys_mgr_base_addr)) {
@@ -231,6 +228,14 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
231228
return ret;
232229
}
233230

231+
static int socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac)
232+
{
233+
struct net_device *ndev = dev_get_drvdata(dwmac->dev);
234+
struct stmmac_priv *priv = netdev_priv(ndev);
235+
236+
return priv->plat->interface;
237+
}
238+
234239
static int socfpga_set_phy_mode_common(int phymode, u32 *val)
235240
{
236241
switch (phymode) {
@@ -255,7 +260,7 @@ static int socfpga_set_phy_mode_common(int phymode, u32 *val)
255260
static int socfpga_gen5_set_phy_mode(struct socfpga_dwmac *dwmac)
256261
{
257262
struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr;
258-
int phymode = dwmac->interface;
263+
int phymode = socfpga_get_plat_phymode(dwmac);
259264
u32 reg_offset = dwmac->reg_offset;
260265
u32 reg_shift = dwmac->reg_shift;
261266
u32 ctrl, val, module;
@@ -314,7 +319,7 @@ static int socfpga_gen5_set_phy_mode(struct socfpga_dwmac *dwmac)
314319
static int socfpga_gen10_set_phy_mode(struct socfpga_dwmac *dwmac)
315320
{
316321
struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr;
317-
int phymode = dwmac->interface;
322+
int phymode = socfpga_get_plat_phymode(dwmac);
318323
u32 reg_offset = dwmac->reg_offset;
319324
u32 reg_shift = dwmac->reg_shift;
320325
u32 ctrl, val, module;

0 commit comments

Comments
 (0)