mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] regulator: fixed: remove duplicate always-on handling
@ 2022-07-08  5:53 Ahmad Fatoum
  2022-07-08  6:02 ` Ahmad Fatoum
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-07-08  5:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Regulator core already handles always-on property, so remove handling in
fixed-regulator driver. For this to have no functional change, all
regulator uses must be balanced as regulator code implements always-on
by initializing use count to baseline of 1, while fixed-regulator
prevents disabling altogether. As mismatched regulator enable/disable
is a bug in need of fixing anyway, this is tolerated.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/regulator/fixed.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index c5f97d78df40..ec64f39b86c7 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -15,7 +15,6 @@
 
 struct regulator_fixed {
 	int gpio;
-	int always_on;
 	struct regulator_dev rdev;
 	struct regulator_desc rdesc;
 };
@@ -34,9 +33,6 @@ static int regulator_fixed_disable(struct regulator_dev *rdev)
 {
 	struct regulator_fixed *fix = container_of(rdev, struct regulator_fixed, rdev);
 
-	if (fix->always_on)
-		return 0;
-
 	if (!gpio_is_valid(fix->gpio))
 		return 0;
 
@@ -76,12 +72,6 @@ static int regulator_fixed_probe(struct device_d *dev)
 	if (!of_property_read_u32(np, "off-on-delay-us", &delay))
 		fix->rdesc.off_on_delay = delay;
 
-	if (of_find_property(np, "regulator-always-on", NULL) ||
-	    of_find_property(np, "regulator-boot-on", NULL)) {
-		fix->always_on = 1;
-		regulator_fixed_enable(&fix->rdev);
-	}
-
 	ret = of_regulator_register(&fix->rdev, np);
 	if (ret)
 		goto err;
-- 
2.34.1




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

* Re: [PATCH] regulator: fixed: remove duplicate always-on handling
  2022-07-08  5:53 [PATCH] regulator: fixed: remove duplicate always-on handling Ahmad Fatoum
@ 2022-07-08  6:02 ` Ahmad Fatoum
  0 siblings, 0 replies; 2+ messages in thread
From: Ahmad Fatoum @ 2022-07-08  6:02 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox

On 08.07.22 07:53, Ahmad Fatoum wrote:
> Regulator core already handles always-on property, so remove handling in
> fixed-regulator driver. For this to have no functional change, all
> regulator uses must be balanced as regulator code implements always-on
> by initializing use count to baseline of 1, while fixed-regulator
> prevents disabling altogether. As mismatched regulator enable/disable
> is a bug in need of fixing anyway, this is tolerated.

Rethinking it, I guess we should just move this into regulator core
instead. That's what Linux does as well.

> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  drivers/regulator/fixed.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> index c5f97d78df40..ec64f39b86c7 100644
> --- a/drivers/regulator/fixed.c
> +++ b/drivers/regulator/fixed.c
> @@ -15,7 +15,6 @@
>  
>  struct regulator_fixed {
>  	int gpio;
> -	int always_on;
>  	struct regulator_dev rdev;
>  	struct regulator_desc rdesc;
>  };
> @@ -34,9 +33,6 @@ static int regulator_fixed_disable(struct regulator_dev *rdev)
>  {
>  	struct regulator_fixed *fix = container_of(rdev, struct regulator_fixed, rdev);
>  
> -	if (fix->always_on)
> -		return 0;
> -
>  	if (!gpio_is_valid(fix->gpio))
>  		return 0;
>  
> @@ -76,12 +72,6 @@ static int regulator_fixed_probe(struct device_d *dev)
>  	if (!of_property_read_u32(np, "off-on-delay-us", &delay))
>  		fix->rdesc.off_on_delay = delay;
>  
> -	if (of_find_property(np, "regulator-always-on", NULL) ||
> -	    of_find_property(np, "regulator-boot-on", NULL)) {
> -		fix->always_on = 1;
> -		regulator_fixed_enable(&fix->rdev);
> -	}
> -
>  	ret = of_regulator_register(&fix->rdev, np);
>  	if (ret)
>  		goto err;


-- 
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] 2+ messages in thread

end of thread, other threads:[~2022-07-08  6:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08  5:53 [PATCH] regulator: fixed: remove duplicate always-on handling Ahmad Fatoum
2022-07-08  6:02 ` Ahmad Fatoum

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