Merge branch 'sii-m15w' into upstream
[pandora-kernel.git] / net / irda / irttp.c
index 6602d90..42acf1c 100644 (file)
@@ -24,7 +24,6 @@
  *
  ********************************************************************/
 
-#include <linux/config.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
@@ -38,7 +37,7 @@
 #include <net/irda/parameters.h>
 #include <net/irda/irttp.h>
 
-static struct irttp_cb *irttp = NULL;
+static struct irttp_cb *irttp;
 
 static void __irttp_close_tsap(struct tsap_cb *self);
 
@@ -86,13 +85,9 @@ static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 };
  */
 int __init irttp_init(void)
 {
-       /* Initialize the irttp structure. */
-       if (irttp == NULL) {
-               irttp = kmalloc(sizeof(struct irttp_cb), GFP_KERNEL);
-               if (irttp == NULL)
-                       return -ENOMEM;
-       }
-       memset(irttp, 0, sizeof(struct irttp_cb));
+       irttp = kzalloc(sizeof(struct irttp_cb), GFP_KERNEL);
+       if (irttp == NULL)
+               return -ENOMEM;
 
        irttp->magic = TTP_MAGIC;
 
@@ -100,6 +95,7 @@ int __init irttp_init(void)
        if (!irttp->tsaps) {
                IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n",
                           __FUNCTION__);
+               kfree(irttp);
                return -ENOMEM;
        }
 
@@ -115,7 +111,6 @@ int __init irttp_init(void)
 void __exit irttp_cleanup(void) 
 {
        /* Check for main structure */
-       IRDA_ASSERT(irttp != NULL, return;);
        IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
 
        /*
@@ -310,7 +305,8 @@ static inline void irttp_fragment_skb(struct tsap_cb *self,
                IRDA_DEBUG(2, "%s(), fragmenting ...\n", __FUNCTION__);
 
                /* Make new segment */
-               frag = dev_alloc_skb(self->max_seg_size+self->max_header_size);
+               frag = alloc_skb(self->max_seg_size+self->max_header_size,
+                                GFP_ATOMIC);
                if (!frag)
                        return;
 
@@ -382,7 +378,6 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
        struct lsap_cb *lsap;
        notify_t ttp_notify;
 
-       IRDA_ASSERT(irttp != NULL, return NULL;);
        IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;);
 
        /* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to
@@ -394,12 +389,11 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
                return NULL;
        }
 
-       self = kmalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
+       self = kzalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
        if (self == NULL) {
                IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__);
                return NULL;
        }
-       memset(self, 0, sizeof(struct tsap_cb));
        spin_lock_init(&self->lock);
 
        /* Initialise todo timer */
@@ -810,7 +804,7 @@ static inline void irttp_give_credit(struct tsap_cb *self)
                   self->send_credit, self->avail_credit, self->remote_credit);
 
        /* Give credit to peer */
-       tx_skb = dev_alloc_skb(64);
+       tx_skb = alloc_skb(64, GFP_ATOMIC);
        if (!tx_skb)
                return;
 
@@ -1099,7 +1093,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
 
        /* Any userdata supplied? */
        if (userdata == NULL) {
-               tx_skb = dev_alloc_skb(64);
+               tx_skb = alloc_skb(64, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
@@ -1347,7 +1341,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
 
        /* Any userdata supplied? */
        if (userdata == NULL) {
-               tx_skb = dev_alloc_skb(64);
+               tx_skb = alloc_skb(64, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
@@ -1546,7 +1540,7 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
 
        if (!userdata) {
                struct sk_buff *tx_skb;
-               tx_skb = dev_alloc_skb(64);
+               tx_skb = alloc_skb(64, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
@@ -1880,10 +1874,8 @@ static int irttp_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct irttp_iter_state *s;
-       
-       IRDA_ASSERT(irttp != NULL, return -EINVAL;);
 
-       s = kmalloc(sizeof(*s), GFP_KERNEL);
+       s = kzalloc(sizeof(*s), GFP_KERNEL);
        if (!s)
                goto out;
 
@@ -1893,7 +1885,6 @@ static int irttp_seq_open(struct inode *inode, struct file *file)
 
        seq          = file->private_data;
        seq->private = s;
-       memset(s, 0, sizeof(*s));
 out:
        return rc;
 out_kfree: