* [PATCH] regulator: bd718x7: Remove double indirection for bd718xx_pmic_inits.rdatas
@ 2018-10-28 16:09 Geert Uytterhoeven
2018-10-29 8:30 ` Matti Vaittinen
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2018-10-28 16:09 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Matti Vaittinen
Cc: Arnd Bergmann, linux-kernel, Geert Uytterhoeven
With gcc 4.1:
drivers/regulator/bd718x7-regulator.c: In function ‘bd718xx_probe’:
drivers/regulator/bd718x7-regulator.c:1020: warning: initialization from incompatible pointer type
drivers/regulator/bd718x7-regulator.c:1024: warning: initialization from incompatible pointer type
Apparently this old compiler can't handle the obscure double
indirection.
However, there is no need for a double indirection. Just store a
pointer to the array instead, like other drivers tend to do.
Fixes: 494edd266b945f36 ("regulator/mfd: Support ROHM BD71847 power management IC")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.
---
drivers/regulator/bd718x7-regulator.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c
index 3a47e0372e77c812..fff5bc4faa2c99aa 100644
--- a/drivers/regulator/bd718x7-regulator.c
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -1007,7 +1007,7 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {
};
struct bd718xx_pmic_inits {
- const struct bd718xx_regulator_data (*r_datas)[];
+ const struct bd718xx_regulator_data *r_datas;
unsigned int r_amount;
};
@@ -1017,11 +1017,11 @@ static int bd718xx_probe(struct platform_device *pdev)
struct regulator_config config = { 0 };
struct bd718xx_pmic_inits pmic_regulators[] = {
[BD718XX_TYPE_BD71837] = {
- .r_datas = &bd71837_regulators,
+ .r_datas = bd71837_regulators,
.r_amount = ARRAY_SIZE(bd71837_regulators),
},
[BD718XX_TYPE_BD71847] = {
- .r_datas = &bd71847_regulators,
+ .r_datas = bd71847_regulators,
.r_amount = ARRAY_SIZE(bd71847_regulators),
},
};
@@ -1059,7 +1059,7 @@ static int bd718xx_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
const struct bd718xx_regulator_data *r;
- r = &(*pmic_regulators[mfd->chip_type].r_datas)[i];
+ r = &pmic_regulators[mfd->chip_type].r_datas[i];
desc = &r->desc;
config.dev = pdev->dev.parent;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: bd718x7: Remove double indirection for bd718xx_pmic_inits.rdatas
2018-10-28 16:09 [PATCH] regulator: bd718x7: Remove double indirection for bd718xx_pmic_inits.rdatas Geert Uytterhoeven
@ 2018-10-29 8:30 ` Matti Vaittinen
0 siblings, 0 replies; 2+ messages in thread
From: Matti Vaittinen @ 2018-10-29 8:30 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Liam Girdwood, Mark Brown, Arnd Bergmann, linux-kernel
On Sun, Oct 28, 2018 at 05:09:22PM +0100, Geert Uytterhoeven wrote:
> With gcc 4.1:
>
> drivers/regulator/bd718x7-regulator.c: In function ‘bd718xx_probe’:
> drivers/regulator/bd718x7-regulator.c:1020: warning: initialization from incompatible pointer type
> drivers/regulator/bd718x7-regulator.c:1024: warning: initialization from incompatible pointer type
>
> Apparently this old compiler can't handle the obscure double
> indirection.
That was surprizing for me. Besides I don't see why this is obscure ;)
> However, there is no need for a double indirection. Just store a
> pointer to the array instead, like other drivers tend to do.
But that's _exactly_ what we have here. A pointer to an array of
structs, not pointer to a struct - or pointer to the first member of an
array =)
But this is one of the cases where practicality should be preferred. And
you are correct. It is easier to understand when we have simple pointer
to a struct - and moreover it should work on all compilers, right?
So this looks good to me.
> Fixes: 494edd266b945f36 ("regulator/mfd: Support ROHM BD71847 power management IC")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Compile-tested only.
> ---
> drivers/regulator/bd718x7-regulator.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c
> index 3a47e0372e77c812..fff5bc4faa2c99aa 100644
> --- a/drivers/regulator/bd718x7-regulator.c
> +++ b/drivers/regulator/bd718x7-regulator.c
> @@ -1007,7 +1007,7 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {
> };
>
> struct bd718xx_pmic_inits {
> - const struct bd718xx_regulator_data (*r_datas)[];
> + const struct bd718xx_regulator_data *r_datas;
> unsigned int r_amount;
> };
>
> @@ -1017,11 +1017,11 @@ static int bd718xx_probe(struct platform_device *pdev)
> struct regulator_config config = { 0 };
> struct bd718xx_pmic_inits pmic_regulators[] = {
> [BD718XX_TYPE_BD71837] = {
> - .r_datas = &bd71837_regulators,
> + .r_datas = bd71837_regulators,
> .r_amount = ARRAY_SIZE(bd71837_regulators),
> },
> [BD718XX_TYPE_BD71847] = {
> - .r_datas = &bd71847_regulators,
> + .r_datas = bd71847_regulators,
> .r_amount = ARRAY_SIZE(bd71847_regulators),
> },
> };
> @@ -1059,7 +1059,7 @@ static int bd718xx_probe(struct platform_device *pdev)
> struct regulator_dev *rdev;
> const struct bd718xx_regulator_data *r;
>
> - r = &(*pmic_regulators[mfd->chip_type].r_datas)[i];
> + r = &pmic_regulators[mfd->chip_type].r_datas[i];
> desc = &r->desc;
>
> config.dev = pdev->dev.parent;
> --
> 2.17.1
>
--
Matti Vaittinen
ROHM Semiconductors
~~~ "I don't think so," said Rene Descartes. Just then, he vanished ~~~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-29 8:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-28 16:09 [PATCH] regulator: bd718x7: Remove double indirection for bd718xx_pmic_inits.rdatas Geert Uytterhoeven
2018-10-29 8:30 ` Matti Vaittinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).