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 c52188f0bf drivers/foc/foc_dummy.c: update dummy device state only if
dev opened
c52188f0bf is described below
commit c52188f0bf188940bb2bf56cec141da15a27aeaa
Author: raiden00pl <[email protected]>
AuthorDate: Mon Oct 2 12:53:04 2023 +0200
drivers/foc/foc_dummy.c: update dummy device state only if dev opened
This is fix for seg fault for sim/foc configuration
---
drivers/motor/foc/foc_dummy.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/motor/foc/foc_dummy.c b/drivers/motor/foc/foc_dummy.c
index 75582439e3..0766da48c5 100644
--- a/drivers/motor/foc/foc_dummy.c
+++ b/drivers/motor/foc/foc_dummy.c
@@ -687,13 +687,18 @@ void foc_dummy_update(void)
dev = &g_foc_dev[i];
- /* Get SIM data */
+ /* Update dummy driver state only if device opened */
- sim = FOC_DUMMY_DATA_FROM_DEV_GET(dev);
-
- if (sim->state == true)
+ if (dev->ocount > 0)
{
- foc_dummy_notifier_handler(dev);
+ /* Get SIM data */
+
+ sim = FOC_DUMMY_DATA_FROM_DEV_GET(dev);
+
+ if (sim->state == true)
+ {
+ foc_dummy_notifier_handler(dev);
+ }
}
}