vserver 2.0 rc7
[linux-2.6.git] / drivers / net / wireless / hermes.c
index 7300901..21c3d0d 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/net.h>
 #include <asm/errno.h>
 
 #include "hermes.h"
@@ -67,8 +68,7 @@ MODULE_LICENSE("Dual MPL/GPL");
  * Debugging helpers
  */
 
-#define IO_TYPE(hw)    ((hw)->io_space ? "IO " : "MEM ")
-#define DMSG(stuff...) do {printk(KERN_DEBUG "hermes @ %s0x%x: " , IO_TYPE(hw), hw->iobase); \
+#define DMSG(stuff...) do {printk(KERN_DEBUG "hermes @ %p: " , hw->iobase); \
                        printk(stuff);} while (0)
 
 #undef HERMES_DEBUG
@@ -123,11 +123,9 @@ static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0)
  * Function definitions
  */
 
-void hermes_struct_init(hermes_t *hw, ulong address,
-                       int io_space, int reg_spacing)
+void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
 {
        hw->iobase = address;
-       hw->io_space = io_space;
        hw->reg_spacing = reg_spacing;
        hw->inten = 0x0;
 
@@ -200,9 +198,9 @@ int hermes_init(hermes_t *hw)
        }
                
        if (! (reg & HERMES_EV_CMD)) {
-               printk(KERN_ERR "hermes @ %s0x%lx: " 
+               printk(KERN_ERR "hermes @ %p: " 
                       "Timeout waiting for card to reset (reg=0x%04x)!\n",
-                      IO_TYPE(hw), hw->iobase, reg);
+                      hw->iobase, reg);
                err = -ETIMEDOUT;
                goto out;
        }
@@ -235,13 +233,16 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
        err = hermes_issue_cmd(hw, cmd, parm0);
        if (err) {
                if (! hermes_present(hw)) {
-                       printk(KERN_WARNING "hermes @ %s0x%lx: "
-                              "Card removed while issuing command.\n",
-                              IO_TYPE(hw), hw->iobase);
+                       if (net_ratelimit())
+                               printk(KERN_WARNING "hermes @ %p: "
+                                      "Card removed while issuing command "
+                                      "0x%04x.\n", hw->iobase, cmd);
                        err = -ENODEV;
                } else 
-                       printk(KERN_ERR "hermes @ %s0x%lx: Error %d issuing command.\n",
-                              IO_TYPE(hw), hw->iobase, err);
+                       if (net_ratelimit())
+                               printk(KERN_ERR "hermes @ %p: "
+                                      "Error %d issuing command 0x%04x.\n",
+                                      hw->iobase, err, cmd);
                goto out;
        }
 
@@ -254,17 +255,16 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
        }
 
        if (! hermes_present(hw)) {
-               printk(KERN_WARNING "hermes @ %s0x%lx: "
-                      "Card removed while waiting for command completion.\n",
-                      IO_TYPE(hw), hw->iobase);
+               printk(KERN_WARNING "hermes @ %p: Card removed "
+                      "while waiting for command 0x%04x completion.\n",
+                      hw->iobase, cmd);
                err = -ENODEV;
                goto out;
        }
                
        if (! (reg & HERMES_EV_CMD)) {
-               printk(KERN_ERR "hermes @ %s0x%lx: "
-                      "Timeout waiting for command completion.\n",
-                      IO_TYPE(hw), hw->iobase);
+               printk(KERN_ERR "hermes @ %p: Timeout waiting for "
+                      "command 0x%04x completion.\n", hw->iobase, cmd);
                err = -ETIMEDOUT;
                goto out;
        }
@@ -309,16 +309,16 @@ int hermes_allocate(hermes_t *hw, u16 size, u16 *fid)
        }
        
        if (! hermes_present(hw)) {
-               printk(KERN_WARNING "hermes @ %s0x%lx: "
+               printk(KERN_WARNING "hermes @ %p: "
                       "Card removed waiting for frame allocation.\n",
-                      IO_TYPE(hw), hw->iobase);
+                      hw->iobase);
                return -ENODEV;
        }
                
        if (! (reg & HERMES_EV_ALLOC)) {
-               printk(KERN_ERR "hermes @ %s0x%lx: "
+               printk(KERN_ERR "hermes @ %p: "
                       "Timeout waiting for frame allocation\n",
-                      IO_TYPE(hw), hw->iobase);
+                      hw->iobase);
                return -ETIMEDOUT;
        }
 
@@ -383,12 +383,17 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
                reg = hermes_read_reg(hw, oreg);
        }
 
-       if (reg & HERMES_OFFSET_BUSY) {
-               return -ETIMEDOUT;
-       }
+       if (reg != offset) {
+               printk(KERN_ERR "hermes @ %p: BAP%d offset %s: "
+                      "reg=0x%x id=0x%x offset=0x%x\n", hw->iobase, bap,
+                      (reg & HERMES_OFFSET_BUSY) ? "timeout" : "error",
+                      reg, id, offset);
+
+               if (reg & HERMES_OFFSET_BUSY) {
+                       return -ETIMEDOUT;
+               }
 
-       if (reg & HERMES_OFFSET_ERR) {
-               return -EIO;
+               return -EIO;            /* error or wrong offset */
        }
 
        return 0;
@@ -476,7 +481,7 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
        rlength = hermes_read_reg(hw, dreg);
 
        if (! rlength)
-               return -ENOENT;
+               return -ENODATA;
 
        rtype = hermes_read_reg(hw, dreg);
 
@@ -484,14 +489,13 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
                *length = rlength;
 
        if (rtype != rid)
-               printk(KERN_WARNING "hermes @ %s0x%lx: "
-                      "hermes_read_ltv(): rid  (0x%04x) does not match type (0x%04x)\n",
-                      IO_TYPE(hw), hw->iobase, rid, rtype);
+               printk(KERN_WARNING "hermes @ %p: %s(): "
+                      "rid (0x%04x) does not match type (0x%04x)\n",
+                      hw->iobase, __FUNCTION__, rid, rtype);
        if (HERMES_RECLEN_TO_BYTES(rlength) > bufsize)
-               printk(KERN_WARNING "hermes @ %s0x%lx: "
+               printk(KERN_WARNING "hermes @ %p: "
                       "Truncating LTV record from %d to %d bytes. "
-                      "(rid=0x%04x, len=0x%04x)\n",
-                      IO_TYPE(hw), hw->iobase,
+                      "(rid=0x%04x, len=0x%04x)\n", hw->iobase,
                       HERMES_RECLEN_TO_BYTES(rlength), bufsize, rid, rlength);
 
        nwords = min((unsigned)rlength - 1, bufsize / 2);