This serie removes 2 fields from struct clk_fractional_divider and shrinks it
from 72 to 56 bytes.
Instead of been pre-computed, thse fields are now computed when needed.
The first patch makes the [mn]mask fields useless.
Patch 2 and 3 make some needed modification in 2 drivers that where using these
fields.
Finally, patch 4 removes the now used fields.
This is a another approach of what was proposed in v1. (i.e. just moving a field
to shrink from 72 ro 64 bytes)
Compared to v1, all 4 patches are new.
Suggested-by: Stephen Boyd <[email protected]>
v1:
https://lore.kernel.org/linux-kernel/d1874eb8848d5f97f87337011188640a1463a666.1676649335.git.christophe.jaillet@wanadoo.fr/
Christophe JAILLET (4):
clk: Compute masks for fractional_divider clk when needed.
clk: imx: Remove values for mmask and nmask in struct
clk_fractional_divider
clk: rockchip: Remove values for mmask and nmask in struct
clk_fractional_divider
clk: Remove mmask and nmask fields in struct clk_fractional_divider
drivers/clk/clk-fractional-divider.c | 16 +++++++++++-----
drivers/clk/imx/clk-composite-7ulp.c | 4 ----
drivers/clk/rockchip/clk.c | 2 --
include/linux/clk-provider.h | 2 --
4 files changed, 11 insertions(+), 13 deletions(-)
--
2.34.1
Now that fractional_divider clk computes mmask and nmask when needed, there
is no more need to provide them explicitly anymore.
Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/clk/rockchip/clk.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index a8646794575a..4059d9365ae6 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -244,10 +244,8 @@ static struct clk *rockchip_clk_register_frac_branch(
div->reg = base + muxdiv_offset;
div->mshift = 16;
div->mwidth = 16;
- div->mmask = GENMASK(div->mwidth - 1, 0) << div->mshift;
div->nshift = 0;
div->nwidth = 16;
- div->nmask = GENMASK(div->nwidth - 1, 0) << div->nshift;
div->lock = lock;
div->approximation = rockchip_fractional_approximation;
div_ops = &clk_fractional_divider_ops;
--
2.34.1
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 <[email protected]>
---
drivers/clk/clk-fractional-divider.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c
index 6affe3565025..479297763e70 100644
--- a/drivers/clk/clk-fractional-divider.c
+++ b/drivers/clk/clk-fractional-divider.c
@@ -71,6 +71,7 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract)
struct clk_fractional_divider *fd = to_clk_fd(hw);
unsigned long flags = 0;
unsigned long m, n;
+ u32 mmask, nmask;
u32 val;
if (fd->lock)
@@ -85,8 +86,11 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract)
else
__release(fd->lock);
- m = (val & fd->mmask) >> fd->mshift;
- n = (val & fd->nmask) >> fd->nshift;
+ mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
+ nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
+
+ m = (val & mmask) >> fd->mshift;
+ n = (val & nmask) >> fd->nshift;
if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) {
m++;
@@ -166,6 +170,7 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
struct clk_fractional_divider *fd = to_clk_fd(hw);
unsigned long flags = 0;
unsigned long m, n;
+ u32 mmask, nmask;
u32 val;
rational_best_approximation(rate, parent_rate,
@@ -182,8 +187,11 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
else
__acquire(fd->lock);
+ mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
+ nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
+
val = clk_fd_readl(fd);
- val &= ~(fd->mmask | fd->nmask);
+ val &= ~(mmask | nmask);
val |= (m << fd->mshift) | (n << fd->nshift);
clk_fd_writel(fd, val);
@@ -260,10 +268,8 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev,
fd->reg = reg;
fd->mshift = mshift;
fd->mwidth = mwidth;
- fd->mmask = GENMASK(mwidth - 1, 0) << mshift;
fd->nshift = nshift;
fd->nwidth = nwidth;
- fd->nmask = GENMASK(nwidth - 1, 0) << nshift;
fd->flags = clk_divider_flags;
fd->lock = lock;
fd->hw.init = &init;
--
2.34.1
Now that fractional_divider clk computes mmask and nmask when needed, there
is no more need to provide them explicitly anymore.
Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/clk/imx/clk-composite-7ulp.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c
index 4eedd45dbaa8..e208ddc51133 100644
--- a/drivers/clk/imx/clk-composite-7ulp.c
+++ b/drivers/clk/imx/clk-composite-7ulp.c
@@ -19,10 +19,8 @@
#define PCG_CGC_SHIFT 30
#define PCG_FRAC_SHIFT 3
#define PCG_FRAC_WIDTH 1
-#define PCG_FRAC_MASK BIT(3)
#define PCG_PCD_SHIFT 0
#define PCG_PCD_WIDTH 3
-#define PCG_PCD_MASK 0x7
#define SW_RST BIT(28)
@@ -102,10 +100,8 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name,
fd->reg = reg;
fd->mshift = PCG_FRAC_SHIFT;
fd->mwidth = PCG_FRAC_WIDTH;
- fd->mmask = PCG_FRAC_MASK;
fd->nshift = PCG_PCD_SHIFT;
fd->nwidth = PCG_PCD_WIDTH;
- fd->nmask = PCG_PCD_MASK;
fd->flags = CLK_FRAC_DIVIDER_ZERO_BASED;
if (has_swrst)
fd->lock = &imx_ccm_lock;
--
2.34.1
All users of these fields have been removed.
They are now computed when needed with [mn]shift and [mn]width.
This shrinks the size of struct clk_fractional_divider from 72 to 56 bytes.
Signed-off-by: Christophe JAILLET <[email protected]>
---
include/linux/clk-provider.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index faad3cdc1e48..eb6930ae550f 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -1154,10 +1154,8 @@ struct clk_fractional_divider {
void __iomem *reg;
u8 mshift;
u8 mwidth;
- u32 mmask;
u8 nshift;
u8 nwidth;
- u32 nmask;
u8 flags;
void (*approximation)(struct clk_hw *hw,
unsigned long rate, unsigned long *parent_rate,
--
2.34.1
Am Sonntag, 2. April 2023, 11:42:04 CEST schrieb Christophe JAILLET:
> 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 <[email protected]>
Reviewed-by: Heiko Stuebner <[email protected]>
Am Sonntag, 2. April 2023, 11:42:04 CEST schrieb Christophe JAILLET:
> 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 <[email protected]>
Reviewed-by: Heiko Stuebner <[email protected]>
Am Sonntag, 2. April 2023, 11:42:06 CEST schrieb Christophe JAILLET:
> Now that fractional_divider clk computes mmask and nmask when needed, there
> is no more need to provide them explicitly anymore.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
Reviewed-by: Heiko Stuebner <[email protected]>
Am Sonntag, 2. April 2023, 11:42:07 CEST schrieb Christophe JAILLET:
> All users of these fields have been removed.
> They are now computed when needed with [mn]shift and [mn]width.
>
> This shrinks the size of struct clk_fractional_divider from 72 to 56 bytes.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
Reviewed-by: Heiko Stuebner <[email protected]>
On 23-04-02 11:42:05, Christophe JAILLET wrote:
> Now that fractional_divider clk computes mmask and nmask when needed, there
> is no more need to provide them explicitly anymore.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
Reviewed-by: Abel Vesa <[email protected]>
> ---
> drivers/clk/imx/clk-composite-7ulp.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c
> index 4eedd45dbaa8..e208ddc51133 100644
> --- a/drivers/clk/imx/clk-composite-7ulp.c
> +++ b/drivers/clk/imx/clk-composite-7ulp.c
> @@ -19,10 +19,8 @@
> #define PCG_CGC_SHIFT 30
> #define PCG_FRAC_SHIFT 3
> #define PCG_FRAC_WIDTH 1
> -#define PCG_FRAC_MASK BIT(3)
> #define PCG_PCD_SHIFT 0
> #define PCG_PCD_WIDTH 3
> -#define PCG_PCD_MASK 0x7
>
> #define SW_RST BIT(28)
>
> @@ -102,10 +100,8 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name,
> fd->reg = reg;
> fd->mshift = PCG_FRAC_SHIFT;
> fd->mwidth = PCG_FRAC_WIDTH;
> - fd->mmask = PCG_FRAC_MASK;
> fd->nshift = PCG_PCD_SHIFT;
> fd->nwidth = PCG_PCD_WIDTH;
> - fd->nmask = PCG_PCD_MASK;
> fd->flags = CLK_FRAC_DIVIDER_ZERO_BASED;
> if (has_swrst)
> fd->lock = &imx_ccm_lock;
> --
> 2.34.1
>
Quoting Christophe JAILLET (2023-04-02 02:42:06)
> Now that fractional_divider clk computes mmask and nmask when needed, there
> is no more need to provide them explicitly anymore.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
Applied to clk-next
Quoting Christophe JAILLET (2023-04-02 02:42:05)
> Now that fractional_divider clk computes mmask and nmask when needed, there
> is no more need to provide them explicitly anymore.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
Applied to clk-next
Quoting Christophe JAILLET (2023-04-02 02:42:07)
> All users of these fields have been removed.
> They are now computed when needed with [mn]shift and [mn]width.
>
> This shrinks the size of struct clk_fractional_divider from 72 to 56 bytes.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
Applied to clk-next
Quoting Christophe JAILLET (2023-04-02 02:42:04)
> 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 <[email protected]>
> ---
Applied to clk-next