rndis_host: allow rndis_wlan to see all indications
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Thu, 30 Jul 2009 16:41:52 +0000 (19:41 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 4 Aug 2009 20:44:17 +0000 (16:44 -0400)
Allow rndis_wlan to see all indications. Currently rndis_host lets rndis_wlan to
know about link state changes only, but there is whole set of other
802.11-specific indications that rndis_wlan should handle properly. So rename
link_change() to indication() and convert rndis_wlan to use it.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/usb/rndis_host.c
drivers/net/wireless/rndis_wlan.c
include/linux/usb/usbnet.h

index 2232232b79899dab8b6ce2f621742961fb26f647..d032bba9bc4cde252ef23518428f96eaa33df113 100644 (file)
@@ -64,6 +64,32 @@ void rndis_status(struct usbnet *dev, struct urb *urb)
 }
 EXPORT_SYMBOL_GPL(rndis_status);
 
+/*
+ * RNDIS indicate messages.
+ */
+static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
+                               int buflen)
+{
+       struct cdc_state *info = (void *)&dev->data;
+       struct device *udev = &info->control->dev;
+
+       if (dev->driver_info->indication) {
+               dev->driver_info->indication(dev, msg, buflen);
+       } else {
+               switch (msg->status) {
+               case RNDIS_STATUS_MEDIA_CONNECT:
+                       dev_info(udev, "rndis media connect\n");
+                       break;
+               case RNDIS_STATUS_MEDIA_DISCONNECT:
+                       dev_info(udev, "rndis media disconnect\n");
+                       break;
+               default:
+                       dev_info(udev, "rndis indication: 0x%08x\n",
+                                       le32_to_cpu(msg->status));
+               }
+       }
+}
+
 /*
  * RPC done RNDIS-style.  Caller guarantees:
  * - message is properly byteswapped
@@ -143,27 +169,9 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
                                        request_id, xid);
                                /* then likely retry */
                        } else switch (buf->msg_type) {
-                       case RNDIS_MSG_INDICATE: {      /* fault/event */
-                               struct rndis_indicate *msg = (void *)buf;
-                               int state = 0;
-
-                               switch (msg->status) {
-                               case RNDIS_STATUS_MEDIA_CONNECT:
-                                       state = 1;
-                               case RNDIS_STATUS_MEDIA_DISCONNECT:
-                                       dev_info(&info->control->dev,
-                                               "rndis media %sconnect\n",
-                                               !state?"dis":"");
-                                       if (dev->driver_info->link_change)
-                                               dev->driver_info->link_change(
-                                                       dev, state);
-                                       break;
-                               default:
-                                       dev_info(&info->control->dev,
-                                               "rndis indication: 0x%08x\n",
-                                               le32_to_cpu(msg->status));
-                               }
-                               }
+                       case RNDIS_MSG_INDICATE:        /* fault/event */
+                               rndis_msg_indicate(dev, (void *)buf, buflen);
+
                                break;
                        case RNDIS_MSG_KEEPALIVE: {     /* ping */
                                struct rndis_keepalive_c *msg = (void *)buf;
index f6dcbb168b78f1acba3ec741a1f2f131af03ac7d..6b6452b0e8c4388bd8928370ff846dfed99b0a5b 100644 (file)
@@ -2211,13 +2211,32 @@ static void rndis_wlan_set_multicast_list(struct net_device *dev)
        queue_work(priv->workqueue, &priv->work);
 }
 
-static void rndis_wlan_link_change(struct usbnet *usbdev, int state)
+static void rndis_wlan_indication(struct usbnet *usbdev, void *ind, int buflen)
 {
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
+       struct rndis_indicate *msg = ind;
 
        /* queue work to avoid recursive calls into rndis_command */
-       set_bit(state ? WORK_LINK_UP : WORK_LINK_DOWN, &priv->work_pending);
-       queue_work(priv->workqueue, &priv->work);
+       switch (msg->status) {
+       case RNDIS_STATUS_MEDIA_CONNECT:
+               devinfo(usbdev, "media connect");
+
+               set_bit(WORK_LINK_UP, &priv->work_pending);
+               queue_work(priv->workqueue, &priv->work);
+               break;
+
+       case RNDIS_STATUS_MEDIA_DISCONNECT:
+               devinfo(usbdev, "media disconnect");
+
+               set_bit(WORK_LINK_DOWN, &priv->work_pending);
+               queue_work(priv->workqueue, &priv->work);
+               break;
+
+       default:
+               devinfo(usbdev, "indication: 0x%08x",
+                               le32_to_cpu(msg->status));
+               break;
+       }
 }
 
 
@@ -2666,7 +2685,7 @@ static const struct driver_info   bcm4320b_info = {
        .reset =        rndis_wlan_reset,
        .stop =         rndis_wlan_stop,
        .early_init =   bcm4320b_early_init,
-       .link_change =  rndis_wlan_link_change,
+       .indication =   rndis_wlan_indication,
 };
 
 static const struct driver_info        bcm4320a_info = {
@@ -2681,7 +2700,7 @@ static const struct driver_info   bcm4320a_info = {
        .reset =        rndis_wlan_reset,
        .stop =         rndis_wlan_stop,
        .early_init =   bcm4320a_early_init,
-       .link_change =  rndis_wlan_link_change,
+       .indication =   rndis_wlan_indication,
 };
 
 static const struct driver_info rndis_wlan_info = {
@@ -2696,7 +2715,7 @@ static const struct driver_info rndis_wlan_info = {
        .reset =        rndis_wlan_reset,
        .stop =         rndis_wlan_stop,
        .early_init =   bcm4320a_early_init,
-       .link_change =  rndis_wlan_link_change,
+       .indication =   rndis_wlan_indication,
 };
 
 /*-------------------------------------------------------------------------*/
index c642f78dd9cf3b6163717730d6fd2b2e588933cd..de8b4b18961b35e154f33f2362bb4a319c9d1145 100644 (file)
@@ -122,9 +122,8 @@ struct driver_info {
         * right after minidriver have initialized hardware. */
        int     (*early_init)(struct usbnet *dev);
 
-       /* called by minidriver when link state changes, state: 0=disconnect,
-        * 1=connect */
-       void    (*link_change)(struct usbnet *dev, int state);
+       /* called by minidriver when receiving indication */
+       void    (*indication)(struct usbnet *dev, void *ind, int indlen);
 
        /* for new devices, use the descriptor-reading code instead */
        int             in;             /* rx endpoint */