charger: fix crash when notify without pollwaiter

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong
2021-12-13 16:38:36 +08:00
committed by Xiang Xiao
parent 68bbcf74c4
commit 8b0d45abef
3 changed files with 18 additions and 3 deletions
+6 -1
View File
@@ -99,12 +99,17 @@ static const struct file_operations g_batteryops =
****************************************************************************/
static int battery_charger_notify(FAR struct battery_charger_priv_s *priv,
uint32_t mask)
uint32_t mask)
{
FAR struct pollfd *fd = priv->fds;
int semcnt;
int ret;
if (!fd)
{
return OK;
}
ret = nxsem_wait_uninterruptible(&priv->lock);
if (ret < 0)
{
+6 -1
View File
@@ -101,12 +101,17 @@ static const struct file_operations g_batteryops =
****************************************************************************/
static int battery_gauge_notify(FAR struct battery_gauge_priv_s *priv,
uint32_t mask)
uint32_t mask)
{
FAR struct pollfd *fd = priv->fds;
int semcnt;
int ret;
if (!fd)
{
return OK;
}
ret = nxsem_wait_uninterruptible(&priv->lock);
if (ret < 0)
{
+6 -1
View File
@@ -100,12 +100,17 @@ static const struct file_operations g_batteryops =
****************************************************************************/
static int battery_monitor_notify(FAR struct battery_monitor_priv_s *priv,
uint32_t mask)
uint32_t mask)
{
FAR struct pollfd *fd = priv->fds;
int semcnt;
int ret;
if (!fd)
{
return OK;
}
ret = nxsem_wait_uninterruptible(&priv->lock);
if (ret < 0)
{