Implemented tty put_char and break_ctl callbacks for kernels newer than 2.6.26
authorFlorian Pose <fp@igh-essen.com>
Fri, 08 Jan 2010 10:34:29 +0100
changeset 1595 8d8657654921
parent 1594 2019bec460ad
child 1611 7c49cd56f96f
Implemented tty put_char and break_ctl callbacks for kernels newer than 2.6.26
or 2.6.27, respectively.
tty/module.c
--- a/tty/module.c	Thu Jan 07 17:26:39 2010 +0100
+++ b/tty/module.c	Fri Jan 08 10:34:29 2010 +0100
@@ -40,6 +40,7 @@
 #include <linux/tty_flip.h>
 #include <linux/termios.h>
 #include <linux/timer.h>
+#include <linux/version.h>
 
 #include "../master/globals.h"
 #include "../include/ectty.h"
@@ -379,7 +380,11 @@
 
 /*****************************************************************************/
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+static int ec_tty_put_char(struct tty_struct *tty, unsigned char ch)
+#else
 static void ec_tty_put_char(struct tty_struct *tty, unsigned char ch)
+#endif
 {
     ec_tty_t *t = (ec_tty_t *) tty->driver_data;
 
@@ -390,8 +395,14 @@
     if (ec_tty_tx_space(t)) {
         t->tx_buffer[t->tx_write_idx] = ch;
         t->tx_write_idx = (t->tx_write_idx + 1) % EC_TTY_TX_BUFFER_SIZE;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+        return 1;
+#endif
     } else {
         printk(KERN_WARNING PFX "%s(): Dropped a byte!\n", __func__);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+        return 0;
+#endif
     }
 }
 
@@ -506,11 +517,19 @@
 
 /*****************************************************************************/
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
+static int ec_tty_break(struct tty_struct *tty, int break_state)
+#else
 static void ec_tty_break(struct tty_struct *tty, int break_state)
+#endif
 {
 #if EC_TTY_DEBUG >= 2
     printk(KERN_INFO PFX "%s(break_state = %i).\n", __func__, break_state);
 #endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
+    return -EIO; // not implemented
+#endif
 }
 
 /*****************************************************************************/