ACK: [PATCH] lib: fwts-battery: make battery type a typedef'd enum
ivanhu
ivan.hu at canonical.com
Thu Sep 21 08:40:56 UTC 2017
On 09/08/2017 04:42 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Rather than passing the battery type as int, make it instead a more
> strongly typed object.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/include/fwts_battery.h | 11 +++++++----
> src/lib/src/fwts_battery.c | 6 +++---
> 2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/lib/include/fwts_battery.h b/src/lib/include/fwts_battery.h
> index c3c168e8..1488a60e 100644
> --- a/src/lib/include/fwts_battery.h
> +++ b/src/lib/include/fwts_battery.h
> @@ -21,16 +21,19 @@
>
> #define FWTS_PROC_ACPI_BATTERY "/proc/acpi/battery"
>
> -#define FWTS_BATTERY_DESIGN_CAPACITY (0x00)
> -#define FWTS_BATTERY_REMAINING_CAPACITY (0x01)
> -#define FWTS_BATTERY_ALL (-1)
> +typedef enum {
> + FWTS_BATTERY_DESIGN_CAPACITY = 0,
> + FWTS_BATTERY_REMAINING_CAPACITY = 1,
> + FWTS_BATTERY_ALL = -1,
> +} fwts_battery_type;
>
> int fwts_battery_get_count(fwts_framework *fw, int *count);
> int fwts_battery_get_cycle_count(fwts_framework *fw, const int index, int *cycle_count);
> bool fwts_battery_check_trip_point_support(fwts_framework *fw, const int index);
> int fwts_battery_set_trip_point(fwts_framework *fw, const int index, const int trip_point);
> int fwts_battery_get_trip_point(fwts_framework *fw, const int index, int *trip_point);
> -int fwts_battery_get_capacity(fwts_framework *fw, const int type, const int index, uint32_t *capacity_mAh, uint32_t *capacity_mWh);
> +int fwts_battery_get_capacity(fwts_framework *fw, const fwts_battery_type type,
> + const int index, uint32_t *capacity_mAh, uint32_t *capacity_mWh);
> int fwts_battery_get_name(fwts_framework *fw, const int index, char *name);
>
> #endif
> diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
> index d61a709a..d2ba81c0 100644
> --- a/src/lib/src/fwts_battery.c
> +++ b/src/lib/src/fwts_battery.c
> @@ -29,7 +29,7 @@
>
> static int fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
> DIR *dir,
> - const int type,
> + const fwts_battery_type type,
> const int index,
> uint32_t *capacity_mAh, /* charge */
> uint32_t *capacity_mWh, /* energy */
> @@ -111,7 +111,7 @@ static int fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
>
> static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
> DIR *dir,
> - const int type,
> + const fwts_battery_type type,
> const int index,
> uint32_t *capacity_mAh,
> uint32_t *capacity_mWh,
> @@ -669,7 +669,7 @@ int fwts_battery_get_count(fwts_framework *fw, int *count)
> }
>
> int fwts_battery_get_capacity(fwts_framework *fw,
> - const int type,
> + const fwts_battery_type type,
> const int index,
> uint32_t *capacity_mAh,
> uint32_t *capacity_mWh)
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list