Commit 18ee91fa authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

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: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9b823b43
...@@ -92,8 +92,13 @@ config USB_RTL8150 ...@@ -92,8 +92,13 @@ config USB_RTL8150
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called rtl8150. module will be called rtl8150.
config USB_USBNET_MII
tristate
default n
config USB_USBNET config USB_USBNET
tristate "Multi-purpose USB Networking Framework" tristate "Multi-purpose USB Networking Framework"
select MII if USBNET_MII != n
---help--- ---help---
This driver supports several kinds of network links over USB, This driver supports several kinds of network links over USB,
with "minidrivers" built around a common network driver core with "minidrivers" built around a common network driver core
...@@ -129,7 +134,7 @@ config USB_NET_AX8817X ...@@ -129,7 +134,7 @@ config USB_NET_AX8817X
tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters"
depends on USB_USBNET && NET_ETHERNET depends on USB_USBNET && NET_ETHERNET
select CRC32 select CRC32
select MII select USB_USBNET_MII
default y default y
help help
This option adds support for ASIX AX88xxx based USB 2.0 This option adds support for ASIX AX88xxx based USB 2.0
...@@ -210,6 +215,7 @@ config USB_NET_PLUSB ...@@ -210,6 +215,7 @@ config USB_NET_PLUSB
config USB_NET_MCS7830 config USB_NET_MCS7830
tristate "MosChip MCS7830 based Ethernet adapters" tristate "MosChip MCS7830 based Ethernet adapters"
depends on USB_USBNET depends on USB_USBNET
select USB_USBNET_MII
help help
Choose this option if you're using a 10/100 Ethernet USB2 Choose this option if you're using a 10/100 Ethernet USB2
adapter based on the MosChip 7830 controller. This includes adapter based on the MosChip 7830 controller. This includes
......
...@@ -669,6 +669,9 @@ static int usbnet_open (struct net_device *net) ...@@ -669,6 +669,9 @@ static int usbnet_open (struct net_device *net)
* they'll probably want to use this base set. * they'll probably want to use this base set.
*/ */
#if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE)
#define HAVE_MII
int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
...@@ -699,20 +702,6 @@ int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd) ...@@ -699,20 +702,6 @@ int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
} }
EXPORT_SYMBOL_GPL(usbnet_set_settings); EXPORT_SYMBOL_GPL(usbnet_set_settings);
void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
{
struct usbnet *dev = netdev_priv(net);
/* REVISIT don't always return "usbnet" */
strncpy (info->driver, driver_name, sizeof info->driver);
strncpy (info->version, DRIVER_VERSION, sizeof info->version);
strncpy (info->fw_version, dev->driver_info->description,
sizeof info->fw_version);
usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
}
EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
u32 usbnet_get_link (struct net_device *net) u32 usbnet_get_link (struct net_device *net)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
...@@ -730,40 +719,57 @@ u32 usbnet_get_link (struct net_device *net) ...@@ -730,40 +719,57 @@ u32 usbnet_get_link (struct net_device *net)
} }
EXPORT_SYMBOL_GPL(usbnet_get_link); EXPORT_SYMBOL_GPL(usbnet_get_link);
u32 usbnet_get_msglevel (struct net_device *net) int usbnet_nway_reset(struct net_device *net)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
return dev->msg_enable; if (!dev->mii.mdio_write)
return -EOPNOTSUPP;
return mii_nway_restart(&dev->mii);
} }
EXPORT_SYMBOL_GPL(usbnet_get_msglevel); EXPORT_SYMBOL_GPL(usbnet_nway_reset);
void usbnet_set_msglevel (struct net_device *net, u32 level) #endif /* HAVE_MII */
void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
dev->msg_enable = level; /* REVISIT don't always return "usbnet" */
strncpy (info->driver, driver_name, sizeof info->driver);
strncpy (info->version, DRIVER_VERSION, sizeof info->version);
strncpy (info->fw_version, dev->driver_info->description,
sizeof info->fw_version);
usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
} }
EXPORT_SYMBOL_GPL(usbnet_set_msglevel); EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
int usbnet_nway_reset(struct net_device *net) u32 usbnet_get_msglevel (struct net_device *net)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
if (!dev->mii.mdio_write) return dev->msg_enable;
return -EOPNOTSUPP; }
EXPORT_SYMBOL_GPL(usbnet_get_msglevel);
return mii_nway_restart(&dev->mii); void usbnet_set_msglevel (struct net_device *net, u32 level)
{
struct usbnet *dev = netdev_priv(net);
dev->msg_enable = level;
} }
EXPORT_SYMBOL_GPL(usbnet_nway_reset); EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
/* drivers may override default ethtool_ops in their bind() routine */ /* drivers may override default ethtool_ops in their bind() routine */
static struct ethtool_ops usbnet_ethtool_ops = { static struct ethtool_ops usbnet_ethtool_ops = {
#ifdef HAVE_MII
.get_settings = usbnet_get_settings, .get_settings = usbnet_get_settings,
.set_settings = usbnet_set_settings, .set_settings = usbnet_set_settings,
.get_drvinfo = usbnet_get_drvinfo,
.get_link = usbnet_get_link, .get_link = usbnet_get_link,
.nway_reset = usbnet_nway_reset, .nway_reset = usbnet_nway_reset,
#endif
.get_drvinfo = usbnet_get_drvinfo,
.get_msglevel = usbnet_get_msglevel, .get_msglevel = usbnet_get_msglevel,
.set_msglevel = usbnet_set_msglevel, .set_msglevel = usbnet_set_msglevel,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment