Skip to content

Commit 34bf68a

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: stmmac: ingenic: use ->set_phy_intf_sel()
Rather than placing the phy_intf_sel() setup in the ->init() method, move it to the new ->set_phy_intf_sel() method. Signed-off-by: Russell King (Oracle) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9352f74 commit 34bf68a

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

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

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,32 +134,21 @@ static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel)
134134
return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val);
135135
}
136136

137-
static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)
137+
static int ingenic_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel)
138138
{
139139
struct ingenic_mac *mac = bsp_priv;
140-
phy_interface_t interface;
141-
int phy_intf_sel, ret;
142-
143-
if (mac->soc_info->set_mode) {
144-
interface = mac->plat_dat->phy_interface;
145-
146-
phy_intf_sel = stmmac_get_phy_intf_sel(interface);
147-
if (phy_intf_sel < 0 || phy_intf_sel >= BITS_PER_BYTE ||
148-
~mac->soc_info->valid_phy_intf_sel & BIT(phy_intf_sel)) {
149-
dev_err(mac->dev, "unsupported interface %s\n",
150-
phy_modes(interface));
151-
return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
152-
}
153140

154-
dev_dbg(mac->dev, "MAC PHY control register: interface %s\n",
155-
phy_modes(interface));
141+
if (!mac->soc_info->set_mode)
142+
return 0;
156143

157-
ret = mac->soc_info->set_mode(mac, phy_intf_sel);
158-
if (ret)
159-
return ret;
160-
}
144+
if (phy_intf_sel >= BITS_PER_BYTE ||
145+
~mac->soc_info->valid_phy_intf_sel & BIT(phy_intf_sel))
146+
return -EINVAL;
147+
148+
dev_dbg(mac->dev, "MAC PHY control register: interface %s\n",
149+
phy_modes(mac->plat_dat->phy_interface));
161150

162-
return 0;
151+
return mac->soc_info->set_mode(mac, phy_intf_sel);
163152
}
164153

165154
static int ingenic_mac_probe(struct platform_device *pdev)
@@ -221,7 +210,7 @@ static int ingenic_mac_probe(struct platform_device *pdev)
221210
mac->plat_dat = plat_dat;
222211

223212
plat_dat->bsp_priv = mac;
224-
plat_dat->init = ingenic_mac_init;
213+
plat_dat->set_phy_intf_sel = ingenic_set_phy_intf_sel;
225214

226215
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
227216
}

0 commit comments

Comments
 (0)