Skip to content

Commit b6b3bf9

Browse files
committed
Fix code to build with recent kernels
This driver code does not build since this commit: commit 1143832eca8f1d64da7d85642c956ae9d25c69e1 Author: Greg Kroah-Hartman <[email protected]> Date: Thu Jun 6 10:32:00 2013 -0700 USB: serial: ports: add minor and port number and another set of commits that dropped the use of interruptible_sleep_on since it is racy. Here's one such commit: commit 106fd892bc714a9b7c28daba98a3623a41c32f1a Author: Arnd Bergmann <[email protected]> Date: Wed Feb 26 12:01:44 2014 +0100 swim3: fix interruptible_sleep_on race I have patched the code for these changes and verified that it works correctly on 4.x kernels for my RGUNO, which is an Indian clone of the Arduino UNO with the CH341 chip. My patches (past, present and future) to this code are licensed as GPLv2 (to match the kernel) but I have no idea what the original code is licensed as, since there is no indication in the code or the website.
1 parent 5d382b9 commit b6b3bf9

File tree

2 files changed

+48
-17
lines changed

2 files changed

+48
-17
lines changed

Readme.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
CH341 USB Serial Driver for Linux
2+
=================================
3+
4+
The original code is available for download from:
5+
6+
http://www.wch.cn/download/CH341SER_LINUX_ZIP.html
7+
8+
However, the code does not build since this commit and another commit that
9+
cleaned up wait_interrupt:
10+
11+
commit 1143832eca8f1d64da7d85642c956ae9d25c69e1
12+
Author: Greg Kroah-Hartman <[email protected]>
13+
Date: Thu Jun 6 10:32:00 2013 -0700
14+
15+
USB: serial: ports: add minor and port number
16+
17+
and another set of commits that dropped the use of
18+
interruptible_sleep_on since it is racy. Here's one such commit:
19+
20+
commit 106fd892bc714a9b7c28daba98a3623a41c32f1a
21+
Author: Arnd Bergmann <[email protected]>
22+
Date: Wed Feb 26 12:01:44 2014 +0100
23+
24+
swim3: fix interruptible_sleep_on race
25+
26+
I have patched the code for these changes and verified that it works
27+
correctly on 4.x kernels for my RGUNO, which is an Indian clone of the
28+
Arduino UNO with the CH341 chip. My patches (past, present and
29+
future) to this code are licensed as GPLv2 (to match the kernel) but I
30+
have no idea what the original code is licensed as, since there is no
31+
indication in the code or the website.

ch34x.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static void ch34x_set_termios( struct usb_serial_port *port,
381381
unsigned short value = 0;
382382
unsigned short index = 0;
383383

384-
dbg_ch34x("%s - port:%d", __func__, port->number);
384+
dbg_ch34x("%s - port:%d", __func__, port->port_number);
385385

386386
spin_lock_irqsave( &priv->lock, flags );
387387
if( !priv->termios_initialized ) {
@@ -402,7 +402,7 @@ static void ch34x_set_termios( struct usb_serial_port *port,
402402
return;
403403

404404
cflag = termios->c_cflag;
405-
dbg_ch34x("%s (%d) cflag=0x%x\n", __func__, port->number, cflag );
405+
dbg_ch34x("%s (%d) cflag=0x%x\n", __func__, port->port_number, cflag );
406406

407407
// Get the byte size
408408
switch( cflag & CSIZE )
@@ -509,7 +509,7 @@ static int ch34x_tiocmget( struct usb_serial_port *port,
509509
/*unsigned int msr;*/
510510
unsigned int retval;
511511

512-
dbg_ch34x("%s - port:%d", __func__, port->number);
512+
dbg_ch34x("%s - port:%d", __func__, port->port_number);
513513

514514
if( !usb_get_intfdata( port->serial->interface) )
515515
return -ENODEV;
@@ -552,7 +552,7 @@ static void ch34x_close( struct usb_serial_port *port,
552552
long timeout;
553553
wait_queue_t wait;
554554

555-
dbg_ch34x("%s - port:%d", __func__, port->number);
555+
dbg_ch34x("%s - port:%d", __func__, port->port_number);
556556

557557
// wait for data do drain from the buffer
558558
spin_lock_irqsave( &priv->lock, flags );
@@ -623,7 +623,7 @@ static int ch34x_open( struct usb_serial_port *port,
623623
struct usb_serial *serial = port->serial;
624624
int retval;
625625

626-
dbg_ch34x("%s - port:%d", __func__, port->number );
626+
dbg_ch34x("%s - port:%d", __func__, port->port_number );
627627

628628
usb_clear_halt( serial->dev, port->write_urb->pipe );
629629
usb_clear_halt( serial->dev, port->read_urb->pipe );
@@ -694,7 +694,7 @@ static int ch34x_tiocmset( struct usb_serial_port *port,
694694
/*unsigned int mcr = priv->line_control;*/
695695
u8 control;
696696

697-
dbg_ch34x("%s - port:%d", __func__, port->number);
697+
dbg_ch34x("%s - port:%d", __func__, port->port_number);
698698

699699
if( !usb_get_intfdata(port->serial->interface) )
700700
return -ENODEV;
@@ -723,14 +723,14 @@ static int wait_modem_info( struct usb_serial_port *port,
723723
unsigned int status;
724724
unsigned int changed;
725725

726-
dbg_ch34x("%s -port:%d", __func__, port->number);
726+
dbg_ch34x("%s -port:%d", __func__, port->port_number);
727727

728728
spin_lock_irqsave( &priv->lock, flags );
729729
prevstatus = priv->line_status;
730730
spin_unlock_irqrestore( &priv->lock, flags );
731731

732732
while(1) {
733-
interruptible_sleep_on( &priv->delta_msr_wait );
733+
wait_event_interruptible (priv->delta_msr_wait, 0);
734734
// see if a signal did it
735735
if( signal_pending(current) )
736736
return -ERESTARTSYS;
@@ -770,13 +770,13 @@ static int ch34x_ioctl( struct usb_serial_port *port,
770770
{
771771
//struct usb_serial_port *port = tty->driver_data;
772772
#endif
773-
dbg_ch34x("%s - port:%d, cmd=0x%04x", __func__, port->number, cmd);
773+
dbg_ch34x("%s - port:%d, cmd=0x%04x", __func__, port->port_number, cmd);
774774

775775
switch(cmd)
776776
{
777777
// Note here
778778
case TIOCMIWAIT:
779-
dbg_ch34x("%s - port:%d TIOCMIWAIT", __func__, port->number);
779+
dbg_ch34x("%s - port:%d TIOCMIWAIT", __func__, port->port_number);
780780
return wait_modem_info(port, arg);
781781
default:
782782
dbg_ch34x("%s not supported=0x%04x", __func__, cmd);
@@ -793,7 +793,7 @@ static void ch34x_send( struct usb_serial_port *port )
793793
struct ch34x_private *priv = usb_get_serial_port_data( port );
794794
unsigned long flags;
795795

796-
dbg_ch34x("%s - port:%d", __func__, port->number );
796+
dbg_ch34x("%s - port:%d", __func__, port->port_number );
797797

798798
spin_lock_irqsave( &priv->lock, flags );
799799
if( priv->write_urb_in_use ) {
@@ -843,7 +843,7 @@ static int ch34x_write( struct usb_serial_port *port,
843843
struct ch34x_private *priv = usb_get_serial_port_data(port);
844844
unsigned long flags;
845845

846-
dbg_ch34x("%s - port:%d, %d bytes", __func__, port->number, count);
846+
dbg_ch34x("%s - port:%d, %d bytes", __func__, port->port_number, count);
847847

848848
if( !count )
849849
return count;
@@ -869,7 +869,7 @@ static int ch34x_write_room( struct usb_serial_port *port )
869869
int room = 0;
870870
unsigned long flags;
871871

872-
dbg_ch34x("%s - port:%d", __func__, port->number );
872+
dbg_ch34x("%s - port:%d", __func__, port->port_number );
873873

874874
spin_lock_irqsave( &priv->lock, flags );
875875
room = ch34x_buf_space_avail( priv->buf );
@@ -891,7 +891,7 @@ static int ch34x_chars_in_buffer( struct usb_serial_port *port )
891891
int chars = 0;
892892
unsigned long flags;
893893

894-
dbg_ch34x("%s - port:%d", __func__, port->number );
894+
dbg_ch34x("%s - port:%d", __func__, port->port_number );
895895

896896
spin_lock_irqsave( &priv->lock, flags );
897897
chars = ch34x_buf_data_avail( priv->buf );
@@ -997,7 +997,7 @@ static void ch34x_read_int_callback( struct urb *urb )
997997
int status = urb->status;
998998
int retval;
999999

1000-
dbg_ch34x("%s port:%d", __func__, port->number );
1000+
dbg_ch34x("%s port:%d", __func__, port->port_number );
10011001

10021002
switch( status ) {
10031003
case 0: //success
@@ -1042,7 +1042,7 @@ static void ch34x_read_bulk_callback( struct urb *urb )
10421042
u8 line_status;
10431043
char tty_flag;
10441044

1045-
dbg_ch34x("%s - port:%d", __func__, port->number );
1045+
dbg_ch34x("%s - port:%d", __func__, port->port_number );
10461046
if( status ) {
10471047
dbg_ch34x("%s - urb status=%d", __func__, status );
10481048
if( status == -EPROTO ) {
@@ -1144,7 +1144,7 @@ static void ch34x_write_bulk_callback( struct urb *urb )
11441144
int retval;
11451145
int status = urb->status;
11461146

1147-
dbg_ch34x("%s - port:%d", __func__, port->number );
1147+
dbg_ch34x("%s - port:%d", __func__, port->port_number );
11481148

11491149
switch( status ) {
11501150
case 0: //success

0 commit comments

Comments
 (0)