clk: visconti: Remove dead code
Subsystems (3)
PATCH 1/1 clk: visconti: Remove dead code
rs_id is of unsigned type, u8. The condition rs_id >= 0 will always be true. Remove the if-else condition and the dead code.
--- drivers/clk/visconti/clkc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clk/visconti/clkc.c +3 -7
@@ -147,13 +147,9 @@ int visconti_clk_register_gates(struct visconti_clk_provider *ctx,if (!dev_name)return -ENOMEM ; -if (clks[i].rs_id >=0 ) { - rson_offset = reset[clks[i].rs_id].rson_offset; - rsoff_offset = reset[clks[i].rs_id].rsoff_offset; - rs_idx = reset[clks[i].rs_id].rs_idx; - }else { - rson_offset = rsoff_offset = rs_idx =-1 ; - } + rson_offset = reset[clks[i].rs_id].rson_offset; + rsoff_offset = reset[clks[i].rs_id].rsoff_offset; + rs_idx = reset[clks[i].rs_id].rs_idx; div_clk = devm_clk_hw_register_fixed_factor(dev, dev_name,
Signature · 1 line
2.30.2
Quoted 3 lines · Muhammad Usama Anjum
rs_idis of unsigned type, u8. The conditionrs_id>= 0 will always be true. Remove the if-else condition and the dead code.
No, this isn't the right fix.
Quoted 13 lines
Signed-off-by Muhammad Usama Anjum <[email protected]>--- drivers/clk/visconti/clkc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/clk/visconti/clkc.c +0
-0@@ -147,13 +147,9 @@ int visconti_clk_register_gates(struct visconti_clk_provider *ctx,if (!dev_name)return -ENOMEM ;
drivers/clk/visconti/clkc.c int visconti_clk_register_gates(struct visconti_clk_provider *ctx, · line 152
Quoted 10 lines
drivers/clk/visconti/clkc.c +3
-7-if (clks[i].rs_id >=0 ) { - rson_offset = reset[clks[i].rs_id].rson_offset; - rsoff_offset = reset[clks[i].rs_id].rsoff_offset; - rs_idx = reset[clks[i].rs_id].rs_idx; - }else { - rson_offset = rsoff_offset = rs_idx =-1 ; - } + rson_offset = reset[clks[i].rs_id].rson_offset; + rsoff_offset = reset[clks[i].rs_id].rsoff_offset; + rs_idx = reset[clks[i].rs_id].rs_idx;
With Smatch you can type:
$ smdb.py where visconti_clk_gate_table rs_id drivers/clk/visconti/clkc-tmpv770x.c | (null) | (struct visconti_clk_gate_table)->rs_id | 0-31,255
That tells you it is assigned 255 as a global in drivers/clk/visconti/clkc-tmpv770x.c It takes some digging to find that assignment...
drivers/clk/visconti/clkc-tmpv770x.c
175 /* PISYSTEM */
176 { TMPV770X_CLK_WRCK, "wrck",
177 clks_parent_data, ARRAY_SIZE(clks_parent_data),
178 0, 0x68, 0x168, 9, 32,
179 -1, }, /* No reset */
^^Really, that -1 there should generate a static checker warning but it doesn't on Smatch... :/
But the probably the correct fix is to make rs_id and related variables and int instead of a u8. I saw this bug but just reported it instead of fixing it.
regards,
dan carpenter