clk: shrink struct clk_fractional_divider
Subsystems (5)
v2 cover clk: shrink struct clk_fractional_divider
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.
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(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 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.
--- drivers/clk/clk-fractional-divider.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/clk/clk-fractional-divider.c +11 -5
@@ -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;
Signature · 1 line
2.34.1
PATCH v2 2/4 clk: imx: Remove values for mmask and nmask in struct clk_fractional_divider
In reply to Christophe JAILLETNow that fractional_divider clk computes mmask and nmask when needed, there is no more need to provide them explicitly anymore.
--- drivers/clk/imx/clk-composite-7ulp.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/clk/imx/clk-composite-7ulp.c +0 -4
@@ -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;
Signature · 1 line
2.34.1
PATCH v2 3/4 clk: rockchip: Remove values for mmask and nmask in struct clk_fractional_divider
In reply to Christophe JAILLETNow that fractional_divider clk computes mmask and nmask when needed, there is no more need to provide them explicitly anymore.
--- drivers/clk/rockchip/clk.c | 2 -- 1 file changed, 2 deletions(-)
drivers/clk/rockchip/clk.c +0 -2
@@ -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;
Signature · 1 line
2.34.1
PATCH v2 4/4 clk: Remove mmask and nmask fields in struct clk_fractional_divider
In reply to Christophe JAILLETAll 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.
--- include/linux/clk-provider.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/clk-provider.h +0 -2
@@ -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,
Signature · 1 line
2.34.1
Re: [PATCH v2 1/4] clk: Compute masks for fractional_divider clk when needed.
In reply to Christophe JAILLETAm Sonntag, 2. April 2023, 11:42:04 CEST schrieb Christophe JAILLET:
Quoted 6 lines
There is no real need to pre-compute mmask and nmask when handling
fractional_dividerclk.They can be computed when needed.
Signed-off-by Christophe JAILLET <[email protected]>
Re: [PATCH v2 1/4] clk: Compute masks for fractional_divider clk when needed.
In reply to Christophe JAILLETAm Sonntag, 2. April 2023, 11:42:04 CEST schrieb Christophe JAILLET:
Quoted 6 lines
There is no real need to pre-compute mmask and nmask when handling
fractional_dividerclk.They can be computed when needed.
Signed-off-by Christophe JAILLET <[email protected]>
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v2 3/4] clk: rockchip: Remove values for mmask and nmask in struct clk_fractional_divider
In reply to Christophe JAILLETAm Sonntag, 2. April 2023, 11:42:06 CEST schrieb Christophe JAILLET:
Quoted 4 lines
Now that
fractional_dividerclk computes mmask and nmask when needed, there is no more need to provide them explicitly anymore.Signed-off-by Christophe JAILLET <[email protected]>
Re: [PATCH v2 4/4] clk: Remove mmask and nmask fields in struct clk_fractional_divider
In reply to Christophe JAILLETAm Sonntag, 2. April 2023, 11:42:07 CEST schrieb Christophe JAILLET:
Quoted 6 lines
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_dividerfrom 72 to 56 bytes.Signed-off-by Christophe JAILLET <[email protected]>
Re: [PATCH v2 2/4] clk: imx: Remove values for mmask and nmask in struct clk_fractional_divider
In reply to Christophe JAILLETQuoted 4 lines · Christophe JAILLET
Now that
fractional_dividerclk computes mmask and nmask when needed, there is no more need to provide them explicitly anymore.Signed-off-by Christophe JAILLET <[email protected]>
Quoted 33 lines
--- drivers/clk/imx/clk-composite-7ulp.c | 4 ---- 1 file changed, 4 deletions(-)drivers/clk/imx/clk-composite-7ulp.c +0
-4@@ -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;Signature · 1 line
2.34.1
Re: [PATCH v2 4/4] clk: Remove mmask and nmask fields in struct clk_fractional_divider
In reply to Christophe JAILLETQuoting Christophe JAILLET (2023-04-02 02:42:07)
Quoted 7 lines
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_dividerfrom 72 to 56 bytes.Signed-off-by Christophe JAILLET <[email protected]>---
Applied to clk-next
Re: [PATCH v2 3/4] clk: rockchip: Remove values for mmask and nmask in struct clk_fractional_divider
In reply to Christophe JAILLETQuoting Christophe JAILLET (2023-04-02 02:42:06)
Quoted 5 lines
Now that
fractional_dividerclk 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
Re: [PATCH v2 2/4] clk: imx: Remove values for mmask and nmask in struct clk_fractional_divider
In reply to Christophe JAILLETQuoting Christophe JAILLET (2023-04-02 02:42:05)
Quoted 5 lines
Now that
fractional_dividerclk 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
Re: [PATCH v2 1/4] clk: Compute masks for fractional_divider clk when needed.
In reply to Christophe JAILLETQuoting Christophe JAILLET (2023-04-02 02:42:04)
Quoted 7 lines
There is no real need to pre-compute mmask and nmask when handling
fractional_dividerclk.They can be computed when needed.
Signed-off-by Christophe JAILLET <[email protected]>---
Applied to clk-next