19 #include <linux/kernel.h>
20 #include <linux/module.h>
22 #include <linux/ppp_defs.h>
25 #include <linux/sched.h>
26 #include <linux/serial.h>
27 #include <linux/slab.h>
28 #include <linux/tty.h>
38 #define IPWIRELESS_PCMCIA_START (0)
39 #define IPWIRELESS_PCMCIA_MINORS (24)
40 #define IPWIRELESS_PCMCIA_MINOR_RANGE (8)
42 #define TTYTYPE_MODEM (0)
43 #define TTYTYPE_MONITOR (1)
44 #define TTYTYPE_RAS_RAW (2)
64 static char *tty_type_name(
int tty_type)
66 static char *channel_names[] = {
72 return channel_names[tty_type];
89 static int ipw_open(
struct tty_struct *linux_tty,
struct file *filp)
102 if (tty->
port.count == 0)
107 tty->
port.tty = linux_tty;
119 static void do_ipw_close(
struct ipw_tty *tty)
123 if (tty->
port.count == 0) {
126 if (linux_tty !=
NULL) {
136 static void ipw_hangup(
struct tty_struct *linux_tty)
144 if (tty->
port.count == 0) {
154 static void ipw_close(
struct tty_struct *linux_tty,
struct file *filp)
156 ipw_hangup(linux_tty);
167 linux_tty = tty->
port.tty;
168 if (linux_tty ==
NULL) {
173 if (!tty->
port.count) {
179 work = tty_insert_flip_string(linux_tty, data, length);
183 ": %d chars not inserted to flip buffer!\n",
193 static void ipw_write_packet_sent_callback(
void *callback_data,
194 unsigned int packet_length)
196 struct ipw_tty *tty = callback_data;
205 static int ipw_write(
struct tty_struct *linux_tty,
206 const unsigned char *
buf,
int count)
215 if (!tty->
port.count) {
234 ipw_write_packet_sent_callback, tty);
246 static int ipw_write_room(
struct tty_struct *linux_tty)
255 if (!tty->
port.count)
265 static int ipwireless_get_serial_info(
struct ipw_tty *tty,
279 tmp.baud_base = 115200;
281 tmp.closing_wait = 0;
282 tmp.custom_divisor = 0;
290 static int ipw_chars_in_buffer(
struct tty_struct *linux_tty)
297 if (!tty->
port.count)
303 static int get_control_lines(
struct ipw_tty *tty)
306 unsigned int out = 0;
322 static int set_control_lines(
struct ipw_tty *tty,
unsigned int set,
370 static int ipw_tiocmget(
struct tty_struct *linux_tty)
378 if (!tty->
port.count)
381 return get_control_lines(tty);
386 unsigned int set,
unsigned int clear)
394 if (!tty->
port.count)
397 return set_control_lines(tty,
set, clear);
400 static int ipw_ioctl(
struct tty_struct *linux_tty,
401 unsigned int cmd,
unsigned long arg)
408 if (!tty->
port.count)
415 return ipwireless_get_serial_info(tty, (
void __user *) arg);
430 if (
put_user(chan, (
int __user *) arg))
442 if (
put_user(unit, (
int __user *) arg))
451 if (
put_user(val, (
int __user *) arg))
462 static int add_tty(
int j,
482 if (secondary_channel_idx != -1)
484 secondary_channel_idx,
489 ": registering %s device ttyIPWp%d\n",
490 tty_type_name(tty_type), j);
505 if (ttys[j] !=
NULL) {
513 if (add_tty(j, hardware, network,
519 if (add_tty(j, hardware, network,
525 if (add_tty(j, hardware, network,
552 ": deregistering %s device ttyIPWp%d\n",
564 while (ttyj->
port.count)
579 .hangup = ipw_hangup,
581 .write_room = ipw_write_room,
583 .chars_in_buffer = ipw_chars_in_buffer,
584 .tiocmget = ipw_tiocmget,
585 .tiocmset = ipw_tiocmset,
597 ipw_tty_driver->
name =
"ttyIPWp";
598 ipw_tty_driver->
major = 0;
612 ": failed to register tty driver\n");
628 ": tty_unregister_driver failed with code %d\n", ret);
638 unsigned int channel_idx,
639 unsigned int control_lines,
640 unsigned int changed_mask)
645 | (control_lines & changed_mask);