static void acm_process_read_urb(struct acm *acm, struct urb *urb)
{
	struct tty_struct *tty;

	if (!urb->actual_length)
		return;

	tty = tty_port_tty_get(&acm->port);
	if (!tty)
		return;

	tty_insert_flip_string(tty, urb->transfer_buffer, urb->actual_length);
	tty_flip_buffer_push(tty);

	tty_kref_put(tty);
}
/**
 * gigaset_if_receive() - pass a received block of data to the tty device
 * @cs:		device descriptor structure.
 * @buffer:	received data.
 * @len:	number of bytes received.
 *
 * Called by asyncdata/isocdata if a block of data received from the
 * device must be sent to userspace through the ttyG* device.
 */
void gigaset_if_receive(struct cardstate *cs,
			unsigned char *buffer, size_t len)
{
	unsigned long flags;
	struct tty_struct *tty;

	spin_lock_irqsave(&cs->lock, flags);
	tty = cs->tty;
	if (tty == NULL)
		gig_dbg(DEBUG_ANY, "receive on closed device");
	else {
		tty_insert_flip_string(tty, buffer, len);
		tty_flip_buffer_push(tty);
	}
	spin_unlock_irqrestore(&cs->lock, flags);
}
Beispiel #3
0
static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
{
    struct tty_struct *to = tty->link;

    if (tty->stopped)
        return 0;

    if (c > 0) {
        /* Stuff the data into the input queue of the other end */
        c = tty_insert_flip_string(to->port, buf, c);
        /* And shovel */
        if (c)
            tty_flip_buffer_push(to->port);
    }
    return c;
}
Beispiel #4
0
static void kobil_read_int_callback(struct urb *urb)
{
    int result;
    struct usb_serial_port *port = urb->context;
    struct tty_struct *tty;
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;
    /*	char *dbg_data; */

    dbg("%s - port %d", __func__, port->number);

    if (status) {
        dbg("%s - port %d Read int status not zero: %d",
            __func__, port->number, status);
        return;
    }

    tty = tty_port_tty_get(&port->port);
    if (urb->actual_length) {

        /* BEGIN DEBUG */
        /*
          dbg_data = kzalloc((3 *  purb->actual_length + 10)
        				* sizeof(char), GFP_KERNEL);
          if (! dbg_data) {
        	  return;
          }
          for (i = 0; i < purb->actual_length; i++) {
        	  sprintf(dbg_data +3*i, "%02X ", data[i]);
          }
          dbg(" <-- %s", dbg_data);
          kfree(dbg_data);
        */
        /* END DEBUG */

        tty_buffer_request_room(tty, urb->actual_length);
        tty_insert_flip_string(tty, data, urb->actual_length);
        tty_flip_buffer_push(tty);
    }
    tty_kref_put(tty);
    /* someone sets the dev to 0 if the close method has been called */
    port->interrupt_in_urb->dev = port->serial->dev;

    result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
    dbg("%s - port %d Send read URB returns: %i",
        __func__, port->number, result);
}
static int receive_chars_read(struct uart_port *port, struct tty_struct *tty)
{
	int saw_console_brk = 0;
	int limit = 10000;

	while (limit-- > 0) {
		unsigned long ra = __pa(con_read_page);
		unsigned long bytes_read, i;
		long stat = sun4v_con_read(ra, PAGE_SIZE, &bytes_read);

		if (stat != HV_EOK) {
			bytes_read = 0;

			if (stat == CON_BREAK) {
				if (uart_handle_break(port))
					continue;
				saw_console_brk = 1;
				*con_read_page = 0;
				bytes_read = 1;
			} else if (stat == CON_HUP) {
				hung_up = 1;
				uart_handle_dcd_change(port, 0);
				continue;
			} else {
				/* HV_EWOULDBLOCK, etc.  */
				break;
			}
		}

		if (hung_up) {
			hung_up = 0;
			uart_handle_dcd_change(port, 1);
		}

		for (i = 0; i < bytes_read; i++)
			uart_handle_sysrq_char(port, con_read_page[i]);

		if (tty == NULL)
			continue;

		port->icount.rx += bytes_read;

		tty_insert_flip_string(tty, con_read_page, bytes_read);
	}

	return saw_console_brk;
}
Beispiel #6
0
static void serial_omap_rx_timeout(unsigned long uart_no)
{
	struct uart_omap_port *up = ui[uart_no - 1];
	unsigned int curr_dma_pos;
	curr_dma_pos = omap_readl(OMAP34XX_DMA4_BASE +
				  OMAP_DMA4_CDAC(up->uart_dma.rx_dma_channel));
	if ((curr_dma_pos == up->uart_dma.prev_rx_dma_pos) ||
			     (curr_dma_pos == 0)) {
		/*
		 * If there is no transfer rx happening for 10sec
		 * then stop the dma else just restart the timer.
		 * See if 10 sec can be improved.
		 */
		if (jiffies_to_msecs(jiffies - isr8250_activity) < 10000)
			mod_timer(&up->uart_dma.rx_timer, jiffies +
				usecs_to_jiffies(up->uart_dma.rx_timeout));
		else {
			del_timer(&up->uart_dma.rx_timer);
			serial_omap_stop_rxdma(up);
			up->ier |= UART_IER_RDI;
			serial_out(up, UART_IER, up->ier);
		}

		return;
	} else {
		unsigned int curr_transmitted_size = curr_dma_pos -
						up->uart_dma.prev_rx_dma_pos;
		up->port.icount.rx += curr_transmitted_size;
		tty_insert_flip_string(up->port.info->port.tty,
				up->uart_dma.rx_buf +
				(up->uart_dma.prev_rx_dma_pos -
				up->uart_dma.rx_buf_dma_phys),
				curr_transmitted_size);
		tty_flip_buffer_push(up->port.info->port.tty);
		up->uart_dma.prev_rx_dma_pos = curr_dma_pos;
		if (up->uart_dma.rx_buf_size +
				up->uart_dma.rx_buf_dma_phys == curr_dma_pos)
			serial_omap_start_rxdma(up);
		else
		mod_timer(&up->uart_dma.rx_timer, jiffies +
				usecs_to_jiffies(up->uart_dma.rx_timeout));
#ifdef CONFIG_OMAP3_PM
		isr8250_activity = jiffies;
#endif

	}
}
/* Push data to tty layer and resubmit the bulk read URB */
static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
{
	struct urb *urb = port->read_urb;
	struct tty_struct *tty = port->port.tty;
	int room;

	/* Push data to tty */
	if (tty && urb->actual_length) {
		room = tty_buffer_request_room(tty, urb->actual_length);
		if (room) {
			tty_insert_flip_string(tty, urb->transfer_buffer, room);
			tty_flip_buffer_push(tty);
		}
	}

	resubmit_read_urb(port, GFP_ATOMIC);
}
Beispiel #8
0
/*
 * Function starts Read and write operation and transfers received data to TTY core. It pulls down MRDY signal
 * in case of single frame transfer then sets "ifx_read_write_completion" to indicate transfer complete.
 */
static void 
ifx_spi_send_and_receive_data(struct ifx_spi_data *spi_data)
{
	unsigned int rx_valid_buf_size;
	int status = 0; 

	status = ifx_spi_sync_read_write(spi_data, ifx_current_frame_size+IFX_SPI_HEADER_SIZE); /* 4 bytes for header */                         
	if(status > 0){
#if defined(LGE_DUMP_SPI_BUFFER)
    dump_spi_buffer("ifx_spi_send_and_receive_data()[Trans]", &(ifx_tx_buffer[4]), COL_SIZE);
#elif defined(LGE_VT_DATA_DUMP)
    dump_spi_wr_buffer(&(ifx_tx_buffer[4]), ifx_valid_frame_size + 4);
#endif

		memset(ifx_tx_buffer,0,IFX_SPI_MAX_BUF_SIZE+IFX_SPI_HEADER_SIZE);
		ifx_ret_count = ifx_ret_count + ifx_valid_frame_size;
	}

	// hgahn
	if(memcmp(rx_dummy, ifx_rx_buffer, IFX_SPI_HEADER_SIZE) ==0) {

		ifx_receiver_buf_size = 0;
		return;
	}

	/* Handling Received data */
	ifx_receiver_buf_size = ifx_spi_get_header_info(&rx_valid_buf_size);


// hgahn
	if((spi_data->throttle == 0) && (rx_valid_buf_size != 0) && !(spi_data->ifx_spi_lock)){
#ifdef LGE_DUMP_SPI_BUFFER
    dump_spi_buffer("ifx_spi_send_and_receive_data()[Recev]", &(ifx_rx_buffer[4]), COL_SIZE);
#elif defined(LGE_VT_DATA_DUMP)
    //dump_spi_rd_buffer(&(ifx_rx_buffer[4]), rx_valid_buf_size-2); /* MUX에서의 Ctrl & Flag Byte 제거 */
#endif

		tty_insert_flip_string(spi_data->ifx_tty, ifx_rx_buffer+IFX_SPI_HEADER_SIZE, rx_valid_buf_size);
		tty_flip_buffer_push(spi_data->ifx_tty);
	}  
	/*else
  	{ 
	handle RTS and CTS in SPI flow control
	Reject the packet as of now 
	}*/
}
static void safe_read_bulk_callback(struct urb *urb)
{
	struct usb_serial_port *port =  urb->context;
	unsigned char *data = urb->transfer_buffer;
	unsigned char length = urb->actual_length;
	int result;
	int status = urb->status;

	dbg("%s", __func__);

	if (status) {
		dbg("%s - nonzero read bulk status received: %d",
		    __func__, status);
		return;
	}

	dbg("safe_read_bulk_callback length: %d",
					port->read_urb->actual_length);
#ifdef ECHO_RCV
	{
		int i;
		unsigned char *cp = port->read_urb->transfer_buffer;
		for (i = 0; i < port->read_urb->actual_length; i++) {
			if ((i % 32) == 0)
				printk("\nru[%02x] ", i);
			printk("%02x ", *cp++);
		}
		printk("\n");
	}
#endif
	if (safe) {
		__u16 fcs;
		fcs = fcs_compute10(data, length, CRC10_INITFCS);
		if (!fcs) {
			int actual_length = data[length - 2] >> 2;
			if (actual_length <= (length - 2)) {
				info("%s - actual: %d", __func__,
							actual_length);
				tty_insert_flip_string(port->port.tty,
							data, actual_length);
				tty_flip_buffer_push(port->port.tty);
			} else {
				err("%s - inconsistent lengths %d:%d",
					__func__, actual_length, length);
			}
		} else {
static int aircable_process_packet(struct tty_struct *tty,
                                   struct usb_serial_port *port, int has_headers,
                                   char *packet, int len)
{
    if (has_headers) {
        len -= HCI_HEADER_LENGTH;
        packet += HCI_HEADER_LENGTH;
    }
    if (len <= 0) {
        dev_dbg(&port->dev, "%s - malformed packet\n", __func__);
        return 0;
    }

    tty_insert_flip_string(tty, packet, len);

    return len;
}
Beispiel #11
0
static void empeg_read_bulk_callback (struct urb *urb)
{
	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
	struct tty_struct *tty;
	unsigned char *data = urb->transfer_buffer;
	int result;
	int status = urb->status;

	dbg("%s - port %d", __FUNCTION__, port->number);

	if (status) {
		dbg("%s - nonzero read bulk status received: %d",
		    __FUNCTION__, status);
		return;
	}

	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);

	tty = port->tty;

	if (urb->actual_length) {
		tty_buffer_request_room(tty, urb->actual_length);
		tty_insert_flip_string(tty, data, urb->actual_length);
		tty_flip_buffer_push(tty);
		bytes_in += urb->actual_length;
	}

	/* Continue trying to always read  */
	usb_fill_bulk_urb(
		port->read_urb,
		port->serial->dev, 
		usb_rcvbulkpipe(port->serial->dev,
			port->bulk_in_endpointAddress),
		port->read_urb->transfer_buffer,
		port->read_urb->transfer_buffer_length,
		empeg_read_bulk_callback,
		port);

	result = usb_submit_urb(port->read_urb, GFP_ATOMIC);

	if (result)
		dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);

	return;

}
Beispiel #12
0
/*
 * It is expected that the callers take the UART lock when this API is called.
 *
 * There are 2 contexts when this function is called:
 *
 * 1. DMA ISR - DMA ISR triggers the threshold complete calback, which calls the
 * dequue API which in-turn calls this callback. UART lock is taken during
 * the call to the threshold callback.
 *
 * 2. UART ISR - UART calls the dequue API which in-turn will call this API.
 * In this case, UART ISR takes the UART lock.
 */
static void tegra_rx_dma_complete_callback(struct tegra_dma_req *req)
{
	struct tegra_uart_port *t = req->dev;
	struct uart_port *u = &t->uport;
	struct tty_struct *tty = u->state->port.tty;
	int copied;

	/* If we are here, DMA is stopped */

	dev_dbg(t->uport.dev, "%s: %d %d\n", __func__, req->bytes_transferred,
		req->status);
	if (req->bytes_transferred) {
		t->uport.icount.rx += req->bytes_transferred;
		dma_sync_single_for_cpu(t->uport.dev, req->dest_addr,
				req->size, DMA_FROM_DEVICE);
		copied = tty_insert_flip_string(tty,
			((unsigned char *)(req->virt_addr)),
			req->bytes_transferred);
		if (copied != req->bytes_transferred) {
			WARN_ON(1);
			dev_err(t->uport.dev, "Not able to copy uart data "
				"to tty layer Req %d and coped %d\n",
				req->bytes_transferred, copied);
		}
		dma_sync_single_for_device(t->uport.dev, req->dest_addr,
				req->size, DMA_TO_DEVICE);
	}

	do_handle_rx_pio(t);

	/* Push the read data later in caller place. */
	if (req->status == -TEGRA_DMA_REQ_ERROR_ABORTED)
		return;

	printk(KERN_ERR "%s: tegra_uart_%d: DMA_REQ: buf_stat(%d),stat(%d)\n",
		__func__, req->instance, req->buffer_status, req->status);

	/* Not out of sync err from dma_isr/dbl_dma */
	if (req->status != -TEGRA_DMA_REQ_ERROR_STOPPED)
		spin_unlock(&u->lock);
	tty_flip_buffer_push(u->state->port.tty);
	/* Not out of sync err from dma_isr/dbl_dma */
	if (req->status != -TEGRA_DMA_REQ_ERROR_STOPPED)
		spin_lock(&u->lock);
}
static void serial_omap_rxdma_poll(unsigned long uart_no)
{
	struct uart_omap_port *up = ui[uart_no];
	unsigned int curr_dma_pos, curr_transmitted_size;
	int ret = 0;

	curr_dma_pos = omap_get_dma_dst_pos(up->uart_dma.rx_dma_channel);
	if ((curr_dma_pos == up->uart_dma.prev_rx_dma_pos) ||
			     (curr_dma_pos == 0)) {
		if (jiffies_to_msecs(jiffies - up->port_activity) <
						up->uart_dma.rx_timeout) {
			mod_timer(&up->uart_dma.rx_timer, jiffies +
				usecs_to_jiffies(up->uart_dma.rx_poll_rate));
		} else {
			serial_omap_stop_rxdma(up);
			up->ier |= (UART_IER_RDI | UART_IER_RLSI);
			serial_out(up, UART_IER, up->ier);
		}
		return;
	}

	curr_transmitted_size = curr_dma_pos -
					up->uart_dma.prev_rx_dma_pos;
	up->port.icount.rx += curr_transmitted_size;
	tty_insert_flip_string(up->port.state->port.tty,
			up->uart_dma.rx_buf +
			(up->uart_dma.prev_rx_dma_pos -
			up->uart_dma.rx_buf_dma_phys),
			curr_transmitted_size);
	tty_flip_buffer_push(up->port.state->port.tty);
	up->uart_dma.prev_rx_dma_pos = curr_dma_pos;
	if (up->uart_dma.rx_buf_size +
			up->uart_dma.rx_buf_dma_phys == curr_dma_pos) {
		ret = serial_omap_start_rxdma(up);
		if (ret < 0) {
			serial_omap_stop_rxdma(up);
			up->ier |= (UART_IER_RDI | UART_IER_RLSI);
			serial_out(up, UART_IER, up->ier);
		}
	} else  {
		mod_timer(&up->uart_dma.rx_timer, jiffies +
			usecs_to_jiffies(up->uart_dma.rx_poll_rate));
	}
	up->port_activity = jiffies;
}
static void pxa_uart_receive_dma_cb(void *data)
{
	unsigned long flags;
	struct uart_pxa_port *up = (struct uart_pxa_port *)data;
	struct uart_pxa_dma *pxa_dma = &up->uart_dma;
	struct tty_port *port = &up->port.state->port;
	unsigned int count;
	unsigned char *tmp = pxa_dma->rxdma_addr;
	struct dma_tx_state dma_state;

	if (!mod_timer(&up->pxa_timer, jiffies + PXA_TIMER_TIMEOUT))
		pm_qos_update_request(&up->qos_idle[PXA_UART_RX],
				      up->lpm_qos);

	dmaengine_tx_status(pxa_dma->rxdma_chan, pxa_dma->rx_cookie,
			    &dma_state);
	count = DMA_BLOCK - dma_state.residue;
	if (up->port.sysrq) {
		while (count > 0) {
			if (!uart_handle_sysrq_char(&up->port, *tmp)) {
				tty_insert_flip_char(port, *tmp, TTY_NORMAL);
				up->port.icount.rx++;
			}
			tmp++;
			count--;
		}
	} else {
		tty_insert_flip_string(port, tmp, count);
		up->port.icount.rx += count;
	}
	tty_flip_buffer_push(port);

	spin_lock_irqsave(&up->port.lock, flags);
	/*
	 * DMA_RUNNING flag should be clear only after
	 * all dma interface operation completed
	 */
	pxa_dma->dma_status &= ~RX_DMA_RUNNING;
	spin_unlock_irqrestore(&up->port.lock, flags);

	if (pxa_dma->rx_stop)
		return;
	pxa_uart_receive_dma_start(up);
	return;
}
Beispiel #15
0
static void __dma_rx_complete(void *param)
{
	struct uart_8250_port	*p = param;
	struct uart_8250_dma	*dma = p->dma;
	struct tty_struct	*tty = p->port.state->port.tty;
	struct dma_tx_state	state;

	dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
				dma->rx_size, DMA_FROM_DEVICE);

	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
	dmaengine_terminate_all(dma->rxchan);

	tty_insert_flip_string(tty, dma->rx_buf, dma->rx_size - state.residue);
	p->port.icount.rx += dma->rx_size - state.residue;

	tty_flip_buffer_push(tty);
}
Beispiel #16
0
/* Puts received data to circular buffer */
static void put_data_to_circ_buf(struct max3107_port *s, unsigned char *data,
					int len)
{
	struct uart_port *port = &s->port;
	struct tty_struct *tty;

	if (!port->state)
		return;

	tty = port->state->port.tty;
	if (!tty)
		return;

	/* Insert received data */
	tty_insert_flip_string(tty, data, len);
	/* Update RX counter */
	port->icount.rx += len;
}
Beispiel #17
0
static void __dma_rx_complete(void *param)
{
	struct uart_8250_port	*p = param;
	struct uart_8250_dma	*dma = p->dma;
	struct tty_port		*tty_port = &p->port.state->port;
	struct dma_tx_state	state;
	int			count;

	dma->rx_running = 0;
	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);

	count = dma->rx_size - state.residue;

	tty_insert_flip_string(tty_port, dma->rx_buf, count);
	p->port.icount.rx += count;

	tty_flip_buffer_push(tty_port);
}
Beispiel #18
0
static void kobil_read_int_callback( struct urb *purb, struct pt_regs *regs)
{
	int result;
	struct usb_serial_port *port = (struct usb_serial_port *) purb->context;
	struct tty_struct *tty;
	unsigned char *data = purb->transfer_buffer;
//	char *dbg_data;

	dbg("%s - port %d", __FUNCTION__, port->number);

	if (purb->status) {
		dbg("%s - port %d Read int status not zero: %d", __FUNCTION__, port->number, purb->status);
		return;
	}
	
	tty = port->tty; 
	if (purb->actual_length) {
		
		// BEGIN DEBUG
		/*
		  dbg_data = (unsigned char *) kmalloc((3 *  purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
		  if (! dbg_data) {
		  return;
		  }
		  memset(dbg_data, 0, (3 *  purb->actual_length + 10));
		  for (i = 0; i < purb->actual_length; i++) { 
		  sprintf(dbg_data +3*i, "%02X ", data[i]); 
		  }
		  dbg(" <-- %s", dbg_data );
		  kfree(dbg_data);
		*/
		// END DEBUG

		tty_buffer_request_room(tty, purb->actual_length);
		tty_insert_flip_string(tty, data, purb->actual_length);
		tty_flip_buffer_push(tty);
	}

	// someone sets the dev to 0 if the close method has been called
	port->interrupt_in_urb->dev = port->serial->dev;

	result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); 
	dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result);
}
Beispiel #19
0
static void cyberjack_read_bulk_callback(struct urb *urb)
{
	struct usb_serial_port *port = urb->context;
	struct cyberjack_private *priv = usb_get_serial_port_data(port);
	struct device *dev = &port->dev;
	unsigned char *data = urb->transfer_buffer;
	short todo;
	int result;
	int status = urb->status;

	usb_serial_debug_data(dev, __func__, urb->actual_length, data);
	if (status) {
		dev_dbg(dev, "%s - nonzero read bulk status received: %d\n",
			__func__, status);
		return;
	}

	if (urb->actual_length) {
		tty_insert_flip_string(&port->port, data, urb->actual_length);
		tty_flip_buffer_push(&port->port);
	}

	spin_lock(&priv->lock);

	/* Reduce urbs to do by one. */
	priv->rdtodo -= urb->actual_length;
	/* Just to be sure */
	if (priv->rdtodo < 0)
		priv->rdtodo = 0;
	todo = priv->rdtodo;

	spin_unlock(&priv->lock);

	dev_dbg(dev, "%s - rdtodo: %d\n", __func__, todo);

	/* Continue to read if we have still urbs to do. */
	if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) {
		result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
		if (result)
			dev_err(dev, "%s - failed resubmitting read urb, error %d\n",
				__func__, result);
		dev_dbg(dev, "%s - usb_submit_urb(read urb)\n", __func__);
	}
}
Beispiel #20
0
static void usa28_indat_callback(struct urb *urb)
{
	int                     err;
	struct usb_serial_port  *port;
	struct tty_struct       *tty;
	unsigned char           *data;
	struct keyspan_port_private             *p_priv;
	int status = urb->status;

	port =  urb->context;
	p_priv = usb_get_serial_port_data(port);
	data = urb->transfer_buffer;

	if (urb != p_priv->in_urbs[p_priv->in_flip])
		return;

	do {
		if (status) {
			dbg("%s - nonzero status: %x on endpoint %d.",
			    __func__, status, usb_pipeendpoint(urb->pipe));
			return;
		}

		port =  urb->context;
		p_priv = usb_get_serial_port_data(port);
		data = urb->transfer_buffer;

		tty =tty_port_tty_get(&port->port);
		if (tty && urb->actual_length) {
			tty_insert_flip_string(tty, data, urb->actual_length);
			tty_flip_buffer_push(tty);
		}
		tty_kref_put(tty);

		/* Resubmit urb so we continue receiving */
		err = usb_submit_urb(urb, GFP_ATOMIC);
		if (err != 0)
			dbg("%s - resubmit read urb failed. (%d)",
							__func__, err);
		p_priv->in_flip ^= 1;

		urb = p_priv->in_urbs[p_priv->in_flip];
	} while (urb->status != -EINPROGRESS);
}
static void kobil_read_int_callback(struct urb *urb)
{
	int result;
	struct usb_serial_port *port = urb->context;
	struct tty_struct *tty;
	unsigned char *data = urb->transfer_buffer;
	int status = urb->status;
/*                 */

	dbg("%s - port %d", __func__, port->number);

	if (status) {
		dbg("%s - port %d Read int status not zero: %d",
		    __func__, port->number, status);
		return;
	}

	tty = tty_port_tty_get(&port->port);
	if (tty && urb->actual_length) {

		/*             */
		/*
                                                      
                                  
                     
            
     
                                               
                                              
     
                             
                    
  */
		/*           */

		tty_insert_flip_string(tty, data, urb->actual_length);
		tty_flip_buffer_push(tty);
	}
	tty_kref_put(tty);

	result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
	dbg("%s - port %d Send read URB returns: %i",
			__func__, port->number, result);
}
Beispiel #22
0
static void navman_read_int_callback(struct urb *urb)
{
	struct usb_serial_port *port = urb->context;
	unsigned char *data = urb->transfer_buffer;
	struct tty_struct *tty;
	int status = urb->status;
	int result;

	switch (status) {
	case 0:
		/* success */
		break;
	case -ECONNRESET:
	case -ENOENT:
	case -ESHUTDOWN:
		/* this urb is terminated, clean up */
		dbg("%s - urb shutting down with status: %d",
		    __func__, status);
		return;
	default:
		dbg("%s - nonzero urb status received: %d",
		    __func__, status);
		goto exit;
	}

	usb_serial_debug_data(debug, &port->dev, __func__,
			      urb->actual_length, data);

	tty = tty_port_tty_get(&port->port);
	if (tty && urb->actual_length) {
		tty_buffer_request_room(tty, urb->actual_length);
		tty_insert_flip_string(tty, data, urb->actual_length);
		tty_flip_buffer_push(tty);
	}
	tty_kref_put(tty);

exit:
	result = usb_submit_urb(urb, GFP_ATOMIC);
	if (result)
		dev_err(&urb->dev->dev,
			"%s - Error %d submitting interrupt urb\n",
			__func__, result);
}
Beispiel #23
0
static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
{
	struct tty_struct *to = tty->link;

	if (tty->stopped || tty->peer_stops) {
		return 0;
	}

	if (c > 0) {
		/* Stuff the data into the input queue of the other end */
		c = tty_insert_flip_string(to, buf, c);
		/* And shovel */
		if (c) {
			tty_flip_buffer_push(to);
			tty_wakeup(tty);
		}
	}
	return c;
}
static int tty_push(struct tty_struct *tty, u8 *buf, int len)
{
	int sent = 0;
	FUNC_ENTER();
	while (sent < len) {
		int count = tty_insert_flip_string(
			tty, buf + sent, len - sent);
		if (count != (len - sent)) {
			mux_print(MSG_WARNING,
				"written size %d is not wanted %d\n",
				count, len - sent);
		}
		sent += count;
		/* tty_flip_buffer_push(tty); */
	}
	tty_flip_buffer_push(tty);
	FUNC_EXIT();
	return sent;
}
Beispiel #25
0
Datei: pty.c Projekt: Lyude/linux
static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
{
	struct tty_struct *to = tty->link;
	unsigned long flags;

	if (tty->stopped)
		return 0;

	if (c > 0) {
		spin_lock_irqsave(&to->port->lock, flags);
		/* Stuff the data into the input queue of the other end */
		c = tty_insert_flip_string(to->port, buf, c);
		/* And shovel */
		if (c)
			tty_flip_buffer_push(to->port);
		spin_unlock_irqrestore(&to->port->lock, flags);
	}
	return c;
}
static void omninet_read_bulk_callback(struct urb *urb)
{
	struct usb_serial_port 	*port 	= urb->context;
	unsigned char 		*data 	= urb->transfer_buffer;
	struct omninet_header 	*header = (struct omninet_header *) &data[0];
	int status = urb->status;
	int result;
	int i;

	dbg("%s - port %d", __func__, port->number);

	if (status) {
		dbg("%s - nonzero read bulk status received: %d",
		    __func__, status);
		return;
	}

	if (debug && header->oh_xxx != 0x30) {
		if (urb->actual_length) {
			printk(KERN_DEBUG "%s: omninet_read %d: ",
			       __FILE__, header->oh_len);
			for (i = 0; i < (header->oh_len +
						OMNINET_HEADERLEN); i++)
				printk("%.2x ", data[i]);
			printk("\n");
		}
	}

	if (urb->actual_length && header->oh_len) {
		struct tty_struct *tty = tty_port_tty_get(&port->port);
		tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET,
							header->oh_len);
		tty_flip_buffer_push(tty);
		tty_kref_put(tty);
	}

	/* Continue trying to always read  */
	result = usb_submit_urb(urb, GFP_ATOMIC);
	if (result)
		dev_err(&port->dev,
			"%s - failed resubmitting read urb, error %d\n",
			__func__, result);
}
int mts_stop_ready_complete(void)
{
	int num_push = 0, total_push = 0;
	int left = strlen(stop_push);
	struct mts_tty *mts_tty_drv = mts_tty;

	if (mts_tty_drv == NULL)  {
		return -1;
	}

	//num_push = tty_insert_flip_string(mts_tty_drv->tty_struct,
	num_push = tty_insert_flip_string(mts_tty_drv->mts_tty_port,
			stop_push + total_push, left);
	total_push += num_push;
	left -= num_push;
	//tty_flip_buffer_push(mts_tty_drv->tty_struct);
	tty_flip_buffer_push(mts_tty_drv->mts_tty_port);
	printk("%s\n", __func__);
	return 0;
}
Beispiel #28
0
static void spi_tty_handle_data(void *context, u8 *buf, u32 count)
{
	int cnt, crc, len;
	struct spi_tty_s *spi_tty;
	spi_msg_header header;

	SPI_IPC_INFO("%s, context=%p, buf=%p, count=%d\n", __func__, context, buf, count);

	if (!context || !buf || !count) {
		pr_err("%s - Invalid param!\n", __func__);
		return;
	}

	spi_ipc_buf_dump("rx header: ", buf, SPI_MSG_HEADER_LEN);

	spi_tty = (struct spi_tty_s *) context;
	spi_msg_get_header(buf, &header);
	crc = spi_msg_cal_crc(&header);

	// validate data
	if (header.type != 1 || header.len > SPI_MTU || header.fcs != crc) {
		pr_err("Invalid data receicved!\n");
		return;
	}

	if (spi_tty->open_count > 0 && header.len > 0) {
		len = header.len;
		spi_ipc_buf_dump_ascii("rx data: ", buf+SPI_MSG_HEADER_LEN, (len>16?16:len));
		SPI_IPC_INFO("insert data to tty\n");
		buf += SPI_MSG_HEADER_LEN;
		do {
			cnt = tty_buffer_request_room(spi_tty->tty, len);
			if (cnt == 0)
				break;
			cnt = tty_insert_flip_string(spi_tty->tty, buf, cnt);
			tty_flip_buffer_push(spi_tty->tty);
			len -= cnt;
			buf += cnt;
		}while(len > 0);
	}
}
static int
receive_chars(struct uart_max3110 *max, unsigned short *str, int len)
{
	struct uart_port *port = &max->port;
	struct tty_port *tport;
	char buf[M3110_RX_FIFO_DEPTH];
	int r, w, usable;

	/* If uart is not opened, just return */
	if (!port->state)
		return 0;

	tport = &port->state->port;

	for (r = 0, w = 0; r < len; r++) {
		if (str[r] & MAX3110_BREAK &&
		    uart_handle_break(port))
			continue;

		if (str[r] & MAX3110_READ_DATA_AVAILABLE) {
			if (uart_handle_sysrq_char(port, str[r] & 0xff))
				continue;

			buf[w++] = str[r] & 0xff;
		}
	}

	if (!w)
		return 0;

	for (r = 0; w; r += usable, w -= usable) {
		usable = tty_buffer_request_room(tport, w);
		if (usable) {
			tty_insert_flip_string(tport, buf + r, usable);
			port->icount.rx += usable;
		}
	}
	tty_flip_buffer_push(tport);

	return r;
}
Beispiel #30
0
static int tty0tty_write(struct tty_struct *tty, const unsigned char *buffer, int count)
{
	struct tty0tty_serial *tty0tty = tty->driver_data;
	int retval = -EINVAL;
	struct tty_struct  *ttyx = NULL;	

        if (!tty0tty)
		return -ENODEV;

	down(&tty0tty->sem);

	if (!tty0tty->open_count)
		/* port was not opened */
		goto exit;

        if( (tty0tty->tty->index % 2) == 0)
        { 
         if(tty0tty_table[tty0tty->tty->index+1] != NULL) 
	   if (tty0tty_table[tty0tty->tty->index+1]->open_count > 0)
             ttyx=tty0tty_table[tty0tty->tty->index+1]->tty;
        }
        else
        {
         if(tty0tty_table[tty0tty->tty->index-1] != NULL) 
	   if (tty0tty_table[tty0tty->tty->index-1]->open_count > 0)
             ttyx=tty0tty_table[tty0tty->tty->index-1]->tty;
        } 

//        tty->low_latency=1;

        if(ttyx != NULL)
        {
          tty_insert_flip_string(ttyx, buffer, count);
          tty_flip_buffer_push(ttyx);
	  retval=count;
        } 
		
exit:
	up(&tty0tty->sem);
	return retval;
}