Add missing andmask to ramips_esw register read for recv_good value.

Without the mask, recv_bad leaks into the recv_good packet count.
Didn't notice the bug before since you don't usually get bad
packets, so I only saw it when I was playing with overlength packets
earlier...

Signed-off-by: Tobias Diedrich <ranma+open...@tdiedrich.de>


Index: 
openwrt-ralink-swconfig/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_esw.c
===================================================================
--- 
openwrt-ralink-swconfig.orig/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_esw.c
     2012-09-02 22:16:57.970994947 +0200
+++ 
openwrt-ralink-swconfig/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_esw.c
  2012-09-02 23:11:48.595590982 +0200
@@ -775,11 +775,13 @@
        struct rt305x_esw *esw = container_of(dev, struct rt305x_esw, swdev);
        int idx = val->port_vlan;
        int shift = attr->id == RT305X_ESW_ATTR_PORT_RECV_GOOD ? 0 : 16;
+       u32 reg;
 
        if (idx < 0 || idx >= RT305X_ESW_NUM_LANWAN)
                return -EINVAL;
 
-       val->value.i = rt305x_esw_rr(esw, RT305X_ESW_REG_P0PC + 4*idx) >> shift;
+       reg = rt305x_esw_rr(esw, RT305X_ESW_REG_P0PC + 4*idx);
+       val->value.i = (reg >> shift) & 0xffff;
 
        return 0;
 }

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to