Пример #1
0
static void hsictty_read_work(struct work_struct *work)
{
	struct hsictty_port_private *portdata =
	    container_of(work, struct hsictty_port_private, hsictty_read_work);

	process_rx_data(portdata);
}
Пример #2
0
static void tpm_rx_handler(uint8_t *data, size_t data_size, int cs_disabled)
{
	if ((sps_tpm_state == SPS_TPM_STATE_RECEIVING_HEADER) ||
	    (sps_tpm_state == SPS_TPM_STATE_RECEIVING_WRITE_DATA))
		process_rx_data(data, data_size);

	if (cs_disabled)
		init_new_cycle();
}
Пример #3
0
static int rx_threadfn(void *x_)
{
	struct hsictty_port_private *portdata = x_;
	long rc = 0;
	struct sched_param param = {.sched_priority = 50 };

	sched_setscheduler(current, SCHED_FIFO, &param);

	while (!kthread_should_stop()) {
		if (portdata->thread_exit) {
			msleep(5);
			continue;
		}
		process_rx_data(portdata);
		rc = wait_for_completion_timeout(&portdata->rx_notifier,
						 5 * HZ);
		INIT_COMPLETION(portdata->rx_notifier);
	}

	return 0;
}
#endif

static void hsictty_read_callback(struct urb *urb)
{
	int endpoint;
	struct _HSICTTY_MSG *msg = NULL;
	int msg_index = -1;
	struct usb_serial_port *port;
	int status = urb->status;
	struct hsictty_port_private *portdata;
	unsigned long flags;
	int err = -1;
	u8 channel = 0;
	struct hsictty_intf_private *intfdata;
	static int error_times = 0;
	int error_times_limits = 50;

	hsictty_dbg("%s: %p\n", __func__, urb);

	endpoint = usb_pipeendpoint(urb->pipe);
	port = urb->context;
	portdata = usb_get_serial_port_data(port);
	intfdata = usb_get_serial_data(port->serial);
	channel = portdata->channel;

	if (status) {
		hsictty_dbg
		    ("%s: nonzero status: %d on channel:%d, endpoint %02x.\n",
		     __func__, status, channel, endpoint);
		if (intfdata->multi_channel_mode) {
			if (((status == -EPROTO) || (status == -EOVERFLOW))
			    && error_times++ < error_times_limits) {
				hsictty_error
				    ("%s: an halted error detected, will try again, status: %d on channel:%d, endpoint %02x.\n",
				     __func__, status, channel, endpoint);
				err = usb_submit_urb(urb, GFP_ATOMIC);
				if (err) {
					if (err != -EPERM) {
						printk(KERN_ERR
						       "%s: resubmit read urb failed in channel:%d.\n"
						       "(%d)", __func__,
						       channel, err);
						/* busy also in error unless we are killed */
						usb_mark_last_busy(port->
								   serial->dev);
					}
				} else {
					usb_mark_last_busy(port->serial->dev);
				}
			} else if (status == -EPROTO) {
				hsictty_error
				    ("%s: unrecorvery halted error detected, please check the hsic connection\n",
				     __func__);
			}
		}
	} else {
		error_times = 0;
		port = urb->context;
		portdata = usb_get_serial_port_data(port);

		if ((msg_index = get_read_msg_index(portdata)) < 0) {
			hsictty_error
			    ("%s: get read msg fail in channel:%d, endpoint:%d.\n",
			     __func__, channel, endpoint);
			err = usb_submit_urb(urb, GFP_ATOMIC);
			if (err) {
				if (err != -EPERM) {
					printk(KERN_ERR
					       "%s: resubmit read urb failed in channel:%d.\n"
					       "(%d)", __func__, channel, err);
					/* busy also in error unless we are killed */
					usb_mark_last_busy(port->serial->dev);
				}
			} else
				usb_mark_last_busy(port->serial->dev);
			return;
		}
		msg = &portdata->read_msg[msg_index];
#ifdef BACKUP_DATA_DUMP
		if (!dumped)
			backup_log(portdata->channel, 0,
					urb->transfer_buffer,
					urb->actual_length);
#endif
		INIT_LIST_HEAD(&msg->link);
		msg->urb = urb;
		wakeup_device(port, 0);
		wake_lock_timeout(&intfdata->rx_wakelock, HZ);
		spin_lock_irqsave(&portdata->pool_lock, flags);
		list_add_tail(&msg->link, &portdata->pool);
		spin_unlock_irqrestore(&portdata->pool_lock, flags);
#ifdef USE_READ_WORK
		queue_work(intfdata->hsictty_read_wq,
			   &(portdata->hsictty_read_work));
#else
		complete_all(&portdata->rx_notifier);
#endif
	}

}