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
+5 -13
View File
@@ -125,7 +125,7 @@ struct cdcacm_dev_s
FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */
FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint structure */
FAR struct usbdev_req_s *ctrlreq; /* Allocated control request */
WDOG_ID rxfailsafe; /* Failsafe timer to prevent RX stalls */
struct wdog_s rxfailsafe; /* Failsafe timer to prevent RX stalls */
struct sq_queue_s txfree; /* Available write request containers */
struct sq_queue_s rxpending; /* Pending read request containers */
@@ -679,7 +679,7 @@ static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv)
/* Cancel any pending failsafe timer */
wd_cancel(priv->rxfailsafe);
wd_cancel(&priv->rxfailsafe);
/* If RX "interrupts" are enabled and if input flow control is not in
* effect, then pass the packet at the head of the pending RX packet list
@@ -746,7 +746,7 @@ static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv)
if (!sq_empty(&priv->rxpending))
{
wd_start(priv->rxfailsafe, CDCACM_RXDELAY,
wd_start(&priv->rxfailsafe, CDCACM_RXDELAY,
cdcacm_rxtimeout, 1, (wdparm_t)priv);
}
@@ -2933,13 +2933,6 @@ int cdcacm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
memcpy(&priv->devinfo, devinfo,
sizeof(struct usbdev_devinfo_s));
/* Allocate a failsafe time so that we can be assured that RX data
* can never stall in the priv->rxpending queue.
*/
priv->rxfailsafe = wd_create();
DEBUGASSERT(priv->rxfailsafe != NULL);
#ifdef CONFIG_CDCACM_IFLOWCONTROL
/* SerialState */
@@ -3008,7 +3001,6 @@ int cdcacm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
return OK;
errout_with_class:
wd_delete(priv->rxfailsafe);
kmm_free(alloc);
return ret;
}
@@ -3142,7 +3134,7 @@ void cdcacm_uninitialize(FAR void *handle)
* free the memory resources.
*/
wd_delete(priv->rxfailsafe);
wd_cancel(&priv->rxfailsafe);
kmm_free(priv);
return;
}
@@ -3174,7 +3166,7 @@ void cdcacm_uninitialize(FAR void *handle)
/* And free the memory resources. */
wd_delete(priv->rxfailsafe);
wd_cancel(&priv->rxfailsafe);
kmm_free(priv);
#else
+5 -11
View File
@@ -158,7 +158,7 @@ struct cdcecm_driver_s
/* Network device */
bool bifup; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
struct wdog_s txpoll; /* TX poll timer */
struct work_s irqwork; /* For deferring interrupt work
* to the work queue */
struct work_s pollwork; /* For deferring poll work to
@@ -707,7 +707,7 @@ static void cdcecm_poll_work(FAR void *arg)
/* Setup the watchdog poll timer again */
wd_start(self->txpoll, CDCECM_WDDELAY,
wd_start(&self->txpoll, CDCECM_WDDELAY,
cdcecm_poll_expiry, 1, (wdparm_t)self);
net_unlock();
@@ -788,7 +788,7 @@ static int cdcecm_ifup(FAR struct net_driver_s *dev)
/* Set and activate a timer process */
wd_start(priv->txpoll, CDCECM_WDDELAY,
wd_start(&priv->txpoll, CDCECM_WDDELAY,
cdcecm_poll_expiry, 1, (wdparm_t)priv);
priv->bifup = true;
@@ -824,7 +824,7 @@ static int cdcecm_ifdown(FAR struct net_driver_s *dev)
/* Cancel the TX poll timer and TX timeout timers */
wd_cancel(priv->txpoll);
wd_cancel(&priv->txpoll);
/* Put the EMAC in its reset, non-operational state. This should be
* a known configuration that will guarantee the cdcecm_ifup() always
@@ -2130,13 +2130,7 @@ static int cdcecm_classobject(int minor,
#ifdef CONFIG_NETDEV_IOCTL
self->dev.d_ioctl = cdcecm_ioctl; /* Handle network IOCTL commands */
#endif
self->dev.d_private = (FAR void *)self; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmissions */
self->txpoll = wd_create(); /* Create periodic poll timer */
DEBUGASSERT(self->txpoll != NULL);
self->dev.d_private = self; /* Used to recover private state from dev */
/* USB device initialization */
+4 -5
View File
@@ -152,7 +152,7 @@ struct rndis_dev_s
struct rndis_req_s wrreqs[CONFIG_RNDIS_NWRREQS];
struct work_s rxwork; /* Worker for dispatching RX packets */
WDOG_ID txpoll; /* TX poll watchdog */
struct wdog_s txpoll; /* TX poll watchdog */
struct work_s pollwork; /* TX poll worker */
bool registered; /* Has netdev_register() been called */
@@ -1123,7 +1123,7 @@ static void rndis_polltimer(int argc, wdparm_t arg, ...)
/* Setup the watchdog poll timer again */
wd_start(priv->txpoll, RNDIS_WDDELAY,
wd_start(&priv->txpoll, RNDIS_WDDELAY,
rndis_polltimer, 1, (wdparm_t)arg);
}
@@ -1139,7 +1139,7 @@ static int rndis_ifup(FAR struct net_driver_s *dev)
{
FAR struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)dev->d_private;
wd_start(priv->txpoll, RNDIS_WDDELAY,
wd_start(&priv->txpoll, RNDIS_WDDELAY,
rndis_polltimer, 1, (wdparm_t)priv);
return OK;
}
@@ -1156,7 +1156,7 @@ static int rndis_ifdown(FAR struct net_driver_s *dev)
{
FAR struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)dev->d_private;
wd_cancel(priv->txpoll);
wd_cancel(&priv->txpoll);
return OK;
}
@@ -2774,7 +2774,6 @@ static int usbclass_classobject(int minor,
sq_init(&priv->reqlist);
memcpy(priv->host_mac_address, g_rndis_default_mac_addr, 6);
priv->txpoll = wd_create();
priv->netdev.d_private = priv;
priv->netdev.d_ifup = &rndis_ifup;
priv->netdev.d_ifdown = &rndis_ifdown;