mfd: da9062: Use MFD_CELL_OF macro
Subsystems (3)
PATCH v4 1/3 mfd: da9062: Use MFD_CELL_OF macro
Use MFD_CELL_OF macro helper instead of plain struct properties, which makes the code a bit shorter and to have commonly defined MFD cell attributes.
---
Cc: Support Opensource <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V3: - Add this patch to the series
V4: - Rebase on current next 20230309
- Add Acked-by tag
--- drivers/mfd/da9062-core.c | 92 +++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 68 deletions(-)
drivers/mfd/da9062-core.c +24 -68
@@ -182,34 +182,16 @@ static const struct resource da9061_onkey_resources[] = { };static const struct mfd_cell da9061_devs[] = { - { - .name ="da9061-core" , - .num_resources =ARRAY_SIZE (da9061_core_resources), - .resources = da9061_core_resources, - }, - { - .name ="da9062-regulators" , - .num_resources =ARRAY_SIZE (da9061_regulators_resources), - .resources = da9061_regulators_resources, - }, - { - .name ="da9061-watchdog" , - .num_resources =ARRAY_SIZE (da9061_wdt_resources), - .resources = da9061_wdt_resources, - .of_compatible ="dlg,da9061-watchdog" , - }, - { - .name ="da9061-thermal" , - .num_resources =ARRAY_SIZE (da9061_thermal_resources), - .resources = da9061_thermal_resources, - .of_compatible ="dlg,da9061-thermal" , - }, - { - .name ="da9061-onkey" , - .num_resources =ARRAY_SIZE (da9061_onkey_resources), - .resources = da9061_onkey_resources, - .of_compatible ="dlg,da9061-onkey" , - }, +MFD_CELL_OF ("da9061-core" , da9061_core_resources,NULL ,0 ,0 , +NULL ), +MFD_CELL_OF ("da9062-regulators" , da9061_regulators_resources,NULL ,0 ,0 , +NULL ), +MFD_CELL_OF ("da9061-watchdog" , da9061_wdt_resources,NULL ,0 ,0 , +"dlg,da9061-watchdog" ), +MFD_CELL_OF ("da9061-thermal" , da9061_thermal_resources,NULL ,0 ,0 , +"dlg,da9061-thermal" ), +MFD_CELL_OF ("da9061-onkey" , da9061_onkey_resources,NULL ,0 ,0 , +"dlg,da9061-onkey" ), };static const struct resource da9062_core_resources[] = {
@@ -246,46 +228,20 @@ static const struct resource da9062_gpio_resources[] = { };static const struct mfd_cell da9062_devs[] = { - { - .name ="da9062-core" , - .num_resources =ARRAY_SIZE (da9062_core_resources), - .resources = da9062_core_resources, - }, - { - .name ="da9062-regulators" , - .num_resources =ARRAY_SIZE (da9062_regulators_resources), - .resources = da9062_regulators_resources, - }, - { - .name ="da9062-watchdog" , - .num_resources =ARRAY_SIZE (da9062_wdt_resources), - .resources = da9062_wdt_resources, - .of_compatible ="dlg,da9062-watchdog" , - }, - { - .name ="da9062-thermal" , - .num_resources =ARRAY_SIZE (da9062_thermal_resources), - .resources = da9062_thermal_resources, - .of_compatible ="dlg,da9062-thermal" , - }, - { - .name ="da9062-rtc" , - .num_resources =ARRAY_SIZE (da9062_rtc_resources), - .resources = da9062_rtc_resources, - .of_compatible ="dlg,da9062-rtc" , - }, - { - .name ="da9062-onkey" , - .num_resources =ARRAY_SIZE (da9062_onkey_resources), - .resources = da9062_onkey_resources, - .of_compatible ="dlg,da9062-onkey" , - }, - { - .name ="da9062-gpio" , - .num_resources =ARRAY_SIZE (da9062_gpio_resources), - .resources = da9062_gpio_resources, - .of_compatible ="dlg,da9062-gpio" , - }, +MFD_CELL_OF ("da9062-core" , da9062_core_resources,NULL ,0 ,0 , +NULL ), +MFD_CELL_OF ("da9062-regulators" , da9062_regulators_resources,NULL ,0 ,0 , +NULL ), +MFD_CELL_OF ("da9062-watchdog" , da9062_wdt_resources,NULL ,0 ,0 , +"dlg,da9062-watchdog" ), +MFD_CELL_OF ("da9062-thermal" , da9062_thermal_resources,NULL ,0 ,0 , +"dlg,da9062-thermal" ), +MFD_CELL_OF ("da9062-rtc" , da9062_rtc_resources,NULL ,0 ,0 , +"dlg,da9062-rtc" ), +MFD_CELL_OF ("da9062-onkey" , da9062_onkey_resources,NULL ,0 ,0 , +"dlg,da9062-onkey" ), +MFD_CELL_OF ("da9062-gpio" , da9062_gpio_resources,NULL ,0 ,0 , +"dlg,da9062-gpio" ), };static int da9062_clear_fault_log (struct da9062 *chip)
Signature · 1 line
2.11.0
PATCH v4 2/3 mfd: da9062: Remove IRQ requirement
This patch removes the requirement for an IRQ, because for the core functionality IRQ isn't needed. So this makes the DA9061/62 chip usable for designs which haven't connected the IRQ pin.
---
Cc: Support Opensource <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V2: - Rebase on current next 20230209
- Add Lee Jones to Cc list
V3: - Rebase on current next 20230307
- Use macro MFD_CELL_OF
- Refactoring the code for use without IRQ
V4: - Rebase on current next 20230309
- Add Acked-by tag
--- drivers/mfd/da9062-core.c | 84 +++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 29 deletions(-)
drivers/mfd/da9062-core.c +55 -29
@@ -181,7 +181,7 @@ static const struct resource da9061_onkey_resources[] = { DEFINE_RES_IRQ_NAMED(DA9061_IRQ_ONKEY, "ONKEY"), }; -static const struct mfd_cell da9061_devs[] = { +static const struct mfd_cell da9061_devs_irq[] = {MFD_CELL_OF ("da9061-core" , da9061_core_resources,NULL ,0 ,0 ,NULL ), MFD_CELL_OF("da9062-regulators", da9061_regulators_resources, NULL, 0, 0,
@@ -194,6 +194,14 @@ static const struct mfd_cell da9061_devs[] = { "dlg,da9061-onkey"), }; +static const struct mfd_cell da9061_devs_noirq[] = { +MFD_CELL_OF ("da9061-core" ,NULL ,NULL ,0 ,0 ,NULL ), +MFD_CELL_OF ("da9062-regulators" ,NULL ,NULL ,0 ,0 ,NULL ), +MFD_CELL_OF ("da9061-watchdog" ,NULL ,NULL ,0 ,0 ,"dlg,da9061-watchdog" ), +MFD_CELL_OF ("da9061-thermal" ,NULL ,NULL ,0 ,0 ,"dlg,da9061-thermal" ), +MFD_CELL_OF ("da9061-onkey" ,NULL ,NULL ,0 ,0 ,"dlg,da9061-onkey" ), +}; +static const struct resource da9062_core_resources[] = {DEFINE_RES_NAMED (DA9062_IRQ_VDD_WARN ,1 ,"VDD_WARN" ,IORESOURCE_IRQ ), };
@@ -227,7 +235,7 @@ static const struct resource da9062_gpio_resources[] = { DEFINE_RES_NAMED(DA9062_IRQ_GPI4, 1, "GPI4", IORESOURCE_IRQ), }; -static const struct mfd_cell da9062_devs[] = { +static const struct mfd_cell da9062_devs_irq[] = {MFD_CELL_OF ("da9062-core" , da9062_core_resources,NULL ,0 ,0 ,NULL ), MFD_CELL_OF("da9062-regulators", da9062_regulators_resources, NULL, 0, 0,
@@ -244,6 +252,16 @@ static const struct mfd_cell da9062_devs[] = { "dlg,da9062-gpio"), }; +static const struct mfd_cell da9062_devs_noirq[] = { +MFD_CELL_OF ("da9062-core" ,NULL ,NULL ,0 ,0 ,NULL ), +MFD_CELL_OF ("da9062-regulators" ,NULL ,NULL ,0 ,0 ,NULL ), +MFD_CELL_OF ("da9062-watchdog" ,NULL ,NULL ,0 ,0 ,"dlg,da9062-watchdog" ), +MFD_CELL_OF ("da9062-thermal" ,NULL ,NULL ,0 ,0 ,"dlg,da9062-thermal" ), +MFD_CELL_OF ("da9062-rtc" ,NULL ,NULL ,0 ,0 ,"dlg,da9062-rtc" ), +MFD_CELL_OF ("da9062-onkey" ,NULL ,NULL ,0 ,0 ,"dlg,da9062-onkey" ), +MFD_CELL_OF ("da9062-gpio" ,NULL ,NULL ,0 ,0 ,"dlg,da9062-gpio" ), +}; +static int da9062_clear_fault_log (struct da9062 *chip) {int ret;
@@ -581,7 +599,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c) {const struct i2c_device_id *id =i2c_client_get_device_id (i2c);struct da9062 *chip; -unsigned int irq_base; +unsigned int irq_base =0 ;const struct mfd_cell *cell;const struct regmap_irq_chip *irq_chip;const struct regmap_config *config;
@@ -601,22 +619,16 @@ static int da9062_i2c_probe(struct i2c_client *i2c)i2c_set_clientdata (i2c, chip); chip->dev = &i2c->dev; -if (!i2c->irq) { -dev_err (chip->dev,"No IRQ configured\n" ); -return -EINVAL ; - } - +/* Start with a base configuration without IRQ */ switch (chip->chip_type) {case COMPAT_TYPE_DA9061 : - cell = da9061_devs; - cell_num =ARRAY_SIZE (da9061_devs); - irq_chip = &da9061_irq_chip; + cell = da9061_devs_noirq; + cell_num =ARRAY_SIZE (da9061_devs_noirq); config = &da9061_regmap_config;break ;case COMPAT_TYPE_DA9062 : - cell = da9062_devs; - cell_num =ARRAY_SIZE (da9062_devs); - irq_chip = &da9062_irq_chip; + cell = da9062_devs_noirq; + cell_num =ARRAY_SIZE (da9062_devs_noirq); config = &da9062_regmap_config;break ;default :
@@ -651,29 +663,43 @@ static int da9062_i2c_probe(struct i2c_client *i2c)if (ret)return ret; - ret =da9062_configure_irq_type (chip, i2c->irq, &trigger_type); -if (ret <0 ) { -dev_err (chip->dev,"Failed to configure IRQ type\n" ); -return ret; - } +/* If IRQ is available, reconfigure it accordingly */ +if (i2c->irq) { +if (chip->chip_type ==COMPAT_TYPE_DA9061 ) { + cell = da9061_devs_irq; + cell_num =ARRAY_SIZE (da9061_devs_irq); + irq_chip = &da9061_irq_chip; + }else { + cell = da9062_devs_irq; + cell_num =ARRAY_SIZE (da9062_devs_irq); + irq_chip = &da9062_irq_chip; + } - ret =regmap_add_irq_chip (chip->regmap, i2c->irq, - trigger_type |IRQF_SHARED |IRQF_ONESHOT , --1 , irq_chip, &chip->regmap_irq); -if (ret) { -dev_err (chip->dev,"Failed to request IRQ %d: %d\n" , - i2c->irq, ret); -return ret; - } + ret =da9062_configure_irq_type (chip, i2c->irq, &trigger_type); +if (ret <0 ) { +dev_err (chip->dev,"Failed to configure IRQ type\n" ); +return ret; + } - irq_base =regmap_irq_chip_get_base (chip->regmap_irq); + ret =regmap_add_irq_chip (chip->regmap, i2c->irq, + trigger_type |IRQF_SHARED |IRQF_ONESHOT , +-1 , irq_chip, &chip->regmap_irq); +if (ret) { +dev_err (chip->dev,"Failed to request IRQ %d: %d\n" , + i2c->irq, ret); +return ret; + } + + irq_base =regmap_irq_chip_get_base (chip->regmap_irq); + } ret =mfd_add_devices (chip->dev,PLATFORM_DEVID_NONE , cell, cell_num,NULL , irq_base,NULL );if (ret) {dev_err (chip->dev,"Cannot register child devices\n" ); -regmap_del_irq_chip (i2c->irq, chip->regmap_irq); +if (i2c->irq) +regmap_del_irq_chip (i2c->irq, chip->regmap_irq);return ret; }
Signature · 1 line
2.11.0
Re: [PATCH V4 2/3] mfd: da9062: Remove IRQ requirement
Quoted 24 lines · Christoph Niedermaier
This patch removes the requirement for an IRQ, because for the core functionality IRQ isn't needed. So this makes the DA9061/62 chip usable for designs which haven't connected the IRQ pin.
Signed-off-by Christoph Niedermaier <[email protected]>Acked-by Adam Ward <[email protected]>---
Cc: Support Opensource <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V2: - Rebase on current next 20230209
- Add Lee Jones to Cc list
V3: - Rebase on current next 20230307
- Use macroMFD_CELL_OF
- Refactoring the code for use without IRQ
V4: - Rebase on current next 20230309
- Add Acked-by tag
Quoted 3 lines
--- drivers/mfd/da9062-core.c | 84 +++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 29 deletions(-)
Applied, thanks
--
Lee Jones [李琼斯]
PATCH v4 3/3 regulator: da9062: Make the use of IRQ optional
In reply to Christoph NiedermaierThis patch makes the use of IRQ optional to make the DA9061/62 usable for designs that don't have the IRQ pin connected, because the regulator is usable without IRQ.
---
Cc: Support Opensource <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V2: - Rebase on current next 20230209
- Add Reviewed-by and Acked-by tags
V3: - Rebase on current next 20230307
v4: - Rebase on current next 20230309
- Fix a missing variable change reported by kernel test robot
--- drivers/regulator/da9062-regulator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/regulator/da9062-regulator.c +5 -6
@@ -924,7 +924,7 @@ static int da9062_regulator_probe(struct platform_device *pdev)struct da9062_regulator *regl;struct regulator_config config = { };const struct da9062_regulator_info *rinfo; -int irq, n, ret; +int n, ret;int max_regulators;switch (chip->chip_type) {
@@ -1012,12 +1012,11 @@ static int da9062_regulator_probe(struct platform_device *pdev) }/* LDOs overcurrent event support */ - irq =platform_get_irq_byname (pdev,"LDO_LIM" ); -if (irq <0 ) -return irq; - regulators->irq_ldo_lim = irq; + regulators->irq_ldo_lim =platform_get_irq_byname_optional (pdev,"LDO_LIM" ); +if (regulators->irq_ldo_lim <0 ) +return 0 ; - ret =devm_request_threaded_irq (&pdev->dev, irq, + ret =devm_request_threaded_irq (&pdev->dev, regulators->irq_ldo_lim,NULL , da9062_ldo_lim_event,IRQF_TRIGGER_LOW |IRQF_ONESHOT ,"LDO_LIM" , regulators);
Signature · 1 line
2.11.0
RE: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
From: Christoph Niedermaier [mailto:[email protected]]
Sent: Thursday, March 9, 2023 10:23 AM
Quoted 48 lines
This patch makes the use of IRQ optional to make the DA9061/62 usable for designs that don't have the IRQ pin connected, because the regulator is usable without IRQ.
Signed-off-by Christoph Niedermaier <[email protected]>Acked-by Mark Brown <[email protected]>Reviewed-by Adam Ward <[email protected]>Reported-by kernel test robot <[email protected]>---
Cc: Support Opensource <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V2: - Rebase on current next 20230209
- Add Reviewed-by and Acked-by tags
V3: - Rebase on current next 20230307
v4: - Rebase on current next 20230309
- Fix a missing variable change reported by kernel test robot--- drivers/regulator/da9062-regulator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/regulator/da9062-regulator.c +1
-4@@ -924,7 +924,7 @@ static int da9062_regulator_probe(struct platform_device *pdev)struct da9062_regulator *regl;struct regulator_config config = { };const struct da9062_regulator_info *rinfo; -int irq, n, ret; +int n, ret;int max_regulators;switch (chip->chip_type) {@@ -1012,12 +1012,11 @@ static int da9062_regulator_probe(struct platform_device *pdev) }/* LDOs overcurrent event support */ - irq =platform_get_irq_byname (pdev,"LDO_LIM" ); -if (irq <0 ) -return irq;
drivers/regulator/da9062-regulator.c static int da9062_regulator_probe(struct platform_device *pdev) · line 1022
Quoted 10 lines
drivers/regulator/da9062-regulator.c +4
-2- regulators->irq_ldo_lim = irq; + regulators->irq_ldo_lim =platform_get_irq_byname_optional (pdev,"LDO_LIM" ); +if (regulators->irq_ldo_lim <0 ) +return 0 ; - ret =devm_request_threaded_irq (&pdev->dev, irq, + ret =devm_request_threaded_irq (&pdev->dev, regulators->irq_ldo_lim,NULL , da9062_ldo_lim_event,IRQF_TRIGGER_LOW |IRQF_ONESHOT ,"LDO_LIM" , regulators);
Hi,
In V3 of this patch the kernel test robot found an issue. A fix is important, because otherwise the normal path with IRQ could have problems. So I fixed it in V4. Any comments or is it OK how I fixed it?
Regards
Christoph
RE: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
Quoted 1 line · Christoph Niedermaier
In V3 of this patch the kernel test robot found an issue. A fix is important, because otherwise the normal path with IRQ could have problems. So I fixed it in V4. Any comments or is it OK how I fixed it?
Hi Christoph,
It looks fine now; sorry I didn't notice before.
Regards,
Adam
Re: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
Quoted 6 lines · DLG Adam Ward
Quoted 1 line · Christoph Niedermaier
In V3 of this patch the kernel test robot found an issue. A fix is important, because otherwise the normal path with IRQ could have problems. So I fixed it in V4. Any comments or is it OK how I fixed it?
Hi Christoph,
It looks fine now; sorry I didn't notice before.
I think a formal Reviewed-by / Acked-by would be nice.
But maybe Mark can pick this 3/3 patch now either way ?
RE: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
Quoted 3 lines · Marek Vasut
Quoted 1 line
It looks fine now; sorry I didn't notice before.
I think a formal Reviewed-by / Acked-by would be nice.
It's already there in the patch - obliquely referred to by "before", the apology because I'd missed that which the robot picked up on after I'd looked at it.
Marek Vasut
Reviewed-byRe: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
Quoted 7 lines · DLG Adam Ward
Quoted 3 lines · Marek Vasut
Quoted 1 line
It looks fine now; sorry I didn't notice before.
I think a formal Reviewed-by / Acked-by would be nice.
It's already there in the patch - obliquely referred to by "before", the apology because I'd missed that which the robot picked up on after I'd looked at it.
Ahh, in that case, sorry for the noise and thanks for the RB .
And for all its worth, patch is also:
RE: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
Quoted 20 lines
From: Marek Vasut [mailto:[email protected]]
Sent: Tuesday, May 9, 2023 11:21 AM
To: DLG Adam Ward <[email protected]>; Christoph Niedermaier <[email protected]>; [email protected]
Cc: Support Opensource <[email protected]>; Liam Girdwood <[email protected]>; Mark Brown <[email protected]>; kernel <kernel@dh- electronics.com>; [email protected]
Subject: Re: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optionalACHTUNG: Diese E-Mail wurde von Extern an Dich gesendet. Bitte klicke deshalb nicht auf Links in der E-Mail! Falls das Öffnen erforderlich ist, bitte Links zuvor auf Authentizität überprüfen – im Zweifelsfall bitte zuerst bei der IT nachfragen!
Quoted 6 lines · DLG Adam Ward
Quoted 3 lines · Marek Vasut
Quoted 1 line
It looks fine now; sorry I didn't notice before.
I think a formal Reviewed-by / Acked-by would be nice.
Quoted 8 lines
Quoted 1 line
It's already there in the patch - obliquely referred to by "before", the apology because
I'd missed that which the robot picked up on after I'd looked at it.
Ahh, in that case, sorry for the noise and thanks for the RB .
And for all its worth, patch is also:
Reviewed-by Marek Vasut <[email protected]>
I was wondering how to continue with this patch. Is there anything against picking this patch or did I miss it?
Thanks and regards
Christoph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [PATCH V4 3/3] regulator: da9062: Make the use of IRQ optional
From: Christoph Niedermaier
Sent: Wednesday, July 12, 2023 3:20 PM
Quoted 10 lines
Quoted 10 lines · DLG Adam Ward
Quoted 7 lines · Marek Vasut
Quoted 4 lines
Quoted 2 lines
It looks fine now; sorry I didn't notice before.
I think a formal Reviewed-by / Acked-by would be nice.
It's already there in the patch - obliquely referred to by "before", the apology because
I'd missed that which the robot picked up on after I'd looked at it.
Quoted 8 lines
Quoted 5 lines
Ahh, in that case, sorry for the noise and thanks for the RB .
And for all its worth, patch is also:
Reviewed-by Marek Vasut <[email protected]>I was wondering how to continue with this patch. Is there anything against picking this patch or did I miss it?
To make it easier I will rebase this leftover
patch on the current next and send it as V5.
Regards
Christoph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 19 lines · Christoph Niedermaier
Use
MFD_CELL_OFmacro helper instead of plain struct properties, which makes the code a bit shorter and to have commonly defined MFD cell attributes.Signed-off-by Christoph Niedermaier <[email protected]>Acked-by Adam Ward <[email protected]>---
Cc: Support Opensource <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V3: - Add this patch to the series
V4: - Rebase on current next 20230309
- Add Acked-by tag
Quoted 3 lines
--- drivers/mfd/da9062-core.c | 92 +++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 68 deletions(-)
Applied, thanks
--
Lee Jones [李琼斯]