Re: [PATCH] clk: don't use __initconst for non-const arrays
On 12 September 2014 00:04, Uwe Kleine-König u.kleine-koe...@pengutronix.de wrote: Hello, On Thu, Sep 11, 2014 at 11:04:31PM +0200, Uwe Kleine-König wrote: /* Mux parent lists. */ -static const char *fin_pll_p[] __initconst = { +static const char *fin_pll_p[] __initdata = { xxti, xusbxti }; As discussed with Tomasz on irc: The sad thing here is that for this array only 8 bytes are freed when .init.rodata is thrown away (that is two pointers). The actual data---5 + 8 bytes + maybe aligning---isn't freed though. We wondered if there is a nice and easy way to throw away the characters, too. The only way I currently see is: const char xxti[] __initconst = xxti; ... static const char *fin_pll_p[] __initdata = { xxti, ... }; but this definitively doesn't qualify as nice and easy. Is there an alternative? What about doing static const char fin_pll_p[][8] __initconst = { xxti, xusbxti }; -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] clk: don't use __initconst for non-const arrays
Hello Ard, On Fri, Sep 12, 2014 at 09:42:29AM +0200, Ard Biesheuvel wrote: On 12 September 2014 00:04, Uwe Kleine-König u.kleine-koe...@pengutronix.de wrote: Hello, On Thu, Sep 11, 2014 at 11:04:31PM +0200, Uwe Kleine-König wrote: /* Mux parent lists. */ -static const char *fin_pll_p[] __initconst = { +static const char *fin_pll_p[] __initdata = { xxti, xusbxti }; As discussed with Tomasz on irc: The sad thing here is that for this array only 8 bytes are freed when .init.rodata is thrown away (that is two pointers). The actual data---5 + 8 bytes + maybe aligning---isn't freed though. We wondered if there is a nice and easy way to throw away the characters, too. The only way I currently see is: const char xxti[] __initconst = xxti; ... static const char *fin_pll_p[] __initdata = { xxti, ... }; but this definitively doesn't qualify as nice and easy. Is there an alternative? What about doing static const char fin_pll_p[][8] __initconst = { xxti, xusbxti }; This results in the strings being moved to .init.rodata and so they are discarded. But it also results in: drivers/clk/samsung/clk-s5pv210.c:412:2: warning: initialization from incompatible pointer type [enabled by default] MUX_F(FIN_PLL, fin_pll, fin_pll_p, OM_STAT, 0, 1, ^ drivers/clk/samsung/clk-s5pv210.c:412:2: warning: (near initialization for 'early_mux_clks[0].parent_names') [enabled by default] That's because early_mux_clks[0].parent_names is of type const char ** while fin_pll_p as suggested doesn't provide an array of pointers to the start of the contained strings. I don't see a way to fix that unless we fix the maximal clock name length globally and so waste much memory. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] clk: don't use __initconst for non-const arrays
The statement static const char *name[]; defines a modifiable array of pointers to constant chars. That is *name[0] = 'f'; is forbidden, but name[0] = f; is not. So marking an array that is defined as above with __initconst is wrong. Either an additional const must be added such that the whole definition reads: static const char *const name[] __initconst; or where this is not possible __initdata must be used. Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de --- drivers/clk/hisilicon/clk-hix5hd2.c | 6 ++-- drivers/clk/mxs/clk-imx23.c | 12 drivers/clk/mxs/clk-imx28.c | 18 ++-- drivers/clk/rockchip/clk.h | 2 +- drivers/clk/samsung/clk-s5pv210.c | 56 ++--- drivers/clk/ti/composite.c | 2 +- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hix5hd2.c b/drivers/clk/hisilicon/clk-hix5hd2.c index e5fcfb4e32ef..7acae2eeb490 100644 --- a/drivers/clk/hisilicon/clk-hix5hd2.c +++ b/drivers/clk/hisilicon/clk-hix5hd2.c @@ -44,15 +44,15 @@ static struct hisi_fixed_rate_clock hix5hd2_fixed_rate_clks[] __initdata = { { HIX5HD2_FIXED_83M, 83m, NULL, CLK_IS_ROOT, 8333, }, }; -static const char *sfc_mux_p[] __initconst = { +static const char *sfc_mux_p[] __initdata = { 24m, 150m, 200m, 100m, 75m, }; static u32 sfc_mux_table[] = {0, 4, 5, 6, 7}; -static const char *sdio1_mux_p[] __initconst = { +static const char *sdio1_mux_p[] __initdata = { 75m, 100m, 50m, 15m, }; static u32 sdio1_mux_table[] = {0, 1, 2, 3}; -static const char *fephy_mux_p[] __initconst = { 25m, 125m}; +static const char *fephy_mux_p[] __initdata = { 25m, 125m}; static u32 fephy_mux_table[] = {0, 1}; diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c index 9fc9359f5133..22d136aa699f 100644 --- a/drivers/clk/mxs/clk-imx23.c +++ b/drivers/clk/mxs/clk-imx23.c @@ -77,12 +77,12 @@ static void __init clk_misc_init(void) writel_relaxed(30 BP_FRAC_IOFRAC, FRAC + SET); } -static const char *sel_pll[] __initconst = { pll, ref_xtal, }; -static const char *sel_cpu[] __initconst = { ref_cpu, ref_xtal, }; -static const char *sel_pix[] __initconst = { ref_pix, ref_xtal, }; -static const char *sel_io[] __initconst = { ref_io, ref_xtal, }; -static const char *cpu_sels[] __initconst = { cpu_pll, cpu_xtal, }; -static const char *emi_sels[] __initconst = { emi_pll, emi_xtal, }; +static const char *sel_pll[] __initdata = { pll, ref_xtal, }; +static const char *sel_cpu[] __initdata = { ref_cpu, ref_xtal, }; +static const char *sel_pix[] __initdata = { ref_pix, ref_xtal, }; +static const char *sel_io[] __initdata = { ref_io, ref_xtal, }; +static const char *cpu_sels[] __initdata = { cpu_pll, cpu_xtal, }; +static const char *emi_sels[] __initdata = { emi_pll, emi_xtal, }; enum imx23_clk { ref_xtal, pll, ref_cpu, ref_emi, ref_pix, ref_io, saif_sel, diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c index a6c35010e4e5..b1be3746ce95 100644 --- a/drivers/clk/mxs/clk-imx28.c +++ b/drivers/clk/mxs/clk-imx28.c @@ -125,15 +125,15 @@ static void __init clk_misc_init(void) writel_relaxed(val, FRAC0); } -static const char *sel_cpu[] __initconst = { ref_cpu, ref_xtal, }; -static const char *sel_io0[] __initconst = { ref_io0, ref_xtal, }; -static const char *sel_io1[] __initconst = { ref_io1, ref_xtal, }; -static const char *sel_pix[] __initconst = { ref_pix, ref_xtal, }; -static const char *sel_gpmi[] __initconst = { ref_gpmi, ref_xtal, }; -static const char *sel_pll0[] __initconst = { pll0, ref_xtal, }; -static const char *cpu_sels[] __initconst = { cpu_pll, cpu_xtal, }; -static const char *emi_sels[] __initconst = { emi_pll, emi_xtal, }; -static const char *ptp_sels[] __initconst = { ref_xtal, pll0, }; +static const char *sel_cpu[] __initdata = { ref_cpu, ref_xtal, }; +static const char *sel_io0[] __initdata = { ref_io0, ref_xtal, }; +static const char *sel_io1[] __initdata = { ref_io1, ref_xtal, }; +static const char *sel_pix[] __initdata = { ref_pix, ref_xtal, }; +static const char *sel_gpmi[] __initdata = { ref_gpmi, ref_xtal, }; +static const char *sel_pll0[] __initdata = { pll0, ref_xtal, }; +static const char *cpu_sels[] __initdata = { cpu_pll, cpu_xtal, }; +static const char *emi_sels[] __initdata = { emi_pll, emi_xtal, }; +static const char *ptp_sels[] __initdata = { ref_xtal, pll0, }; enum imx28_clk { ref_xtal, pll0, pll1, pll2, ref_cpu, ref_emi, ref_io0, ref_io1, diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h index 887cbdeca2aa..74fbb9c4b6de 100644 --- a/drivers/clk/rockchip/clk.h +++ b/drivers/clk/rockchip/clk.h @@ -120,7 +120,7 @@ struct clk *rockchip_clk_register_pll(enum rockchip_pll_type pll_type, struct rockchip_pll_rate_table *rate_table, spinlock_t *lock); -#define
Re: [PATCH] clk: don't use __initconst for non-const arrays
[adding Sylwester and removing my samsung.com e-mail which is no longer valid] On 11.09.2014 23:04, Uwe Kleine-König wrote: The statement static const char *name[]; defines a modifiable array of pointers to constant chars. That is *name[0] = 'f'; is forbidden, but name[0] = f; is not. So marking an array that is defined as above with __initconst is wrong. Either an additional const must be added such that the whole definition reads: static const char *const name[] __initconst; or where this is not possible __initdata must be used. Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de --- drivers/clk/hisilicon/clk-hix5hd2.c | 6 ++-- drivers/clk/mxs/clk-imx23.c | 12 drivers/clk/mxs/clk-imx28.c | 18 ++-- drivers/clk/rockchip/clk.h | 2 +- drivers/clk/samsung/clk-s5pv210.c | 56 ++--- For drivers/clk/samsung/* Acked-by: Tomasz Figa tomasz.f...@gmail.com Best regards, Tomasz -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] clk: don't use __initconst for non-const arrays
Hello, On Thu, Sep 11, 2014 at 11:04:31PM +0200, Uwe Kleine-König wrote: /* Mux parent lists. */ -static const char *fin_pll_p[] __initconst = { +static const char *fin_pll_p[] __initdata = { xxti, xusbxti }; As discussed with Tomasz on irc: The sad thing here is that for this array only 8 bytes are freed when .init.rodata is thrown away (that is two pointers). The actual data---5 + 8 bytes + maybe aligning---isn't freed though. We wondered if there is a nice and easy way to throw away the characters, too. The only way I currently see is: const char xxti[] __initconst = xxti; ... static const char *fin_pll_p[] __initdata = { xxti, ... }; but this definitively doesn't qualify as nice and easy. Is there an alternative? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html