Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-drm-fsl-dcu.git] / net / irda / iriap.c
index 2d2e2b1919f40f70230c1527edbf8bb0c23d5fa4..98b0fa9657908b7600faff555b2446b887e4d0b4 100644 (file)
  *
  ********************************************************************/
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
+#include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
@@ -79,10 +79,10 @@ static int iriap_data_indication(void *instance, void *sap,
 
 static void iriap_watchdog_timer_expired(void *data);
 
-static inline void iriap_start_watchdog_timer(struct iriap_cb *self, 
-                                             int timeout) 
+static inline void iriap_start_watchdog_timer(struct iriap_cb *self,
+                                             int timeout)
 {
-       irda_start_timer(&self->watchdog_timer, timeout, self, 
+       irda_start_timer(&self->watchdog_timer, timeout, self,
                         iriap_watchdog_timer_expired);
 }
 
@@ -173,7 +173,7 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
-       self = kmalloc(sizeof(struct iriap_cb), GFP_ATOMIC);
+       self = kzalloc(sizeof(*self), GFP_ATOMIC);
        if (!self) {
                IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
                return NULL;
@@ -182,7 +182,6 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
        /*
         *  Initialize instance
         */
-       memset(self, 0, sizeof(struct iriap_cb));
 
        self->magic = IAS_MAGIC;
        self->mode = mode;
@@ -346,10 +345,11 @@ static void iriap_disconnect_request(struct iriap_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
 
-       tx_skb = dev_alloc_skb(64);
+       tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
        if (tx_skb == NULL) {
-               IRDA_DEBUG(0, "%s(), Could not allocate an sk_buff of length %d\n", 
-                       __FUNCTION__, 64);
+               IRDA_DEBUG(0,
+                          "%s(), Could not allocate an sk_buff of length %d\n",
+                          __FUNCTION__, LMP_MAX_HEADER);
                return;
        }
 
@@ -397,7 +397,7 @@ int iriap_getvaluebyclass_request(struct iriap_cb *self,
        attr_len = strlen(attr);        /* Up to IAS_MAX_ATTRIBNAME = 60 */
 
        skb_len = self->max_header_size+2+name_len+1+attr_len+4;
-       tx_skb = dev_alloc_skb(skb_len);
+       tx_skb = alloc_skb(skb_len, GFP_ATOMIC);
        if (!tx_skb)
                return -ENOMEM;
 
@@ -451,12 +451,12 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
        n = 2;
 
        /* Get length, MSB first */
-       len = be16_to_cpu(get_unaligned((__u16 *)(fp+n))); n += 2;
+       len = be16_to_cpu(get_unaligned((__be16 *)(fp+n))); n += 2;
 
        IRDA_DEBUG(4, "%s(), len=%d\n", __FUNCTION__, len);
 
        /* Get object ID, MSB first */
-       obj_id = be16_to_cpu(get_unaligned((__u16 *)(fp+n))); n += 2;
+       obj_id = be16_to_cpu(get_unaligned((__be16 *)(fp+n))); n += 2;
 
        type = fp[n++];
        IRDA_DEBUG(4, "%s(), Value type = %d\n", __FUNCTION__, type);
@@ -506,7 +506,7 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
                value = irias_new_string_value(fp+n);
                break;
        case IAS_OCT_SEQ:
-               value_len = be16_to_cpu(get_unaligned((__u16 *)(fp+n)));
+               value_len = be16_to_cpu(get_unaligned((__be16 *)(fp+n)));
                n += 2;
 
                /* Will truncate to IAS_MAX_OCTET_STRING bytes */
@@ -544,7 +544,7 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
 {
        struct sk_buff *tx_skb;
        int n;
-       __u32 tmp_be32;
+       __be32 tmp_be32;
        __be16 tmp_be16;
        __u8 *fp;
 
@@ -563,7 +563,8 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
         *  value. We add 32 bytes because of the 6 bytes for the frame and
         *  max 5 bytes for the value coding.
         */
-       tx_skb = dev_alloc_skb(value->len + self->max_header_size + 32);
+       tx_skb = alloc_skb(value->len + self->max_header_size + 32,
+                          GFP_ATOMIC);
        if (!tx_skb)
                return;
 
@@ -673,7 +674,7 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self,
        if (attrib == NULL) {
                IRDA_DEBUG(2, "LM-IAS: Attribute %s not found\n", attr);
                iriap_getvaluebyclass_response(self, obj->id,
-                                              IAS_ATTRIB_UNKNOWN, 
+                                              IAS_ATTRIB_UNKNOWN,
                                               &irias_missing);
                return;
        }
@@ -701,7 +702,7 @@ void iriap_send_ack(struct iriap_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
 
-       tx_skb = dev_alloc_skb(64);
+       tx_skb = alloc_skb(LMP_MAX_HEADER + 1, GFP_ATOMIC);
        if (!tx_skb)
                return;
 
@@ -970,7 +971,7 @@ static const char *ias_value_types[] = {
        "IAS_STRING"
 };
 
-static inline struct ias_object *irias_seq_idx(loff_t pos) 
+static inline struct ias_object *irias_seq_idx(loff_t pos)
 {
        struct ias_object *obj;
 
@@ -979,7 +980,7 @@ static inline struct ias_object *irias_seq_idx(loff_t pos)
                if (pos-- == 0)
                        break;
        }
-               
+
        return obj;
 }
 
@@ -994,7 +995,7 @@ static void *irias_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
 
-       return (v == SEQ_START_TOKEN) 
+       return (v == SEQ_START_TOKEN)
                ? (void *) hashbin_get_first(irias_objects)
                : (void *) hashbin_get_next(irias_objects);
 }
@@ -1026,7 +1027,7 @@ static int irias_seq_show(struct seq_file *seq, void *v)
                for (attrib = (struct ias_attrib *) hashbin_get_first(obj->attribs);
                     attrib != NULL;
                     attrib = (struct ias_attrib *) hashbin_get_next(obj->attribs)) {
-                    
+
                        IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC,
                                    goto outloop; );
 
@@ -1045,14 +1046,14 @@ static int irias_seq_show(struct seq_file *seq, void *v)
                                           attrib->value->t.string);
                                break;
                        case IAS_OCT_SEQ:
-                               seq_printf(seq, "octet sequence (%d bytes)\n", 
+                               seq_printf(seq, "octet sequence (%d bytes)\n",
                                           attrib->value->len);
                                break;
                        case IAS_MISSING:
                                seq_puts(seq, "missing\n");
                                break;
                        default:
-                               seq_printf(seq, "type %d?\n", 
+                               seq_printf(seq, "type %d?\n",
                                           attrib->value->type);
                        }
                        seq_putc(seq, '\n');