Commit d23736abe5be73415a3be4700555c61be86e857f

Authored by Jeff Buchbinder
2 parents ed7c25d3 c5a9bd66

Merge pull request #4 from ReallyNiceGuy/master

Make version 1.2 compile and run on linux 3.2
Showing 1 changed file with 18 additions and 1 deletions
module/tty0tty.c
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
38 #include <linux/tty_flip.h> 38 #include <linux/tty_flip.h>
39 #include <linux/serial.h> 39 #include <linux/serial.h>
40 #include <linux/sched.h> 40 #include <linux/sched.h>
  41 +#include <linux/version.h>
41 #include <asm/uaccess.h> 42 #include <asm/uaccess.h>
42 43
43 44
@@ -240,8 +241,13 @@ static int tty0tty_write(struct tty_struct *tty, const unsigned char *buffer, in @@ -240,8 +241,13 @@ static int tty0tty_write(struct tty_struct *tty, const unsigned char *buffer, in
240 241
241 if(ttyx != NULL) 242 if(ttyx != NULL)
242 { 243 {
  244 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
243 tty_insert_flip_string(ttyx->port, buffer, count); 245 tty_insert_flip_string(ttyx->port, buffer, count);
244 tty_flip_buffer_push(ttyx->port); 246 tty_flip_buffer_push(ttyx->port);
  247 +#else
  248 + tty_insert_flip_string(ttyx, buffer, count);
  249 + tty_flip_buffer_push(ttyx);
  250 +#endif
245 retval=count; 251 retval=count;
246 } 252 }
247 253
@@ -280,17 +286,24 @@ exit: @@ -280,17 +286,24 @@ exit:
280 static void tty0tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 286 static void tty0tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
281 { 287 {
282 unsigned int cflag; 288 unsigned int cflag;
  289 + unsigned int iflag;
283 290
284 #ifdef SCULL_DEBUG 291 #ifdef SCULL_DEBUG
285 printk(KERN_DEBUG "%s - \n", __FUNCTION__); 292 printk(KERN_DEBUG "%s - \n", __FUNCTION__);
286 #endif 293 #endif
287 294
  295 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
288 cflag = tty->termios.c_cflag; 296 cflag = tty->termios.c_cflag;
  297 + iflag = tty->termios.c_iflag;
  298 +#else
  299 + cflag = tty->termios->c_cflag;
  300 + iflag = tty->termios->c_iflag;
  301 +#endif
289 302
290 /* check that they really want us to change something */ 303 /* check that they really want us to change something */
291 if (old_termios) { 304 if (old_termios) {
292 if ((cflag == old_termios->c_cflag) && 305 if ((cflag == old_termios->c_cflag) &&
293 - (RELEVANT_IFLAG(tty->termios.c_iflag) == 306 + (RELEVANT_IFLAG(iflag) ==
294 RELEVANT_IFLAG(old_termios->c_iflag))) { 307 RELEVANT_IFLAG(old_termios->c_iflag))) {
295 #ifdef SCULL_DEBUG 308 #ifdef SCULL_DEBUG
296 printk(KERN_DEBUG " - nothing to change...\n"); 309 printk(KERN_DEBUG " - nothing to change...\n");
@@ -643,7 +656,9 @@ static int __init tty0tty_init(void) @@ -643,7 +656,9 @@ static int __init tty0tty_init(void)
643 for(i=0;i<TTY0TTY_MINORS;i++) 656 for(i=0;i<TTY0TTY_MINORS;i++)
644 { 657 {
645 tty_port_init(&tport[i]); 658 tty_port_init(&tport[i]);
  659 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
646 tty_port_link_device(&tport[i],tty0tty_tty_driver, i); 660 tty_port_link_device(&tport[i],tty0tty_tty_driver, i);
  661 +#endif
647 } 662 }
648 663
649 retval = tty_register_driver(tty0tty_tty_driver); 664 retval = tty_register_driver(tty0tty_tty_driver);
@@ -667,7 +682,9 @@ static void __exit tty0tty_exit(void) @@ -667,7 +682,9 @@ static void __exit tty0tty_exit(void)
667 #endif 682 #endif
668 for (i = 0; i < TTY0TTY_MINORS; ++i) 683 for (i = 0; i < TTY0TTY_MINORS; ++i)
669 { 684 {
  685 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
670 tty_port_destroy(&tport[i]); 686 tty_port_destroy(&tport[i]);
  687 +#endif
671 tty_unregister_device(tty0tty_tty_driver, i); 688 tty_unregister_device(tty0tty_tty_driver, i);
672 } 689 }
673 tty_unregister_driver(tty0tty_tty_driver); 690 tty_unregister_driver(tty0tty_tty_driver);