power: charger-manager: clarify num_properties starting value
diff mbox series

Message ID c262c4b0921d916712de6a15133ff016fb721c4f.1588343350.git.mirq-linux@rere.qmqm.pl
State Accepted
Commit 97ed79f4931964069fc3be7ae5122c3026273f9e
Headers show
Series
  • power: charger-manager: clarify num_properties starting value
Related show

Commit Message

Michał Mirosław May 1, 2020, 2:30 p.m. UTC
Initialize num_properties with length of the copied array instead
of relying on previously memcpy'd value. This makes it clear how
the array and the counter are related.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/power/supply/charger-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sebastian Reichel May 1, 2020, 2:58 p.m. UTC | #1
Hi,

On Fri, May 01, 2020 at 04:30:43PM +0200, Michał Mirosław wrote:
> Initialize num_properties with length of the copied array instead
> of relying on previously memcpy'd value. This makes it clear how
> the array and the counter are related.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/charger-manager.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
> index 415a9efa6816..2ef53dc1f2fb 100644
> --- a/drivers/power/supply/charger-manager.c
> +++ b/drivers/power/supply/charger-manager.c
> @@ -1729,7 +1729,7 @@ static int charger_manager_probe(struct platform_device *pdev)
>  	memcpy(properties, default_charger_props,
>  		sizeof(enum power_supply_property) *
>  		ARRAY_SIZE(default_charger_props));
> -	num_properties = psy_default.num_properties;
> +	num_properties = ARRAY_SIZE(default_charger_props);
>  
>  	/* Find which optional psy-properties are available */
>  	fuel_gauge = power_supply_get_by_name(desc->psy_fuel_gauge);
> -- 
> 2.20.1
>

Patch
diff mbox series

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 415a9efa6816..2ef53dc1f2fb 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1729,7 +1729,7 @@  static int charger_manager_probe(struct platform_device *pdev)
 	memcpy(properties, default_charger_props,
 		sizeof(enum power_supply_property) *
 		ARRAY_SIZE(default_charger_props));
-	num_properties = psy_default.num_properties;
+	num_properties = ARRAY_SIZE(default_charger_props);
 
 	/* Find which optional psy-properties are available */
 	fuel_gauge = power_supply_get_by_name(desc->psy_fuel_gauge);