ipv4: udp: fix short packet and bad checksum logging
[safe/jmp/linux-2.6] / net / irda / iriap.c
index dc5e34a..79a1e5a 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -44,7 +45,7 @@
 
 #ifdef CONFIG_IRDA_DEBUG
 /* FIXME: This one should go in irlmp.c */
-static const char *ias_charset_types[] = {
+static const char *const ias_charset_types[] = {
        "CS_ASCII",
        "CS_ISO_8859_1",
        "CS_ISO_8859_2",
@@ -108,7 +109,7 @@ int __init iriap_init(void)
        irias_objects = hashbin_new(HB_LOCK);
        if (!irias_objects) {
                IRDA_WARNING("%s: Can't allocate irias_objects hashbin!\n",
-                            __FUNCTION__);
+                            __func__);
                hashbin_delete(iriap, NULL);
                return -ENOMEM;
        }
@@ -139,7 +140,7 @@ int __init iriap_init(void)
         */
        server = iriap_open(LSAP_IAS, IAS_SERVER, NULL, NULL);
        if (!server) {
-               IRDA_DEBUG(0, "%s(), unable to open server\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), unable to open server\n", __func__);
                return -1;
        }
        iriap_register_lsap(server, LSAP_IAS, IAS_SERVER);
@@ -171,11 +172,11 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
 {
        struct iriap_cb *self;
 
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        self = kzalloc(sizeof(*self), GFP_ATOMIC);
        if (!self) {
-               IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
+               IRDA_WARNING("%s: Unable to kmalloc!\n", __func__);
                return NULL;
        }
 
@@ -217,7 +218,7 @@ EXPORT_SYMBOL(iriap_open);
  */
 static void __iriap_close(struct iriap_cb *self)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -241,7 +242,7 @@ void iriap_close(struct iriap_cb *self)
 {
        struct iriap_cb *entry;
 
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -262,7 +263,7 @@ static int iriap_register_lsap(struct iriap_cb *self, __u8 slsap_sel, int mode)
 {
        notify_t notify;
 
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        irda_notify_init(&notify);
        notify.connect_confirm       = iriap_connect_confirm;
@@ -277,7 +278,7 @@ static int iriap_register_lsap(struct iriap_cb *self, __u8 slsap_sel, int mode)
 
        self->lsap = irlmp_open_lsap(slsap_sel, &notify, 0);
        if (self->lsap == NULL) {
-               IRDA_ERROR("%s: Unable to allocated LSAP!\n", __FUNCTION__);
+               IRDA_ERROR("%s: Unable to allocated LSAP!\n", __func__);
                return -1;
        }
        self->slsap_sel = self->lsap->slsap_sel;
@@ -297,7 +298,7 @@ static void iriap_disconnect_indication(void *instance, void *sap,
 {
        struct iriap_cb *self;
 
-       IRDA_DEBUG(4, "%s(), reason=%s\n", __FUNCTION__, irlmp_reasons[reason]);
+       IRDA_DEBUG(4, "%s(), reason=%s\n", __func__, irlmp_reasons[reason]);
 
        self = (struct iriap_cb *) instance;
 
@@ -313,7 +314,7 @@ static void iriap_disconnect_indication(void *instance, void *sap,
                dev_kfree_skb(skb);
 
        if (self->mode == IAS_CLIENT) {
-               IRDA_DEBUG(4, "%s(), disconnect as client\n", __FUNCTION__);
+               IRDA_DEBUG(4, "%s(), disconnect as client\n", __func__);
 
 
                iriap_do_client_event(self, IAP_LM_DISCONNECT_INDICATION,
@@ -326,7 +327,7 @@ static void iriap_disconnect_indication(void *instance, void *sap,
                if (self->confirm)
                        self->confirm(IAS_DISCONNECT, 0, NULL, self->priv);
        } else {
-               IRDA_DEBUG(4, "%s(), disconnect as server\n", __FUNCTION__);
+               IRDA_DEBUG(4, "%s(), disconnect as server\n", __func__);
                iriap_do_server_event(self, IAP_LM_DISCONNECT_INDICATION,
                                      NULL);
                iriap_close(self);
@@ -340,7 +341,7 @@ static void iriap_disconnect_request(struct iriap_cb *self)
 {
        struct sk_buff *tx_skb;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -349,7 +350,7 @@ static void iriap_disconnect_request(struct iriap_cb *self)
        if (tx_skb == NULL) {
                IRDA_DEBUG(0,
                           "%s(), Could not allocate an sk_buff of length %d\n",
-                          __FUNCTION__, LMP_MAX_HEADER);
+                          __func__, LMP_MAX_HEADER);
                return;
        }
 
@@ -451,15 +452,17 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
        n = 2;
 
        /* Get length, MSB first */
-       len = be16_to_cpu(get_unaligned((__be16 *)(fp+n))); n += 2;
+       len = get_unaligned_be16(fp + n);
+       n += 2;
 
-       IRDA_DEBUG(4, "%s(), len=%d\n", __FUNCTION__, len);
+       IRDA_DEBUG(4, "%s(), len=%d\n", __func__, len);
 
        /* Get object ID, MSB first */
-       obj_id = be16_to_cpu(get_unaligned((__be16 *)(fp+n))); n += 2;
+       obj_id = get_unaligned_be16(fp + n);
+       n += 2;
 
        type = fp[n++];
-       IRDA_DEBUG(4, "%s(), Value type = %d\n", __FUNCTION__, type);
+       IRDA_DEBUG(4, "%s(), Value type = %d\n", __func__, type);
 
        switch (type) {
        case IAS_INTEGER:
@@ -468,7 +471,7 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
                value = irias_new_integer_value(tmp_cpu32);
 
                /*  Legal values restricted to 0x01-0x6f, page 15 irttp */
-               IRDA_DEBUG(4, "%s(), lsap=%d\n", __FUNCTION__, value->t.integer);
+               IRDA_DEBUG(4, "%s(), lsap=%d\n", __func__, value->t.integer);
                break;
        case IAS_STRING:
                charset = fp[n++];
@@ -488,7 +491,7 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
 /*             case CS_UNICODE: */
                default:
                        IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
-                                  __FUNCTION__, ias_charset_types[charset]);
+                                  __func__, ias_charset_types[charset]);
 
                        /* Aborting, close connection! */
                        iriap_disconnect_request(self);
@@ -496,7 +499,7 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
                        /* break; */
                }
                value_len = fp[n++];
-               IRDA_DEBUG(4, "%s(), strlen=%d\n", __FUNCTION__, value_len);
+               IRDA_DEBUG(4, "%s(), strlen=%d\n", __func__, value_len);
 
                /* Make sure the string is null-terminated */
                fp[n+value_len] = 0x00;
@@ -506,7 +509,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((__be16 *)(fp+n)));
+               value_len = get_unaligned_be16(fp + n);
                n += 2;
 
                /* Will truncate to IAS_MAX_OCTET_STRING bytes */
@@ -526,7 +529,7 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
        if (self->confirm)
                self->confirm(IAS_SUCCESS, obj_id, value, self->priv);
        else {
-               IRDA_DEBUG(0, "%s(), missing handler!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), missing handler!\n", __func__);
                irias_delete_value(value);
        }
 }
@@ -548,7 +551,7 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
        __be16 tmp_be16;
        __u8 *fp;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -579,7 +582,7 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
        fp[n++] = ret_code;
 
        /* Insert list length (MSB first) */
-       tmp_be16 = __constant_htons(0x0001);
+       tmp_be16 = htons(0x0001);
        memcpy(fp+n, &tmp_be16, 2);  n += 2;
 
        /* Insert object identifier ( MSB first) */
@@ -610,12 +613,12 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
                memcpy(fp+n, value->t.oct_seq, value->len); n+=value->len;
                break;
        case IAS_MISSING:
-               IRDA_DEBUG( 3, "%s: sending IAS_MISSING\n", __FUNCTION__);
+               IRDA_DEBUG( 3, "%s: sending IAS_MISSING\n", __func__);
                skb_put(tx_skb, 1);
                fp[n++] = value->type;
                break;
        default:
-               IRDA_DEBUG(0, "%s(), type not implemented!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), type not implemented!\n", __func__);
                break;
        }
        iriap_do_r_connect_event(self, IAP_CALL_RESPONSE, tx_skb);
@@ -642,7 +645,7 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self,
        __u8 *fp;
        int n;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -697,7 +700,7 @@ void iriap_send_ack(struct iriap_cb *self)
        struct sk_buff *tx_skb;
        __u8 *frame;
 
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -728,7 +731,7 @@ void iriap_connect_request(struct iriap_cb *self)
                                    self->saddr, self->daddr,
                                    NULL, NULL);
        if (ret < 0) {
-               IRDA_DEBUG(0, "%s(), connect failed!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), connect failed!\n", __func__);
                self->confirm(IAS_DISCONNECT, 0, NULL, self->priv);
        }
 }
@@ -776,7 +779,7 @@ static void iriap_connect_indication(void *instance, void *sap,
 {
        struct iriap_cb *self, *new;
 
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
 
        self = (struct iriap_cb *) instance;
 
@@ -787,14 +790,14 @@ static void iriap_connect_indication(void *instance, void *sap,
        /* Start new server */
        new = iriap_open(LSAP_IAS, IAS_SERVER, NULL, NULL);
        if (!new) {
-               IRDA_DEBUG(0, "%s(), open failed\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), open failed\n", __func__);
                goto out;
        }
 
        /* Now attach up the new "socket" */
        new->lsap = irlmp_dup(self->lsap, new);
        if (!new->lsap) {
-               IRDA_DEBUG(0, "%s(), dup failed!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), dup failed!\n", __func__);
                goto out;
        }
 
@@ -824,7 +827,7 @@ static int iriap_data_indication(void *instance, void *sap,
        __u8  *frame;
        __u8  opcode;
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        self = (struct iriap_cb *) instance;
 
@@ -836,7 +839,7 @@ static int iriap_data_indication(void *instance, void *sap,
 
        if (self->mode == IAS_SERVER) {
                /* Call server */
-               IRDA_DEBUG(4, "%s(), Calling server!\n", __FUNCTION__);
+               IRDA_DEBUG(4, "%s(), Calling server!\n", __func__);
                iriap_do_r_connect_event(self, IAP_RECV_F_LST, skb);
                goto out;
        }
@@ -844,13 +847,13 @@ static int iriap_data_indication(void *instance, void *sap,
        if (~opcode & IAP_LST) {
                IRDA_WARNING("%s:, IrIAS multiframe commands or "
                             "results is not implemented yet!\n",
-                            __FUNCTION__);
+                            __func__);
                goto out;
        }
 
        /* Check for ack frames since they don't contain any data */
        if (opcode & IAP_ACK) {
-               IRDA_DEBUG(0, "%s() Got ack frame!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s() Got ack frame!\n", __func__);
                goto out;
        }
 
@@ -868,7 +871,7 @@ static int iriap_data_indication(void *instance, void *sap,
                        iriap_getvaluebyclass_confirm(self, skb);
                        break;
                case IAS_CLASS_UNKNOWN:
-                       IRDA_DEBUG(1, "%s(), No such class!\n", __FUNCTION__);
+                       IRDA_DEBUG(1, "%s(), No such class!\n", __func__);
                        /* Finished, close connection! */
                        iriap_disconnect_request(self);
 
@@ -881,7 +884,7 @@ static int iriap_data_indication(void *instance, void *sap,
                                              self->priv);
                        break;
                case IAS_ATTRIB_UNKNOWN:
-                       IRDA_DEBUG(1, "%s(), No such attribute!\n", __FUNCTION__);
+                       IRDA_DEBUG(1, "%s(), No such attribute!\n", __func__);
                        /* Finished, close connection! */
                        iriap_disconnect_request(self);
 
@@ -896,7 +899,7 @@ static int iriap_data_indication(void *instance, void *sap,
                }
                break;
        default:
-               IRDA_DEBUG(0, "%s(), Unknown op-code: %02x\n", __FUNCTION__,
+               IRDA_DEBUG(0, "%s(), Unknown op-code: %02x\n", __func__,
                           opcode);
                break;
        }
@@ -918,7 +921,7 @@ void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb)
        __u8 *fp;
        __u8 opcode;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
@@ -928,8 +931,8 @@ void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb)
 
        opcode = fp[0];
        if (~opcode & 0x80) {
-               IRDA_WARNING("%s: IrIAS multiframe commands or results"
-                            "is not implemented yet!\n", __FUNCTION__);
+               IRDA_WARNING("%s: IrIAS multiframe commands or results "
+                            "is not implemented yet!\n", __func__);
                return;
        }
        opcode &= 0x7f; /* Mask away LST bit */
@@ -937,7 +940,7 @@ void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb)
        switch (opcode) {
        case GET_INFO_BASE:
                IRDA_WARNING("%s: GetInfoBaseDetails not implemented yet!\n",
-                            __FUNCTION__);
+                            __func__);
                break;
        case GET_VALUE_BY_CLASS:
                iriap_getvaluebyclass_indication(self, skb);
@@ -964,7 +967,7 @@ static void iriap_watchdog_timer_expired(void *data)
 
 #ifdef CONFIG_PROC_FS
 
-static const char *ias_value_types[] = {
+static const char *const ias_value_types[] = {
        "IAS_MISSING",
        "IAS_INTEGER",
        "IAS_OCT_SEQ",