File uport1130i_14.04.patch of Package moxa

diff -Nur mxu11x0/driver/mxu11x0.c mxu11x0-git/driver/mxu11x0.c
--- mxu11x0/driver/mxu11x0.c	2013-06-10 13:26:04.000000000 +0400
+++ mxu11x0-git/driver/mxu11x0.c	2014-07-30 13:06:29.998836254 +0400
@@ -900,8 +900,11 @@
 			     MXU1_PIPE_TIMEOUT_ENABLE | 
 			     (MXU1_TRANSFER_TIMEOUT << 2));
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
-
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 	if (mxport == NULL)
 		return -ENODEV;
 
@@ -915,12 +918,20 @@
 	if (port->tty)
 		port->tty->low_latency = MXU1_DEFAULT_LOW_LATENCY;
 #else
+
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+	if (port->port.tty)
+        port->port.tty->low_latency = MXU1_DEFAULT_LOW_LATENCY;
+	port_number = port->number - port->serial->minor;
+#else
 	if (port->port.tty)
-		port->port.tty->low_latency = MXU1_DEFAULT_LOW_LATENCY;
+        port->port.low_latency = MXU1_DEFAULT_LOW_LATENCY;
+	port_number = port->port_number - port->minor;
+#endif 
+
 #endif	
 		
 
-	port_number = port->number - port->serial->minor;
 
 	memset(&(mxport->mxp_icount), 0x00, sizeof(mxport->mxp_icount));
 
@@ -1059,8 +1070,12 @@
 	int status = 0;
 	int do_up;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
-			 
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
+
 	mxdev = usb_get_serial_data(port->serial);
 	mxport = usb_get_serial_port_data(port);
 	if (mxdev == NULL || mxport == NULL)
@@ -1080,7 +1095,12 @@
 	
 	mxport->mxp_write_urb_in_use = 0;
 
-	port_number = port->number - port->serial->minor;
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+    port_number = port->number - port->serial->minor;
+#else
+    port_number = port->port_number - port->minor;
+#endif 
+
 
 	dbg("%s - sending MXU1_CLOSE_PORT", __FUNCTION__);
 	status = mxu1_command_out_sync(mxdev, MXU1_CLOSE_PORT,
@@ -1121,7 +1141,12 @@
 {
 	struct mxu1_port *mxport = usb_get_serial_port_data(port);
 
+	
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (count == 0) {
 		dbg("%s - write request of 0 bytes", __FUNCTION__);
@@ -1157,7 +1182,11 @@
 	int room = 0;
 	unsigned long flags;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (mxport == NULL)
 		return -ENODEV;
@@ -1184,7 +1213,11 @@
 	int chars = 0;
 	unsigned long flags;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (mxport == NULL)
 		return -ENODEV;
@@ -1213,7 +1246,12 @@
 #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
 	struct tty_struct *tty;
 #endif
+
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (mxport == NULL)
 		return;
@@ -1248,7 +1286,11 @@
 #endif		
 	int status = 0;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (mxport == NULL)
 		return;
@@ -1279,7 +1321,11 @@
 	struct async_icount cnow = mxport->mxp_icount;
 
 	dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d",
-		__func__, port->number,
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+            __func__, port->number,
+#else
+            __func__, port->port_number,
+#endif 
 		cnow.rx, cnow.tx);
 
 	icount->cts = cnow.cts;
@@ -1317,27 +1363,43 @@
 	struct mxu1_port *mxport = usb_get_serial_port_data(port);
 	struct async_icount cnow;
 	struct async_icount cprev;
-
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d, cmd = 0x%04X", __FUNCTION__, port->number, cmd);
+#else
+	dbg("%s - port %d, cmd = 0x%04X", __FUNCTION__, port->port_number, cmd);
+#endif 
 
 	if (mxport == NULL)
 		return -ENODEV;
 
 	switch (cmd) {
 		case TIOCGSERIAL:
-			dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+            dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->number);
+#else
+            dbg("%s - (%d) TIOCGSERIAL", __FUNCTION__, port->port_number);
+#endif 
 			return mxu1_get_serial_info(mxport, (struct serial_struct __user *)arg);
 
 		case TIOCSSERIAL:
-			dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->number);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+            dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->number);
+#else
+            dbg("%s - (%d) TIOCSSERIAL", __FUNCTION__, port->port_number);
+#endif 
 			return mxu1_set_serial_info(mxport, (struct serial_struct __user *)arg);
 
 		case TIOCMIWAIT:
-			dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->number);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+            dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->number);
+#else
+            dbg("%s - (%d) TIOCMIWAIT", __FUNCTION__, port->port_number);
+#endif 
 			cprev = mxport->mxp_icount;
 			mxport->mxp_msr_wait_flags = 1;
 			while (1) {
-				wait_event_interruptible_timeout(mxport->mxp_msr_wait,(mxport->mxp_msr_wait_flags == 0),MXU1_MSR_WAIT_TIMEOUT);
+				wait_event_interruptible_timeout(mxport->mxp_msr_wait,
+                        (mxport->mxp_msr_wait_flags == 0),MXU1_MSR_WAIT_TIMEOUT);
 				if (signal_pending(current))
 					return -ERESTARTSYS;
 				cnow = mxport->mxp_icount;
@@ -1355,13 +1417,24 @@
 			break;
 
 		case TIOCGICOUNT:
-			dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, port->number, mxport->mxp_icount.rx, mxport->mxp_icount.tx);
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+			dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 
+                    port->number, mxport->mxp_icount.rx, mxport->mxp_icount.tx);
+#else
+			dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 
+                    port->port_number, mxport->mxp_icount.rx, mxport->mxp_icount.tx);
+#endif 
 			if (copy_to_user((void __user *)arg, &mxport->mxp_icount, sizeof(mxport->mxp_icount)))
 				return -EFAULT;
 			return 0;
 
 		case MOXA_SET_INTERFACE:
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 			dbg("%s - port%d MOXA_SET_INTERFACE=%d",__FUNCTION__,port->number,(int)arg);
+#else
+			dbg("%s - port%d MOXA_SET_INTERFACE=%d",__FUNCTION__,
+                    port->port_number,(int)arg);
+#endif 
 			
 			if(mxport->mxp_mxdev->mxd_model_name != MXU1_MODEL_1110){ //UPort 1130, 1150, 1150I
 				switch(arg){
@@ -1423,10 +1496,16 @@
 	tcflag_t cflag,iflag;
 	int baud;
 	int status = 0;
-	int port_number = port->number - port->serial->minor;
-	unsigned int mcr;
+	int port_number = 0; 	unsigned int mcr;
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+    port_number = port->number - port->serial->minor;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+    port_number = port->port_number - port->minor;
+
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 #if(LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
 	if (!tty || !tty->termios) {
@@ -1585,7 +1664,11 @@
 	unsigned int msr;
 	unsigned int mcr;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (mxport == NULL)
 		return -ENODEV;
@@ -1625,7 +1708,11 @@
 	struct mxu1_port *mxport = usb_get_serial_port_data(port);
 	unsigned int mcr;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	if (mxport == NULL)
 		return -ENODEV;
@@ -1862,7 +1949,11 @@
 	struct device *dev = &urb->dev->dev;
 #endif
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	/* Check port is valid or not */
 	if(mxport == NULL)
@@ -1900,15 +1991,20 @@
 	                  unsigned char *data, int length)
 {
 	int cnt;
-	struct tty_struct *tty;
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))		
+    struct tty_struct *tty;
 #if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
 	tty = mxport->mxp_port->tty;
 #else
-
 	tty = mxport->mxp_port->port.tty;
 #endif	
 
-	do{
+#else
+    struct tty_port *tty;
+	tty = &(mxport->mxp_port->port);
+#endif		
+
+    do{
 	    	if (mxport->mxp_read_urb_state == MXU1_READ_URB_STOPPING){
         	    	dbg("%s - [1] dropping data, %d bytes lost\n", __FUNCTION__, length);			    
             		break;
@@ -2031,7 +2127,11 @@
 #endif	
 	unsigned long flags;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	spin_lock_irqsave(&mxport->mxp_lock, flags);
 
@@ -2113,10 +2213,16 @@
 	int size,status;
 	struct mxu1_device *mxdev = mxport->mxp_mxdev;
 	struct usb_serial_port *port = mxport->mxp_port;
-	int port_number = port->number - port->serial->minor;
-	struct mxu1_port_status *data;
+	int port_number = 0;
+    struct mxu1_port_status *data;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+    port_number =  port->number - port->serial->minor;
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+    port_number =  port->port_number - port->minor;
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	size = sizeof(struct mxu1_port_status);
 	data = kmalloc(size, GFP_KERNEL);
@@ -2154,7 +2260,11 @@
 	memset(&ret_serial, 0, sizeof(ret_serial));
 
 	ret_serial.type = PORT_16550A;
-	ret_serial.line = port->serial->minor;
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+    ret_serial.line = port->serial->minor;
+#else
+    ret_serial.line = port->minor;
+#endif 
 	ret_serial.port = mxport->mxp_user_get_uart_mode;
 	ret_serial.flags = mxport->mxp_flags;
 	ret_serial.xmit_fifo_size = MXU1_WRITE_BUF_SIZE;
@@ -2278,7 +2388,11 @@
 	wait_queue_t wait;
 	unsigned long flags;
 
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
 	dbg("%s - port %d", __FUNCTION__, port->number);
+#else
+	dbg("%s - port %d", __FUNCTION__, port->port_number);
+#endif 
 
 	spin_lock_irqsave(&mxport->mxp_lock, flags);