Re: [PATCH 1/2] clk: pistachio: Fix initconst confusion

From: Stephen Boyd
Date: Wed Jun 29 2022 - 04:21:13 EST


Quoting Jiri Slaby (2022-06-27 00:46:15)
> On 24. 06. 22, 2:42, Stephen Boyd wrote:
> > Quoting Jiri Slaby (2022-06-23 01:32:16)
> >> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> >>
> >> A variable pointing to const isn't const itself. It'd have to contain
> >> "const" keyword after "*" too. Therefore, PNAME() cannot put the strings
> >> to "rodata". Hence use __initdata instead of __initconst to fix this.
> >>
> >> [js] more explanatory commit message.
> >>
> >> Cc: Michael Turquette <mturquette@xxxxxxxxxxxx>
> >> Cc: Stephen Boyd <sboyd@xxxxxxxxxx>
> >> Cc: linux-clk@xxxxxxxxxxxxxxx
> >> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> >> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> >> ---
> >> drivers/clk/pistachio/clk.h | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/clk/pistachio/clk.h b/drivers/clk/pistachio/clk.h
> >> index f9c31e3a0e47..742e5fab00c0 100644
> >> --- a/drivers/clk/pistachio/clk.h
> >> +++ b/drivers/clk/pistachio/clk.h
> >> @@ -34,7 +34,7 @@ struct pistachio_mux {
> >> const char **parents;
> >> };
> >>
> >> -#define PNAME(x) static const char *x[] __initconst
> >> +#define PNAME(x) static const char *x[] __initdata
> >
> > Can it be const char * const and left as __initconst?
>
> Let me check, IIRC the struct where this is assigned would need to be
> updated too.
>
> I will get into it only some time next week.
>

Ok, sounds good. This seems to at least compile locally.

----8<---

diff --git a/drivers/clk/pistachio/clk.h b/drivers/clk/pistachio/clk.h
index f9c31e3a0e47..8be02ac2d909 100644
--- a/drivers/clk/pistachio/clk.h
+++ b/drivers/clk/pistachio/clk.h
@@ -31,10 +31,10 @@ struct pistachio_mux {
unsigned int shift;
unsigned int num_parents;
const char *name;
- const char **parents;
+ const char * const *parents;
};

-#define PNAME(x) static const char *x[] __initconst
+#define PNAME(x) static const char * const x[] __initconst

#define MUX(_id, _name, _pnames, _reg, _shift) \
{ \