16 #include <asm/uaccess.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/slab.h>
20 #include <linux/module.h>
22 #include <linux/serio.h>
23 #include <linux/tty.h>
30 #define SERPORT_BUSY 1
31 #define SERPORT_ACTIVE 2
32 #define SERPORT_DEAD 3
47 static int serport_serio_write(
struct serio *
serio,
unsigned char data)
50 return -(serport->
tty->ops->write(serport->
tty, &data, 1) != 1);
53 static int serport_serio_open(
struct serio *
serio)
60 spin_unlock_irqrestore(&serport->
lock, flags);
66 static void serport_serio_close(
struct serio *
serio)
74 spin_unlock_irqrestore(&serport->
lock, flags);
91 serport = kzalloc(
sizeof(
struct serport),
GFP_KERNEL);
110 static void serport_ldisc_close(
struct tty_struct *tty)
112 struct serport *serport = (
struct serport *) tty->
disc_data;
123 static void serport_ldisc_receive(
struct tty_struct *tty,
const unsigned char *
cp,
char *
fp,
int count)
125 struct serport *serport = (
struct serport*) tty->
disc_data;
127 unsigned int ch_flags;
154 spin_unlock_irqrestore(&serport->
lock,
flags);
165 struct serport *serport = (
struct serport*) tty->
disc_data;
203 static int serport_ldisc_ioctl(
struct tty_struct * tty,
struct file * file,
unsigned int cmd,
unsigned long arg)
205 struct serport *serport = (
struct serport*) tty->
disc_data;
212 serport->
id.proto =
type & 0x000000ff;
213 serport->
id.id = (
type & 0x0000ff00) >> 8;
214 serport->
id.extra = (
type & 0x00ff0000) >> 16;
222 static void serport_ldisc_write_wakeup(
struct tty_struct * tty)
224 struct serport *serport = (
struct serport *) tty->
disc_data;
229 serio_drv_write_wakeup(serport->
serio);
230 spin_unlock_irqrestore(&serport->
lock,
flags);
240 .open = serport_ldisc_open,
241 .close = serport_ldisc_close,
242 .read = serport_ldisc_read,
243 .ioctl = serport_ldisc_ioctl,
244 .receive_buf = serport_ldisc_receive,
245 .write_wakeup = serport_ldisc_write_wakeup
252 static int __init serport_init(
void)
257 printk(
KERN_ERR "serport.c: Error registering line discipline.\n");
262 static void __exit serport_exit(
void)