Skip to content

Commit 141b325

Browse files
tititiou36bebarino
authored andcommitted
clk: Compute masks for fractional_divider clk when needed.
There is no real need to pre-compute mmask and nmask when handling fractional_divider clk. They can be computed when needed. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/0fd6357242c974259c9e034c6e28a0391c480bf0.1680423909.git.christophe.jaillet@wanadoo.fr Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent fe15c26 commit 141b325

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/clk/clk-fractional-divider.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract)
7171
struct clk_fractional_divider *fd = to_clk_fd(hw);
7272
unsigned long flags = 0;
7373
unsigned long m, n;
74+
u32 mmask, nmask;
7475
u32 val;
7576

7677
if (fd->lock)
@@ -85,8 +86,11 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract)
8586
else
8687
__release(fd->lock);
8788

88-
m = (val & fd->mmask) >> fd->mshift;
89-
n = (val & fd->nmask) >> fd->nshift;
89+
mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
90+
nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
91+
92+
m = (val & mmask) >> fd->mshift;
93+
n = (val & nmask) >> fd->nshift;
9094

9195
if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) {
9296
m++;
@@ -166,6 +170,7 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
166170
struct clk_fractional_divider *fd = to_clk_fd(hw);
167171
unsigned long flags = 0;
168172
unsigned long m, n;
173+
u32 mmask, nmask;
169174
u32 val;
170175

171176
rational_best_approximation(rate, parent_rate,
@@ -182,8 +187,11 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
182187
else
183188
__acquire(fd->lock);
184189

190+
mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
191+
nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
192+
185193
val = clk_fd_readl(fd);
186-
val &= ~(fd->mmask | fd->nmask);
194+
val &= ~(mmask | nmask);
187195
val |= (m << fd->mshift) | (n << fd->nshift);
188196
clk_fd_writel(fd, val);
189197

@@ -260,10 +268,8 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev,
260268
fd->reg = reg;
261269
fd->mshift = mshift;
262270
fd->mwidth = mwidth;
263-
fd->mmask = GENMASK(mwidth - 1, 0) << mshift;
264271
fd->nshift = nshift;
265272
fd->nwidth = nwidth;
266-
fd->nmask = GENMASK(nwidth - 1, 0) << nshift;
267273
fd->flags = clk_divider_flags;
268274
fd->lock = lock;
269275
fd->hw.init = &init;

0 commit comments

Comments
 (0)