smsc95xx.c (448cc2fb3a7b327823a9afd374808c37b8e6194f) | smsc95xx.c (a049a30fc27c1cb2e12889bbdbd463dbf750103a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2 /*************************************************************************** 3 * 4 * Copyright (C) 2007-2008 SMSC 5 * 6 *****************************************************************************/ 7 8#include <linux/module.h> --- 1036 unchanged lines hidden (view full) --- 1045 .ndo_get_stats64 = dev_get_tstats64, 1046 .ndo_set_mac_address = eth_mac_addr, 1047 .ndo_validate_addr = eth_validate_addr, 1048 .ndo_eth_ioctl = smsc95xx_ioctl, 1049 .ndo_set_rx_mode = smsc95xx_set_multicast, 1050 .ndo_set_features = smsc95xx_set_features, 1051}; 1052 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2 /*************************************************************************** 3 * 4 * Copyright (C) 2007-2008 SMSC 5 * 6 *****************************************************************************/ 7 8#include <linux/module.h> --- 1036 unchanged lines hidden (view full) --- 1045 .ndo_get_stats64 = dev_get_tstats64, 1046 .ndo_set_mac_address = eth_mac_addr, 1047 .ndo_validate_addr = eth_validate_addr, 1048 .ndo_eth_ioctl = smsc95xx_ioctl, 1049 .ndo_set_rx_mode = smsc95xx_set_multicast, 1050 .ndo_set_features = smsc95xx_set_features, 1051}; 1052 |
1053static void smsc95xx_handle_link_change(struct net_device *net) 1054{ 1055 struct usbnet *dev = netdev_priv(net); 1056 1057 phy_print_status(net->phydev); 1058 usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); 1059} 1060 |
|
1053static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) 1054{ 1055 struct smsc95xx_priv *pdata; 1056 bool is_internal_phy; 1057 u32 val; 1058 int ret; 1059 1060 printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); --- 88 unchanged lines hidden (view full) --- 1149 1150 dev->net->netdev_ops = &smsc95xx_netdev_ops; 1151 dev->net->ethtool_ops = &smsc95xx_ethtool_ops; 1152 dev->net->flags |= IFF_MULTICAST; 1153 dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM; 1154 dev->net->min_mtu = ETH_MIN_MTU; 1155 dev->net->max_mtu = ETH_DATA_LEN; 1156 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; | 1061static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) 1062{ 1063 struct smsc95xx_priv *pdata; 1064 bool is_internal_phy; 1065 u32 val; 1066 int ret; 1067 1068 printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); --- 88 unchanged lines hidden (view full) --- 1157 1158 dev->net->netdev_ops = &smsc95xx_netdev_ops; 1159 dev->net->ethtool_ops = &smsc95xx_ethtool_ops; 1160 dev->net->flags |= IFF_MULTICAST; 1161 dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM; 1162 dev->net->min_mtu = ETH_MIN_MTU; 1163 dev->net->max_mtu = ETH_DATA_LEN; 1164 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; |
1165 1166 ret = phy_connect_direct(dev->net, pdata->phydev, 1167 &smsc95xx_handle_link_change, 1168 PHY_INTERFACE_MODE_MII); 1169 if (ret) { 1170 netdev_err(dev->net, "can't attach PHY to %s\n", pdata->mdiobus->id); 1171 goto unregister_mdio; 1172 } 1173 1174 phy_attached_info(dev->net->phydev); 1175 |
|
1157 return 0; 1158 1159unregister_mdio: 1160 mdiobus_unregister(pdata->mdiobus); 1161 1162free_mdio: 1163 mdiobus_free(pdata->mdiobus); 1164 1165free_pdata: 1166 kfree(pdata); 1167 return ret; 1168} 1169 1170static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) 1171{ 1172 struct smsc95xx_priv *pdata = dev->driver_priv; 1173 | 1176 return 0; 1177 1178unregister_mdio: 1179 mdiobus_unregister(pdata->mdiobus); 1180 1181free_mdio: 1182 mdiobus_free(pdata->mdiobus); 1183 1184free_pdata: 1185 kfree(pdata); 1186 return ret; 1187} 1188 1189static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) 1190{ 1191 struct smsc95xx_priv *pdata = dev->driver_priv; 1192 |
1193 phy_disconnect(dev->net->phydev); |
|
1174 mdiobus_unregister(pdata->mdiobus); 1175 mdiobus_free(pdata->mdiobus); 1176 netif_dbg(dev, ifdown, dev->net, "free pdata\n"); 1177 kfree(pdata); 1178} 1179 | 1194 mdiobus_unregister(pdata->mdiobus); 1195 mdiobus_free(pdata->mdiobus); 1196 netif_dbg(dev, ifdown, dev->net, "free pdata\n"); 1197 kfree(pdata); 1198} 1199 |
1180static void smsc95xx_handle_link_change(struct net_device *net) 1181{ 1182 struct usbnet *dev = netdev_priv(net); 1183 1184 phy_print_status(net->phydev); 1185 usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); 1186} 1187 | |
1188static int smsc95xx_start_phy(struct usbnet *dev) 1189{ | 1200static int smsc95xx_start_phy(struct usbnet *dev) 1201{ |
1190 struct smsc95xx_priv *pdata = dev->driver_priv; 1191 struct net_device *net = dev->net; 1192 int ret; | 1202 phy_start(dev->net->phydev); |
1193 | 1203 |
1194 ret = smsc95xx_reset(dev); 1195 if (ret < 0) 1196 return ret; 1197 1198 ret = phy_connect_direct(net, pdata->phydev, 1199 &smsc95xx_handle_link_change, 1200 PHY_INTERFACE_MODE_MII); 1201 if (ret) { 1202 netdev_err(net, "can't attach PHY to %s\n", pdata->mdiobus->id); 1203 return ret; 1204 } 1205 1206 phy_attached_info(net->phydev); 1207 phy_start(net->phydev); | |
1208 return 0; 1209} 1210 | 1204 return 0; 1205} 1206 |
1211static int smsc95xx_disconnect_phy(struct usbnet *dev) | 1207static int smsc95xx_stop(struct usbnet *dev) |
1212{ | 1208{ |
1213 phy_stop(dev->net->phydev); 1214 phy_disconnect(dev->net->phydev); | 1209 if (dev->net->phydev) 1210 phy_stop(dev->net->phydev); 1211 |
1215 return 0; 1216} 1217 1218static u32 smsc_crc(const u8 *buffer, size_t len, int filter) 1219{ 1220 u32 crc = bitrev16(crc16(0xFFFF, buffer, len)); 1221 return crc << ((filter % 2) * 16); 1222} --- 738 unchanged lines hidden (view full) --- 1961} 1962 1963static const struct driver_info smsc95xx_info = { 1964 .description = "smsc95xx USB 2.0 Ethernet", 1965 .bind = smsc95xx_bind, 1966 .unbind = smsc95xx_unbind, 1967 .link_reset = smsc95xx_link_reset, 1968 .reset = smsc95xx_start_phy, | 1212 return 0; 1213} 1214 1215static u32 smsc_crc(const u8 *buffer, size_t len, int filter) 1216{ 1217 u32 crc = bitrev16(crc16(0xFFFF, buffer, len)); 1218 return crc << ((filter % 2) * 16); 1219} --- 738 unchanged lines hidden (view full) --- 1958} 1959 1960static const struct driver_info smsc95xx_info = { 1961 .description = "smsc95xx USB 2.0 Ethernet", 1962 .bind = smsc95xx_bind, 1963 .unbind = smsc95xx_unbind, 1964 .link_reset = smsc95xx_link_reset, 1965 .reset = smsc95xx_start_phy, |
1969 .stop = smsc95xx_disconnect_phy, | 1966 .stop = smsc95xx_stop, |
1970 .rx_fixup = smsc95xx_rx_fixup, 1971 .tx_fixup = smsc95xx_tx_fixup, 1972 .status = smsc95xx_status, 1973 .manage_power = smsc95xx_manage_power, 1974 .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR, 1975}; 1976 1977static const struct usb_device_id products[] = { --- 112 unchanged lines hidden --- | 1967 .rx_fixup = smsc95xx_rx_fixup, 1968 .tx_fixup = smsc95xx_tx_fixup, 1969 .status = smsc95xx_status, 1970 .manage_power = smsc95xx_manage_power, 1971 .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR, 1972}; 1973 1974static const struct usb_device_id products[] = { --- 112 unchanged lines hidden --- |