static void ghsuart_ctrl_connect_w(struct work_struct *w)
{
	struct ghsuart_ctrl_port	*port =
			container_of(w, struct ghsuart_ctrl_port, connect_w);
	int			retval;

	if (!port || !test_bit(CH_READY, &port->channel_sts))
		return;

	pr_debug("%s: port:%p\n", __func__, port);

	if (test_bit(CH_OPENED, &port->channel_sts)) {
		retval = wait_for_completion_timeout(
				&port->close_complete, 3 * HZ);
		if (retval == 0) {
			pr_err("%s: smux close timedout\n", __func__);
			return;
		}
	}
	retval = msm_smux_open(port->ch_id, port->ctxt, smux_control_event,
				rx_control_buffer);
	if (retval < 0) {
		pr_err(" %s smux_open failed\n", __func__);
		return;
	}
	set_bit(CH_OPENED, &port->channel_sts);

}
static int smux_open(int id)
{
	int err = 0;
	struct diag_smux_info *ch = NULL;

	if (id < 0 || id >= NUM_SMUX_DEV)
		return -EINVAL;

	ch = &diag_smux[id];
	if (ch->opened) {
		DIAGFWD_DBUG("diag: SMUX channel %d is already connected\n",
			 ch->id);
		return 0;
	}

	err = diag_smux_init_ch(ch);
	if (err) {
		pr_err("diag: Unable to initialize SMUX channel %d, err: %d\n",
		       ch->id, err);
		return err;
	}

	err = msm_smux_open(ch->lcid, (void *)ch->id, diag_smux_event,
			    smux_get_rx_buffer);
	if (err) {
		pr_err("diag: failed to open SMUX ch %d, err: %d\n",
		       ch->id, err);
		return err;
	}
	msm_smux_tiocm_set(ch->lcid, TIOCM_DTR, 0);
	ch->opened = 1;
	pr_info("diag: SMUX ch %d is connected\n", ch->id);
	return 0;
}
static void ghsuart_ctrl_connect_w(struct work_struct *w)
{
	struct ghsuart_ctrl_port	*port =
			container_of(w, struct ghsuart_ctrl_port, connect_w);
	int			retval;

	if (!port || !test_bit(CH_READY, &port->channel_sts))
		return;

	pr_debug("%s: port:%p\n", __func__, port);

	retval = msm_smux_open(port->ch_id, port->ctxt, smux_control_event,
				rx_control_buffer);
	if (retval < 0) {
		pr_err(" %s smux_open failed\n", __func__);
		return;
	}

}
int diagfwd_connect_smux(void)
{
	void *priv = NULL;
	int ret = 0;

	if (driver->lcid == LCID_INVALID) {
		ret = msm_smux_open(LCID_VALID, priv, diag_smux_event,
						 diag_get_rx_buffer);
		if (!ret) {
			driver->lcid = LCID_VALID;
			msm_smux_tiocm_set(driver->lcid, TIOCM_DTR, 0);
			pr_info("diag: open SMUX ch, r = %d\n", ret);
		} else {
			pr_err("diag: failed to open SMUX ch, r = %d\n", ret);
			return ret;
		}
	}
	/* Poll USB channel to check for data*/
	queue_work(diag_bridge[SMUX].wq, &(diag_bridge[SMUX].diag_read_work));
	return ret;
}
Esempio n. 5
0
static int smux_rmnet_probe(struct platform_device *pdev)
{
	int i;
	int r;
	struct rmnet_private *p;

	for (i = 0; i < RMNET_SMUX_DEVICE_COUNT; i++) {
		p = netdev_priv(netdevs[i]);

		if (p != NULL) {
			r =  msm_smux_open(p->ch_id,
					   netdevs[i],
					   rmnet_smux_notify,
					   get_rx_buffers);

			if (r < 0) {
				DBG0("%s: ch=%d open failed with rc %d\n",
				      __func__, p->ch_id, r);
			}
		}
	}
	return 0;
}