Skip to contentSkip to conversation

drivers: clk: zynqmp: Allow zero divisor value

PATCH Applied Jolly Shah 3 participants 5 messages Mar 4, 2019 – Apr 11, 2019

Subsystems (2)
lore
Share & tools
lore

Jolly Shah

author
#0 lore raw

PATCH 1/1 drivers: clk: zynqmp: Allow zero divisor value

From: Rajan Vaja <[email protected]>

Zero divider is valid and default for some of ZynqMP clocks. Allow zero divisor when CLK_DIVIDER_ALLOW_ZERO for the clock is set.

---
 drivers/clk/zynqmp/divider.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/clk/zynqmp/divider.c +7 -0
index a371c66..e146b6f 100644
@@ -76,6 +76,13 @@ static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw,
 	else
 		value = div >> 16;
 
+	if (!value) {
+		WARN(!(divider->flags & CLK_DIVIDER_ALLOW_ZERO),
+		     "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
+		     clk_name);
+		return parent_rate;
+	}
+
 	return DIV_ROUND_UP_ULL(parent_rate, value);
 }
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 21 lines · Jolly Shah

From: Rajan Vaja <[email protected]>

Zero divider is valid and default for some of ZynqMP clocks. Allow zero divisor when CLK_DIVIDER_ALLOW_ZERO for the clock is set.

---
 drivers/clk/zynqmp/divider.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/clk/zynqmp/divider.c +0 -0
index a371c66..e146b6f 100644
@@ -76,6 +76,13 @@ static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw,
 	else
 		value = div >> 16;
 

drivers/clk/zynqmp/divider.c static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw, · line 88

Quoted 10 lines
drivers/clk/zynqmp/divider.c +7 -0
+	if (!value) {
+		WARN(!(divider->flags & CLK_DIVIDER_ALLOW_ZERO),
+		     "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
+		     clk_name);
+		return parent_rate;
+	}
+
 	return DIV_ROUND_UP_ULL(parent_rate, value);
 }
 

Stephen: Do you want to take it via your tree?

Thanks,
Michal

maintainer
#2 lore raw

Quoting Michal Simek (2019-03-18 05:48:52)

Quoted 21 lines · Jolly Shah
Quoted 20 lines

From: Rajan Vaja <[email protected]>

Zero divider is valid and default for some of ZynqMP clocks. Allow zero divisor when CLK_DIVIDER_ALLOW_ZERO for the clock is set.

---
 drivers/clk/zynqmp/divider.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/clk/zynqmp/divider.c +0 -0
index a371c66..e146b6f 100644
@@ -76,6 +76,13 @@ static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw,
      else
              value = div >> 16;
 
Quoted 14 lines

drivers/clk/zynqmp/divider.c static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw, · line 88

Quoted 11 lines
drivers/clk/zynqmp/divider.c +7 -0
+     if (!value) {
+             WARN(!(divider->flags & CLK_DIVIDER_ALLOW_ZERO),
+                  "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
+                  clk_name);
+             return parent_rate;
+     }
+
      return DIV_ROUND_UP_ULL(parent_rate, value);
 }
 

Stephen: Do you want to take it via your tree?

Sure.

#3 lore raw
Quoted 37 lines · Stephen Boyd

Quoting Michal Simek (2019-03-18 05:48:52)

Quoted 21 lines · Jolly Shah
Quoted 20 lines

From: Rajan Vaja <[email protected]>

Zero divider is valid and default for some of ZynqMP clocks. Allow zero divisor when CLK_DIVIDER_ALLOW_ZERO for the clock is set.

---
 drivers/clk/zynqmp/divider.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/clk/zynqmp/divider.c +0 -0
index a371c66..e146b6f 100644
@@ -76,6 +76,13 @@ static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw,
      else
              value = div >> 16;
 
Quoted 14 lines

drivers/clk/zynqmp/divider.c static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw, · line 88

Quoted 11 lines
drivers/clk/zynqmp/divider.c +7 -0
+     if (!value) {
+             WARN(!(divider->flags & CLK_DIVIDER_ALLOW_ZERO),
+                  "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
+                  clk_name);
+             return parent_rate;
+     }
+
      return DIV_ROUND_UP_ULL(parent_rate, value);
 }
 

Stephen: Do you want to take it via your tree?

Quoted 1 line

Sure.

ok. Then your turn with that two patches when you have time.

Thanks,
Michal