pinctrl: imx: prepare for making "group_names" in "function_desc" const
Subsystems (5)
PATCH v2 1/4 pinctrl: imx: prepare for making "group_names" in "function_desc" const
From: Rafał Miłecki <[email protected]>
The plan for "struct function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data.
This imx change is required to avoid:drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinctrl_parse_functions':drivers/pinctrl/freescale/pinctrl-imx.c:672:24: error: assignment of read-only location '*(func->group_names + (sizetype)(i * 4))'
672 | func->group_names[i] = child->name;
| ^
--- drivers/pinctrl/freescale/pinctrl-imx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +7 -4
@@ -648,6 +648,7 @@ static int imx_pinctrl_parse_functions(struct device_node *np,struct device_node *child;struct function_desc *func;struct group_desc *grp; +const char **group_names;u32 i =0 ;dev_dbg (pctl->dev,"parse function(%d): %pOFn\n" , index, np);
@@ -663,14 +664,16 @@ static int imx_pinctrl_parse_functions(struct device_node *np,dev_err (ipctl->dev,"no groups defined in %pOF\n" , np);return -EINVAL ; } - func->group_names =devm_kcalloc (ipctl->dev, func->num_group_names, -sizeof (char *),GFP_KERNEL ); + + group_names =devm_kcalloc (ipctl->dev, func->num_group_names, +sizeof (char *),GFP_KERNEL );if (!func->group_names)return -ENOMEM ; +for_each_child_of_node (np, child) + group_names[i] = child->name; + func->group_names = group_names;for_each_child_of_node (np, child) { - func->group_names[i] = child->name; - grp =devm_kzalloc (ipctl->dev,sizeof (struct group_desc ),GFP_KERNEL );if (!grp) {
Signature · 1 line
2.31.1
PATCH v2 2/4 pinctrl: keembay: comment process of building functions a bit
From: Rafał Miłecki <[email protected]>
This should make code a bit easier to follow. While at it use some "for" loops to simplify array iteration loops.
--- drivers/pinctrl/pinctrl-keembay.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl-keembay.c +11 -10
@@ -1617,37 +1617,38 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)struct function_desc *keembay_funcs, *new_funcs;int i; -/* Allocate total number of functions */ +/* +* Allocate maximum possible number of functions. Assume every pin +* being part of 8 (hw maximum) globally unique muxes. +*/ kpc->nfuncs =0 ; keembay_funcs =kcalloc (kpc->npins *8 ,sizeof (*keembay_funcs),GFP_KERNEL );if (!keembay_funcs)return -ENOMEM ; -/* Find total number of functions and each's properties */ +/* Setup 1 function for each unique mux */ for (i =0 ; i < kpc->npins; i++) {const struct pinctrl_pin_desc *pdesc = keembay_pins + i; -struct keembay_mux_desc *mux = pdesc->drv_data; +struct keembay_mux_desc *mux; -while (mux->name) { -struct function_desc *fdesc = keembay_funcs; +for (mux = pdesc->drv_data; mux->name; mux++) { +struct function_desc *fdesc; -while (fdesc->name) { +/* Check if we already have function for this mux */ +for (fdesc = keembay_funcs; fdesc->name; fdesc++) {if (!strcmp (mux->name, fdesc->name)) { fdesc->num_group_names++;break ; } - - fdesc++; } +/* Setup new function for this mux we didn't see before */ if (!fdesc->name) { fdesc->name = mux->name; fdesc->num_group_names =1 ; fdesc->data = &mux->mode; kpc->nfuncs++; } - - mux++; } }
Signature · 1 line
2.31.1
PATCH v2 3/4 pinctrl: keembay: rework loops looking for groups names
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
Make the outer loop iterate over functions as that's the real subject. This simplifies code (and reduces amount of lines of code) as allocating memory for names doesn't require extra checks anymore.
While at it use local "group_names" variable. The plan for "struct function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data.
This keembay "group_names" change is required to avoid:drivers/pinctrl/pinctrl-keembay.c: In function 'keembay_add_functions':drivers/pinctrl/pinctrl-keembay.c:1594:8: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1594 | grp = func->group_names;
| ^
---
This has been runtime tested. I verified that output of /sys/kernel/debug/pinctrl/*/pinmux-functions is the same without and with my patches.
--- drivers/pinctrl/pinctrl-keembay.c | 66 ++++++++++++------------------- 1 file changed, 25 insertions(+), 41 deletions(-)
drivers/pinctrl/pinctrl-keembay.c +25 -41
@@ -1555,58 +1555,42 @@ static int keembay_pinctrl_reg(struct keembay_pinctrl *kpc, struct device *dev) }static int keembay_add_functions (struct keembay_pinctrl *kpc, -struct function_desc *function) +struct function_desc *functions) {unsigned int i;/* Assign the groups for each function */ -for (i =0 ; i < kpc->npins; i++) { -const struct pinctrl_pin_desc *pdesc = keembay_pins + i; -struct keembay_mux_desc *mux = pdesc->drv_data; - -while (mux->name) { -struct function_desc *func; -const char **grp; -size_t grp_size; -u32 j, grp_num; - -for (j =0 ; j < kpc->nfuncs; j++) { -if (!strcmp (mux->name, function[j].name)) -break ; - } - -if (j == kpc->nfuncs) -return -EINVAL ; - - func = function + j; - grp_num = func->num_group_names; - grp_size =sizeof (*func->group_names); - -if (!func->group_names) { - func->group_names =devm_kcalloc (kpc->dev, - grp_num, - grp_size, -GFP_KERNEL ); -if (!func->group_names) -return -ENOMEM ; +for (i =0 ; i < kpc->nfuncs; i++) { +struct function_desc *func = &functions[i]; +const char **group_names; +unsigned int grp_idx =0 ; +int j; + + group_names =devm_kcalloc (kpc->dev, func->num_group_names, +sizeof (*group_names),GFP_KERNEL ); +if (!group_names) +return -ENOMEM ; + +for (j =0 ; j < kpc->npins; j++) { +const struct pinctrl_pin_desc *pdesc = &keembay_pins[j]; +struct keembay_mux_desc *mux; + +for (mux = pdesc->drv_data; mux->name; mux++) { +if (!strcmp (mux->name, func->name)) + group_names[grp_idx++] = pdesc->name; } - - grp = func->group_names; -while (*grp) - grp++; - - *grp = pdesc->name; - mux++; } + + func->group_names = group_names; }/* Add all functions */ for (i =0 ; i < kpc->nfuncs; i++) {pinmux_generic_add_function (kpc->pctrl, - function[i].name, - function[i].group_names, - function[i].num_group_names, - function[i].data); + functions[i].name, + functions[i].group_names, + functions[i].num_group_names, + functions[i].data); }return 0 ;
Signature · 1 line
2.31.1
PATCH v2 4/4 pinctrl: add one more "const" for generic function groups
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in GENERIC_PINMUX_FUNCTIONS users.
--- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinmux.c +1 -1
@@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function);*/ int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,const unsigned int num_groups,void *data) {
drivers/pinctrl/pinmux.h +2 -2
@@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,*/ struct function_desc {const char *name; -const char **group_names; +const char *const *group_names;int num_group_names;void *data; };
@@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,unsigned const num_groups,void *data);
Signature · 1 line
2.31.1
Re: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups
Hi Rafał,
Quoted 51 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in
GENERIC_PINMUX_FUNCTIONSusers.Signed-off-by Rafał Miłecki <[email protected]>--- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/pinctrl/pinmux.c +1
-1@@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function);*/ int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,const unsigned int num_groups,void *data) {drivers/pinctrl/pinmux.h +2
-2@@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,*/ struct function_desc {const char *name; -const char **group_names; +const char *const *group_names;int num_group_names;void *data; };@@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,unsigned const num_groups,void *data);Signature · 1 line
2.31.1
I have not seen this reported yet, even though it has been broken for a couple of weeks now. I see the following error in -next:
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- allmodconfig drivers/pinctrl/pinctrl-thunderbay.o
drivers/pinctrl/pinctrl-thunderbay.c: In function ‘thunderbay_add_functions’:
drivers/pinctrl/pinctrl-thunderbay.c:815:29: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
815 | grp = func->group_names;
| ^
cc1: all warnings being treated as errorsLooks like something like the third patch of the series is needed for the Thunderbay driver, which it appears was in development at the same time as this series.
Cheers,
Nathan
Re: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups
Quoted 63 lines · Nathan Chancellor
Quoted 51 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in
GENERIC_PINMUX_FUNCTIONSusers.Signed-off-by Rafał Miłecki <[email protected]>--- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/pinctrl/pinmux.c +1
-1@@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function);*/ int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,const unsigned int num_groups,void *data) {drivers/pinctrl/pinmux.h +2
-2@@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,*/ struct function_desc {const char *name; -const char **group_names; +const char *const *group_names;int num_group_names;void *data; };@@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,unsigned const num_groups,void *data);Signature · 1 line
2.31.1I have not seen this reported yet, even though it has been broken for a couple of weeks now. I see the following error in -next:
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- allmodconfig drivers/pinctrl/pinctrl-thunderbay.o drivers/pinctrl/pinctrl-thunderbay.c: In function ‘thunderbay_add_functions’: drivers/pinctrl/pinctrl-thunderbay.c:815:29: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 815 | grp = func->group_names; | ^ cc1: all warnings being treated as errors
Quoted 3 lines
Looks like something like the third patch of the series is needed for the Thunderbay driver, which it appears was in development at the same time as this series.
Correct, this driver didn't exist in Linus's tree when I developed my changes.
Too bad thunderbay copies that old & complex logic that I just fixed in the keembay driver. I'll have to redo my changes for the thunderbay now.
I don't agree with the idea of reverting my patchset and working on V3 though. It's a relatively simple thing we need to fix, it just be just a follow-up commit.
Re: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups
Quoted 9 lines · Rafał Miłecki
Quoted 3 lines
Looks like something like the third patch of the series is needed for the Thunderbay driver, which it appears was in development at the same time as this series.
Correct, this driver didn't exist in Linus's tree when I developed my changes.
Too bad thunderbay copies that old & complex logic that I just fixed in the keembay driver. I'll have to redo my changes for the thunderbay now.
I don't agree with the idea of reverting my patchset and working on V3 though. It's a relatively simple thing we need to fix, it just be just a follow-up commit.
Yeah this kind of things happens, we just deal with it throughout the -rc:s no big deal. Release candidates exist for a reason. Let's make a fixup patch.
Yours,
Linus Walleij
Re: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups
In reply to Rafał MiłeckiQuoted 62 lines · Rafał Miłecki
Quoted 61 lines · Nathan Chancellor
Quoted 49 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in
GENERIC_PINMUX_FUNCTIONSusers.Signed-off-by Rafał Miłecki <[email protected]>--- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/pinctrl/pinmux.c +1
-1@@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function);*/ int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,const unsigned int num_groups,void *data) {drivers/pinctrl/pinmux.h +2
-2@@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,*/ struct function_desc {const char *name; -const char **group_names; +const char *const *group_names;int num_group_names;void *data; };@@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,unsigned const num_groups,void *data);Signature · 1 line
2.31.1I have not seen this reported yet, even though it has been broken for a couple of weeks now. I see the following error in -next:
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- allmodconfig drivers/pinctrl/pinctrl-thunderbay.o drivers/pinctrl/pinctrl-thunderbay.c: In function ‘thunderbay_add_functions’: drivers/pinctrl/pinctrl-thunderbay.c:815:29: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 815 | grp = func->group_names; | ^ cc1: all warnings being treated as errors
Quoted 5 lines
Quoted 3 lines
Looks like something like the third patch of the series is needed for the Thunderbay driver, which it appears was in development at the same time as this series.
Correct, this driver didn't exist in Linus's tree when I developed my changes.
I stumbled above this issue, too. For the record, this patch fixes the build issue:
drivers/pinctrl/pinctrl-thunderbay.c +1 -1
@@ -812,7 +812,7 @@ static int thunderbay_add_functions(struct thunderbay_pinctrl *tpc, struct funct } } - grp = func->group_names; + grp = (void *)func->group_names;while (*grp) grp++;
(however it's probably not safe for runtime).
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups
Quoted 63 lines · Uwe Kleine-König
Quoted 62 lines · Rafał Miłecki
Quoted 61 lines · Nathan Chancellor
Quoted 49 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in
GENERIC_PINMUX_FUNCTIONSusers.Signed-off-by Rafał Miłecki <[email protected]>--- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/pinctrl/pinmux.c +1
-1@@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function);*/ int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,const unsigned int num_groups,void *data) {drivers/pinctrl/pinmux.h +2
-2@@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,*/ struct function_desc {const char *name; -const char **group_names; +const char *const *group_names;int num_group_names;void *data; };@@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,unsigned const num_groups,void *data);Signature · 1 line
2.31.1I have not seen this reported yet, even though it has been broken for a couple of weeks now. I see the following error in -next:
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- allmodconfig drivers/pinctrl/pinctrl-thunderbay.o drivers/pinctrl/pinctrl-thunderbay.c: In function ‘thunderbay_add_functions’: drivers/pinctrl/pinctrl-thunderbay.c:815:29: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 815 | grp = func->group_names; | ^ cc1: all warnings being treated as errors
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Looks like something like the third patch of the series is needed for the Thunderbay driver, which it appears was in development at the same time as this series.
Correct, this driver didn't exist in Linus's tree when I developed my changes.
I stumbled above this issue, too. For the record, this patch fixes the build issue:
[PATCH 5.17 1/2] pinctrl: thunderbay: comment process of building functions a bit [PATCH 5.17 2/2] pinctrl: thunderbay: rework loops looking for groups names
https://patchwork.ozlabs.org/project/linux-gpio/list/?series=280568
Patches already queued in the:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=fixes
Re: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups
Quoted 73 lines · Rafał Miłecki
Quoted 63 lines · Uwe Kleine-König
Quoted 62 lines · Rafał Miłecki
Quoted 61 lines · Nathan Chancellor
Quoted 49 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in
GENERIC_PINMUX_FUNCTIONSusers.Signed-off-by Rafał Miłecki <[email protected]>--- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/pinctrl/pinmux.c +1
-1@@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function);*/ int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,const unsigned int num_groups,void *data) {drivers/pinctrl/pinmux.h +2
-2@@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,*/ struct function_desc {const char *name; -const char **group_names; +const char *const *group_names;int num_group_names;void *data; };@@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,int pinmux_generic_add_function (struct pinctrl_dev *pctldev,const char *name, -const char **groups, +const char *const *groups,unsigned const num_groups,void *data);Signature · 1 line
2.31.1I have not seen this reported yet, even though it has been broken for a couple of weeks now. I see the following error in -next:
$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- allmodconfig drivers/pinctrl/pinctrl-thunderbay.o drivers/pinctrl/pinctrl-thunderbay.c: In function ‘thunderbay_add_functions’: drivers/pinctrl/pinctrl-thunderbay.c:815:29: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 815 | grp = func->group_names; | ^ cc1: all warnings being treated as errorsQuoted 8 lines
Quoted 5 lines
Quoted 3 lines
Looks like something like the third patch of the series is needed for the Thunderbay driver, which it appears was in development at the same time as this series.
Correct, this driver didn't exist in Linus's tree when I developed my changes.
I stumbled above this issue, too. For the record, this patch fixes the build issue:
Quoted 6 lines
[PATCH 5.17 1/2] pinctrl: thunderbay: comment process of building functions a bit [PATCH 5.17 2/2] pinctrl: thunderbay: rework loops looking for groups names
https://patchwork.ozlabs.org/project/linux-gpio/list/?series=280568Patches already queued in the:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=fixes
Ah great. I hope this makes it into Linus Torvald's tree before -rc1 is tagged. Having allmodconfig build broken in release candidates is really annoying.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The plan for "struct
function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data.
Good plan, I support it!
Quoted 5 lines
This imx change is required to avoid:
drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinctrl_parse_functions':drivers/pinctrl/freescale/pinctrl-imx.c:672:24: error: assignment of read-only location '*(func->group_names + (sizetype)(i * 4))'
672 | func->group_names[i] =child->name;
| ^
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The plan for "struct
function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data.
Quoted 7 lines
This imx change is required to avoid:
drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinctrl_parse_functions':drivers/pinctrl/freescale/pinctrl-imx.c:672:24: error: assignment of read-only location '*(func->group_names + (sizetype)(i * 4))'
672 | func->group_names[i] =child->name;
| ^Signed-off-by Rafał Miłecki <[email protected]>
Patches applied, let's see what happens!
Yours,
Linus Walleij
Quoted 30 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The plan for "struct
function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data.This imx change is required to avoid:
drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinctrl_parse_functions':drivers/pinctrl/freescale/pinctrl-imx.c:672:24: error: assignment of read-only location '*(func->group_names + (sizetype)(i * 4))'
672 | func->group_names[i] =child->name;
| ^Signed-off-by Rafał Miłecki <[email protected]>--- drivers/pinctrl/freescale/pinctrl-imx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/pinctrl/freescale/pinctrl-imx.c +1
-0@@ -648,6 +648,7 @@ static int imx_pinctrl_parse_functions(struct device_node *np,struct device_node *child;struct function_desc *func;struct group_desc *grp; +const char **group_names;u32 i =0 ;dev_dbg (pctl->dev,"parse function(%d): %pOFn\n" , index, np);
drivers/pinctrl/freescale/pinctrl-imx.c static int imx_pinctrl_parse_functions(struct device_node *np, · line 670
Quoted 9 lines
drivers/pinctrl/freescale/pinctrl-imx.c +3
-2@@ -663,14 +664,16 @@ static int imx_pinctrl_parse_functions(struct device_node *np,dev_err (ipctl->dev,"no groups defined in %pOF\n" , np);return -EINVAL ; } - func->group_names =devm_kcalloc (ipctl->dev, func->num_group_names, -sizeof (char *),GFP_KERNEL ); + + group_names =devm_kcalloc (ipctl->dev, func->num_group_names, +sizeof (char *),GFP_KERNEL );if (!func->group_names)
This line needs to be:
if (!group_names)
Otherwise, the driver never probes successufully.
Linus, maybe you can squashed this fix in your tree without a resend.
Quoted 14 lines
drivers/pinctrl/freescale/pinctrl-imx.c +3
-2return -ENOMEM ; +for_each_child_of_node (np, child) + group_names[i] = child->name; + func->group_names = group_names;for_each_child_of_node (np, child) { - func->group_names[i] = child->name; - grp =devm_kzalloc (ipctl->dev,sizeof (struct group_desc ),GFP_KERNEL );if (!grp) {Signature · 1 line
2.31.1
Quoted 44 lines · Abel Vesa
Quoted 31 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The plan for "struct
function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data.This imx change is required to avoid:
drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinctrl_parse_functions':drivers/pinctrl/freescale/pinctrl-imx.c:672:24: error: assignment of read-only location '*(func-Quoted 1 line
group_names+ (sizetype)(i * 4))'672 | func->group_names[i] =
child->name;
| ^Signed-off-by Rafał Miłecki <[email protected]>---
drivers/pinctrl/freescale/pinctrl-imx.c | 11 +++++++----1 file changed, 7 insertions(+), 4 deletions(-)drivers/pinctrl/freescale/pinctrl-imx.c +1
-0@@ -648,6 +648,7 @@ static int imx_pinctrl_parse_functions(struct device_node *np, struct device_node *child; struct function_desc *func; struct group_desc *grp; + const char **group_names; u32 i = 0;
dev_dbg(pctl->dev, "parse function(%d): %pOFn\n", index, np);drivers/pinctrl/freescale/pinctrl-imx.c static int imx_pinctrl_parse_functions(struct device_node *np, · line 670
Quoted 9 lines
drivers/pinctrl/freescale/pinctrl-imx.c +3
-2@@ -663,14 +664,16 @@ static int imx_pinctrl_parse_functions(struct device_node *np, dev_err(ipctl->dev, "no groups defined in %pOF\n", np); return -EINVAL; } - func->group_names = devm_kcalloc(ipctl->dev, func->num_group_names, - sizeof(char *), GFP_KERNEL); + + group_names = devm_kcalloc(ipctl->dev, func->num_group_names, + sizeof(char *), GFP_KERNEL); if (!func->group_names)This line needs to be:
if (!group_names)
Quoted 1 line
Otherwise, the driver never probes successufully.
After my i.MX 8M Mini target running latest -next just hang early boot I bisected it to this commit.
I can confirm that this fixes it. Thanks!
Quoted 15 lines
Linus, maybe you can squashed this fix in your tree without a resend.
Quoted 13 lines
drivers/pinctrl/freescale/pinctrl-imx.c +3
-0return -ENOMEM; + for_each_child_of_node(np, child) + group_names[i] = child->name; + func->group_names = group_names;
for_each_child_of_node(np, child) {
- func->group_names[i] =child->name;
-
grp =devm_kzalloc(ipctl->dev, sizeof(struct group_desc), GFP_KERNEL);
if (!grp) {Signature · 1 line
2.31.1
Signature · 7 lines
Best regards - Mit freundlichen Grüssen - Meilleures salutations Marcel Ziswiler Software Team Lead - Embedded Linux BSP Toradex AG Ebenaustrasse 10 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 4800
Quoted 14 lines · Marcel Ziswiler
Quoted 13 lines · Abel Vesa
drivers/pinctrl/freescale/pinctrl-imx.c static int imx_pinctrl_parse_functions(struct device_node *np, · line 670
Quoted 10 lines
drivers/pinctrl/freescale/pinctrl-imx.c +3
-2@@ -663,14 +664,16 @@ static int imx_pinctrl_parse_functions(struct device_node *np, dev_err(ipctl->dev, "no groups defined in %pOF\n", np); return -EINVAL; } - func->group_names = devm_kcalloc(ipctl->dev, func->num_group_names, - sizeof(char *), GFP_KERNEL); + + group_names = devm_kcalloc(ipctl->dev, func->num_group_names, + sizeof(char *), GFP_KERNEL); if (!func->group_names)This line needs to be:
if (!group_names)
Quoted 5 lines
Quoted 1 line
Otherwise, the driver never probes successufully.
After my i.MX 8M Mini target running latest -next just hang early boot I bisected it to this commit.
I can confirm that this fixes it. Thanks!
Please note there is one more pending fix. Please apply both:
[PATCH] pinctrl: imx: fix allocation result check [PATCH] pinctrl: imx: fix assigning groups names
Quoted 17 lines · Rafał Miłecki
Quoted 16 lines · Marcel Ziswiler
Quoted 14 lines · Abel Vesa
drivers/pinctrl/freescale/pinctrl-imx.c static int imx_pinctrl_parse_functions(struct device_node *np, · line 670
Quoted 10 lines
drivers/pinctrl/freescale/pinctrl-imx.c +3
-2@@ -663,14 +664,16 @@ static int imx_pinctrl_parse_functions(struct device_node *np, dev_err(ipctl->dev, "no groups defined in %pOF\n", np); return -EINVAL; } - func->group_names = devm_kcalloc(ipctl->dev, func->num_group_names, - sizeof(char *), GFP_KERNEL); + + group_names = devm_kcalloc(ipctl->dev, func->num_group_names, + sizeof(char *), GFP_KERNEL); if (!func->group_names)This line needs to be:
if (!group_names)Otherwise, the driver never probes successufully.
Quoted 7 lines
Quoted 3 lines
After my i.MX 8M Mini target running latest -next just hang early boot I bisected it to this commit.
I can confirm that this fixes it. Thanks!
Please note there is one more pending fix. Please apply both:
[PATCH] pinctrl: imx: fix allocation result check [PATCH] pinctrl: imx: fix assigning groups names
Yep, also just noticed that. Thanks!