tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / net / irda / irlmp.c
index 9df0461..0e7d8bd 100644 (file)
@@ -18,7 +18,7 @@
  *     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
+ *     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.
  *
@@ -76,7 +76,7 @@ const char *irlmp_reasons[] = {
  */
 int __init irlmp_init(void)
 {
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
        /* Initialize the irlmp structure. */
        irlmp = kzalloc( sizeof(struct irlmp_cb), GFP_KERNEL);
        if (irlmp == NULL)
@@ -103,9 +103,12 @@ int __init irlmp_init(void)
        irlmp->last_lsap_sel = 0x0f; /* Reserved 0x00-0x0f */
        strcpy(sysctl_devname, "Linux");
 
-       /* Do discovery every 3 seconds */
        init_timer(&irlmp->discovery_timer);
-       irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout*HZ);
+
+       /* Do discovery every 3 seconds, conditionally */
+       if (sysctl_discovery)
+               irlmp_start_discovery_timer(irlmp,
+                                           sysctl_discovery_timeout*HZ);
 
        return 0;
 }
@@ -116,7 +119,7 @@ int __init irlmp_init(void)
  *    Remove IrLMP layer
  *
  */
-void __exit irlmp_cleanup(void)
+void irlmp_cleanup(void)
 {
        /* Check for main structure */
        IRDA_ASSERT(irlmp != NULL, return;);
@@ -161,7 +164,7 @@ struct lsap_cb *irlmp_open_lsap(__u8 slsap_sel, notify_t *notify, __u8 pid)
        /* Allocate new instance of a LSAP connection */
        self = kzalloc(sizeof(struct lsap_cb), GFP_ATOMIC);
        if (self == NULL) {
-               IRDA_ERROR("%s: can't allocate memory\n", __FUNCTION__);
+               IRDA_ERROR("%s: can't allocate memory\n", __func__);
                return NULL;
        }
 
@@ -199,7 +202,7 @@ EXPORT_SYMBOL(irlmp_open_lsap);
  */
 static void __irlmp_close_lsap(struct lsap_cb *self)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LSAP_MAGIC, return;);
@@ -261,7 +264,7 @@ void irlmp_close_lsap(struct lsap_cb *self)
        if (!lsap) {
                IRDA_DEBUG(0,
                     "%s(), Looks like somebody has removed me already!\n",
-                          __FUNCTION__);
+                          __func__);
                return;
        }
        __irlmp_close_lsap(self);
@@ -288,7 +291,7 @@ void irlmp_register_link(struct irlap_cb *irlap, __u32 saddr, notify_t *notify)
         */
        lap = kzalloc(sizeof(struct lap_cb), GFP_KERNEL);
        if (lap == NULL) {
-               IRDA_ERROR("%s: unable to kmalloc\n", __FUNCTION__);
+               IRDA_ERROR("%s: unable to kmalloc\n", __func__);
                return;
        }
 
@@ -301,7 +304,7 @@ void irlmp_register_link(struct irlap_cb *irlap, __u32 saddr, notify_t *notify)
 #endif
        lap->lsaps = hashbin_new(HB_LOCK);
        if (lap->lsaps == NULL) {
-               IRDA_WARNING("%s(), unable to kmalloc lsaps\n", __FUNCTION__);
+               IRDA_WARNING("%s(), unable to kmalloc lsaps\n", __func__);
                kfree(lap);
                return;
        }
@@ -333,7 +336,7 @@ void irlmp_unregister_link(__u32 saddr)
 {
        struct lap_cb *link;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        /* We must remove ourselves from the hashbin *first*. This ensure
         * that no more LSAPs will be open on this link and no discovery
@@ -353,6 +356,7 @@ void irlmp_unregister_link(__u32 saddr)
                /* Final cleanup */
                del_timer(&link->idle_timer);
                link->magic = 0;
+               hashbin_delete(link->lsaps, (FREE_FUNC) __irlmp_close_lsap);
                kfree(link);
        }
 }
@@ -377,7 +381,7 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
 
        IRDA_DEBUG(2,
              "%s(), slsap_sel=%02x, dlsap_sel=%02x, saddr=%08x, daddr=%08x\n",
-             __FUNCTION__, self->slsap_sel, dlsap_sel, saddr, daddr);
+             __func__, self->slsap_sel, dlsap_sel, saddr, daddr);
 
        if (test_bit(0, &self->connected)) {
                ret = -EISCONN;
@@ -421,7 +425,7 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
                if (daddr != DEV_ADDR_ANY)
                        discovery = hashbin_find(irlmp->cachelog, daddr, NULL);
                else {
-                       IRDA_DEBUG(2, "%s(), no daddr\n", __FUNCTION__);
+                       IRDA_DEBUG(2, "%s(), no daddr\n", __func__);
                        discovery = (discovery_t *)
                                hashbin_get_first(irlmp->cachelog);
                }
@@ -434,7 +438,7 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
        }
        lap = hashbin_lock_find(irlmp->links, saddr, NULL);
        if (lap == NULL) {
-               IRDA_DEBUG(1, "%s(), Unable to find a usable link!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Unable to find a usable link!\n", __func__);
                ret = -EHOSTUNREACH;
                goto err;
        }
@@ -449,14 +453,14 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
                         * disconnected yet (waiting for timeout in LAP).
                         * Maybe we could give LAP a bit of help in this case.
                         */
-                       IRDA_DEBUG(0, "%s(), sorry, but I'm waiting for LAP to timeout!\n", __FUNCTION__);
+                       IRDA_DEBUG(0, "%s(), sorry, but I'm waiting for LAP to timeout!\n", __func__);
                        ret = -EAGAIN;
                        goto err;
                }
 
                /* LAP is already connected to a different node, and LAP
                 * can only talk to one node at a time */
-               IRDA_DEBUG(0, "%s(), sorry, but link is busy!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), sorry, but link is busy!\n", __func__);
                ret = -EBUSY;
                goto err;
        }
@@ -518,7 +522,7 @@ void irlmp_connect_indication(struct lsap_cb *self, struct sk_buff *skb)
        IRDA_ASSERT(self->lap != NULL, return;);
 
        IRDA_DEBUG(2, "%s(), slsap_sel=%02x, dlsap_sel=%02x\n",
-                  __FUNCTION__, self->slsap_sel, self->dlsap_sel);
+                  __func__, self->slsap_sel, self->dlsap_sel);
 
        /* Note : self->lap is set in irlmp_link_data_indication(),
         * (case CONNECT_CMD:) because we have no way to set it here.
@@ -559,7 +563,7 @@ int irlmp_connect_response(struct lsap_cb *self, struct sk_buff *userdata)
         * in the state machine itself. Jean II */
 
        IRDA_DEBUG(2, "%s(), slsap_sel=%02x, dlsap_sel=%02x\n",
-                  __FUNCTION__, self->slsap_sel, self->dlsap_sel);
+                  __func__, self->slsap_sel, self->dlsap_sel);
 
        /* Make room for MUX control header (3 bytes) */
        IRDA_ASSERT(skb_headroom(userdata) >= LMP_CONTROL_HEADER, return -1;);
@@ -585,7 +589,7 @@ void irlmp_connect_confirm(struct lsap_cb *self, struct sk_buff *skb)
        int lap_header_size;
        int max_seg_size;
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        IRDA_ASSERT(skb != NULL, return;);
        IRDA_ASSERT(self != NULL, return;);
@@ -599,7 +603,7 @@ void irlmp_connect_confirm(struct lsap_cb *self, struct sk_buff *skb)
        max_header_size = LMP_HEADER + lap_header_size;
 
        IRDA_DEBUG(2, "%s(), max_header_size=%d\n",
-                  __FUNCTION__, max_header_size);
+                  __func__, max_header_size);
 
        /* Hide LMP_CONTROL_HEADER header from layer above */
        skb_pull(skb, LMP_CONTROL_HEADER);
@@ -625,7 +629,7 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
        struct lsap_cb *new;
        unsigned long flags;
 
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
 
        spin_lock_irqsave(&irlmp->unconnected_lsaps->hb_spinlock, flags);
 
@@ -634,7 +638,7 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
        if ((!hashbin_find(irlmp->unconnected_lsaps, (long) orig, NULL)) ||
            (orig->lap == NULL)) {
                IRDA_DEBUG(0, "%s(), invalid LSAP (wrong state)\n",
-                          __FUNCTION__);
+                          __func__);
                spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock,
                                       flags);
                return NULL;
@@ -643,7 +647,7 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
        /* Allocate a new instance */
        new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
        if (!new)  {
-               IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __func__);
                spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock,
                                       flags);
                return NULL;
@@ -689,7 +693,7 @@ int irlmp_disconnect_request(struct lsap_cb *self, struct sk_buff *userdata)
         * and us that might mess up the hashbins below. This fixes it.
         * Jean II */
        if (! test_and_clear_bit(0, &self->connected)) {
-               IRDA_DEBUG(0, "%s(), already disconnected!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), already disconnected!\n", __func__);
                dev_kfree_skb(userdata);
                return -1;
        }
@@ -743,19 +747,19 @@ void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason,
 {
        struct lsap_cb *lsap;
 
-       IRDA_DEBUG(1, "%s(), reason=%s\n", __FUNCTION__, irlmp_reasons[reason]);
+       IRDA_DEBUG(1, "%s(), reason=%s\n", __func__, irlmp_reasons[reason]);
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LSAP_MAGIC, return;);
 
        IRDA_DEBUG(3, "%s(), slsap_sel=%02x, dlsap_sel=%02x\n",
-                  __FUNCTION__, self->slsap_sel, self->dlsap_sel);
+                  __func__, self->slsap_sel, self->dlsap_sel);
 
        /* Already disconnected ?
         * There is a race condition between irlmp_disconnect_request()
         * and us that might mess up the hashbins below. This fixes it.
         * Jean II */
        if (! test_and_clear_bit(0, &self->connected)) {
-               IRDA_DEBUG(0, "%s(), already disconnected!\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), already disconnected!\n", __func__);
                return;
        }
 
@@ -788,7 +792,7 @@ void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason,
                self->notify.disconnect_indication(self->notify.instance,
                                                   self, reason, skb);
        } else {
-               IRDA_DEBUG(0, "%s(), no handler\n", __FUNCTION__);
+               IRDA_DEBUG(0, "%s(), no handler\n", __func__);
        }
 }
 
@@ -841,7 +845,7 @@ void irlmp_do_discovery(int nslots)
        /* Make sure the value is sane */
        if ((nslots != 1) && (nslots != 6) && (nslots != 8) && (nslots != 16)){
                IRDA_WARNING("%s: invalid value for number of slots!\n",
-                            __FUNCTION__);
+                            __func__);
                nslots = sysctl_discovery_slots = 8;
        }
 
@@ -959,7 +963,7 @@ irlmp_notify_client(irlmp_client_t *client,
        int     number;                 /* Number of nodes in the log */
        int     i;
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        /* Check if client wants or not partial/selective log (optimisation) */
        if (!client->disco_callback)
@@ -1010,7 +1014,7 @@ void irlmp_discovery_confirm(hashbin_t *log, DISCOVERY_MODE mode)
        irlmp_client_t *client;
        irlmp_client_t *client_next;
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        IRDA_ASSERT(log != NULL, return;);
 
@@ -1045,7 +1049,7 @@ void irlmp_discovery_expiry(discinfo_t *expiries, int number)
        irlmp_client_t *client_next;
        int             i;
 
-       IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(3, "%s()\n", __func__);
 
        IRDA_ASSERT(expiries != NULL, return;);
 
@@ -1058,7 +1062,8 @@ void irlmp_discovery_expiry(discinfo_t *expiries, int number)
                for(i = 0; i < number; i++) {
                        /* Check if we should notify client */
                        if ((client->expir_callback) &&
-                           (client->hint_mask.word & u16ho(expiries[i].hints)
+                           (client->hint_mask.word &
+                            get_unaligned((__u16 *)expiries[i].hints)
                             & 0x7f7f) )
                                client->expir_callback(&(expiries[i]),
                                                       EXPIRY_TIMEOUT,
@@ -1078,11 +1083,11 @@ void irlmp_discovery_expiry(discinfo_t *expiries, int number)
  */
 discovery_t *irlmp_get_discovery_response(void)
 {
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(irlmp != NULL, return NULL;);
 
-       u16ho(irlmp->discovery_rsp.data.hints) = irlmp->hints.word;
+       put_unaligned(irlmp->hints.word, (__u16 *)irlmp->discovery_rsp.data.hints);
 
        /*
         *  Set character set for device name (we use ASCII), and
@@ -1156,7 +1161,7 @@ int irlmp_udata_request(struct lsap_cb *self, struct sk_buff *userdata)
 {
        int     ret;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(userdata != NULL, return -1;);
 
@@ -1180,7 +1185,7 @@ int irlmp_udata_request(struct lsap_cb *self, struct sk_buff *userdata)
  */
 void irlmp_udata_indication(struct lsap_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 == LMP_LSAP_MAGIC, return;);
@@ -1207,7 +1212,7 @@ int irlmp_connless_data_request(struct lsap_cb *self, struct sk_buff *userdata,
        struct sk_buff *clone_skb;
        struct lap_cb *lap;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        IRDA_ASSERT(userdata != NULL, return -1;);
 
@@ -1258,7 +1263,7 @@ int irlmp_connless_data_request(struct lsap_cb *self, struct sk_buff *userdata,
 #ifdef CONFIG_IRDA_ULTRA
 void irlmp_connless_data_indication(struct lsap_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 == LMP_LSAP_MAGIC, return;);
@@ -1301,7 +1306,7 @@ void irlmp_status_indication(struct lap_cb *self,
                        curr->notify.status_indication(curr->notify.instance,
                                                       link, lock);
                else
-                       IRDA_DEBUG(2, "%s(), no handler\n", __FUNCTION__);
+                       IRDA_DEBUG(2, "%s(), no handler\n", __func__);
 
                curr = next;
        }
@@ -1329,7 +1334,7 @@ void irlmp_flow_indication(struct lap_cb *self, LOCAL_FLOW flow)
        /* Get the number of lsap. That's the only safe way to know
         * that we have looped around... - Jean II */
        lsap_todo = HASHBIN_GET_SIZE(self->lsaps);
-       IRDA_DEBUG(4, "%s() : %d lsaps to scan\n", __FUNCTION__, lsap_todo);
+       IRDA_DEBUG(4, "%s() : %d lsaps to scan\n", __func__, lsap_todo);
 
        /* Poll lsap in order until the queue is full or until we
         * tried them all.
@@ -1348,14 +1353,14 @@ void irlmp_flow_indication(struct lap_cb *self, LOCAL_FLOW flow)
                /* Uh-oh... Paranoia */
                if(curr == NULL)
                        break;
-               IRDA_DEBUG(4, "%s() : curr is %p, next was %p and is now %p, still %d to go - queue len = %d\n", __FUNCTION__, curr, next, self->flow_next, lsap_todo, IRLAP_GET_TX_QUEUE_LEN(self->irlap));
+               IRDA_DEBUG(4, "%s() : curr is %p, next was %p and is now %p, still %d to go - queue len = %d\n", __func__, curr, next, self->flow_next, lsap_todo, IRLAP_GET_TX_QUEUE_LEN(self->irlap));
 
                /* Inform lsap user that it can send one more packet. */
                if (curr->notify.flow_indication != NULL)
                        curr->notify.flow_indication(curr->notify.instance,
                                                     curr, flow);
                else
-                       IRDA_DEBUG(1, "%s(), no handler\n", __FUNCTION__);
+                       IRDA_DEBUG(1, "%s(), no handler\n", __func__);
        }
 }
 
@@ -1377,7 +1382,7 @@ __u8 *irlmp_hint_to_service(__u8 *hint)
         */
        service = kmalloc(16, GFP_ATOMIC);
        if (!service) {
-               IRDA_DEBUG(1, "%s(), Unable to kmalloc!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Unable to kmalloc!\n", __func__);
                return NULL;
        }
 
@@ -1478,12 +1483,12 @@ void *irlmp_register_service(__u16 hints)
 {
        irlmp_service_t *service;
 
-       IRDA_DEBUG(4, "%s(), hints = %04x\n", __FUNCTION__, hints);
+       IRDA_DEBUG(4, "%s(), hints = %04x\n", __func__, hints);
 
        /* Make a new registration */
        service = kmalloc(sizeof(irlmp_service_t), GFP_ATOMIC);
        if (!service) {
-               IRDA_DEBUG(1, "%s(), Unable to kmalloc!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Unable to kmalloc!\n", __func__);
                return NULL;
        }
        service->hints.word = hints;
@@ -1508,7 +1513,7 @@ int irlmp_unregister_service(void *handle)
        irlmp_service_t *service;
        unsigned long flags;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        if (!handle)
                return -1;
@@ -1516,7 +1521,7 @@ int irlmp_unregister_service(void *handle)
        /* Caller may call with invalid handle (it's legal) - Jean II */
        service = hashbin_lock_find(irlmp->services, (long) handle, NULL);
        if (!service) {
-               IRDA_DEBUG(1, "%s(), Unknown service!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Unknown service!\n", __func__);
                return -1;
        }
 
@@ -1553,13 +1558,13 @@ void *irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 disco_clb,
 {
        irlmp_client_t *client;
 
-       IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(1, "%s()\n", __func__);
        IRDA_ASSERT(irlmp != NULL, return NULL;);
 
        /* Make a new registration */
        client = kmalloc(sizeof(irlmp_client_t), GFP_ATOMIC);
        if (!client) {
-               IRDA_DEBUG( 1, "%s(), Unable to kmalloc!\n", __FUNCTION__);
+               IRDA_DEBUG( 1, "%s(), Unable to kmalloc!\n", __func__);
                return NULL;
        }
 
@@ -1595,7 +1600,7 @@ int irlmp_update_client(void *handle, __u16 hint_mask,
 
        client = hashbin_lock_find(irlmp->clients, (long) handle, NULL);
        if (!client) {
-               IRDA_DEBUG(1, "%s(), Unknown client!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Unknown client!\n", __func__);
                return -1;
        }
 
@@ -1618,7 +1623,7 @@ int irlmp_unregister_client(void *handle)
 {
        struct irlmp_client *client;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
        if (!handle)
                return -1;
@@ -1626,11 +1631,11 @@ int irlmp_unregister_client(void *handle)
        /* Caller may call with invalid handle (it's legal) - Jean II */
        client = hashbin_lock_find(irlmp->clients, (long) handle, NULL);
        if (!client) {
-               IRDA_DEBUG(1, "%s(), Unknown client!\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), Unknown client!\n", __func__);
                return -1;
        }
 
-       IRDA_DEBUG(4, "%s(), removing client!\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s(), removing client!\n", __func__);
        hashbin_remove_this(irlmp->clients, (irda_queue_t *) client);
        kfree(client);
 
@@ -1659,7 +1664,7 @@ static int irlmp_slsap_inuse(__u8 slsap_sel)
        IRDA_ASSERT(irlmp->magic == LMP_MAGIC, return TRUE;);
        IRDA_ASSERT(slsap_sel != LSAP_ANY, return TRUE;);
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+       IRDA_DEBUG(4, "%s()\n", __func__);
 
 #ifdef CONFIG_IRDA_ULTRA
        /* Accept all bindings to the connectionless LSAP */
@@ -1786,7 +1791,7 @@ static __u8 irlmp_find_free_slsap(void)
                        /* Make sure we terminate the loop */
                        if (wrapped++) {
                                IRDA_ERROR("%s: no more free LSAPs !\n",
-                                          __FUNCTION__);
+                                          __func__);
                                return 0;
                        }
                }
@@ -1801,7 +1806,7 @@ static __u8 irlmp_find_free_slsap(void)
        /* Got it ! */
        lsap_sel = irlmp->last_lsap_sel;
        IRDA_DEBUG(4, "%s(), found free lsap_sel=%02x\n",
-                  __FUNCTION__, lsap_sel);
+                  __func__, lsap_sel);
 
        return lsap_sel;
 }
@@ -1819,26 +1824,26 @@ LM_REASON irlmp_convert_lap_reason( LAP_REASON lap_reason)
 
        switch (lap_reason) {
        case LAP_DISC_INDICATION: /* Received a disconnect request from peer */
-               IRDA_DEBUG( 1, "%s(), LAP_DISC_INDICATION\n", __FUNCTION__);
+               IRDA_DEBUG( 1, "%s(), LAP_DISC_INDICATION\n", __func__);
                reason = LM_USER_REQUEST;
                break;
        case LAP_NO_RESPONSE:    /* To many retransmits without response */
-               IRDA_DEBUG( 1, "%s(), LAP_NO_RESPONSE\n", __FUNCTION__);
+               IRDA_DEBUG( 1, "%s(), LAP_NO_RESPONSE\n", __func__);
                reason = LM_LAP_DISCONNECT;
                break;
        case LAP_RESET_INDICATION:
-               IRDA_DEBUG( 1, "%s(), LAP_RESET_INDICATION\n", __FUNCTION__);
+               IRDA_DEBUG( 1, "%s(), LAP_RESET_INDICATION\n", __func__);
                reason = LM_LAP_RESET;
                break;
        case LAP_FOUND_NONE:
        case LAP_MEDIA_BUSY:
        case LAP_PRIMARY_CONFLICT:
-               IRDA_DEBUG(1, "%s(), LAP_FOUND_NONE, LAP_MEDIA_BUSY or LAP_PRIMARY_CONFLICT\n", __FUNCTION__);
+               IRDA_DEBUG(1, "%s(), LAP_FOUND_NONE, LAP_MEDIA_BUSY or LAP_PRIMARY_CONFLICT\n", __func__);
                reason = LM_CONNECT_FAILURE;
                break;
        default:
-               IRDA_DEBUG(1, "%s(), Unknow IrLAP disconnect reason %d!\n",
-                          __FUNCTION__, lap_reason);
+               IRDA_DEBUG(1, "%s(), Unknown IrLAP disconnect reason %d!\n",
+                          __func__, lap_reason);
                reason = LM_LAP_DISCONNECT;
                break;
        }
@@ -1994,7 +1999,7 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static struct seq_operations irlmp_seq_ops = {
+static const struct seq_operations irlmp_seq_ops = {
        .start  = irlmp_seq_start,
        .next   = irlmp_seq_next,
        .stop   = irlmp_seq_stop,
@@ -2003,27 +2008,10 @@ static struct seq_operations irlmp_seq_ops = {
 
 static int irlmp_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct irlmp_iter_state *s;
-
        IRDA_ASSERT(irlmp != NULL, return -EINVAL;);
 
-       s = kmalloc(sizeof(*s), GFP_KERNEL);
-       if (!s)
-               goto out;
-
-       rc = seq_open(file, &irlmp_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq          = file->private_data;
-       seq->private = s;
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &irlmp_seq_ops,
+                       sizeof(struct irlmp_iter_state));
 }
 
 const struct file_operations irlmp_seq_fops = {