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

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

commit 64c0d2d059bf05679718b315f8fb546e42572a61
Author: chenzihan1 <[email protected]>
AuthorDate: Tue Dec 30 17:57:05 2025 +0800

    drivers/goldfish/battery: start the battery work during driver 
initialization
    
    Add a work queue call in goldfish_battery_register() to trigger an initial
    battery state update immediately after driver initialization.
    
    Previously, the battery state was only updated when a interrupt occurred.
    This could cause the battery_state uORB topic to have no data
    available during early boot, leading to failures when applications tried
    to read battery information via orb_copy().
    
    Signed-off-by: chenzihan1 <[email protected]>
---
 drivers/power/battery/goldfish_battery.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/power/battery/goldfish_battery.c 
b/drivers/power/battery/goldfish_battery.c
index 0e13bd7b37b..7f67d1a4f13 100644
--- a/drivers/power/battery/goldfish_battery.c
+++ b/drivers/power/battery/goldfish_battery.c
@@ -320,6 +320,14 @@ int goldfish_battery_register(FAR void *regs, int irq)
   up_enable_irq(data->irq);
   GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
 
+  /* Trigger initial battery state update */
+
+  ret = work_queue(HPWORK, &data->work, goldfish_battery_work, data, 0);
+  if (ret < 0)
+    {
+      batwarn("initial battery work queue failed: %d\n", ret);
+    }
+
   batinfo("goldfish_battery_register over");
   return 0;
 fail:

Reply via email to