Skip to contentSkip to conversation

clk: meson: fix SET_PARM macro

PATCH In review Jerome Brunet 3 participants 5 messages Feb 28, 2017 – Mar 1, 2017

Subsystems (3)
lore
Share & tools
lore

Jerome Brunet

author maintainer
#0 lore raw

PATCH 1/1 clk: meson: fix SET_PARM macro

parameter val is not enclosed in parenthesis which is buggy when given an expression instead of a simple value

---
 drivers/clk/meson/clkc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/meson/clkc.h +1 -1
index 9bb70e7a7d6a..c6be77dd8694 100644
@@ -25,7 +25,7 @@
 #define PARM_GET(width, shift, reg)					\
 	(((reg) & SETPMASK(width, shift)) >> (shift))
 #define PARM_SET(width, shift, reg, val)				\
-	(((reg) & CLRPMASK(width, shift)) | (val << (shift)))
+	(((reg) & CLRPMASK(width, shift)) | ((val) << (shift)))
 
 #define MESON_PARM_APPLICABLE(p)		(!!((p)->width))
 
Signature · 1 line
2.9.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jerome Brunet

parameter val is not enclosed in parenthesis which is buggy when given an expression instead of a simple value

Quoted 16 lines
---
 drivers/clk/meson/clkc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/meson/clkc.h +1 -1
index 9bb70e7a7d6a..c6be77dd8694 100644
@@ -25,7 +25,7 @@
 #define PARM_GET(width, shift, reg)					\
 	(((reg) & SETPMASK(width, shift)) >> (shift))
 #define PARM_SET(width, shift, reg, val)				\
-	(((reg) & CLRPMASK(width, shift)) | (val << (shift)))
+	(((reg) & CLRPMASK(width, shift)) | ((val) << (shift)))
 
 #define MESON_PARM_APPLICABLE(p)		(!!((p)->width))
#2 lore raw
In reply to Jerome Brunet
Quoted 4 lines · Jerome Brunet

parameter val is not enclosed in parenthesis which is buggy when given an expression instead of a simple value

Fixes tag? Is there a place in the code that is using a complex expression for val right now?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author maintainer
#3 lore raw
Quoted 10 lines · Stephen Boyd
Quoted 5 lines · Jerome Brunet

parameter val is not enclosed in parenthesis which is buggy when given an
expression instead of a simple value

Fixes tag? Is there a place in the code that is using a complex expression for val right now?

Not if with what's already in, afaik. However "clk: meson: mpll: add rw operation" I sent earlier today uses a ternary operator for val. That's??how I found this issue. Instead of running the test, it would always use the "else" clause.

I realize I should sent these patches in the same series. Would you prefer me to do so ?

Jerome

#4 lore raw
Quoted 12 lines · Jerome Brunet
Quoted 10 lines · Stephen Boyd
Quoted 5 lines · Jerome Brunet

parameter val is not enclosed in parenthesis which is buggy when given an
expression instead of a simple value

Fixes tag? Is there a place in the code that is using a complex expression for val right now?

Quoted 7 lines

Not if with what's already in, afaik. However "clk: meson: mpll: add rw operation" I sent earlier today uses a ternary operator for val. That's??how I found this issue. Instead of running the test, it would always use the "else" clause.

I realize I should sent these patches in the same series. Would you prefer me to do so ?

Sure, but wait a little while for any review comments on the series first please. For now I'll drop this from my queue because it isn't an urgent fix and wait for it to come back as part of the larger series.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project