/* handleRxChar runs on uart isr */
static int 
handleRxChar(uint8_t c)
{
  if (put_ringbuf(c) == -1) {
    printf("Ringbuf full. Skip char\n");
  } else {
    /* Send event to rx data handler */
    process_poll(&rx_data_process);
  }
  return 0;
}
示例#2
0
文件: spcp8x5.c 项目: maraz/linux-2.6
/* write data to ring buffer. and then start the write transfer */
static int spcp8x5_write(struct usb_serial_port *port,
			 const unsigned char *buf, int count)
{
	struct spcp8x5_private *priv = usb_get_serial_port_data(port);
	unsigned long flags;

	dev_dbg(&port->dev, "%d bytes\n", count);

	if (!count)
		return count;

	spin_lock_irqsave(&priv->lock, flags);
	count = put_ringbuf(priv->buf, buf, count);
	spin_unlock_irqrestore(&priv->lock, flags);

	spcp8x5_send(port);

	return count;
}