mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] regulator: core: don't call of_regulator_get with NULL argument
@ 2022-12-01 13:38 Ahmad Fatoum
  2022-12-02  8:50 ` Marco Felsch
  2022-12-02  8:53 ` Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2022-12-01 13:38 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

regulator_get calls either of_regulator_get or dev_regulator_get, both
of which accept a supply parameter. Only dev_regulator_get gracefully
handles a NULL supply by considering all registered regulators.

of_regulator_get on the other hand, will complain at debug level,
before returning NULL:

  uart-pl011 fe201000.serial@7e201000.of: No <NULL>-supply node found,
  using dummy regulator

Avoid this message by skipping of_regulator_get if no supply was found
and directly call dev_regulator_get.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4876f0f44bdd..d25aba38c3e2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -388,7 +388,7 @@ struct regulator *regulator_get(struct device_d *dev, const char *supply)
 	struct regulator *r;
 	int ret;
 
-	if (dev->device_node) {
+	if (dev->device_node && supply) {
 		ri = of_regulator_get(dev, supply);
 		if (IS_ERR(ri))
 			return ERR_CAST(ri);
-- 
2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: core: don't call of_regulator_get with NULL argument
  2022-12-01 13:38 [PATCH] regulator: core: don't call of_regulator_get with NULL argument Ahmad Fatoum
@ 2022-12-02  8:50 ` Marco Felsch
  2022-12-02  9:03   ` Ahmad Fatoum
  2022-12-02  8:53 ` Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Marco Felsch @ 2022-12-02  8:50 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On 22-12-01, Ahmad Fatoum wrote:
> regulator_get calls either of_regulator_get or dev_regulator_get, both
> of which accept a supply parameter. Only dev_regulator_get gracefully
> handles a NULL supply by considering all registered regulators.

Wouldn't it be better to align of_regulator_get behaviour with
dev_regulator_get?

> of_regulator_get on the other hand, will complain at debug level,
> before returning NULL:
> 
>   uart-pl011 fe201000.serial@7e201000.of: No <NULL>-supply node found,
>   using dummy regulator
> 
> Avoid this message by skipping of_regulator_get if no supply was found
> and directly call dev_regulator_get.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/regulator/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 4876f0f44bdd..d25aba38c3e2 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -388,7 +388,7 @@ struct regulator *regulator_get(struct device_d *dev, const char *supply)
>  	struct regulator *r;
>  	int ret;
>  
> -	if (dev->device_node) {
> +	if (dev->device_node && supply) {
>  		ri = of_regulator_get(dev, supply);
>  		if (IS_ERR(ri))
>  			return ERR_CAST(ri);

Nevertheless the change is correct, so:

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

Regards,
  Marco
> -- 
> 2.30.2
> 
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: core: don't call of_regulator_get with NULL argument
  2022-12-01 13:38 [PATCH] regulator: core: don't call of_regulator_get with NULL argument Ahmad Fatoum
  2022-12-02  8:50 ` Marco Felsch
@ 2022-12-02  8:53 ` Sascha Hauer
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2022-12-02  8:53 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Thu, Dec 01, 2022 at 02:38:53PM +0100, Ahmad Fatoum wrote:
> regulator_get calls either of_regulator_get or dev_regulator_get, both
> of which accept a supply parameter. Only dev_regulator_get gracefully
> handles a NULL supply by considering all registered regulators.
> 
> of_regulator_get on the other hand, will complain at debug level,
> before returning NULL:
> 
>   uart-pl011 fe201000.serial@7e201000.of: No <NULL>-supply node found,
>   using dummy regulator
> 
> Avoid this message by skipping of_regulator_get if no supply was found
> and directly call dev_regulator_get.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/regulator/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 4876f0f44bdd..d25aba38c3e2 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -388,7 +388,7 @@ struct regulator *regulator_get(struct device_d *dev, const char *supply)
>  	struct regulator *r;
>  	int ret;
>  
> -	if (dev->device_node) {
> +	if (dev->device_node && supply) {
>  		ri = of_regulator_get(dev, supply);
>  		if (IS_ERR(ri))
>  			return ERR_CAST(ri);
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: core: don't call of_regulator_get with NULL argument
  2022-12-02  8:50 ` Marco Felsch
@ 2022-12-02  9:03   ` Ahmad Fatoum
  0 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2022-12-02  9:03 UTC (permalink / raw)
  To: Marco Felsch; +Cc: barebox

On 02.12.22 09:50, Marco Felsch wrote:
> On 22-12-01, Ahmad Fatoum wrote:
>> regulator_get calls either of_regulator_get or dev_regulator_get, both
>> of which accept a supply parameter. Only dev_regulator_get gracefully
>> handles a NULL supply by considering all registered regulators.
> 
> Wouldn't it be better to align of_regulator_get behaviour with
> dev_regulator_get?

Nope, not specifying a supply id is legacy behavior. Consumers
should be expected to know the name of the supply they want to
control. In Linux, regulator_get(dev, NULL) is already an error. 

> 
>> of_regulator_get on the other hand, will complain at debug level,
>> before returning NULL:
>>
>>   uart-pl011 fe201000.serial@7e201000.of: No <NULL>-supply node found,
>>   using dummy regulator
>>
>> Avoid this message by skipping of_regulator_get if no supply was found
>> and directly call dev_regulator_get.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  drivers/regulator/core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
>> index 4876f0f44bdd..d25aba38c3e2 100644
>> --- a/drivers/regulator/core.c
>> +++ b/drivers/regulator/core.c
>> @@ -388,7 +388,7 @@ struct regulator *regulator_get(struct device_d *dev, const char *supply)
>>  	struct regulator *r;
>>  	int ret;
>>  
>> -	if (dev->device_node) {
>> +	if (dev->device_node && supply) {
>>  		ri = of_regulator_get(dev, supply);
>>  		if (IS_ERR(ri))
>>  			return ERR_CAST(ri);
> 
> Nevertheless the change is correct, so:
> 
> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> 
> Regards,
>   Marco
>> -- 
>> 2.30.2
>>
>>
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-02  9:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 13:38 [PATCH] regulator: core: don't call of_regulator_get with NULL argument Ahmad Fatoum
2022-12-02  8:50 ` Marco Felsch
2022-12-02  9:03   ` Ahmad Fatoum
2022-12-02  8:53 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox