Skip to contentSkip to conversation

drivers: CCI: Correct use of ! and &

PATCH In review Himangi Saraogi 4 participants 6 messages Jul 7, 2014 – Jul 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: CCI: Correct use of ! and &

In commit ae91d60ba88ef0bdb1b5e9b2363bd52fc45d2af7, a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way.

The Coccinelle semantic patch that makes this change is as follows:

// <smpl>
@@ expression E1,E2; @@
(
!E1 & !E2
|
- !E1 & E2
+ !(E1 & E2)
)
// </smpl>

---
This is not tested and clearly changes the semantics, so it is only something to consider.

 drivers/bus/arm-cci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +2 -1
index 5a86da9..7af78df 100644
@@ -397,7 +397,8 @@ static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
 		hw_counter = &event->hw;
 
 		/* Did this counter overflow? */
-		if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
+		if (!(pmu_read_register(idx, CCI_PMU_OVRFLW) &
+		      CCI_PMU_OVRFLW_FLAG))
 			continue;
 
 		pmu_write_register(CCI_PMU_OVRFLW_FLAG, idx, CCI_PMU_OVRFLW);
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw

Adding alkml and Will

Hi Himangi,

In future it would help if you send the patch to the the maintainers by running the get_maintainers.pl script on the patch.

Quoted 29 lines · Himangi Saraogi

In commit ae91d60ba88ef0bdb1b5e9b2363bd52fc45d2af7, a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way.

The Coccinelle semantic patch that makes this change is as follows:

// <smpl>
@@ expression E1,E2; @@
(
!E1 & !E2
|
- !E1 & E2
+ !(E1 & E2)
)
// </smpl>

---
This is not tested and clearly changes the semantics, so it is only something to consider.

 drivers/bus/arm-cci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +0 -0
index 5a86da9..7af78df 100644

drivers/bus/arm-cci.c static irqreturn_t pmu_handle_irq(int irq_num, void *dev) · line 402

Quoted 7 lines
drivers/bus/arm-cci.c +2 -1
@@ -397,7 +397,8 @@ static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
 		hw_counter = &event->hw;
 
 		/* Did this counter overflow? */
-		if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
+		if (!(pmu_read_register(idx, CCI_PMU_OVRFLW) &
+		      CCI_PMU_OVRFLW_FLAG))
 			continue;

Going back to the manual, this fix looks correct.

Will, would this go via your tree?

Quoted 2 lines
drivers/bus/arm-cci.c +0 -0
 		pmu_write_register(CCI_PMU_OVRFLW_FLAG, idx, CCI_PMU_OVRFLW);
#2 lore raw
Quoted 16 lines · Punit Agrawal

drivers/bus/arm-cci.c static irqreturn_t pmu_handle_irq(int irq_num, void *dev) · line 402

Quoted 12 lines
drivers/bus/arm-cci.c +2 -1
index 5a86da9..7af78df 100644
@@ -397,7 +397,8 @@ static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
 		hw_counter = &event->hw;
 
 		/* Did this counter overflow? */
-		if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
+		if (!(pmu_read_register(idx, CCI_PMU_OVRFLW) &
+		      CCI_PMU_OVRFLW_FLAG))
 			continue;

Going back to the manual, this fix looks correct.

Quoted 3 lines

Will, would this go via your tree?

Given that you're happy with it, I don't mind which tree it goes in. Probably deserves a CC stable on it too.

If you get stuck, put it in rmk's patch system.

Will

#3 lore raw

Hi Arnd,

Quoted 17 lines · Will Deacon
Quoted 16 lines · Punit Agrawal

drivers/bus/arm-cci.c static irqreturn_t pmu_handle_irq(int irq_num, void *dev) · line 402

Quoted 12 lines
drivers/bus/arm-cci.c +2 -1
index 5a86da9..7af78df 100644
@@ -397,7 +397,8 @@ static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
 		hw_counter = &event->hw;
 
 		/* Did this counter overflow? */
-		if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
+		if (!(pmu_read_register(idx, CCI_PMU_OVRFLW) &
+		      CCI_PMU_OVRFLW_FLAG))
 			continue;

Going back to the manual, this fix looks correct.

Quoted 6 lines
Quoted 3 lines

Will, would this go via your tree?

Given that you're happy with it, I don't mind which tree it goes in. Probably deserves a CC stable on it too.

The CCI PMU patches went via arm-soc. Are you happy to pick this fix with the Ack and a Cc to stable.

Cheers,
Punit

Quoted 9 lines

If you get stuck, put it in rmk's patch system.

Will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
Quoted 23 lines · Punit Agrawal

Hi Arnd,

Quoted 19 lines · Will Deacon
Quoted 18 lines · Punit Agrawal

drivers/bus/arm-cci.c static irqreturn_t pmu_handle_irq(int irq_num, void *dev) · line 402

Quoted 12 lines
drivers/bus/arm-cci.c +2 -1
index 5a86da9..7af78df 100644
@@ -397,7 +397,8 @@ static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
           hw_counter = &event->hw;
 
           /* Did this counter overflow? */
-          if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
+          if (!(pmu_read_register(idx, CCI_PMU_OVRFLW) &
+                CCI_PMU_OVRFLW_FLAG))
                   continue;

Going back to the manual, this fix looks correct.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Will, would this go via your tree?

Given that you're happy with it, I don't mind which tree it goes in. Probably deserves a CC stable on it too.

The CCI PMU patches went via arm-soc. Are you happy to pick this fix with the Ack and a Cc to stable.

Yeah, we've been merging most of the CCI patches.

Please resend the patch to arm at kernel.org if you want us to apply it.

Thanks,

-Olof

#5 lore raw
Quoted 29 lines · Olof Johansson
Quoted 28 lines · Punit Agrawal

Hi Arnd,

Quoted 23 lines · Will Deacon
Quoted 16 lines · Punit Agrawal

drivers/bus/arm-cci.c static irqreturn_t pmu_handle_irq(int irq_num, void *dev) · line 402

Quoted 12 lines
drivers/bus/arm-cci.c +2 -1
index 5a86da9..7af78df 100644
@@ -397,7 +397,8 @@ static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
           hw_counter = &event->hw;
 
           /* Did this counter overflow? */
-          if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
+          if (!(pmu_read_register(idx, CCI_PMU_OVRFLW) &
+                CCI_PMU_OVRFLW_FLAG))
                   continue;

Going back to the manual, this fix looks correct.

Quoted 3 lines

Will, would this go via your tree?

Given that you're happy with it, I don't mind which tree it goes in. Probably deserves a CC stable on it too.

Quoted 6 lines
Quoted 2 lines

The CCI PMU patches went via arm-soc. Are you happy to pick this fix with the Ack and a Cc to stable.

Yeah, we've been merging most of the CCI patches.

Please resend the patch to arm at kernel.org if you want us to apply it.

Ok, thanks! I'll send the patch with the tags applied shortly.

Quoted 10 lines

Thanks,

-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/