include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / isdn / isdnloop / isdnloop.c
index 23afba4..b8a1098 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include "isdnloop.h"
@@ -415,7 +416,8 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
                spin_lock_irqsave(&card->isdnloop_lock, flags);
                nskb = dev_alloc_skb(skb->len);
                if (nskb) {
-                       memcpy(skb_put(nskb, len), skb->data, len);
+                       skb_copy_from_linear_data(skb,
+                                                 skb_put(nskb, len), len);
                        skb_queue_tail(&card->bqueue[channel], nskb);
                        dev_kfree_skb(skb);
                } else
@@ -446,7 +448,8 @@ isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card * card)
        for (p = buf, count = 0; count < len; p++, count++) {
                if (card->msg_buf_read == card->msg_buf_write)
                        return count;
-               put_user(*card->msg_buf_read++, p);
+               if (put_user(*card->msg_buf_read++, p))
+                       return -EFAULT;
                if (card->msg_buf_read > card->msg_buf_end)
                        card->msg_buf_read = card->msg_buf;
        }
@@ -1182,7 +1185,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                        }
                        break;
                case ISDN_CMD_DIAL:
-                       if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                       if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                return -ENODEV;
                        if (card->leased)
                                break;
@@ -1208,7 +1211,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                        }
                        break;
                case ISDN_CMD_ACCEPTD:
-                       if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                       if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                return -ENODEV;
                        if (c->arg < ISDNLOOP_BCH) {
                                a = c->arg + 1;
@@ -1236,7 +1239,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                        }
                        break;
                case ISDN_CMD_ACCEPTB:
-                       if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                       if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                return -ENODEV;
                        if (c->arg < ISDNLOOP_BCH) {
                                a = c->arg + 1;
@@ -1262,7 +1265,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                                i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card);
                                break;
                case ISDN_CMD_HANGUP:
-                               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                        return -ENODEV;
                                if (c->arg < ISDNLOOP_BCH) {
                                        a = c->arg + 1;
@@ -1271,7 +1274,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                                }
                                break;
                case ISDN_CMD_SETEAZ:
-                               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                        return -ENODEV;
                                if (card->leased)
                                        break;
@@ -1287,7 +1290,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                                }
                                break;
                case ISDN_CMD_CLREAZ:
-                               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                        return -ENODEV;
                                if (card->leased)
                                        break;
@@ -1301,7 +1304,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                                }
                                break;
                case ISDN_CMD_SETL2:
-                               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                        return -ENODEV;
                                if ((c->arg & 255) < ISDNLOOP_BCH) {
                                        a = c->arg;
@@ -1331,7 +1334,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
                                }
                                break;
                case ISDN_CMD_SETL3:
-                               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+                               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                                        return -ENODEV;
                                return 0;
                default:
@@ -1378,7 +1381,7 @@ if_writecmd(const u_char __user *buf, int len, int id, int channel)
        isdnloop_card *card = isdnloop_findcard(id);
 
        if (card) {
-               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                        return -ENODEV;
                return (isdnloop_writecmd(buf, len, 1, card));
        }
@@ -1393,7 +1396,7 @@ if_readstatus(u_char __user *buf, int len, int id, int channel)
        isdnloop_card *card = isdnloop_findcard(id);
 
        if (card) {
-               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                        return -ENODEV;
                return (isdnloop_readstatus(buf, len, card));
        }
@@ -1408,7 +1411,7 @@ if_sendbuf(int id, int channel, int ack, struct sk_buff *skb)
        isdnloop_card *card = isdnloop_findcard(id);
 
        if (card) {
-               if (!card->flags & ISDNLOOP_FLAGS_RUNNING)
+               if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
                        return -ENODEV;
                /* ack request stored in skb scratch area */
                *(skb->head) = ack;
@@ -1429,12 +1432,11 @@ isdnloop_initcard(char *id)
        isdnloop_card *card;
        int i;
 
-       if (!(card = (isdnloop_card *) kmalloc(sizeof(isdnloop_card), GFP_KERNEL))) {
+       if (!(card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL))) {
                printk(KERN_WARNING
                 "isdnloop: (%s) Could not allocate card-struct.\n", id);
                return (isdnloop_card *) 0;
        }
-       memset((char *) card, 0, sizeof(isdnloop_card));
        card->interface.owner = THIS_MODULE;
        card->interface.channels = ISDNLOOP_BCH;
        card->interface.hl_hdrlen  = 1; /* scratch area for storing ack flag*/ 
@@ -1461,7 +1463,7 @@ isdnloop_initcard(char *id)
                skb_queue_head_init(&card->bqueue[i]);
        }
        skb_queue_head_init(&card->dqueue);
-       card->isdnloop_lock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&card->isdnloop_lock);
        card->next = cards;
        cards = card;
        if (!register_isdn(&card->interface)) {