Re: Fix g_ether ethtool link reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 04, 2009 at 01:45:17PM -0800, David Brownell wrote:
> On Wednesday 04 March 2009, Jonathan McDowell wrote:
> > The g_ether USB gadget driver currently decides whether or not there's a
> > link to report back for eth_get_link based on if the USB link speed is
> > set. The USB gadget speed is however often set even before the device is
> > enumerated. It seems more sensible to only report a "link" if we're
> > actually connected to a host that wants to talk to us. The patch below
> > does this for me - tested with the PXA27x UDC driver.
> > 
> > Signed-Off-By: Jonathan McDowell <noodles@xxxxxxxx>
> 
> Wouldn't it make more sense to use ethtool_op_get_link()
> instead of this private function?  That utility looks
> new, else it surely would have been used a long time ago.
 
That looks viable, and gives the below. It's not actually detecting the
link going away again for me at present (it correctly says no link until
the cable is plugged in and enumerated), but neither is the patch I sent
yesterday any more so I've broken something separately.

Signed-Off-By: Jonathan McDowell <noodles@xxxxxxxx>

-----
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 96d65ca..4007770 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -175,12 +175,6 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)
 	strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info);
 }
 
-static u32 eth_get_link(struct net_device *net)
-{
-	struct eth_dev	*dev = netdev_priv(net);
-	return dev->gadget->speed != USB_SPEED_UNKNOWN;
-}
-
 /* REVISIT can also support:
  *   - WOL (by tracking suspends and issuing remote wakeup)
  *   - msglevel (implies updated messaging)
@@ -189,7 +183,7 @@ static u32 eth_get_link(struct net_device *net)
 
 static struct ethtool_ops ops = {
 	.get_drvinfo = eth_get_drvinfo,
-	.get_link = eth_get_link
+	.get_link = ethtool_op_get_link,
 };
 
 static void defer_kevent(struct eth_dev *dev, int flag)
-----

J.

-- 
I may be cool Beavis, but I can't change the future.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux