net 03/05: fib_rules: add oif classification
[safe/jmp/linux-2.6] / net / irda / irlap.c
index 7029618..356e65b 100644 (file)
@@ -29,7 +29,6 @@
  *
  ********************************************************************/
 
-#include <linux/config.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/skbuff.h>
@@ -64,7 +63,7 @@ static void irlap_init_qos_capabilities(struct irlap_cb *self,
                                        struct qos_info *qos_user);
 
 #ifdef CONFIG_IRDA_DEBUG
-static char *lap_reasons[] = {
+static const char *const lap_reasons[] = {
        "ERROR, NOT USED",
        "LAP_DISC_INDICATION",
        "LAP_NO_RESPONSE",
@@ -88,15 +87,15 @@ int __init irlap_init(void)
        /* Allocate master array */
        irlap = hashbin_new(HB_LOCK);
        if (irlap == NULL) {
-               IRDA_ERROR("%s: can't allocate irlap hashbin!\n",
-                          __FUNCTION__);
+               IRDA_ERROR("%s: can't allocate irlap hashbin!\n",
+                          __func__);
                return -ENOMEM;
        }
 
        return 0;
 }
 
-void __exit irlap_cleanup(void)
+void irlap_cleanup(void)
 {
        IRDA_ASSERT(irlap != NULL, return;);
 
@@ -114,14 +113,13 @@ struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos,
 {
        struct irlap_cb *self;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        /* Initialize the irlap structure. */
-       self = kmalloc(sizeof(struct irlap_cb), GFP_KERNEL);
+       self = kzalloc(sizeof(struct irlap_cb), GFP_KERNEL);
        if (self == NULL)
                return NULL;
 
-       memset(self, 0, sizeof(struct irlap_cb));
        self->magic = LAP_MAGIC;
 
        /* Make a binding between the layers */
@@ -217,7 +215,7 @@ void irlap_close(struct irlap_cb *self)
 {
        struct irlap_cb *lap;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -233,7 +231,7 @@ void irlap_close(struct irlap_cb *self)
        /* Be sure that we manage to remove ourself from the hash */
        lap = hashbin_remove(irlap, self->saddr, NULL);
        if (!lap) {
-               IRDA_DEBUG(1, "%s(), Didn't find myself!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Didn't find myself!\n", __func__);
                return;
        }
        __irlap_close(lap);
@@ -248,7 +246,7 @@ EXPORT_SYMBOL(irlap_close);
  */
 void irlap_connect_indication(struct irlap_cb *self, 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 == LAP_MAGIC, return;);
@@ -267,7 +265,7 @@ void irlap_connect_indication(struct irlap_cb *self, struct sk_buff *skb)
  */
 void irlap_connect_response(struct irlap_cb *self, struct sk_buff *userdata)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        irlap_do_event(self, CONNECT_RESPONSE, userdata, NULL);
 }
@@ -282,7 +280,7 @@ void irlap_connect_response(struct irlap_cb *self, struct sk_buff *userdata)
 void irlap_connect_request(struct irlap_cb *self, __u32 daddr,
                           struct qos_info *qos_user, int sniff)
 {
-       IRDA_DEBUG(3, "%s(), daddr=0x%08x\n", __FUNCTION__, daddr);
+       IRDA_DEBUG(3, "%s(), daddr=0x%08x\n", __func__, daddr);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -309,7 +307,7 @@ void irlap_connect_request(struct irlap_cb *self, __u32 daddr,
  */
 void irlap_connect_confirm(struct irlap_cb *self, 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 == LAP_MAGIC, return;);
@@ -346,7 +344,7 @@ void irlap_data_request(struct irlap_cb *self, struct sk_buff *skb,
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        IRDA_ASSERT(skb_headroom(skb) >= (LAP_ADDR_HEADER+LAP_CTRL_HEADER),
                    return;);
@@ -393,7 +391,7 @@ void irlap_unitdata_request(struct irlap_cb *self, struct sk_buff *skb)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        IRDA_ASSERT(skb_headroom(skb) >= (LAP_ADDR_HEADER+LAP_CTRL_HEADER),
               return;);
@@ -419,7 +417,7 @@ void irlap_unitdata_request(struct irlap_cb *self, struct sk_buff *skb)
 #ifdef CONFIG_IRDA_ULTRA
 void irlap_unitdata_indication(struct irlap_cb *self, struct sk_buff *skb)
 {
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -439,7 +437,7 @@ void irlap_unitdata_indication(struct irlap_cb *self, struct sk_buff *skb)
  */
 void irlap_disconnect_request(struct irlap_cb *self)
 {
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -460,7 +458,7 @@ void irlap_disconnect_request(struct irlap_cb *self)
                irlap_do_event(self, DISCONNECT_REQUEST, NULL, NULL);
                break;
        default:
-               IRDA_DEBUG(2, "%s(), disconnect pending!\n", __FUNCTION__);
+               IRDA_DEBUG(2, "%s(), disconnect pending!\n", __func__);
                self->disconnect_pending = TRUE;
                break;
        }
@@ -474,7 +472,7 @@ void irlap_disconnect_request(struct irlap_cb *self)
  */
 void irlap_disconnect_indication(struct irlap_cb *self, LAP_REASON reason)
 {
-       IRDA_DEBUG(1, "%s(), reason=%s\n", __FUNCTION__, lap_reasons[reason]);
+       IRDA_DEBUG(1, "%s(), reason=%s\n", __func__, lap_reasons[reason]);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -484,7 +482,7 @@ void irlap_disconnect_indication(struct irlap_cb *self, LAP_REASON reason)
 
        switch (reason) {
        case LAP_RESET_INDICATION:
-               IRDA_DEBUG(1, "%s(), Sending reset request!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Sending reset request!\n", __func__);
                irlap_do_event(self, RESET_REQUEST, NULL, NULL);
                break;
        case LAP_NO_RESPONSE:      /* FALLTROUGH */
@@ -495,7 +493,7 @@ void irlap_disconnect_indication(struct irlap_cb *self, LAP_REASON reason)
                                                 reason, NULL);
                break;
        default:
-               IRDA_ERROR("%s: Unknown reason %d\n", __FUNCTION__, reason);
+               IRDA_ERROR("%s: Unknown reason %d\n", __func__, reason);
        }
 }
 
@@ -513,7 +511,7 @@ void irlap_discovery_request(struct irlap_cb *self, discovery_t *discovery)
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
        IRDA_ASSERT(discovery != NULL, return;);
 
-       IRDA_DEBUG(4, "%s(), nslots = %d\n", __FUNCTION__, discovery->nslots);
+       IRDA_DEBUG(4, "%s(), nslots = %d\n", __func__, discovery->nslots);
 
        IRDA_ASSERT((discovery->nslots == 1) || (discovery->nslots == 6) ||
                    (discovery->nslots == 8) || (discovery->nslots == 16),
@@ -522,7 +520,7 @@ void irlap_discovery_request(struct irlap_cb *self, discovery_t *discovery)
        /* Discovery is only possible in NDM mode */
        if (self->state != LAP_NDM) {
                IRDA_DEBUG(4, "%s(), discovery only possible in NDM mode\n",
-                          __FUNCTION__);
+                          __func__);
                irlap_discovery_confirm(self, NULL);
                /* Note : in theory, if we are not in NDM, we could postpone
                 * the discovery like we do for connection request.
@@ -545,7 +543,7 @@ void irlap_discovery_request(struct irlap_cb *self, discovery_t *discovery)
 
        if (self->discovery_log == NULL) {
                IRDA_WARNING("%s(), Unable to allocate discovery log!\n",
-                            __FUNCTION__);
+                            __func__);
                return;
        }
 
@@ -600,7 +598,7 @@ void irlap_discovery_confirm(struct irlap_cb *self, hashbin_t *discovery_log)
  */
 void irlap_discovery_indication(struct irlap_cb *self, discovery_t *discovery)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -646,7 +644,7 @@ void irlap_status_indication(struct irlap_cb *self, int quality_of_link)
  */
 void irlap_reset_indication(struct irlap_cb *self)
 {
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -662,7 +660,7 @@ void irlap_reset_indication(struct irlap_cb *self)
  */
 void irlap_reset_confirm(void)
 {
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
 }
 
 /*
@@ -703,8 +701,8 @@ void irlap_update_nr_received(struct irlap_cb *self, int nr)
        int count = 0;
 
        /*
-         * Remove all the ack-ed frames from the window queue.
-         */
+        * Remove all the ack-ed frames from the window queue.
+        */
 
        /*
         *  Optimize for the common case. It is most likely that the receiver
@@ -762,7 +760,7 @@ int irlap_validate_nr_received(struct irlap_cb *self, int nr)
 {
        /*  nr as expected?  */
        if (nr == self->vs) {
-               IRDA_DEBUG(4, "%s(), expected!\n", __FUNCTION__);
+               IRDA_DEBUG(4, "%s(), expected!\n", __func__);
                return NR_EXPECTED;
        }
 
@@ -790,7 +788,7 @@ int irlap_validate_nr_received(struct irlap_cb *self, int nr)
  */
 void irlap_initiate_connection_state(struct irlap_cb *self)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -873,7 +871,7 @@ static void irlap_change_speed(struct irlap_cb *self, __u32 speed, int now)
 {
        struct sk_buff *skb;
 
-       IRDA_DEBUG(0, "%s(), setting speed to %d\n", __FUNCTION__, speed);
+       IRDA_DEBUG(0, "%s(), setting speed to %d\n", __func__, speed);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -883,8 +881,9 @@ static void irlap_change_speed(struct irlap_cb *self, __u32 speed, int now)
        /* Change speed now, or just piggyback speed on frames */
        if (now) {
                /* Send down empty frame to trigger speed change */
-               skb = dev_alloc_skb(0);
-               irlap_queue_xmit(self, skb);
+               skb = alloc_skb(0, GFP_ATOMIC);
+               if (skb)
+                       irlap_queue_xmit(self, skb);
        }
 }
 
@@ -915,7 +914,7 @@ static void irlap_init_qos_capabilities(struct irlap_cb *self,
         *  user may not have set all of them.
         */
        if (qos_user) {
-               IRDA_DEBUG(1, "%s(), Found user specified QoS!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Found user specified QoS!\n", __func__);
 
                if (qos_user->baud_rate.bits)
                        self->qos_rx.baud_rate.bits &= qos_user->baud_rate.bits;
@@ -945,7 +944,7 @@ static void irlap_init_qos_capabilities(struct irlap_cb *self,
  */
 void irlap_apply_default_connection_parameters(struct irlap_cb *self)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -1008,7 +1007,7 @@ void irlap_apply_default_connection_parameters(struct irlap_cb *self)
  */
 void irlap_apply_connection_parameters(struct irlap_cb *self, int now)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -1110,13 +1109,13 @@ static void *irlap_seq_start(struct seq_file *seq, loff_t *pos)
        spin_lock_irq(&irlap->hb_spinlock);
        iter->id = 0;
 
-       for (self = (struct irlap_cb *) hashbin_get_first(irlap); 
+       for (self = (struct irlap_cb *) hashbin_get_first(irlap);
             self; self = (struct irlap_cb *) hashbin_get_next(irlap)) {
                if (iter->id == *pos)
                        break;
                ++iter->id;
        }
-               
+
        return self;
 }
 
@@ -1138,7 +1137,7 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
 {
        const struct irlap_iter_state *iter = seq->private;
        const struct irlap_cb *self = v;
-       
+
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -EINVAL;);
 
        seq_printf(seq, "irlap%d ", iter->id);
@@ -1211,7 +1210,7 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static struct seq_operations irlap_seq_ops = {
+static const struct seq_operations irlap_seq_ops = {
        .start  = irlap_seq_start,
        .next   = irlap_seq_next,
        .stop   = irlap_seq_stop,
@@ -1220,33 +1219,14 @@ static struct seq_operations irlap_seq_ops = {
 
 static int irlap_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct irlap_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
-       
-       if (!s)
-               goto out;
-
-       if (irlap == NULL) {
-               rc = -EINVAL;
-               goto out_kfree;
-       }
+       if (irlap == NULL)
+               return -EINVAL;
 
-       rc = seq_open(file, &irlap_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq          = file->private_data;
-       seq->private = s;
-       memset(s, 0, sizeof(*s));
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &irlap_seq_ops,
+                       sizeof(struct irlap_iter_state));
 }
 
-struct file_operations irlap_seq_fops = {
+const struct file_operations irlap_seq_fops = {
        .owner          = THIS_MODULE,
        .open           = irlap_seq_open,
        .read           = seq_read,