コード例 #1
0
ファイル: spcp8x5.c プロジェクト: kizukukoto/WDN900_GPL
/* open the serial port. do some usb system call. set termios and get the line
 * status of the device. then submit the read urb */
static int spcp8x5_open(struct tty_struct *tty,
			struct usb_serial_port *port, struct file *filp)
{
	struct ktermios tmp_termios;
	struct usb_serial *serial = port->serial;
	struct spcp8x5_private *priv = usb_get_serial_port_data(port);
	int ret;
	unsigned long flags;
	u8 status = 0x30;
	/* status 0x30 means DSR and CTS = 1 other CDC RI and delta = 0 */

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

	usb_clear_halt(serial->dev, port->write_urb->pipe);
	usb_clear_halt(serial->dev, port->read_urb->pipe);

	ret = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
			      0x09, 0x00,
			      0x01, 0x00, NULL, 0x00, 100);
	if (ret)
		return ret;

	spin_lock_irqsave(&priv->lock, flags);
	if (tty && (tty->termios->c_cflag & CBAUD))
		priv->line_control = MCR_DTR | MCR_RTS;
	else
		priv->line_control = 0;
	spin_unlock_irqrestore(&priv->lock, flags);

	spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type);

	/* Setup termios */
	if (tty)
		spcp8x5_set_termios(tty, port, &tmp_termios);

	spcp8x5_get_msr(serial->dev, &status, priv->type);

	/* may be we should update uart status here but now we did not do */
	spin_lock_irqsave(&priv->lock, flags);
	priv->line_status = status & 0xf0 ;
	spin_unlock_irqrestore(&priv->lock, flags);

	/* FIXME: need to assert RTS and DTR if CRTSCTS off */

	dbg("%s - submitting read urb", __func__);
	port->read_urb->dev = serial->dev;
	ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
	if (ret) {
		spcp8x5_close(tty, port, NULL);
		return -EPROTO;
	}
	return 0;
}
コード例 #2
0
ファイル: spcp8x5.c プロジェクト: kdave/btrfs-devel
static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
{
	struct usb_serial *serial = port->serial;
	struct spcp8x5_private *priv = usb_get_serial_port_data(port);
	int ret;

	usb_clear_halt(serial->dev, port->write_urb->pipe);
	usb_clear_halt(serial->dev, port->read_urb->pipe);

	ret = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
			      0x09, 0x00,
			      0x01, 0x00, NULL, 0x00, 100);
	if (ret)
		return ret;

	spcp8x5_set_ctrl_line(port, priv->line_control);

	if (tty)
		spcp8x5_set_termios(tty, port, NULL);

	return usb_serial_generic_open(tty, port);
}
コード例 #3
0
ファイル: spcp8x5.c プロジェクト: CoerWatt/linux
/* open the serial port. do some usb system call. set termios and get the line
 * status of the device. */
static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
{
	struct ktermios tmp_termios;
	struct usb_serial *serial = port->serial;
	struct spcp8x5_private *priv = usb_get_serial_port_data(port);
	int ret;
	unsigned long flags;
	u8 status = 0x30;
	/* status 0x30 means DSR and CTS = 1 other CDC RI and delta = 0 */

	usb_clear_halt(serial->dev, port->write_urb->pipe);
	usb_clear_halt(serial->dev, port->read_urb->pipe);

	ret = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
			      0x09, 0x00,
			      0x01, 0x00, NULL, 0x00, 100);
	if (ret)
		return ret;

	spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type);

	/* Setup termios */
	if (tty)
		spcp8x5_set_termios(tty, port, &tmp_termios);

	spcp8x5_get_msr(serial->dev, &status, priv->type);

	/* may be we should update uart status here but now we did not do */
	spin_lock_irqsave(&priv->lock, flags);
	priv->line_status = status & 0xf0 ;
	spin_unlock_irqrestore(&priv->lock, flags);

	port->port.drain_delay = 256;

	return usb_serial_generic_open(tty, port);
}