Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / net / wireless / bcm43xx / bcm43xx_debugfs.c
index b9df06a..35a4fcb 100644 (file)
@@ -54,7 +54,7 @@ static ssize_t write_file_dummy(struct file *file, const char __user *buf,
 
 static int open_file_generic(struct inode *inode, struct file *file)
 {
-       file->private_data = inode->i_private;
+       file->private_data = inode->u.generic_ip;
        return 0;
 }
 
@@ -77,9 +77,8 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
 
        down(&big_buffer_sem);
 
-       mutex_lock(&bcm->mutex);
-       spin_lock_irqsave(&bcm->irq_lock, flags);
-       if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
+       bcm43xx_lock_mmio(bcm, flags);
+       if (!bcm->initialized) {
                fappend("Board not initialized.\n");
                goto out;
        }
@@ -93,7 +92,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
        fappend("subsystem_vendor: 0x%04x   subsystem_device: 0x%04x\n",
                pci_dev->subsystem_vendor, pci_dev->subsystem_device);
        fappend("IRQ: %d\n", bcm->irq);
-       fappend("mmio_addr: 0x%p\n", bcm->mmio_addr);
+       fappend("mmio_addr: 0x%p   mmio_len: %u\n", bcm->mmio_addr, bcm->mmio_len);
        fappend("chip_id: 0x%04x   chip_rev: 0x%02x\n", bcm->chip_id, bcm->chip_rev);
        if ((bcm->core_80211[0].rev >= 3) && (bcm43xx_read32(bcm, 0x0158) & (1 << 16)))
                fappend("Radio disabled by hardware!\n");
@@ -122,8 +121,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
        fappend("\n");
 
 out:
-       spin_unlock_irqrestore(&bcm->irq_lock, flags);
-       mutex_unlock(&bcm->mutex);
+       bcm43xx_unlock_mmio(bcm, flags);
        res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
        up(&big_buffer_sem);
        return res;
@@ -161,9 +159,8 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
        unsigned long flags;
 
        down(&big_buffer_sem);
-       mutex_lock(&bcm->mutex);
-       spin_lock_irqsave(&bcm->irq_lock, flags);
-       if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
+       bcm43xx_lock_mmio(bcm, flags);
+       if (!bcm->initialized) {
                fappend("Board not initialized.\n");
                goto out;
        }
@@ -172,8 +169,7 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
        fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);
 
 out:
-       spin_unlock_irqrestore(&bcm->irq_lock, flags);
-       mutex_unlock(&bcm->mutex);
+       bcm43xx_unlock_mmio(bcm, flags);
        res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
        up(&big_buffer_sem);
        return res;
@@ -192,9 +188,8 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
        u64 tsf;
 
        down(&big_buffer_sem);
-       mutex_lock(&bcm->mutex);
-       spin_lock_irqsave(&bcm->irq_lock, flags);
-       if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
+       bcm43xx_lock_mmio(bcm, flags);
+       if (!bcm->initialized) {
                fappend("Board not initialized.\n");
                goto out;
        }
@@ -204,8 +199,7 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
                (unsigned int)(tsf & 0xFFFFFFFFULL));
 
 out:
-       spin_unlock_irqrestore(&bcm->irq_lock, flags);
-       mutex_unlock(&bcm->mutex);
+       bcm43xx_unlock_mmio(bcm, flags);
        res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
        up(&big_buffer_sem);
        return res;
@@ -227,9 +221,8 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
                res = -EFAULT;
                goto out_up;
        }
-       mutex_lock(&bcm->mutex);
-       spin_lock_irqsave(&bcm->irq_lock, flags);
-       if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
+       bcm43xx_lock_mmio(bcm, flags);
+       if (!bcm->initialized) {
                printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
                res = -EFAULT;
                goto out_unlock;
@@ -240,12 +233,10 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
                goto out_unlock;
        }
        bcm43xx_tsf_write(bcm, tsf);
-       mmiowb();
        res = buf_size;
        
 out_unlock:
-       spin_unlock_irqrestore(&bcm->irq_lock, flags);
-       mutex_unlock(&bcm->mutex);
+       bcm43xx_unlock_mmio(bcm, flags);
 out_up:
        up(&big_buffer_sem);
        return res;
@@ -266,8 +257,7 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
        int i, cnt, j = 0;
 
        down(&big_buffer_sem);
-       mutex_lock(&bcm->mutex);
-       spin_lock_irqsave(&bcm->irq_lock, flags);
+       bcm43xx_lock(bcm, flags);
 
        fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
                BCM43xx_NR_LOGGED_XMITSTATUS);
@@ -303,51 +293,14 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
                        i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
        }
 
-       spin_unlock_irqrestore(&bcm->irq_lock, flags);
+       bcm43xx_unlock(bcm, flags);
        res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
-       spin_lock_irqsave(&bcm->irq_lock, flags);
+       bcm43xx_lock(bcm, flags);
        if (*ppos == pos) {
                /* Done. Drop the copied data. */
                e->xmitstatus_printing = 0;
        }
-       spin_unlock_irqrestore(&bcm->irq_lock, flags);
-       mutex_unlock(&bcm->mutex);
-       up(&big_buffer_sem);
-       return res;
-}
-
-static ssize_t restart_write_file(struct file *file, const char __user *user_buf,
-                                 size_t count, loff_t *ppos)
-{
-       struct bcm43xx_private *bcm = file->private_data;
-       char *buf = really_big_buffer;
-       ssize_t buf_size;
-       ssize_t res;
-       unsigned long flags;
-
-       buf_size = min(count, sizeof (really_big_buffer) - 1);
-       down(&big_buffer_sem);
-       if (copy_from_user(buf, user_buf, buf_size)) {
-               res = -EFAULT;
-               goto out_up;
-       }
-       mutex_lock(&(bcm)->mutex);
-       spin_lock_irqsave(&(bcm)->irq_lock, flags);
-       if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
-               printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
-               res = -EFAULT;
-               goto out_unlock;
-       }
-       if (count > 0 && buf[0] == '1') {
-               bcm43xx_controller_restart(bcm, "manually restarted");
-               res = count;
-       } else
-               res = -EINVAL;
-
-out_unlock:
-       spin_unlock_irqrestore(&(bcm)->irq_lock, flags);
-       mutex_unlock(&(bcm)->mutex);
-out_up:
+       bcm43xx_unlock(bcm, flags);
        up(&big_buffer_sem);
        return res;
 }
@@ -385,11 +338,6 @@ static struct file_operations txstat_fops = {
        .open = open_file_generic,
 };
 
-static struct file_operations restart_fops = {
-       .write = restart_write_file,
-       .open = open_file_generic,
-};
-
 
 void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm)
 {
@@ -441,10 +389,6 @@ void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm)
                                                bcm, &txstat_fops);
        if (!e->dentry_txstat)
                printk(KERN_ERR PFX "debugfs: creating \"tx_status\" for \"%s\" failed!\n", devdir);
-       e->dentry_restart = debugfs_create_file("restart", 0222, e->subdir,
-                                               bcm, &restart_fops);
-       if (!e->dentry_restart)
-               printk(KERN_ERR PFX "debugfs: creating \"restart\" for \"%s\" failed!\n", devdir);
 }
 
 void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm)
@@ -460,7 +404,6 @@ void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm)
        debugfs_remove(e->dentry_devinfo);
        debugfs_remove(e->dentry_tsf);
        debugfs_remove(e->dentry_txstat);
-       debugfs_remove(e->dentry_restart);
        debugfs_remove(e->subdir);
        kfree(e->xmitstatus_buffer);
        kfree(e->xmitstatus_print_buffer);