USB: use MII hooks only if CONFIG_MII is enabled

Fix mcs7830 patch

The recent mcs7830 update to make the MII support sharable goofed various
pre-existing configurations in two ways:

- it made the usbnet infrastructure reference MII symbols even
when they're not needed in the kernel being built

- it didn't enable MII along with the mcs7830 minidriver

This patch fixes these two problems.

However, there does seem to be a Kconfig reverse dependency bug in that MII
gets wrongly enabled in some cases (like USBNET=y and USBNET_MII=n); I think
I've noticed that same problem in other situations too. So the result can
mean kernels being bloated by stuff that's needlessly enabled ... better
than wrongly being disabled, but contributing to bloat.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by David Brownell and committed by Greg Kroah-Hartman 18ee91fa 9b823b43

+39 -27
+7 -1
drivers/usb/net/Kconfig
··· 92 To compile this driver as a module, choose M here: the 93 module will be called rtl8150. 94 95 config USB_USBNET 96 tristate "Multi-purpose USB Networking Framework" 97 ---help--- 98 This driver supports several kinds of network links over USB, 99 with "minidrivers" built around a common network driver core ··· 134 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 135 depends on USB_USBNET && NET_ETHERNET 136 select CRC32 137 - select MII 138 default y 139 help 140 This option adds support for ASIX AX88xxx based USB 2.0 ··· 215 config USB_NET_MCS7830 216 tristate "MosChip MCS7830 based Ethernet adapters" 217 depends on USB_USBNET 218 help 219 Choose this option if you're using a 10/100 Ethernet USB2 220 adapter based on the MosChip 7830 controller. This includes
··· 92 To compile this driver as a module, choose M here: the 93 module will be called rtl8150. 94 95 + config USB_USBNET_MII 96 + tristate 97 + default n 98 + 99 config USB_USBNET 100 tristate "Multi-purpose USB Networking Framework" 101 + select MII if USBNET_MII != n 102 ---help--- 103 This driver supports several kinds of network links over USB, 104 with "minidrivers" built around a common network driver core ··· 129 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 130 depends on USB_USBNET && NET_ETHERNET 131 select CRC32 132 + select USB_USBNET_MII 133 default y 134 help 135 This option adds support for ASIX AX88xxx based USB 2.0 ··· 210 config USB_NET_MCS7830 211 tristate "MosChip MCS7830 based Ethernet adapters" 212 depends on USB_USBNET 213 + select USB_USBNET_MII 214 help 215 Choose this option if you're using a 10/100 Ethernet USB2 216 adapter based on the MosChip 7830 controller. This includes
+32 -26
drivers/usb/net/usbnet.c
··· 669 * they'll probably want to use this base set. 670 */ 671 672 int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) 673 { 674 struct usbnet *dev = netdev_priv(net); ··· 702 } 703 EXPORT_SYMBOL_GPL(usbnet_set_settings); 704 705 - 706 - void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 707 - { 708 - struct usbnet *dev = netdev_priv(net); 709 - 710 - /* REVISIT don't always return "usbnet" */ 711 - strncpy (info->driver, driver_name, sizeof info->driver); 712 - strncpy (info->version, DRIVER_VERSION, sizeof info->version); 713 - strncpy (info->fw_version, dev->driver_info->description, 714 - sizeof info->fw_version); 715 - usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); 716 - } 717 - EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); 718 - 719 u32 usbnet_get_link (struct net_device *net) 720 { 721 struct usbnet *dev = netdev_priv(net); ··· 719 } 720 EXPORT_SYMBOL_GPL(usbnet_get_link); 721 722 u32 usbnet_get_msglevel (struct net_device *net) 723 { 724 struct usbnet *dev = netdev_priv(net); ··· 761 } 762 EXPORT_SYMBOL_GPL(usbnet_set_msglevel); 763 764 - int usbnet_nway_reset(struct net_device *net) 765 - { 766 - struct usbnet *dev = netdev_priv(net); 767 - 768 - if (!dev->mii.mdio_write) 769 - return -EOPNOTSUPP; 770 - 771 - return mii_nway_restart(&dev->mii); 772 - } 773 - EXPORT_SYMBOL_GPL(usbnet_nway_reset); 774 - 775 /* drivers may override default ethtool_ops in their bind() routine */ 776 static struct ethtool_ops usbnet_ethtool_ops = { 777 .get_settings = usbnet_get_settings, 778 .set_settings = usbnet_set_settings, 779 - .get_drvinfo = usbnet_get_drvinfo, 780 .get_link = usbnet_get_link, 781 .nway_reset = usbnet_nway_reset, 782 .get_msglevel = usbnet_get_msglevel, 783 .set_msglevel = usbnet_set_msglevel, 784 };
··· 669 * they'll probably want to use this base set. 670 */ 671 672 + #if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE) 673 + #define HAVE_MII 674 + 675 int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) 676 { 677 struct usbnet *dev = netdev_priv(net); ··· 699 } 700 EXPORT_SYMBOL_GPL(usbnet_set_settings); 701 702 u32 usbnet_get_link (struct net_device *net) 703 { 704 struct usbnet *dev = netdev_priv(net); ··· 730 } 731 EXPORT_SYMBOL_GPL(usbnet_get_link); 732 733 + int usbnet_nway_reset(struct net_device *net) 734 + { 735 + struct usbnet *dev = netdev_priv(net); 736 + 737 + if (!dev->mii.mdio_write) 738 + return -EOPNOTSUPP; 739 + 740 + return mii_nway_restart(&dev->mii); 741 + } 742 + EXPORT_SYMBOL_GPL(usbnet_nway_reset); 743 + 744 + #endif /* HAVE_MII */ 745 + 746 + void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 747 + { 748 + struct usbnet *dev = netdev_priv(net); 749 + 750 + /* REVISIT don't always return "usbnet" */ 751 + strncpy (info->driver, driver_name, sizeof info->driver); 752 + strncpy (info->version, DRIVER_VERSION, sizeof info->version); 753 + strncpy (info->fw_version, dev->driver_info->description, 754 + sizeof info->fw_version); 755 + usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); 756 + } 757 + EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); 758 + 759 u32 usbnet_get_msglevel (struct net_device *net) 760 { 761 struct usbnet *dev = netdev_priv(net); ··· 746 } 747 EXPORT_SYMBOL_GPL(usbnet_set_msglevel); 748 749 /* drivers may override default ethtool_ops in their bind() routine */ 750 static struct ethtool_ops usbnet_ethtool_ops = { 751 + #ifdef HAVE_MII 752 .get_settings = usbnet_get_settings, 753 .set_settings = usbnet_set_settings, 754 .get_link = usbnet_get_link, 755 .nway_reset = usbnet_nway_reset, 756 + #endif 757 + .get_drvinfo = usbnet_get_drvinfo, 758 .get_msglevel = usbnet_get_msglevel, 759 .set_msglevel = usbnet_set_msglevel, 760 };