Exemple #1
0
int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
{
  FAR struct aio_container_s *aioc;
  FAR struct aio_container_s *next;
  int status;
  int ret;

  /* Check if a non-NULL aiocbp was provided */

  /* Lock the scheduler so that no I/O events can complete on the worker
   * thread until we set complete this operation.
   */

  ret = AIO_ALLDONE;
  sched_lock();
  aio_lock();

  if (aiocbp)
    {
      /* Check if the I/O has completed */

      if (aiocbp->aio_result == -EINPROGRESS)
        {
          /* No.. Find the container for this AIO control block */

          for (aioc = (FAR struct aio_container_s *)g_aio_pending.head;
               aioc && aioc->aioc_aiocbp != aiocbp;
               aioc = (FAR struct aio_container_s *)aioc->aioc_link.flink);

          /* Did we find a container for this fildes?  We should; the aio_result says
           * that the transfer is pending.  If not we return AIO_ALLDONE.
           */

          if (aioc)
            {
              /* Yes... attempt to cancel the I/O.  There are two
               * possibilities:* (1) the work has already been started and
               * is no longer queued, or (2) the work has not been started
               * and is still in the work queue.  Only the second case can
               * be cancelled.  work_cancel() will return -ENOENT in the
               * first case.
               */

              status = work_cancel(LPWORK, &aioc->aioc_work);
              if (status >= 0)
                {
                  aiocbp->aio_result = -ECANCELED;
                  ret = AIO_CANCELED;
                }
              else
                {
                  ret = AIO_NOTCANCELED;
                }

              /* Remove the container from the list of pending transfers */

              (void)aioc_decant(aioc);
            }
        }
    }
  else
    {
      /* No aiocbp.. cancel all outstanding I/O for the fildes */

      next = (FAR struct aio_container_s *)g_aio_pending.head;
      do
        {
          /* Find the next container with this AIO control block */

          for (aioc = next;
               aioc && aioc->aioc_aiocbp->aio_fildes != fildes;
               aioc = (FAR struct aio_container_s *)aioc->aioc_link.flink);

          /* Did we find the container?  We should; the aio_result says
           * that the transfer is pending.  If not we return AIO_ALLDONE.
           */

          if (aioc)
            {
              /* Yes... attempt to cancel the I/O.  There are two
               * possibilities:* (1) the work has already been started and
               * is no longer queued, or (2) the work has not been started
               * and is still in the work queue.  Only the second case can
               * be cancelled.  work_cancel() will return -ENOENT in the
               * first case.
               */

              status = work_cancel(LPWORK, &aioc->aioc_work);

              /* Remove the container from the list of pending transfers */

              next   = (FAR struct aio_container_s *)aioc->aioc_link.flink;
              aiocbp = aioc_decant(aioc);
              DEBUGASSERT(aiocbp);

              if (status >= 0)
                {
                  aiocbp->aio_result = -ECANCELED;
                  if (ret != AIO_NOTCANCELED)
                    {
                      ret = AIO_CANCELED;
                    }
                }
              else
                {
                  ret = AIO_NOTCANCELED;
                }
            }
        }
      while (aioc);
    }

  aio_unlock();
  sched_unlock();
  return ret;
}
Exemple #2
0
void
PMW3901::stop()
{
	work_cancel(HPWORK, &_work);
}
void
leddar_one::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #4
0
void
LL40LS::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #5
0
LandDetector::~LandDetector()
{
	work_cancel(LPWORK, &_work);
	_taskShouldExit = true;
}
Exemple #6
0
void LidarLitePWM::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #7
0
void
HMC5883::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #8
0
void
MB12XX::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #9
0
void
TFMINI::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #10
0
void
OREOLED::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #11
0
void
Gimbal::stop()
{
	work_cancel(LPWORK, &_work);
}
Exemple #12
0
void
AK8975::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #13
0
void
LM73::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #14
0
void
IST8310::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #15
0
/**
 * Set mode, if mode not changed has no any effect (doesn't reset blinks phase)
 */
void
RGBLED::set_mode(rgbled_mode_t mode)
{
	if (mode != _mode) {
		_mode = mode;
		bool should_run = false;

		switch (mode) {
		case RGBLED_MODE_OFF:
			send_led_enable(false);
			break;

		case RGBLED_MODE_ON:
			_brightness = 1.0f;
			send_led_rgb();
			send_led_enable(true);
			break;

		case RGBLED_MODE_BLINK_SLOW:
			should_run = true;
			_counter = 0;
			_led_interval = 2000;
			_brightness = 1.0f;
			send_led_rgb();
			break;

		case RGBLED_MODE_BLINK_NORMAL:
			should_run = true;
			_counter = 0;
			_led_interval = 500;
			_brightness = 1.0f;
			send_led_rgb();
			break;

		case RGBLED_MODE_BLINK_FAST:
			should_run = true;
			_counter = 0;
			_led_interval = 100;
			_brightness = 1.0f;
			send_led_rgb();
			break;

		case RGBLED_MODE_BREATHE:
			should_run = true;
			_counter = 0;
			_led_interval = 25;
			send_led_enable(true);
			break;

		case RGBLED_MODE_PATTERN:
			should_run = true;
			_counter = 0;
			_brightness = 1.0f;
			send_led_enable(true);
			break;

		default:
			warnx("mode unknown");
			break;
		}

		/* if it should run now, start the workq */
		if (should_run && !_running) {
			_running = true;
			work_queue(LPWORK, &_work, (worker_t)&RGBLED::led_trampoline, this, 1);
		}

		/* if it should stop, then cancel the workq */
		if (!should_run && _running) {
			_running = false;
			work_cancel(LPWORK, &_work);
		}
	}
}
Exemple #16
0
void
TRONE::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #17
0
static void usbhost_disconnect_event(FAR void *arg)
{
  FAR struct usbhost_class_s *hubclass = (FAR struct usbhost_class_s *)arg;
  FAR struct usbhost_hubpriv_s *priv;
  FAR struct usbhost_hubport_s *hport;
  FAR struct usbhost_hubport_s *child;
  irqstate_t flags;
  int port;

  uvdbg("Disconnecting\n");

  DEBUGASSERT(hubclass != NULL && hubclass->hport != NULL);
  priv  = &((FAR struct usbhost_hubclass_s *)hubclass)->hubpriv;
  hport = hubclass->hport;

  uvdbg("Destroying hub on port  %d\n", hport->port);

  /* Set an indication to any users of the device that the device is no
   * longer available.
   */

  flags = irqsave();

  /* Cancel any pending transfers on the interrupt IN pipe */

  DRVR_CANCEL(hport->drvr, priv->intin);

  /* Cancel any pending port status change events */

  work_cancel(LPWORK, &priv->work);

  /* Disable power to all downstream ports */

  (void)usbhost_hubpwr(priv, hport, false);

  /* Free the allocated control request */

  DRVR_FREE(hport->drvr, (FAR uint8_t *)priv->ctrlreq);

  /* Free buffer for status change (INT) endpoint */

  DRVR_IOFREE(hport->drvr, priv->buffer);

  /* Destroy the interrupt IN endpoint */

  DRVR_EPFREE(hport->drvr, priv->intin);

  /* Release per-port resources */

  for (port = 0; port < USBHUB_MAX_PORTS; port++)
    {
      /* Free any devices classes connect on this hub port */

      child = &priv->hport[port];
      if (child->devclass != NULL)
        {
          CLASS_DISCONNECTED(child->devclass);
          child->devclass = NULL;
        }

      /* Free any resources used by the hub port */

      usbhost_hport_deactivate(child);
    }

  /* Deactivate the parent hub port (unless it is the root hub port) */

  usbhost_hport_deactivate(hport);

  /* Destroy the semaphores */

  sem_destroy(&priv->exclsem);

  /* Disconnect the USB host device */

  DRVR_DISCONNECT(hport->drvr, hport);

  /* Free the class instance */

  kmm_free(hubclass);
  hport->devclass = NULL;
  irqrestore(flags);
}
Exemple #18
0
void
AirspeedSim::stop()
{
    work_cancel(HPWORK, &_work);
}
Exemple #19
0
void
PX4FLOW::stop()
{
    work_cancel(HPWORK, &_work);
}
Exemple #20
0
void
SF0X::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #21
0
void
SRF02::stop()
{
	work_cancel(HPWORK, &_work);
}
Exemple #22
0
static inline void rwb_wrcanceltimeout(struct rwbuffer_s *rwb)
{
  (void)work_cancel(LPWORK, &rwb->work);
}
Exemple #23
0
void
TEENSYSENSE::stop()
{
	work_cancel(LPWORK, &_work);
}