parisc: invoke oom-killer from page fault
[safe/jmp/linux-2.6] / drivers / net / wan / cosa.c
index e2c33c0..f0bd70f 100644 (file)
@@ -297,8 +297,8 @@ static ssize_t cosa_write(struct file *file,
 static unsigned int cosa_poll(struct file *file, poll_table *poll);
 static int cosa_open(struct inode *inode, struct file *file);
 static int cosa_release(struct inode *inode, struct file *file);
-static int cosa_chardev_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg);
+static long cosa_chardev_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg);
 #ifdef COSA_FASYNC_WORKING
 static int cosa_fasync(struct inode *inode, struct file *file, int on);
 #endif
@@ -309,7 +309,7 @@ static const struct file_operations cosa_fops = {
        .read           = cosa_read,
        .write          = cosa_write,
        .poll           = cosa_poll,
-       .ioctl          = cosa_chardev_ioctl,
+       .unlocked_ioctl = cosa_chardev_ioctl,
        .open           = cosa_open,
        .release        = cosa_release,
 #ifdef COSA_FASYNC_WORKING
@@ -811,7 +811,7 @@ static ssize_t cosa_read(struct file *file,
        cosa_enable_rx(chan);
        spin_lock_irqsave(&cosa->lock, flags);
        add_wait_queue(&chan->rxwaitq, &wait);
-       while(!chan->rx_status) {
+       while (!chan->rx_status) {
                current->state = TASK_INTERRUPTIBLE;
                spin_unlock_irqrestore(&cosa->lock, flags);
                schedule();
@@ -896,7 +896,7 @@ static ssize_t cosa_write(struct file *file,
 
        spin_lock_irqsave(&cosa->lock, flags);
        add_wait_queue(&chan->txwaitq, &wait);
-       while(!chan->tx_status) {
+       while (!chan->tx_status) {
                current->state = TASK_INTERRUPTIBLE;
                spin_unlock_irqrestore(&cosa->lock, flags);
                schedule();
@@ -907,6 +907,7 @@ static ssize_t cosa_write(struct file *file,
                        current->state = TASK_RUNNING;
                        chan->tx_status = 1;
                        spin_unlock_irqrestore(&cosa->lock, flags);
+                       up(&chan->wsem);
                        return -ERESTARTSYS;
                }
        }
@@ -1152,7 +1153,7 @@ static int cosa_ioctl_common(struct cosa_data *cosa,
        struct channel_data *channel, unsigned int cmd, unsigned long arg)
 {
        void __user *argp = (void __user *)arg;
-       switch(cmd) {
+       switch (cmd) {
        case COSAIORSET:        /* Reset the device */
                if (!capable(CAP_NET_ADMIN))
                        return -EACCES;
@@ -1204,12 +1205,18 @@ static int cosa_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return hdlc_ioctl(dev, ifr, cmd);
 }
 
-static int cosa_chardev_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg)
+static long cosa_chardev_ioctl(struct file *file, unsigned int cmd,
+                                                       unsigned long arg)
 {
        struct channel_data *channel = file->private_data;
-       struct cosa_data *cosa = channel->cosa;
-       return cosa_ioctl_common(cosa, channel, cmd, arg);
+       struct cosa_data *cosa;
+       long ret;
+
+       lock_kernel();
+       cosa = channel->cosa;
+       ret = cosa_ioctl_common(cosa, channel, cmd, arg);
+       unlock_kernel();
+       return ret;
 }
 
 \f
@@ -1697,7 +1704,7 @@ static inline void tx_interrupt(struct cosa_data *cosa, int status)
                        spin_unlock_irqrestore(&cosa->lock, flags);
                        return;
                }
-               while(1) {
+               while (1) {
                        cosa->txchan++;
                        i++;
                        if (cosa->txchan >= cosa->nchannels)
@@ -2003,7 +2010,7 @@ again:
 static void debug_status_in(struct cosa_data *cosa, int status)
 {
        char *s;
-       switch(status & SR_CMD_FROM_SRP_MASK) {
+       switch (status & SR_CMD_FROM_SRP_MASK) {
        case SR_UP_REQUEST:
                s = "RX_REQ";
                break;