~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/net/wan/cosa.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
#include <linux/spinlock.h>
90
90
#include <linux/mutex.h>
91
91
#include <linux/device.h>
92
 
#include <linux/smp_lock.h>
93
92
#include <asm/io.h>
94
93
#include <asm/dma.h>
95
94
#include <asm/byteorder.h>
174
173
 * Character device major number. 117 was allocated for us.
175
174
 * The value of 0 means to allocate a first free one.
176
175
 */
 
176
static DEFINE_MUTEX(cosa_chardev_mutex);
177
177
static int cosa_major = 117;
178
178
 
179
179
/*
297
297
static unsigned int cosa_poll(struct file *file, poll_table *poll);
298
298
static int cosa_open(struct inode *inode, struct file *file);
299
299
static int cosa_release(struct inode *inode, struct file *file);
300
 
static int cosa_chardev_ioctl(struct inode *inode, struct file *file,
301
 
        unsigned int cmd, unsigned long arg);
 
300
static long cosa_chardev_ioctl(struct file *file, unsigned int cmd,
 
301
                                unsigned long arg);
302
302
#ifdef COSA_FASYNC_WORKING
303
303
static int cosa_fasync(struct inode *inode, struct file *file, int on);
304
304
#endif
309
309
        .read           = cosa_read,
310
310
        .write          = cosa_write,
311
311
        .poll           = cosa_poll,
312
 
        .ioctl          = cosa_chardev_ioctl,
 
312
        .unlocked_ioctl = cosa_chardev_ioctl,
313
313
        .open           = cosa_open,
314
314
        .release        = cosa_release,
315
315
#ifdef COSA_FASYNC_WORKING
575
575
 
576
576
                /* Initialize the chardev data structures */
577
577
                mutex_init(&chan->rlock);
578
 
                init_MUTEX(&chan->wsem);
 
578
                sema_init(&chan->wsem, 1);
579
579
 
580
580
                /* Register the network interface */
581
581
                if (!(chan->netdev = alloc_hdlcdev(chan))) {
811
811
        cosa_enable_rx(chan);
812
812
        spin_lock_irqsave(&cosa->lock, flags);
813
813
        add_wait_queue(&chan->rxwaitq, &wait);
814
 
        while(!chan->rx_status) {
 
814
        while (!chan->rx_status) {
815
815
                current->state = TASK_INTERRUPTIBLE;
816
816
                spin_unlock_irqrestore(&cosa->lock, flags);
817
817
                schedule();
896
896
 
897
897
        spin_lock_irqsave(&cosa->lock, flags);
898
898
        add_wait_queue(&chan->txwaitq, &wait);
899
 
        while(!chan->tx_status) {
 
899
        while (!chan->tx_status) {
900
900
                current->state = TASK_INTERRUPTIBLE;
901
901
                spin_unlock_irqrestore(&cosa->lock, flags);
902
902
                schedule();
944
944
        int n;
945
945
        int ret = 0;
946
946
 
947
 
        lock_kernel();
 
947
        mutex_lock(&cosa_chardev_mutex);
948
948
        if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS)
949
949
                >= nr_cards) {
950
950
                ret = -ENODEV;
976
976
        chan->rx_done = chrdev_rx_done;
977
977
        spin_unlock_irqrestore(&cosa->lock, flags);
978
978
out:
979
 
        unlock_kernel();
 
979
        mutex_unlock(&cosa_chardev_mutex);
980
980
        return ret;
981
981
}
982
982
 
1153
1153
        struct channel_data *channel, unsigned int cmd, unsigned long arg)
1154
1154
{
1155
1155
        void __user *argp = (void __user *)arg;
1156
 
        switch(cmd) {
 
1156
        switch (cmd) {
1157
1157
        case COSAIORSET:        /* Reset the device */
1158
1158
                if (!capable(CAP_NET_ADMIN))
1159
1159
                        return -EACCES;
1205
1205
        return hdlc_ioctl(dev, ifr, cmd);
1206
1206
}
1207
1207
 
1208
 
static int cosa_chardev_ioctl(struct inode *inode, struct file *file,
1209
 
        unsigned int cmd, unsigned long arg)
 
1208
static long cosa_chardev_ioctl(struct file *file, unsigned int cmd,
 
1209
                                                        unsigned long arg)
1210
1210
{
1211
1211
        struct channel_data *channel = file->private_data;
1212
 
        struct cosa_data *cosa = channel->cosa;
1213
 
        return cosa_ioctl_common(cosa, channel, cmd, arg);
 
1212
        struct cosa_data *cosa;
 
1213
        long ret;
 
1214
 
 
1215
        mutex_lock(&cosa_chardev_mutex);
 
1216
        cosa = channel->cosa;
 
1217
        ret = cosa_ioctl_common(cosa, channel, cmd, arg);
 
1218
        mutex_unlock(&cosa_chardev_mutex);
 
1219
        return ret;
1214
1220
}
1215
1221
 
1216
1222
 
1698
1704
                        spin_unlock_irqrestore(&cosa->lock, flags);
1699
1705
                        return;
1700
1706
                }
1701
 
                while(1) {
 
1707
                while (1) {
1702
1708
                        cosa->txchan++;
1703
1709
                        i++;
1704
1710
                        if (cosa->txchan >= cosa->nchannels)
2004
2010
static void debug_status_in(struct cosa_data *cosa, int status)
2005
2011
{
2006
2012
        char *s;
2007
 
        switch(status & SR_CMD_FROM_SRP_MASK) {
 
2013
        switch (status & SR_CMD_FROM_SRP_MASK) {
2008
2014
        case SR_UP_REQUEST:
2009
2015
                s = "RX_REQ";
2010
2016
                break;