2023-04-07 14:23:27

by Shengyu Qu

[permalink] [raw]
Subject: [PATCH v1 4/4] regulator: axp20x: Set DCDC frequency only when property exists

Current axp20x regulator driver would always set DCDC frequency even if
there is no x-powers,dcdc-freq in device tree data. Causing meaningless
warning info output on variants that do not support DCDC frequency
modification. So only try to set DCDC frequency when there is frequency
property.

Signed-off-by: Shengyu Qu <[email protected]>
---
drivers/regulator/axp20x-regulator.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index ece4af93df7b..12a12923bc7b 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -1247,10 +1247,10 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
if (!regulators) {
dev_warn(&pdev->dev, "regulators node not found\n");
} else {
- of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
- ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
- if (ret < 0) {
- dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret);
+ if (of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq) != -EINVAL) {
+ ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
+ if (ret < 0)
+ dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret);
}
of_node_put(regulators);
}
--
2.25.1


2023-04-17 14:25:42

by Andre Przywara

[permalink] [raw]
Subject: Re: [PATCH v1 4/4] regulator: axp20x: Set DCDC frequency only when property exists

On Fri, 7 Apr 2023 22:18:13 +0800
Shengyu Qu <[email protected]> wrote:

> Current axp20x regulator driver would always set DCDC frequency even if
> there is no x-powers,dcdc-freq in device tree data. Causing meaningless
> warning info output on variants that do not support DCDC frequency
> modification. So only try to set DCDC frequency when there is frequency
> property.

This patch should not be needed. You should disallow the
x-powers,dcdc-freq property in the binding (see [1]), then handle that
like the AXP313a driver does: by explicitly checking that the property
does not exist, then returning, see [2].

In general you might want to rebase your series on top of the AXP313a v10
series, as this most likely goes in before.

Cheers,
Andre

[1]
https://lore.kernel.org/linux-sunxi/[email protected]/
[2]
https://lore.kernel.org/linux-sunxi/[email protected]/

> Signed-off-by: Shengyu Qu <[email protected]>
> ---
> drivers/regulator/axp20x-regulator.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index ece4af93df7b..12a12923bc7b 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -1247,10 +1247,10 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
> if (!regulators) {
> dev_warn(&pdev->dev, "regulators node not found\n");
> } else {
> - of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
> - ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret);
> + if (of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq) != -EINVAL) {
> + ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
> + if (ret < 0)
> + dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret);
> }
> of_node_put(regulators);
> }

2023-04-17 16:39:28

by Shengyu Qu

[permalink] [raw]
Subject: Re: [PATCH v1 4/4] regulator: axp20x: Set DCDC frequency only when property exists

Hi Andre,

> On Fri, 7 Apr 2023 22:18:13 +0800
> Shengyu Qu <[email protected]> wrote:
>
>> Current axp20x regulator driver would always set DCDC frequency even if
>> there is no x-powers,dcdc-freq in device tree data. Causing meaningless
>> warning info output on variants that do not support DCDC frequency
>> modification. So only try to set DCDC frequency when there is frequency
>> property.
> This patch should not be needed. You should disallow the
> x-powers,dcdc-freq property in the binding (see [1]), then handle that
> like the AXP313a driver does: by explicitly checking that the property
> does not exist, then returning, see [2].
>
> In general you might want to rebase your series on top of the AXP313a v10
> series, as this most likely goes in before.

Thanks for pointing out this :) Would fix and rebase in next version.

Best regards,

Shengyu

> Cheers,
> Andre
>
> [1]
> https://lore.kernel.org/linux-sunxi/[email protected]/
> [2]
> https://lore.kernel.org/linux-sunxi/[email protected]/
>
>> Signed-off-by: Shengyu Qu <[email protected]>
>> ---
>> drivers/regulator/axp20x-regulator.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
>> index ece4af93df7b..12a12923bc7b 100644
>> --- a/drivers/regulator/axp20x-regulator.c
>> +++ b/drivers/regulator/axp20x-regulator.c
>> @@ -1247,10 +1247,10 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>> if (!regulators) {
>> dev_warn(&pdev->dev, "regulators node not found\n");
>> } else {
>> - of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
>> - ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
>> - if (ret < 0) {
>> - dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret);
>> + if (of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq) != -EINVAL) {
>> + ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
>> + if (ret < 0)
>> + dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret);
>> }
>> of_node_put(regulators);
>> }


Attachments:
OpenPGP_0xE3520CC91929C8E7.asc (6.81 kB)
OpenPGP public key
OpenPGP_signature (849.00 B)
OpenPGP digital signature
Download all attachments