You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/08/14 05:40:43 UTC

[nuttx] branch master updated: fix g_goldfish_gauge_ops init C89 compatible and align style

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 3591de08c6 fix g_goldfish_gauge_ops init C89 compatible and align style
3591de08c6 is described below

commit 3591de08c69cbfcc01f7c8b82e5c1864da155152
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Mon Aug 14 10:11:46 2023 +0800

    fix g_goldfish_gauge_ops init C89 compatible and align style
    
    Signed-off-by: dulibo1 <du...@xiaomi.com>
---
 drivers/power/battery/goldfish_battery.c | 103 ++++++++++++++++---------------
 1 file changed, 52 insertions(+), 51 deletions(-)

diff --git a/drivers/power/battery/goldfish_battery.c b/drivers/power/battery/goldfish_battery.c
index 7da4946b30..1991ab9794 100644
--- a/drivers/power/battery/goldfish_battery.c
+++ b/drivers/power/battery/goldfish_battery.c
@@ -45,47 +45,47 @@
 
 enum
 {
-    /* Status register */
-
-    BATTERY_INT_STATUS = 0x00,
-
-    /* Set this to enable IRQ */
-
-    BATTERY_INT_ENABLE = 0x04,
-    BATTERY_AC_ONLINE = 0x08,
-    BATTERY_STATUS = 0x0c,
-    BATTERY_HEALTH = 0x10,
-    BATTERY_PRESENT = 0x14,
-    BATTERY_CAPACITY = 0x18,
-    BATTERY_VOLTAGE = 0x1c,
-    BATTERY_TEMP = 0x20,
-    BATTERY_CHARGE_COUNTER = 0x24,
-    BATTERY_VOLTAGE_MAX = 0x28,
-    BATTERY_CURRENT_MAX = 0x2c,
-    BATTERY_CURRENT_NOW = 0x30,
-    BATTERY_CURRENT_AVG = 0x34,
-    BATTERY_CHARGE_FULL_UAH = 0x38,
-    BATTERY_CYCLE_COUNT = 0x40,
-    BATTERY_STATUS_CHANGED = 1u << 0,
-    AC_STATUS_CHANGED = 1u << 1,
-    BATTERY_INT_MASK = BATTERY_STATUS_CHANGED | AC_STATUS_CHANGED,
+  /* Status register */
+
+  BATTERY_INT_STATUS = 0x00,
+
+  /* Set this to enable IRQ */
+
+  BATTERY_INT_ENABLE = 0x04,
+  BATTERY_AC_ONLINE = 0x08,
+  BATTERY_STATUS = 0x0c,
+  BATTERY_HEALTH = 0x10,
+  BATTERY_PRESENT = 0x14,
+  BATTERY_CAPACITY = 0x18,
+  BATTERY_VOLTAGE = 0x1c,
+  BATTERY_TEMP = 0x20,
+  BATTERY_CHARGE_COUNTER = 0x24,
+  BATTERY_VOLTAGE_MAX = 0x28,
+  BATTERY_CURRENT_MAX = 0x2c,
+  BATTERY_CURRENT_NOW = 0x30,
+  BATTERY_CURRENT_AVG = 0x34,
+  BATTERY_CHARGE_FULL_UAH = 0x38,
+  BATTERY_CYCLE_COUNT = 0x40,
+  BATTERY_STATUS_CHANGED = 1u << 0,
+  AC_STATUS_CHANGED = 1u << 1,
+  BATTERY_INT_MASK = BATTERY_STATUS_CHANGED | AC_STATUS_CHANGED,
 };
 
 enum
 {
-    POWER_SUPPLY_STATUS_UNKNOWN,
-    POWER_SUPPLY_STATUS_CHARGING,
-    POWER_SUPPLY_STATUS_DISCHARGING,
-    POWER_SUPPLY_STATUS_NOT_CHARGING,
-    POWER_SUPPLY_STATUS_FULL,
+  POWER_SUPPLY_STATUS_UNKNOWN,
+  POWER_SUPPLY_STATUS_CHARGING,
+  POWER_SUPPLY_STATUS_DISCHARGING,
+  POWER_SUPPLY_STATUS_NOT_CHARGING,
+  POWER_SUPPLY_STATUS_FULL,
 };
 
 struct goldfish_battery_data_s
 {
-    FAR void *reg_base;
-    int irq;
-    struct battery_gauge_dev_s battery;
-    struct work_s work;
+  FAR void *reg_base;
+  int irq;
+  struct battery_gauge_dev_s battery;
+  struct work_s work;
 };
 
 /****************************************************************************
@@ -111,12 +111,13 @@ static int goldfish_battery_temp(FAR struct battery_gauge_dev_s *dev,
 
 static const struct battery_gauge_operations_s g_goldfish_gauge_ops =
 {
-  .online = goldfish_charger_online,
-  .state = goldfish_battery_state,
-  .voltage = goldfish_battery_voltage,
-  .current = goldfish_battery_current,
-  .capacity = goldfish_battery_capacity,
-  .temp = goldfish_battery_temp,
+  goldfish_battery_state,
+  goldfish_charger_online,
+  goldfish_battery_voltage,
+  goldfish_battery_capacity,
+  goldfish_battery_current,
+  goldfish_battery_temp,
+  NULL,
 };
 
 /****************************************************************************
@@ -145,23 +146,23 @@ static int goldfish_battery_state(FAR struct battery_gauge_dev_s *dev,
   switch (regval)
   {
     case POWER_SUPPLY_STATUS_UNKNOWN:
-        *status = BATTERY_UNKNOWN;
-        break;
+      *status = BATTERY_UNKNOWN;
+      break;
     case POWER_SUPPLY_STATUS_CHARGING:
-        *status = BATTERY_CHARGING;
-        break;
+      *status = BATTERY_CHARGING;
+      break;
     case POWER_SUPPLY_STATUS_DISCHARGING:
-        *status = BATTERY_DISCHARGING;
-        break;
+      *status = BATTERY_DISCHARGING;
+      break;
     case POWER_SUPPLY_STATUS_NOT_CHARGING:
-        *status = BATTERY_IDLE;
-        break;
+      *status = BATTERY_IDLE;
+      break;
     case POWER_SUPPLY_STATUS_FULL:
-        *status = BATTERY_FULL;
-        break;
+      *status = BATTERY_FULL;
+      break;
     default:
-        *status = BATTERY_UNKNOWN;
-        break;
+      *status = BATTERY_UNKNOWN;
+      break;
   }
 
   return OK;