BNX2X: IO funcs spatched
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 4 Feb 2015 20:15:34 +0000 (15:15 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Mar 2015 16:59:08 +0000 (11:59 -0500)
e.g. readl -> read32.

Yes, we could have kept the Linux io helpers the way Linux expects, but if
we're putting something useful in the main kernel, I'd like it to be the way we
want.

Though the spatch did require --disable-multi-pass for it to work on the macros
in bnx2x.h, and the writel macros needed to be manually joined onto one line.
I think those were broken by a previous spatch.

kern/drivers/net/bnx2x/akaros_compat.h
kern/drivers/net/bnx2x/bnx2x.h
kern/drivers/net/bnx2x/bnx2x_vfpf.c
scripts/spatch/linux/io_funcs.cocci [new file with mode: 0644]

index dc92159..0a63d51 100644 (file)
@@ -20,6 +20,7 @@
 #include <bitmap.h>
 #include <mii.h>
 #include <umem.h>
+#include <mmio.h>
 
 #define __rcu
 typedef unsigned long dma_addr_t;
index c1f9377..bacecb2 100644 (file)
@@ -148,16 +148,13 @@ do {                                              \
 
 #define REG_ADDR(bp, offset)           ((bp->regview) + (offset))
 
-#define REG_RD(bp, offset)             readl(REG_ADDR(bp, offset))
-#define REG_RD8(bp, offset)            readb(REG_ADDR(bp, offset))
-#define REG_RD16(bp, offset)           readw(REG_ADDR(bp, offset))
+#define REG_RD(bp, offset)             read32(REG_ADDR(bp, offset))
+#define REG_RD8(bp, offset)            read8(REG_ADDR(bp, offset))
+#define REG_RD16(bp, offset)           read16(REG_ADDR(bp, offset))
 
-#define REG_WR(bp, offset, val)                writel((uint32_t)val,
-                                                     REG_ADDR(bp, offset))
-#define REG_WR8(bp, offset, val)       writeb((uint8_t)val,
-                                              REG_ADDR(bp, offset))
-#define REG_WR16(bp, offset, val)      writew((uint16_t)val,
-                                               REG_ADDR(bp, offset))
+#define REG_WR(bp, offset, val)                write32((uint32_t)val, REG_ADDR(bp, offset))
+#define REG_WR8(bp, offset, val)       write8((uint8_t)val, REG_ADDR(bp, offset))
+#define REG_WR16(bp, offset, val)      write16((uint16_t)val, REG_ADDR(bp, offset))
 
 #define REG_RD_IND(bp, offset)         bnx2x_reg_rd_ind(bp, offset)
 #define REG_WR_IND(bp, offset, val)    bnx2x_reg_wr_ind(bp, offset, val)
@@ -890,7 +887,7 @@ static inline bool bnx2x_fp_ll_disable(struct bnx2x_fastpath *fp)
 #endif
 #define DOORBELL(bp, cid, val) \
        do { \
-               writel((uint32_t)(val), bp->doorbells + (bp->db_size * (cid))); \
+               write32((uint32_t)(val), bp->doorbells + (bp->db_size * (cid))); \
        } while (0)
 
 /* TX CSUM helpers */
index c5fd309..250fe0f 100644 (file)
@@ -161,16 +161,16 @@ static int bnx2x_send_msg2pf(struct bnx2x *bp, uint8_t *done,
        }
 
        /* Write message address */
-       writel(U64_LO(msg_mapping),
+       write32(U64_LO(msg_mapping),
               &zone_data->non_trigger.vf_pf_channel.msg_addr_lo);
-       writel(U64_HI(msg_mapping),
+       write32(U64_HI(msg_mapping),
               &zone_data->non_trigger.vf_pf_channel.msg_addr_hi);
 
        /* make sure the address is written before FW accesses it */
        wmb();
 
        /* Trigger the PF FW */
-       writeb(1, &zone_data->trigger.vf_pf_channel.addr_valid);
+       write8(1, &zone_data->trigger.vf_pf_channel.addr_valid);
 
        /* Wait for PF to complete */
        while ((tout >= 0) && (!*done)) {
@@ -198,7 +198,7 @@ static int bnx2x_get_vf_id(struct bnx2x *bp, uint32_t *vf_id)
 
        do {
                /* pxp traps vf read of doorbells and returns me reg value */
-               me_reg = readl(bp->doorbells);
+               me_reg = read32(bp->doorbells);
                if (GOOD_ME_REG(me_reg))
                        break;
 
diff --git a/scripts/spatch/linux/io_funcs.cocci b/scripts/spatch/linux/io_funcs.cocci
new file mode 100644 (file)
index 0000000..a96261a
--- /dev/null
@@ -0,0 +1,98 @@
+@@
+@@
+-writeb(
++write8(
+ ...)
+
+@@
+@@
+-writew(
++write16(
+ ...)
+
+@@
+@@
+-writel(
++write32(
+ ...)
+
+@@
+@@
+-writeq(
++write64(
+ ...)
+
+@@
+@@
+-__raw_writeb(
++__raw_write8(
+ ...)
+
+@@
+@@
+-__raw_writew(
++__raw_write16(
+ ...)
+
+@@
+@@
+-__raw_writel(
++__raw_write32(
+ ...)
+
+@@
+@@
+-__raw_writeq(
++__raw_write64(
+ ...)
+
+
+
+@@
+@@
+-readb(
++read8(
+ ...)
+
+@@
+@@
+-readw(
++read16(
+ ...)
+
+@@
+@@
+-readl(
++read32(
+ ...)
+
+@@
+@@
+-readq(
++read64(
+ ...)
+
+@@
+@@
+-__raw_readb(
++__raw_read8(
+ ...)
+
+@@
+@@
+-__raw_readw(
++__raw_read16(
+ ...)
+
+@@
+@@
+-__raw_readl(
++__raw_read32(
+ ...)
+
+@@
+@@
+-__raw_readq(
++__raw_read64(
+ ...)
+