|
@@ -38,7 +38,6 @@
|
|
|
*/
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
-#include <linux/version.h>
|
|
|
#include <linux/sched.h> /* For jiffies, task states */
|
|
|
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
|
|
|
#include <linux/module.h>
|
|
@@ -60,11 +59,9 @@
|
|
|
#include "dpacompat.h"
|
|
|
#include "dgnc_sysfs.h"
|
|
|
|
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
|
|
|
#define init_MUTEX(sem) sema_init(sem, 1)
|
|
|
#define DECLARE_MUTEX(name) \
|
|
|
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
|
|
|
-#endif
|
|
|
|
|
|
/*
|
|
|
* internal variables
|
|
@@ -126,13 +123,8 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty);
|
|
|
static void dgnc_tty_hangup(struct tty_struct *tty);
|
|
|
static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value);
|
|
|
static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value);
|
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
|
|
|
static int dgnc_tty_tiocmget(struct tty_struct *tty);
|
|
|
static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);
|
|
|
-#else
|
|
|
-static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file);
|
|
|
-static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
|
|
|
-#endif
|
|
|
static int dgnc_tty_send_break(struct tty_struct *tty, int msec);
|
|
|
static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout);
|
|
|
static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count);
|
|
@@ -234,21 +226,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
|
|
|
if (!brd->SerialDriver.ttys)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
|
|
|
- brd->SerialDriver.refcount = brd->TtyRefCnt;
|
|
|
-#else
|
|
|
kref_init(&brd->SerialDriver.kref);
|
|
|
-#endif
|
|
|
-
|
|
|
brd->SerialDriver.termios = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
|
|
|
if (!brd->SerialDriver.termios)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
|
|
- brd->SerialDriver.termios_locked = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
|
|
|
- if (!brd->SerialDriver.termios_locked)
|
|
|
- return -ENOMEM;
|
|
|
-#endif
|
|
|
/*
|
|
|
* Entry points for driver. Called by the kernel from
|
|
|
* tty_io.c and n_tty.c.
|
|
@@ -292,23 +274,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
|
|
|
brd->PrintDriver.ttys = kzalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL);
|
|
|
if (!brd->PrintDriver.ttys)
|
|
|
return -ENOMEM;
|
|
|
-
|
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
|
|
|
- brd->PrintDriver.refcount = brd->TtyRefCnt;
|
|
|
-#else
|
|
|
kref_init(&brd->PrintDriver.kref);
|
|
|
-#endif
|
|
|
-
|
|
|
brd->PrintDriver.termios = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
|
|
|
if (!brd->PrintDriver.termios)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
|
|
- brd->PrintDriver.termios_locked = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
|
|
|
- if (!brd->PrintDriver.termios_locked)
|
|
|
- return -ENOMEM;
|
|
|
-#endif
|
|
|
-
|
|
|
/*
|
|
|
* Entry points for driver. Called by the kernel from
|
|
|
* tty_io.c and n_tty.c.
|
|
@@ -1158,7 +1128,6 @@ void dgnc_wakeup_writes(struct channel_t *ch)
|
|
|
}
|
|
|
|
|
|
if (ch->ch_tun.un_flags & UN_ISOPEN) {
|
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
|
|
|
if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
|
|
ch->ch_tun.un_tty->ldisc->ops->write_wakeup)
|
|
|
{
|
|
@@ -1166,15 +1135,6 @@ void dgnc_wakeup_writes(struct channel_t *ch)
|
|
|
(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
|
|
|
DGNC_LOCK(ch->ch_lock, lock_flags);
|
|
|
}
|
|
|
-#else
|
|
|
- if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
|
|
- ch->ch_tun.un_tty->ldisc.ops->write_wakeup)
|
|
|
- {
|
|
|
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
|
|
|
- (ch->ch_tun.un_tty->ldisc.ops->write_wakeup)(ch->ch_tun.un_tty);
|
|
|
- DGNC_LOCK(ch->ch_lock, lock_flags);
|
|
|
- }
|
|
|
-#endif
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
|
|
|
|
|
@@ -1210,7 +1170,6 @@ void dgnc_wakeup_writes(struct channel_t *ch)
|
|
|
}
|
|
|
|
|
|
if (ch->ch_pun.un_flags & UN_ISOPEN) {
|
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
|
|
|
if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
|
|
ch->ch_pun.un_tty->ldisc->ops->write_wakeup)
|
|
|
{
|
|
@@ -1218,15 +1177,6 @@ void dgnc_wakeup_writes(struct channel_t *ch)
|
|
|
(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
|
|
|
DGNC_LOCK(ch->ch_lock, lock_flags);
|
|
|
}
|
|
|
-#else
|
|
|
- if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
|
|
- ch->ch_pun.un_tty->ldisc.ops->write_wakeup)
|
|
|
- {
|
|
|
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
|
|
|
- (ch->ch_pun.un_tty->ldisc.ops->write_wakeup)(ch->ch_pun.un_tty);
|
|
|
- DGNC_LOCK(ch->ch_lock, lock_flags);
|
|
|
- }
|
|
|
-#endif
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
|
|
|
|
|
@@ -2236,11 +2186,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
|
|
|
/*
|
|
|
* Return modem signals to ld.
|
|
|
*/
|
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
|
|
|
+
|
|
|
static int dgnc_tty_tiocmget(struct tty_struct *tty)
|
|
|
-#else
|
|
|
-static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file)
|
|
|
-#endif
|
|
|
{
|
|
|
struct channel_t *ch;
|
|
|
struct un_t *un;
|
|
@@ -2293,13 +2240,9 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file)
|
|
|
*
|
|
|
* Set modem signals, called by ld.
|
|
|
*/
|
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
|
|
|
+
|
|
|
static int dgnc_tty_tiocmset(struct tty_struct *tty,
|
|
|
unsigned int set, unsigned int clear)
|
|
|
-#else
|
|
|
-static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file,
|
|
|
- unsigned int set, unsigned int clear)
|
|
|
-#endif
|
|
|
{
|
|
|
struct dgnc_board *bd;
|
|
|
struct channel_t *ch;
|