linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: bd99954: Use LINEAR_RANGE()
@ 2022-10-31  7:36 Matti Vaittinen
  2022-11-01  0:04 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Matti Vaittinen @ 2022-10-31  7:36 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Matti Vaittinen, Sebastian Reichel, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3589 bytes --]

Do minor clean-up by using newly inroduced LINEAR_RANGE() initialization
macro.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
 drivers/power/supply/bd99954-charger.c | 84 ++++----------------------
 1 file changed, 13 insertions(+), 71 deletions(-)

diff --git a/drivers/power/supply/bd99954-charger.c b/drivers/power/supply/bd99954-charger.c
index 96e93e1b8094..250362e15c98 100644
--- a/drivers/power/supply/bd99954-charger.c
+++ b/drivers/power/supply/bd99954-charger.c
@@ -768,27 +768,13 @@ static const struct power_supply_desc bd9995x_power_supply_desc = {
  * Describe the setting in linear_range table.
  */
 static const struct linear_range input_current_limit_ranges[] = {
-	{
-		.min = 0,
-		.step = 32000,
-		.min_sel = 0x0,
-		.max_sel = 0x1ff,
-	},
+	LINEAR_RANGE(0, 0x0, 0x1ff, 32000),
 };
 
 /* Possible trickle, pre-charging and termination current values */
 static const struct linear_range charging_current_ranges[] = {
-	{
-		.min = 0,
-		.step = 64000,
-		.min_sel = 0x0,
-		.max_sel = 0x10,
-	}, {
-		.min = 1024000,
-		.step = 0,
-		.min_sel = 0x11,
-		.max_sel = 0x1f,
-	},
+	LINEAR_RANGE(0, 0x0, 0x10, 64000),
+	LINEAR_RANGE(1024000, 0x11, 0x1f, 0),
 };
 
 /*
@@ -796,72 +782,28 @@ static const struct linear_range charging_current_ranges[] = {
  * and battery over voltage protection have same possible values
  */
 static const struct linear_range charge_voltage_regulation_ranges[] = {
-	{
-		.min = 2560000,
-		.step = 0,
-		.min_sel = 0,
-		.max_sel = 0xA0,
-	}, {
-		.min = 2560000,
-		.step = 16000,
-		.min_sel = 0xA0,
-		.max_sel = 0x4B0,
-	}, {
-		.min = 19200000,
-		.step = 0,
-		.min_sel = 0x4B0,
-		.max_sel = 0x7FF,
-	},
+	LINEAR_RANGE(2560000, 0, 0xA0, 0),
+	LINEAR_RANGE(2560000, 0xA0, 0x4B0, 16000),
+	LINEAR_RANGE(19200000, 0x4B0, 0x7FF, 0),
 };
 
 /* Possible VSYS voltage regulation values */
 static const struct linear_range vsys_voltage_regulation_ranges[] = {
-	{
-		.min = 2560000,
-		.step = 0,
-		.min_sel = 0,
-		.max_sel = 0x28,
-	}, {
-		.min = 2560000,
-		.step = 64000,
-		.min_sel = 0x28,
-		.max_sel = 0x12C,
-	}, {
-		.min = 19200000,
-		.step = 0,
-		.min_sel = 0x12C,
-		.max_sel = 0x1FF,
-	},
+	LINEAR_RANGE(2560000, 0, 0x28, 0),
+	LINEAR_RANGE(2560000, 0x28, 0x12C, 64000),
+	LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0),
 };
 
 /* Possible settings for switching from trickle to pre-charging limits */
 static const struct linear_range trickle_to_pre_threshold_ranges[] = {
-	{
-		.min = 2048000,
-		.step = 0,
-		.min_sel = 0,
-		.max_sel = 0x20,
-	}, {
-		.min = 2048000,
-		.step = 64000,
-		.min_sel = 0x20,
-		.max_sel = 0x12C,
-	}, {
-		.min = 19200000,
-		.step = 0,
-		.min_sel = 0x12C,
-		.max_sel = 0x1FF
-	}
+	LINEAR_RANGE(2048000, 0, 0x20, 0),
+	LINEAR_RANGE(2048000, 0x20, 0x12C, 64000),
+	LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0),
 };
 
 /* Possible current values for fast-charging constant current phase */
 static const struct linear_range fast_charge_current_ranges[] = {
-	{
-		.min = 0,
-		.step = 64000,
-		.min_sel = 0,
-		.max_sel = 0xFF,
-	}
+	LINEAR_RANGE(0, 0, 0xFF, 64000),
 };
 
 struct battery_init {
-- 
2.37.3


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] power: supply: bd99954: Use LINEAR_RANGE()
  2022-10-31  7:36 [PATCH] power: supply: bd99954: Use LINEAR_RANGE() Matti Vaittinen
@ 2022-11-01  0:04 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2022-11-01  0:04 UTC (permalink / raw)
  To: Matti Vaittinen; +Cc: Matti Vaittinen, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3985 bytes --]

Hi,

On Mon, Oct 31, 2022 at 09:36:21AM +0200, Matti Vaittinen wrote:
> Do minor clean-up by using newly inroduced LINEAR_RANGE() initialization
> macro.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/bd99954-charger.c | 84 ++++----------------------
>  1 file changed, 13 insertions(+), 71 deletions(-)
> 
> diff --git a/drivers/power/supply/bd99954-charger.c b/drivers/power/supply/bd99954-charger.c
> index 96e93e1b8094..250362e15c98 100644
> --- a/drivers/power/supply/bd99954-charger.c
> +++ b/drivers/power/supply/bd99954-charger.c
> @@ -768,27 +768,13 @@ static const struct power_supply_desc bd9995x_power_supply_desc = {
>   * Describe the setting in linear_range table.
>   */
>  static const struct linear_range input_current_limit_ranges[] = {
> -	{
> -		.min = 0,
> -		.step = 32000,
> -		.min_sel = 0x0,
> -		.max_sel = 0x1ff,
> -	},
> +	LINEAR_RANGE(0, 0x0, 0x1ff, 32000),
>  };
>  
>  /* Possible trickle, pre-charging and termination current values */
>  static const struct linear_range charging_current_ranges[] = {
> -	{
> -		.min = 0,
> -		.step = 64000,
> -		.min_sel = 0x0,
> -		.max_sel = 0x10,
> -	}, {
> -		.min = 1024000,
> -		.step = 0,
> -		.min_sel = 0x11,
> -		.max_sel = 0x1f,
> -	},
> +	LINEAR_RANGE(0, 0x0, 0x10, 64000),
> +	LINEAR_RANGE(1024000, 0x11, 0x1f, 0),
>  };
>  
>  /*
> @@ -796,72 +782,28 @@ static const struct linear_range charging_current_ranges[] = {
>   * and battery over voltage protection have same possible values
>   */
>  static const struct linear_range charge_voltage_regulation_ranges[] = {
> -	{
> -		.min = 2560000,
> -		.step = 0,
> -		.min_sel = 0,
> -		.max_sel = 0xA0,
> -	}, {
> -		.min = 2560000,
> -		.step = 16000,
> -		.min_sel = 0xA0,
> -		.max_sel = 0x4B0,
> -	}, {
> -		.min = 19200000,
> -		.step = 0,
> -		.min_sel = 0x4B0,
> -		.max_sel = 0x7FF,
> -	},
> +	LINEAR_RANGE(2560000, 0, 0xA0, 0),
> +	LINEAR_RANGE(2560000, 0xA0, 0x4B0, 16000),
> +	LINEAR_RANGE(19200000, 0x4B0, 0x7FF, 0),
>  };
>  
>  /* Possible VSYS voltage regulation values */
>  static const struct linear_range vsys_voltage_regulation_ranges[] = {
> -	{
> -		.min = 2560000,
> -		.step = 0,
> -		.min_sel = 0,
> -		.max_sel = 0x28,
> -	}, {
> -		.min = 2560000,
> -		.step = 64000,
> -		.min_sel = 0x28,
> -		.max_sel = 0x12C,
> -	}, {
> -		.min = 19200000,
> -		.step = 0,
> -		.min_sel = 0x12C,
> -		.max_sel = 0x1FF,
> -	},
> +	LINEAR_RANGE(2560000, 0, 0x28, 0),
> +	LINEAR_RANGE(2560000, 0x28, 0x12C, 64000),
> +	LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0),
>  };
>  
>  /* Possible settings for switching from trickle to pre-charging limits */
>  static const struct linear_range trickle_to_pre_threshold_ranges[] = {
> -	{
> -		.min = 2048000,
> -		.step = 0,
> -		.min_sel = 0,
> -		.max_sel = 0x20,
> -	}, {
> -		.min = 2048000,
> -		.step = 64000,
> -		.min_sel = 0x20,
> -		.max_sel = 0x12C,
> -	}, {
> -		.min = 19200000,
> -		.step = 0,
> -		.min_sel = 0x12C,
> -		.max_sel = 0x1FF
> -	}
> +	LINEAR_RANGE(2048000, 0, 0x20, 0),
> +	LINEAR_RANGE(2048000, 0x20, 0x12C, 64000),
> +	LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0),
>  };
>  
>  /* Possible current values for fast-charging constant current phase */
>  static const struct linear_range fast_charge_current_ranges[] = {
> -	{
> -		.min = 0,
> -		.step = 64000,
> -		.min_sel = 0,
> -		.max_sel = 0xFF,
> -	}
> +	LINEAR_RANGE(0, 0, 0xFF, 64000),
>  };
>  
>  struct battery_init {
> -- 
> 2.37.3
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-11-01  0:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31  7:36 [PATCH] power: supply: bd99954: Use LINEAR_RANGE() Matti Vaittinen
2022-11-01  0:04 ` Sebastian Reichel

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).