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 92 To compile this driver as a module, choose M here: the 93 93 module will be called rtl8150. 94 94 95 + config USB_USBNET_MII 96 + tristate 97 + default n 98 + 95 99 config USB_USBNET 96 100 tristate "Multi-purpose USB Networking Framework" 101 + select MII if USBNET_MII != n 97 102 ---help--- 98 103 This driver supports several kinds of network links over USB, 99 104 with "minidrivers" built around a common network driver core ··· 134 129 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 135 130 depends on USB_USBNET && NET_ETHERNET 136 131 select CRC32 137 - select MII 132 + select USB_USBNET_MII 138 133 default y 139 134 help 140 135 This option adds support for ASIX AX88xxx based USB 2.0 ··· 215 210 config USB_NET_MCS7830 216 211 tristate "MosChip MCS7830 based Ethernet adapters" 217 212 depends on USB_USBNET 213 + select USB_USBNET_MII 218 214 help 219 215 Choose this option if you're using a 10/100 Ethernet USB2 220 216 adapter based on the MosChip 7830 controller. This includes
+32 -26
drivers/usb/net/usbnet.c
··· 669 669 * they'll probably want to use this base set. 670 670 */ 671 671 672 + #if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE) 673 + #define HAVE_MII 674 + 672 675 int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) 673 676 { 674 677 struct usbnet *dev = netdev_priv(net); ··· 702 699 } 703 700 EXPORT_SYMBOL_GPL(usbnet_set_settings); 704 701 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 702 u32 usbnet_get_link (struct net_device *net) 720 703 { 721 704 struct usbnet *dev = netdev_priv(net); ··· 719 730 } 720 731 EXPORT_SYMBOL_GPL(usbnet_get_link); 721 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 + 722 759 u32 usbnet_get_msglevel (struct net_device *net) 723 760 { 724 761 struct usbnet *dev = netdev_priv(net); ··· 761 746 } 762 747 EXPORT_SYMBOL_GPL(usbnet_set_msglevel); 763 748 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 749 /* drivers may override default ethtool_ops in their bind() routine */ 776 750 static struct ethtool_ops usbnet_ethtool_ops = { 751 + #ifdef HAVE_MII 777 752 .get_settings = usbnet_get_settings, 778 753 .set_settings = usbnet_set_settings, 779 - .get_drvinfo = usbnet_get_drvinfo, 780 754 .get_link = usbnet_get_link, 781 755 .nway_reset = usbnet_nway_reset, 756 + #endif 757 + .get_drvinfo = usbnet_get_drvinfo, 782 758 .get_msglevel = usbnet_get_msglevel, 783 759 .set_msglevel = usbnet_set_msglevel, 784 760 };