Skip to contentSkip to conversation

xilinx_axienet: Fix bit mask code

PATCH Applied Stefan Weil 3 participants 3 messages Jun 9, 2013 – Jun 10, 2013 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xilinx_axienet: Fix bit mask code

Obviously the code wanted to mask the lower bits but failed to do so because of a missing "<".

cppcheck detected a conditional expression which was always true (1 < 7).

---

Please review - I did not look for a Xilinx manual to see whether the code was correct at all.

Regards,
Stefan Weil

 hw/net/xilinx_axienet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/xilinx_axienet.c +1 -1
index 8989e95..2ca1511 100644
@@ -575,7 +575,7 @@ static void enet_write(void *opaque, hwaddr addr,
             break;
 
         case R_MC:
-             value &= ((1 < 7) - 1);
+             value &= ((1 << 7) - 1);
 
              /* Enable the MII.  */
              if (value & MC_EN) {
Signature · 1 line
1.7.10.4
#1 lore raw

hw/net/xilinx_axienet.c static void enet_write(void *opaque, hwaddr addr, · line 578

Quoted 10 lines · Stefan Weil
hw/net/xilinx_axienet.c +1 -1
index 8989e95..2ca1511 100644
@@ -575,7 +575,7 @@ static void enet_write(void *opaque, hwaddr addr,
             break;
 
         case R_MC:
-             value &= ((1 < 7) - 1);
+             value &= ((1 << 7) - 1);

Whoops. No objection to this patch as it stands; another option would be

    value = extract32(value, 0, 7);

thanks
-- PMM

#2 lore raw
In reply to Stefan Weil
Quoted 4 lines · Stefan Weil

Obviously the code wanted to mask the lower bits but failed to do so because of a missing "<".

cppcheck detected a conditional expression which was always true (1 < 7).

Applied, thanks Stefan

Quoted 29 lines

---

Please review - I did not look for a Xilinx manual to see whether the code was correct at all.

Regards,
Stefan Weil

 hw/net/xilinx_axienet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/xilinx_axienet.c +1 -1
index 8989e95..2ca1511 100644
@@ -575,7 +575,7 @@ static void enet_write(void *opaque, hwaddr addr,
             break;
 
         case R_MC:
-             value &= ((1 < 7) - 1);
+             value &= ((1 << 7) - 1);
 
              /* Enable the MII.  */
              if (value & MC_EN) {
Signature · 1 line
1.7.10.4