mfd: arizona: fix undefined behavior
Subsystems (3)
Charles Keepax
maintainerPATCH RESEND 1/4 mfd: arizona: fix undefined behavior
From: Arnd Bergmann <[email protected]>
When the driver is used with a subdevice that is disabled in the kernel configuration, clang gets a little confused about the control flow and fails to notice that n_subdevs is only uninitialized when subdevs is NULL, and we check for that, leading to a false-positive warning:
drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here
[-Werror,-Wuninitialized]
subdevs, n_subdevs, NULL, 0, NULL);
^~~~~~~~~
drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning
int n_subdevs, ret, i;
^
= 0Ideally, we would rearrange the code to avoid all those early initializations and have an explicit exit in each disabled case, but it's much easier to chicken out and add one more initialization here to shut up the warning.
--- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/arizona-core.c +1 -1
@@ -996,7 +996,7 @@ int arizona_dev_init(struct arizona *arizona)unsigned int reg, val;int (*apply_patch)(struct arizona *) =NULL ;const struct mfd_cell *subdevs =NULL ; -int n_subdevs, ret, i; +int n_subdevs =0 , ret, i;dev_set_drvdata (arizona->dev, arizona);mutex_init (&arizona->clk_lock);
Signature · 1 line
2.11.0
Charles Keepax
maintainerPATCH RESEND 2/4 mfd: madera: Fix bad reference to pinctrl.txt file
From: Otto Sabart <[email protected]>
The pinctrl.txt file was converted into reStructuredText and moved into driver-api folder. This patch updates the broken reference.
--- include/linux/mfd/madera/pdata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/mfd/madera/pdata.h +2 -1
@@ -34,7 +34,8 @@ struct madera_codec_pdata;* @micvdd: Substruct of pdata for the MICVDD regulator * @irq_flags: Mode for primary IRQ (defaults to active low) * @gpio_base: Base GPIO number -* @gpio_configs: Array of GPIO configurations (See Documentation/pinctrl.txt) +* @gpio_configs: Array of GPIO configurations (See +* Documentation/driver-api/pinctl.rst) * @n_gpio_configs: Number of entries in gpio_configs * @gpsw: General purpose switch mode setting. Depends on the external * hardware connected to the switch. (See the SW1_MODE field
Signature · 1 line
2.11.0
Re: [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file
Em Mon, 20 May 2019 10:06:26 +0100
Charles Keepax <[email protected]> escreveu:
Quoted 8 lines
From: Otto Sabart <[email protected]>
The pinctrl.txt file was converted into reStructuredText and moved into driver-api folder. This patch updates the broken reference.
Fixes 5a9b73832e9e ("pinctrl.txt: move it to the driver-api book")Signed-off-by Otto Sabart <[email protected]>Signed-off-by Charles Keepax <[email protected]>
Quoted 9 lines
--- include/linux/mfd/madera/pdata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/linux/mfd/madera/pdata.h +0
-0
include/linux/mfd/madera/pdata.h struct madera_codec_pdata; · line 41
Quoted 9 lines
include/linux/mfd/madera/pdata.h +2
-1@@ -34,7 +34,8 @@ struct madera_codec_pdata;* @micvdd: Substruct of pdata for the MICVDD regulator * @irq_flags: Mode for primary IRQ (defaults to active low) * @gpio_base: Base GPIO number -* @gpio_configs: Array of GPIO configurations (See Documentation/pinctrl.txt) +* @gpio_configs: Array of GPIO configurations (See +* Documentation/driver-api/pinctl.rst) * @n_gpio_configs: Number of entries in gpio_configs * @gpsw: General purpose switch mode setting. Depends on the external * hardware connected to the switch. (See the SW1_MODE field
Thanks,
Mauro
Lee Jones
AppliedRe: [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file
In reply to Charles KeepaxQuoted 11 lines · Charles Keepax
From: Otto Sabart <[email protected]>
The pinctrl.txt file was converted into reStructuredText and moved into driver-api folder. This patch updates the broken reference.
Fixes 5a9b73832e9e ("pinctrl.txt: move it to the driver-api book")Signed-off-by Otto Sabart <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- include/linux/mfd/madera/pdata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Charles Keepax
maintainerPATCH 3/4 mfd: madera: Fix potential uninitialised use of variable
In reply to Charles KeepaxFrom: Stuart Henderson <[email protected]>
regmap_read won't set val to anything if an ACKed bus fails.
--- drivers/mfd/madera-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/madera-core.c +1 -1
@@ -139,7 +139,7 @@ EXPORT_SYMBOL_GPL(madera_name_from_type);static int madera_wait_for_boot (struct madera *madera) {ktime_t timeout; -unsigned int val; +unsigned int val =0 ;int ret =0 ;/*
Signature · 1 line
2.11.0
Lee Jones
AppliedRe: [PATCH 3/4] mfd: madera: Fix potential uninitialised use of variable
Quoted 9 lines · Charles Keepax
From: Stuart Henderson <[email protected]>
regmap_readwon't set val to anything if an ACKed bus fails.Signed-off-by Stuart Henderson <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/madera-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Charles Keepax
maintainerPATCH 4/4 mfd: madera: Add supply mapping for MICVDD
In reply to Charles KeepaxCurrently we are relying on the exact match of the regulator name to find MICVDD, we should add an explicit supply mapping to allow this to be found more reliably.
--- drivers/mfd/madera-core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/mfd/madera-core.c +15 -3
@@ -59,7 +59,11 @@ static const struct mfd_cell cs47l35_devs[] = { { .name = "madera-irq", }, { .name = "madera-micsupp", }, { .name = "madera-gpio", }, - { .name = "madera-extcon", }, + { + .name = "madera-extcon", + .parent_supplies = cs47l35_supplies, + .num_parent_supplies = 1, /* We only need MICVDD */ + }, { .name = "cs47l35-codec", .parent_supplies = cs47l35_supplies,
@@ -83,7 +87,11 @@ static const struct mfd_cell cs47l85_devs[] = { { .name = "madera-irq", }, { .name = "madera-micsupp" }, { .name = "madera-gpio", }, - { .name = "madera-extcon", }, + { + .name = "madera-extcon", + .parent_supplies = cs47l85_supplies, + .num_parent_supplies = 1, /* We only need MICVDD */ + }, { .name = "cs47l85-codec", .parent_supplies = cs47l85_supplies,
@@ -105,7 +113,11 @@ static const struct mfd_cell cs47l90_devs[] = { { .name = "madera-irq", }, { .name = "madera-micsupp", }, { .name = "madera-gpio", }, - { .name = "madera-extcon", }, + { + .name = "madera-extcon", + .parent_supplies = cs47l90_supplies, + .num_parent_supplies = 1, /* We only need MICVDD */ + }, { .name = "cs47l90-codec", .parent_supplies = cs47l90_supplies,
Signature · 1 line
2.11.0
Lee Jones
AppliedRe: [PATCH 4/4] mfd: madera: Add supply mapping for MICVDD
Quoted 8 lines · Charles Keepax
Currently we are relying on the exact match of the regulator name to find MICVDD, we should add an explicit supply mapping to allow this to be found more reliably.
Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/madera-core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Lee Jones
AppliedQuoted 22 lines · Charles Keepax
From: Arnd Bergmann <[email protected]>
When the driver is used with a subdevice that is disabled in the kernel configuration, clang gets a little confused about the control flow and fails to notice that
n_subdevsis only uninitialized when subdevs is NULL, and we check for that, leading to a false-positive warning:
drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here[-Werror,-Wuninitialized] subdevs, n_subdevs, NULL, 0, NULL); ^~~~~~~~~ drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning int n_subdevs, ret, i; ^ = 0Ideally, we would rearrange the code to avoid all those early initializations and have an explicit exit in each disabled case, but it's much easier to chicken out and add one more initialization here to shut up the warning.
Quoted 6 lines
Signed-off-by Arnd Bergmann <[email protected]>Reviewed-by Nathan Chancellor <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog