sched/wdog: Don't dynamically allocate wdog_s

to save the preserved space(1KB) and also avoid the heap overhead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I694073f68e1bd63960cedeea1ddec441437be025
This commit is contained in:
Xiang Xiao
2020-08-04 18:31:31 +08:00
committed by patacongo
parent 4df42ba9fb
commit a0ce81d659
666 changed files with 915 additions and 3286 deletions
+6 -18
View File
@@ -141,7 +141,7 @@ struct ft5x06_dev_s
struct work_s work; /* Supports the interrupt
* handling "bottom half" */
#ifdef CONFIG_FT5X06_POLLMODE
WDOG_ID polltimer; /* Poll timer */
struct wdog_s polltimer; /* Poll timer */
#endif
uint8_t touchbuf[FT5X06_TOUCH_DATA_LEN]; /* Raw touch data */
@@ -363,7 +363,7 @@ static void ft5x06_data_worker(FAR void *arg)
#ifdef CONFIG_FT5X06_POLLMODE
/* Exit, re-starting the poll. */
wd_start(priv->polltimer, priv->delay,
wd_start(&priv->polltimer, priv->delay,
ft5x06_poll_timeout, 1, (wdparm_t)priv);
#else
@@ -764,7 +764,7 @@ static void ft5x06_shutdown(FAR struct ft5x06_dev_s *priv)
#ifdef CONFIG_FT5X06_POLLMODE
/* Stop the poll timer */
wd_cancel(priv->polltimer);
wd_cancel(&priv->polltimer);
#else
FAR const struct ft5x06_config_s *config = priv->config;
@@ -1176,13 +1176,6 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
/* Allocate a timer for polling the FT5x06 */
priv->delay = POLL_MAXDELAY;
priv->polltimer = wd_create();
if (priv->polltimer == NULL)
{
ierr("ERROR: Failed to allocate polltimer\n");
ret = -EBUSY;
goto errout_with_priv;
}
#else
/* Make sure that the FT5x06 interrupt interrupt is disabled */
@@ -1196,7 +1189,7 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
if (ret < 0)
{
ierr("ERROR: Failed to attach interrupt\n");
goto errout_with_timer;
goto errout_with_priv;
}
#endif
@@ -1209,7 +1202,7 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
if (ret < 0)
{
ierr("ERROR: register_driver() failed: %d\n", ret);
goto errout_with_timer;
goto errout_with_priv;
}
/* Schedule work to perform the initial sampling and to set the data
@@ -1220,19 +1213,14 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
if (ret < 0)
{
ierr("ERROR: Failed to queue work: %d\n", ret);
goto errout_with_timer;
goto errout_with_priv;
}
/* And return success */
return OK;
errout_with_timer:
#ifdef CONFIG_FT5X06_POLLMODE
wd_delete(priv->polltimer);
errout_with_priv:
#endif
nxsem_destroy(&priv->devsem);
kmm_free(priv);
return ret;