Commit 15b2d2b5 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

usb gadget: RNDIS cleanups

Some cleanup to the RNDIS code:

 - Minor bugfix:  rndis_unit() is supposed to put the link into the
   RNDIS_UNINITIALIZED state, which does not mean "unused".  There's
   a separate method to stop using the link.  (Bug doesn't affect
   anything right now because of how the code is used.)

 - Reduce coupling between RNDIS code and its user(s), in preparation
   for updates in that code:

    * Decouple RNDIS_RESPONSE_AVAILABLE notifications from net_device
      by passing just a void* handle.  (Also, remove the unused return
      value of the notification callback.)
    * When it needs a copy of net_device stats, just ask for it

 - Remove unused/untested code backing various never-used OIDs:

    * RNDIS_PM, RNDIS_WAKEUP ... "should" get implemented, but the
      relevant docs were unclear, ambguous, and incomplete.  Someone
      with access to the Hidden Gospels (maybe in the EU?) might be
      able to figure out what this should do.
    * RNDIS_OPTIONAL_STATS ... as the name suggests, optional.  Never
      implemented in part because not all the semantics were clear.
    * OID_GEN_RNDIS_CONFIG_PARAMETER, which has been #if 0 forever.

 - A few small whitespace fixes

Plus switch the VERBOSE symbol over to the newer VERBOSE_DEBUG style.

There should be no functional changes because of this patch; it's a
net source code shrink (because of the dead/unused code removal) and
a small object code shrink (a couple hundred bytes on ARMv5).
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7bb5ea54
...@@ -1106,6 +1106,8 @@ static void eth_reset_config (struct eth_dev *dev) ...@@ -1106,6 +1106,8 @@ static void eth_reset_config (struct eth_dev *dev)
netif_stop_queue (dev->net); netif_stop_queue (dev->net);
netif_carrier_off (dev->net); netif_carrier_off (dev->net);
/* RNDIS enters RNDIS_UNINITIALIZED state */
rndis_uninit(dev->rndis_config); rndis_uninit(dev->rndis_config);
/* disable endpoints, forcing (synchronous) completion of /* disable endpoints, forcing (synchronous) completion of
...@@ -1604,8 +1606,6 @@ eth_disconnect (struct usb_gadget *gadget) ...@@ -1604,8 +1606,6 @@ eth_disconnect (struct usb_gadget *gadget)
eth_reset_config (dev); eth_reset_config (dev);
spin_unlock_irqrestore (&dev->lock, flags); spin_unlock_irqrestore (&dev->lock, flags);
/* FIXME RNDIS should enter RNDIS_UNINITIALIZED */
/* next we may get setup() calls to enumerate new connections; /* next we may get setup() calls to enumerate new connections;
* or an unbind() during shutdown (including removing module). * or an unbind() during shutdown (including removing module).
*/ */
...@@ -2067,23 +2067,23 @@ rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req) ...@@ -2067,23 +2067,23 @@ rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
eth_req_free(ep, req); eth_req_free(ep, req);
} }
static int rndis_control_ack (struct net_device *net) static void rndis_resp_avail(void *_dev)
{ {
struct eth_dev *dev = netdev_priv(net); struct eth_dev *dev = _dev;
int length; int length;
struct usb_request *resp = dev->stat_req; struct usb_request *resp = dev->stat_req;
/* in case RNDIS calls this after disconnect */ /* in case RNDIS calls this after disconnect */
if (!dev->status) { if (!dev->status) {
DEBUG (dev, "status ENODEV\n"); DEBUG (dev, "status ENODEV\n");
return -ENODEV; return;
} }
/* in case queue length > 1 */ /* in case queue length > 1 */
if (resp->context) { if (resp->context) {
resp = eth_req_alloc (dev->status_ep, 8, GFP_ATOMIC); resp = eth_req_alloc (dev->status_ep, 8, GFP_ATOMIC);
if (!resp) if (!resp)
return -ENOMEM; return;
} }
/* Send RNDIS RESPONSE_AVAILABLE notification; /* Send RNDIS RESPONSE_AVAILABLE notification;
...@@ -2101,13 +2101,11 @@ static int rndis_control_ack (struct net_device *net) ...@@ -2101,13 +2101,11 @@ static int rndis_control_ack (struct net_device *net)
resp->status = 0; resp->status = 0;
rndis_control_ack_complete (dev->status_ep, resp); rndis_control_ack_complete (dev->status_ep, resp);
} }
return 0;
} }
#else #else
#define rndis_control_ack NULL #define rndis_resp_avail NULL
#endif /* RNDIS */ #endif /* RNDIS */
...@@ -2566,18 +2564,18 @@ eth_bind (struct usb_gadget *gadget) ...@@ -2566,18 +2564,18 @@ eth_bind (struct usb_gadget *gadget)
/* FIXME RNDIS vendor id == "vendor NIC code" == ? */ /* FIXME RNDIS vendor id == "vendor NIC code" == ? */
dev->rndis_config = rndis_register (rndis_control_ack); status = rndis_register(rndis_resp_avail, dev);
if (dev->rndis_config < 0) { if (status < 0) {
fail0: fail0:
unregister_netdev (dev->net); unregister_netdev (dev->net);
status = -ENODEV;
goto fail; goto fail;
} }
dev->rndis_config = status;
/* these set up a lot of the OIDs that RNDIS needs */ /* these set up a lot of the OIDs that RNDIS needs */
rndis_set_host_mac (dev->rndis_config, dev->host_mac); rndis_set_host_mac (dev->rndis_config, dev->host_mac);
if (rndis_set_param_dev (dev->rndis_config, dev->net, if (rndis_set_param_dev (dev->rndis_config, dev->net,
&dev->stats, &dev->cdc_filter)) &dev->cdc_filter))
goto fail0; goto fail0;
if (rndis_set_param_vendor(dev->rndis_config, vendorID, if (rndis_set_param_vendor(dev->rndis_config, vendorID,
manufacturer)) manufacturer))
......
This diff is collapsed.
...@@ -233,20 +233,19 @@ typedef struct rndis_params ...@@ -233,20 +233,19 @@ typedef struct rndis_params
const u8 *host_mac; const u8 *host_mac;
u16 *filter; u16 *filter;
struct net_device *dev; struct net_device *dev;
struct net_device_stats *stats;
u32 vendorID; u32 vendorID;
const char *vendorDescr; const char *vendorDescr;
int (*ack) (struct net_device *); void (*resp_avail)(void *v);
void *v;
struct list_head resp_queue; struct list_head resp_queue;
} rndis_params; } rndis_params;
/* RNDIS Message parser and other useless functions */ /* RNDIS Message parser and other useless functions */
int rndis_msg_parser (u8 configNr, u8 *buf); int rndis_msg_parser (u8 configNr, u8 *buf);
int rndis_register (int (*rndis_control_ack) (struct net_device *)); int rndis_register(void (*resp_avail)(void *v), void *v);
void rndis_deregister (int configNr); void rndis_deregister (int configNr);
int rndis_set_param_dev (u8 configNr, struct net_device *dev, int rndis_set_param_dev (u8 configNr, struct net_device *dev,
struct net_device_stats *stats,
u16 *cdc_filter); u16 *cdc_filter);
int rndis_set_param_vendor (u8 configNr, u32 vendorID, int rndis_set_param_vendor (u8 configNr, u32 vendorID,
const char *vendorDescr); const char *vendorDescr);
......
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