예제 #1
0
static void gctrl_disconnect_w(struct work_struct *w)
{
    struct gctrl_port	*port =
        container_of(w, struct gctrl_port, disconnect_w);

    if (!test_bit(CH_OPENED, &port->bridge_sts))
        return;


    ctrl_bridge_close(port->brdg.ch_id);
    clear_bit(CH_OPENED, &port->bridge_sts);
}
static void ghsic_ctrl_connect_w(struct work_struct *w)
{
	struct gserial		*gser = NULL;
	struct grmnet		*gr = NULL;
	struct gctrl_port	*port =
			container_of(w, struct gctrl_port, connect_w);
	unsigned long		flags;
	int			retval;
	unsigned		cbits;

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

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

	retval = ctrl_bridge_open(&port->brdg);
	if (retval) {
		pr_err("%s: ctrl bridge open failed :%d\n", __func__, retval);
		return;
	}

	spin_lock_irqsave(&port->port_lock, flags);
	if (!port->port_usb) {
		ctrl_bridge_close(port->brdg.ch_id);
		spin_unlock_irqrestore(&port->port_lock, flags);
		return;
	}
	set_bit(CH_OPENED, &port->bridge_sts);

	if (port->cbits_tomodem)
		ctrl_bridge_set_cbits(port->brdg.ch_id, port->cbits_tomodem);

	spin_unlock_irqrestore(&port->port_lock, flags);

	cbits = ctrl_bridge_get_cbits_tohost(port->brdg.ch_id);

	if (port->gtype == USB_GADGET_SERIAL && (cbits & ACM_CTRL_DCD)) {
		gser = port->port_usb;
		if (gser && gser->connect)
			gser->connect(gser);
		return;
	}

	if (port->gtype == USB_GADGET_RMNET) {
		gr = port->port_usb;
		if (gr && gr->connect)
			gr->connect(gr);
	}
}
예제 #3
0
static int ghsic_ctrl_remove(struct platform_device *pdev)
{
    struct gctrl_port	*port;
    struct gserial		*gser = NULL;
    struct grmnet		*gr = NULL;
    unsigned long		flags;
    int			id;

    pr_debug("%s: name:%s\n", __func__, pdev->name);

    id = ghsic_ctrl_get_port_id(pdev->name);
    if (id < 0 || id >= no_ctrl_ports) {
        pr_err("%s: invalid port: %d\n", __func__, id);
        return -EINVAL;
    }

    port = gctrl_ports[id].port;

    spin_lock_irqsave(&port->port_lock, flags);
    if (!port->port_usb) {
        spin_unlock_irqrestore(&port->port_lock, flags);
        goto not_ready;
    }

    if (port->gtype == USB_GADGET_SERIAL)
        gser = port->port_usb;
    else
        gr = port->port_usb;

    port->cbits_tohost = 0;
    spin_unlock_irqrestore(&port->port_lock, flags);

    if (gr && gr->disconnect)
        gr->disconnect(gr);

    if (gser && gser->disconnect)
        gser->disconnect(gser);

    ctrl_bridge_close(port->brdg.ch_id);

    clear_bit(CH_OPENED, &port->bridge_sts);
not_ready:
    clear_bit(CH_READY, &port->bridge_sts);

    return 0;
}