Skip to contentSkip to conversation

clk: socfpga: remove redundant assignment after a mask operation

PATCH Applied Colin Ian King 3 participants 3 messages Dec 30, 2021 – Jan 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: socfpga: remove redundant assignment after a mask operation

The assignment operation after a & mask operation is redundant, the variables being assigned are not used afterwards. Replace the &= operator with just & operator.

Cleans up two clang-scan warnings:
drivers/clk/socfpga/clk-gate.c:37:10: warning: Although the value stored to 'l4_src' is used in the enclosing expression, the value is never actually read from 'l4_src' [deadcode.DeadStores]

                return l4_src &= 0x1;
                       ^         ~~~
drivers/clk/socfpga/clk-gate.c:46:10: warning: Although the value stored
to 'perpll_src' is used in the enclosing expression, the value is never
actually read from 'perpll_src' [deadcode.DeadStores]
                return perpll_src &= 0x3;
---
 drivers/clk/socfpga/clk-gate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/socfpga/clk-gate.c +2 -2
index 1ec9678d8cd3..53d6e3ec4309 100644
@@ -34,7 +34,7 @@ static u8 socfpga_clk_get_parent(struct clk_hw *hwclk)
 
 	if (streq(name, SOCFPGA_L4_MP_CLK)) {
 		l4_src = readl(clk_mgr_base_addr + CLKMGR_L4SRC);
-		return l4_src &= 0x1;
+		return l4_src & 0x1;
 	}
 	if (streq(name, SOCFPGA_L4_SP_CLK)) {
 		l4_src = readl(clk_mgr_base_addr + CLKMGR_L4SRC);
@@ -43,7 +43,7 @@ static u8 socfpga_clk_get_parent(struct clk_hw *hwclk)
 
 	perpll_src = readl(clk_mgr_base_addr + CLKMGR_PERPLL_SRC);
 	if (streq(name, SOCFPGA_MMC_CLK))
-		return perpll_src &= 0x3;
+		return perpll_src & 0x3;
 	if (streq(name, SOCFPGA_NAND_CLK) ||
 	    streq(name, SOCFPGA_NAND_X_CLK))
 		return (perpll_src >> 2) & 3;
Signature · 1 line
2.33.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 35 lines · Colin Ian King

The assignment operation after a & mask operation is redundant, the variables being assigned are not used afterwards. Replace the &= operator with just & operator.

Cleans up two clang-scan warnings:
drivers/clk/socfpga/clk-gate.c:37:10: warning: Although the value stored to 'l4_src' is used in the enclosing expression, the value is never actually read from 'l4_src' [deadcode.DeadStores]

                 return l4_src &= 0x1;
                        ^         ~~~
drivers/clk/socfpga/clk-gate.c:46:10: warning: Although the value stored
to 'perpll_src' is used in the enclosing expression, the value is never
actually read from 'perpll_src' [deadcode.DeadStores]
                 return perpll_src &= 0x3;
---
  drivers/clk/socfpga/clk-gate.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/socfpga/clk-gate.c +1 -1
index 1ec9678d8cd3..53d6e3ec4309 100644
@@ -34,7 +34,7 @@ static u8 socfpga_clk_get_parent(struct clk_hw *hwclk)
 
  	if (streq(name, SOCFPGA_L4_MP_CLK)) {
  		l4_src = readl(clk_mgr_base_addr + CLKMGR_L4SRC);
-		return l4_src &= 0x1;
+		return l4_src & 0x1;
  	}
  	if (streq(name, SOCFPGA_L4_SP_CLK)) {
  		l4_src = readl(clk_mgr_base_addr + CLKMGR_L4SRC);

drivers/clk/socfpga/clk-gate.c static u8 socfpga_clk_get_parent(struct clk_hw *hwclk) · line 49

Quoted 8 lines
drivers/clk/socfpga/clk-gate.c +1 -1
@@ -43,7 +43,7 @@ static u8 socfpga_clk_get_parent(struct clk_hw *hwclk)
 
  	perpll_src = readl(clk_mgr_base_addr + CLKMGR_PERPLL_SRC);
  	if (streq(name, SOCFPGA_MMC_CLK))
-		return perpll_src &= 0x3;
+		return perpll_src & 0x3;
  	if (streq(name, SOCFPGA_NAND_CLK) ||
  	    streq(name, SOCFPGA_NAND_X_CLK))
  		return (perpll_src >> 2) & 3;
maintainer Applied
#2 lore raw
In reply to Colin Ian King

Quoting Colin Ian King (2021-12-30 07:03:21)

Quoted 15 lines

The assignment operation after a & mask operation is redundant, the variables being assigned are not used afterwards. Replace the &= operator with just & operator.

Cleans up two clang-scan warnings:
drivers/clk/socfpga/clk-gate.c:37:10: warning: Although the value stored to 'l4_src' is used in the enclosing expression, the value is never actually read from 'l4_src' [deadcode.DeadStores]

                return l4_src &= 0x1;
                       ^         ~~~
drivers/clk/socfpga/clk-gate.c:46:10: warning: Although the value stored
to 'perpll_src' is used in the enclosing expression, the value is never
actually read from 'perpll_src' [deadcode.DeadStores]
                return perpll_src &= 0x3;
Quoted 2 lines

---

Applied to clk-next