Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: cpsw: isolate cpsw_ndo_ioctl() to just the old driver

cpsw->slaves[slave_no].phy should be equal to netdev->phydev, because it
is assigned from phy_attach_direct(). The latter is indirectly called
from the two identically named cpsw_slave_open() functions, one in
cpsw.c and another in cpsw_new.c.

Thus, the driver should not need custom logic to find the PHY, the core
can find it, and phy_do_ioctl_running() achieves exactly that.

However, that is only the case for cpsw_new and for the cpsw driver in
dual EMAC mode. This is explained in more detail in the previous commit.
Thus, allow the simpler core logic to execute for cpsw_new, and move
cpsw_ndo_ioctl() to cpsw.c.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20250512114422.4176010-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
4cde0e42 36d9b542

+22 -19
+21
drivers/net/ethernet/ti/cpsw.c
··· 1156 1156 } 1157 1157 #endif 1158 1158 1159 + /* We need a custom implementation of phy_do_ioctl_running() because in switch 1160 + * mode, dev->phydev may be different than the phy of the active_slave. We need 1161 + * to operate on the locally saved phy instead. 1162 + */ 1163 + static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 1164 + { 1165 + struct cpsw_priv *priv = netdev_priv(dev); 1166 + struct cpsw_common *cpsw = priv->cpsw; 1167 + int slave_no = cpsw_slave_index(cpsw, priv); 1168 + struct phy_device *phy; 1169 + 1170 + if (!netif_running(dev)) 1171 + return -EINVAL; 1172 + 1173 + phy = cpsw->slaves[slave_no].phy; 1174 + if (phy) 1175 + return phy_mii_ioctl(phy, req, cmd); 1176 + 1177 + return -EOPNOTSUPP; 1178 + } 1179 + 1159 1180 static const struct net_device_ops cpsw_netdev_ops = { 1160 1181 .ndo_open = cpsw_ndo_open, 1161 1182 .ndo_stop = cpsw_ndo_stop,
+1 -1
drivers/net/ethernet/ti/cpsw_new.c
··· 1132 1132 .ndo_stop = cpsw_ndo_stop, 1133 1133 .ndo_start_xmit = cpsw_ndo_start_xmit, 1134 1134 .ndo_set_mac_address = cpsw_ndo_set_mac_address, 1135 - .ndo_eth_ioctl = cpsw_ndo_ioctl, 1135 + .ndo_eth_ioctl = phy_do_ioctl_running, 1136 1136 .ndo_validate_addr = eth_validate_addr, 1137 1137 .ndo_tx_timeout = cpsw_ndo_tx_timeout, 1138 1138 .ndo_set_rx_mode = cpsw_ndo_set_rx_mode,
-17
drivers/net/ethernet/ti/cpsw_priv.c
··· 710 710 } 711 711 #endif /*CONFIG_TI_CPTS*/ 712 712 713 - int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 714 - { 715 - struct cpsw_priv *priv = netdev_priv(dev); 716 - struct cpsw_common *cpsw = priv->cpsw; 717 - int slave_no = cpsw_slave_index(cpsw, priv); 718 - struct phy_device *phy; 719 - 720 - if (!netif_running(dev)) 721 - return -EINVAL; 722 - 723 - phy = cpsw->slaves[slave_no].phy; 724 - if (phy) 725 - return phy_mii_ioctl(phy, req, cmd); 726 - 727 - return -EOPNOTSUPP; 728 - } 729 - 730 713 int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate) 731 714 { 732 715 struct cpsw_priv *priv = netdev_priv(ndev);
-1
drivers/net/ethernet/ti/cpsw_priv.h
··· 461 461 void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv); 462 462 void cpsw_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue); 463 463 int cpsw_need_resplit(struct cpsw_common *cpsw); 464 - int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd); 465 464 int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate); 466 465 int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type, 467 466 void *type_data);