Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[linux-drm-fsl-dcu.git] / net / irda / irlmp_frame.c
index 39761a1d18f53058e5c45490d44e5dfa3e647855..3750884094daf2996b04d89c2de7970cf7247113 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlmp_frame.c
  * Version:       0.9
  * Description:   IrLMP frame implementation
@@ -8,18 +8,18 @@
  * Created at:    Tue Aug 19 02:09:59 1997
  * Modified at:   Mon Dec 13 13:41:12 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>
  *     All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
- *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     Neither Dag Brattli nor University of Tromsø admit liability nor
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
@@ -34,7 +34,7 @@
 #include <net/irda/irlmp_frame.h>
 #include <net/irda/discovery.h>
 
-static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap, 
+static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap,
                                       __u8 slsap, int status, hashbin_t *);
 
 inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
@@ -44,7 +44,7 @@ inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
        skb->data[1] = slsap;
 
        if (expedited) {
-               IRDA_DEBUG(4, "%s(), sending expedited data\n", __FUNCTION__);
+               IRDA_DEBUG(4, "%s(), sending expedited data\n", __func__);
                irlap_data_request(self->irlap, skb, TRUE);
        } else
                irlap_data_request(self->irlap, skb, FALSE);
@@ -56,18 +56,18 @@ inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
  *    Send Link Control Frame to IrLAP
  */
 void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
-                       __u8 opcode, struct sk_buff *skb) 
+                       __u8 opcode, struct sk_buff *skb)
 {
        __u8 *frame;
-       
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
        IRDA_ASSERT(skb != NULL, return;);
-       
+
        frame = skb->data;
-       
+
        frame[0] = dlsap | CONTROL_BIT;
        frame[1] = slsap;
 
@@ -87,15 +87,15 @@ void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
  *    Used by IrLAP to pass received data frames to IrLMP layer
  *
  */
-void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb, 
+void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                                int unreliable)
 {
        struct lsap_cb *lsap;
        __u8   slsap_sel;   /* Source (this) LSAP address */
        __u8   dlsap_sel;   /* Destination LSAP address */
        __u8   *fp;
-       
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
@@ -104,11 +104,11 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
        fp = skb->data;
 
        /*
-        *  The next statements may be confusing, but we do this so that 
+        *  The next statements may be confusing, but we do this so that
         *  destination LSAP of received frame is source LSAP in our view
         */
-       slsap_sel = fp[0] & LSAP_MASK; 
-       dlsap_sel = fp[1];      
+       slsap_sel = fp[0] & LSAP_MASK;
+       dlsap_sel = fp[1];
 
        /*
         *  Check if this is an incoming connection, since we must deal with
@@ -117,37 +117,37 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
        if ((fp[0] & CONTROL_BIT) && (fp[2] == CONNECT_CMD)) {
                IRDA_DEBUG(3, "%s(), incoming connection, "
                           "source LSAP=%d, dest LSAP=%d\n",
-                          __FUNCTION__, slsap_sel, dlsap_sel);
-               
+                          __func__, slsap_sel, dlsap_sel);
+
                /* Try to find LSAP among the unconnected LSAPs */
                lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, CONNECT_CMD,
                                       irlmp->unconnected_lsaps);
-               
+
                /* Maybe LSAP was already connected, so try one more time */
                if (!lsap) {
-                       IRDA_DEBUG(1, "%s(), incoming connection for LSAP already connected\n", __FUNCTION__);
+                       IRDA_DEBUG(1, "%s(), incoming connection for LSAP already connected\n", __func__);
                        lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0,
                                               self->lsaps);
                }
        } else
-               lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0, 
+               lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0,
                                       self->lsaps);
-       
+
        if (lsap == NULL) {
                IRDA_DEBUG(2, "IrLMP, Sorry, no LSAP for received frame!\n");
                IRDA_DEBUG(2, "%s(), slsap_sel = %02x, dlsap_sel = %02x\n",
-                          __FUNCTION__, slsap_sel, dlsap_sel);
+                          __func__, slsap_sel, dlsap_sel);
                if (fp[0] & CONTROL_BIT) {
                        IRDA_DEBUG(2, "%s(), received control frame %02x\n",
-                                  __FUNCTION__, fp[2]);
+                                  __func__, fp[2]);
                } else {
-                       IRDA_DEBUG(2, "%s(), received data frame\n", __FUNCTION__);
+                       IRDA_DEBUG(2, "%s(), received data frame\n", __func__);
                }
                return;
        }
 
-       /* 
-        *  Check if we received a control frame? 
+       /*
+        *  Check if we received a control frame?
         */
        if (fp[0] & CONTROL_BIT) {
                switch (fp[2]) {
@@ -160,8 +160,8 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                        break;
                case DISCONNECT:
                        IRDA_DEBUG(4, "%s(), Disconnect indication!\n",
-                                  __FUNCTION__);
-                       irlmp_do_lsap_event(lsap, LM_DISCONNECT_INDICATION, 
+                                  __func__);
+                       irlmp_do_lsap_event(lsap, LM_DISCONNECT_INDICATION,
                                            skb);
                        break;
                case ACCESSMODE_CMD:
@@ -172,7 +172,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                        break;
                default:
                        IRDA_DEBUG(0, "%s(), Unknown control frame %02x\n",
-                                  __FUNCTION__, fp[2]);
+                                  __func__, fp[2]);
                        break;
                }
        } else if (unreliable) {
@@ -181,7 +181,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                        irlmp_udata_indication(lsap, skb);
                else
                        irlmp_do_lsap_event(lsap, LM_UDATA_INDICATION, skb);
-       } else {        
+       } else {
                /* Optimize and bypass the state machine if possible */
                if (lsap->lsap_state == LSAP_DATA_TRANSFER_READY)
                        irlmp_data_indication(lsap, skb);
@@ -193,7 +193,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
 /*
  * Function irlmp_link_unitdata_indication (self, skb)
  *
- *    
+ *
  *
  */
 #ifdef CONFIG_IRDA_ULTRA
@@ -205,8 +205,8 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
        __u8   pid;         /* Protocol identifier */
        __u8   *fp;
        unsigned long flags;
-       
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
@@ -215,25 +215,25 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
        fp = skb->data;
 
        /*
-        *  The next statements may be confusing, but we do this so that 
+        *  The next statements may be confusing, but we do this so that
         *  destination LSAP of received frame is source LSAP in our view
         */
-       slsap_sel = fp[0] & LSAP_MASK; 
+       slsap_sel = fp[0] & LSAP_MASK;
        dlsap_sel = fp[1];
        pid       = fp[2];
-       
+
        if (pid & 0x80) {
                IRDA_DEBUG(0, "%s(), extension in PID not supp!\n",
-                          __FUNCTION__);
+                          __func__);
                return;
        }
 
        /* Check if frame is addressed to the connectionless LSAP */
        if ((slsap_sel != LSAP_CONNLESS) || (dlsap_sel != LSAP_CONNLESS)) {
-               IRDA_DEBUG(0, "%s(), dropping frame!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), dropping frame!\n", __func__);
                return;
        }
-       
+
        /* Search the connectionless LSAP */
        spin_lock_irqsave(&irlmp->unconnected_lsaps->hb_spinlock, flags);
        lsap = (struct lsap_cb *) hashbin_get_first(irlmp->unconnected_lsaps);
@@ -241,10 +241,10 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
                /*
                 *  Check if source LSAP and dest LSAP selectors and PID match.
                 */
-               if ((lsap->slsap_sel == slsap_sel) && 
-                   (lsap->dlsap_sel == dlsap_sel) && 
-                   (lsap->pid == pid)) 
-               {                       
+               if ((lsap->slsap_sel == slsap_sel) &&
+                   (lsap->dlsap_sel == dlsap_sel) &&
+                   (lsap->pid == pid))
+               {
                        break;
                }
                lsap = (struct lsap_cb *) hashbin_get_next(irlmp->unconnected_lsaps);
@@ -254,7 +254,7 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
        if (lsap)
                irlmp_connless_data_indication(lsap, skb);
        else {
-               IRDA_DEBUG(0, "%s(), found no matching LSAP!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), found no matching LSAP!\n", __func__);
        }
 }
 #endif /* CONFIG_IRDA_ULTRA */
@@ -262,15 +262,15 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
 /*
  * Function irlmp_link_disconnect_indication (reason, userdata)
  *
- *    IrLAP has disconnected 
+ *    IrLAP has disconnected
  *
  */
-void irlmp_link_disconnect_indication(struct lap_cb *lap, 
-                                     struct irlap_cb *irlap, 
-                                     LAP_REASON reason, 
+void irlmp_link_disconnect_indication(struct lap_cb *lap,
+                                     struct irlap_cb *irlap,
+                                     LAP_REASON reason,
                                      struct sk_buff *skb)
 {
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        IRDA_ASSERT(lap != NULL, return;);
        IRDA_ASSERT(lap->magic == LMP_LAP_MAGIC, return;);
@@ -278,8 +278,8 @@ void irlmp_link_disconnect_indication(struct lap_cb *lap,
        lap->reason = reason;
        lap->daddr = DEV_ADDR_ANY;
 
-        /* FIXME: must do something with the skb if any */
-       
+       /* FIXME: must do something with the skb if any */
+
        /*
         *  Inform station state machine
         */
@@ -292,11 +292,11 @@ void irlmp_link_disconnect_indication(struct lap_cb *lap,
  *    Incoming LAP connection!
  *
  */
-void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr, 
+void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr,
                                   __u32 daddr, struct qos_info *qos,
-                                  struct sk_buff *skb) 
+                                  struct sk_buff *skb)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        /* Copy QoS settings for this session */
        self->qos = qos;
@@ -314,10 +314,10 @@ void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr,
  *    LAP connection confirmed!
  *
  */
-void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos, 
+void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos,
                                struct sk_buff *skb)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
@@ -359,7 +359,7 @@ void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos,
  *
  * Jean II
  */
-void irlmp_link_discovery_indication(struct lap_cb *self, 
+void irlmp_link_discovery_indication(struct lap_cb *self,
                                     discovery_t *discovery)
 {
        IRDA_ASSERT(self != NULL, return;);
@@ -367,7 +367,7 @@ void irlmp_link_discovery_indication(struct lap_cb *self,
 
        /* Add to main log, cleanup */
        irlmp_add_discovery(irlmp->cachelog, discovery);
-       
+
        /* Just handle it the same way as a discovery confirm,
         * bypass the LM_LAP state machine (see below) */
        irlmp_discovery_confirm(irlmp->cachelog, DISCOVERY_PASSIVE);
@@ -383,11 +383,11 @@ void irlmp_link_discovery_indication(struct lap_cb *self,
  */
 void irlmp_link_discovery_confirm(struct lap_cb *self, hashbin_t *log)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
-       
+
        /* Add to main log, cleanup */
        irlmp_add_discovery_log(irlmp->cachelog, log);
 
@@ -420,7 +420,7 @@ static inline void irlmp_update_cache(struct lap_cb *lap,
  *    Find handle associated with destination and source LSAP
  *
  * Any IrDA connection (LSAP/TSAP) is uniquely identified by
- * 3 parameters, the local lsap, the remote lsap and the remote address. 
+ * 3 parameters, the local lsap, the remote lsap and the remote address.
  * We may initiate multiple connections to the same remote service
  * (they will have different local lsap), a remote device may initiate
  * multiple connections to the same local service (they will have
@@ -433,20 +433,20 @@ static inline void irlmp_update_cache(struct lap_cb *lap,
  */
 static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
                                       __u8 slsap_sel, int status,
-                                      hashbin_t *queue) 
+                                      hashbin_t *queue)
 {
        struct lsap_cb *lsap;
        unsigned long flags;
-       
-       /* 
+
+       /*
         *  Optimize for the common case. We assume that the last frame
         *  received is in the same connection as the last one, so check in
         *  cache first to avoid the linear search
         */
 #ifdef CONFIG_IRDA_CACHE_LAST_LSAP
-       if ((self->cache.valid) && 
-           (self->cache.slsap_sel == slsap_sel) && 
-           (self->cache.dlsap_sel == dlsap_sel)) 
+       if ((self->cache.valid) &&
+           (self->cache.slsap_sel == slsap_sel) &&
+           (self->cache.dlsap_sel == dlsap_sel))
        {
                return (self->cache.lsap);
        }
@@ -456,14 +456,14 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
 
        lsap = (struct lsap_cb *) hashbin_get_first(queue);
        while (lsap != NULL) {
-               /* 
-                *  If this is an incoming connection, then the destination 
-                *  LSAP selector may have been specified as LM_ANY so that 
+               /*
+                *  If this is an incoming connection, then the destination
+                *  LSAP selector may have been specified as LM_ANY so that
                 *  any client can connect. In that case we only need to check
                 *  if the source LSAP (in our view!) match!
                 */
-               if ((status == CONNECT_CMD) && 
-                   (lsap->slsap_sel == slsap_sel) &&      
+               if ((status == CONNECT_CMD) &&
+                   (lsap->slsap_sel == slsap_sel) &&
                    (lsap->dlsap_sel == LSAP_ANY)) {
                        /* This is where the dest lsap sel is set on incoming
                         * lsaps */
@@ -473,8 +473,8 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
                /*
                 *  Check if source LSAP and dest LSAP selectors match.
                 */
-               if ((lsap->slsap_sel == slsap_sel) && 
-                   (lsap->dlsap_sel == dlsap_sel)) 
+               if ((lsap->slsap_sel == slsap_sel) &&
+                   (lsap->dlsap_sel == dlsap_sel))
                        break;
 
                lsap = (struct lsap_cb *) hashbin_get_next(queue);