]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
b43: Add mask/set capability to debugfs MMIO interface
authorMichael Buesch <mb@bu3sch.de>
Thu, 19 Jun 2008 17:38:32 +0000 (19:38 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 26 Jun 2008 20:49:18 +0000 (16:49 -0400)
This adds an atomic mask/set capability to the debugfs MMIO interface.
This is needed to support mask and/or set operations from the userspace
debugging tools.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/debugfs.c

index dd40ad826c78a48e5cb4869770abfba2da21066d..cfe8e202e4c395cf641ed7c553d0bf128ae61429 100644 (file)
@@ -267,6 +267,8 @@ static int mmio16read__write_file(struct b43_wldev *dev,
                return -EINVAL;
        if (addr > B43_MAX_MMIO_ACCESS)
                return -EADDRNOTAVAIL;
+       if ((addr % 2) != 0)
+               return -EINVAL;
 
        dev->dfsentry->mmio16read_next = addr;
 
@@ -276,17 +278,26 @@ static int mmio16read__write_file(struct b43_wldev *dev,
 static int mmio16write__write_file(struct b43_wldev *dev,
                                   const char *buf, size_t count)
 {
-       unsigned int addr, val;
+       unsigned int addr, mask, set;
        int res;
+       u16 val;
 
-       res = sscanf(buf, "0x%X = 0x%X", &addr, &val);
-       if (res != 2)
+       res = sscanf(buf, "0x%X 0x%X 0x%X", &addr, &mask, &set);
+       if (res != 3)
                return -EINVAL;
        if (addr > B43_MAX_MMIO_ACCESS)
                return -EADDRNOTAVAIL;
-       if (val > 0xFFFF)
+       if ((mask > 0xFFFF) || (set > 0xFFFF))
                return -E2BIG;
+       if ((addr % 2) != 0)
+               return -EINVAL;
 
+       if (mask == 0)
+               val = 0;
+       else
+               val = b43_read16(dev, addr);
+       val &= mask;
+       val |= set;
        b43_write16(dev, addr, val);
 
        return 0;
@@ -320,6 +331,8 @@ static int mmio32read__write_file(struct b43_wldev *dev,
                return -EINVAL;
        if (addr > B43_MAX_MMIO_ACCESS)
                return -EADDRNOTAVAIL;
+       if ((addr % 4) != 0)
+               return -EINVAL;
 
        dev->dfsentry->mmio32read_next = addr;
 
@@ -329,17 +342,26 @@ static int mmio32read__write_file(struct b43_wldev *dev,
 static int mmio32write__write_file(struct b43_wldev *dev,
                                   const char *buf, size_t count)
 {
-       unsigned int addr, val;
+       unsigned int addr, mask, set;
        int res;
+       u32 val;
 
-       res = sscanf(buf, "0x%X = 0x%X", &addr, &val);
-       if (res != 2)
+       res = sscanf(buf, "0x%X 0x%X 0x%X", &addr, &mask, &set);
+       if (res != 3)
                return -EINVAL;
        if (addr > B43_MAX_MMIO_ACCESS)
                return -EADDRNOTAVAIL;
-       if (val > 0xFFFFFFFF)
+       if ((mask > 0xFFFFFFFF) || (set > 0xFFFFFFFF))
                return -E2BIG;
+       if ((addr % 4) != 0)
+               return -EINVAL;
 
+       if (mask == 0)
+               val = 0;
+       else
+               val = b43_read32(dev, addr);
+       val &= mask;
+       val |= set;
        b43_write32(dev, addr, val);
 
        return 0;