Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 8 Nov 2010 18:55:29 +0000 (10:55 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 8 Nov 2010 18:55:29 +0000 (10:55 -0800)
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6:
  TTY: move .gitignore from drivers/char/ to drivers/tty/vt/
  TTY: create drivers/tty/vt and move the vt code there
  TTY: create drivers/tty and move the tty core files there

50 files changed:
drivers/Makefile
drivers/char/.gitignore [deleted file]
drivers/char/Makefile
drivers/char/consolemap.c [deleted file]
drivers/char/cp437.uni [deleted file]
drivers/char/defkeymap.c_shipped [deleted file]
drivers/char/defkeymap.map [deleted file]
drivers/char/keyboard.c [deleted file]
drivers/char/n_gsm.c [deleted file]
drivers/char/n_hdlc.c [deleted file]
drivers/char/n_r3964.c [deleted file]
drivers/char/n_tty.c [deleted file]
drivers/char/pty.c [deleted file]
drivers/char/selection.c [deleted file]
drivers/char/sysrq.c [deleted file]
drivers/char/tty_audit.c [deleted file]
drivers/char/tty_buffer.c [deleted file]
drivers/char/tty_io.c [deleted file]
drivers/char/tty_ioctl.c [deleted file]
drivers/char/tty_ldisc.c [deleted file]
drivers/char/tty_mutex.c [deleted file]
drivers/char/tty_port.c [deleted file]
drivers/char/vc_screen.c [deleted file]
drivers/char/vt.c [deleted file]
drivers/char/vt_ioctl.c [deleted file]
drivers/tty/Makefile [new file with mode: 0644]
drivers/tty/n_gsm.c [new file with mode: 0644]
drivers/tty/n_hdlc.c [new file with mode: 0644]
drivers/tty/n_r3964.c [new file with mode: 0644]
drivers/tty/n_tty.c [new file with mode: 0644]
drivers/tty/pty.c [new file with mode: 0644]
drivers/tty/sysrq.c [new file with mode: 0644]
drivers/tty/tty_audit.c [new file with mode: 0644]
drivers/tty/tty_buffer.c [new file with mode: 0644]
drivers/tty/tty_io.c [new file with mode: 0644]
drivers/tty/tty_ioctl.c [new file with mode: 0644]
drivers/tty/tty_ldisc.c [new file with mode: 0644]
drivers/tty/tty_mutex.c [new file with mode: 0644]
drivers/tty/tty_port.c [new file with mode: 0644]
drivers/tty/vt/.gitignore [new file with mode: 0644]
drivers/tty/vt/Makefile [new file with mode: 0644]
drivers/tty/vt/consolemap.c [new file with mode: 0644]
drivers/tty/vt/cp437.uni [new file with mode: 0644]
drivers/tty/vt/defkeymap.c_shipped [new file with mode: 0644]
drivers/tty/vt/defkeymap.map [new file with mode: 0644]
drivers/tty/vt/keyboard.c [new file with mode: 0644]
drivers/tty/vt/selection.c [new file with mode: 0644]
drivers/tty/vt/vc_screen.c [new file with mode: 0644]
drivers/tty/vt/vt.c [new file with mode: 0644]
drivers/tty/vt/vt_ioctl.c [new file with mode: 0644]

index 14cf9077bb2bcf4f01025518b11b0e87e072e9b5..f3ebb30f1b7fd9c7ed93d6328dbe4d8c54b1fd87 100644 (file)
@@ -26,6 +26,7 @@ obj-$(CONFIG_REGULATOR)               += regulator/
 
 # char/ comes before serial/ etc so that the VT console is the boot-time
 # default.
+obj-y                          += tty/
 obj-y                          += char/
 
 # gpu/ comes after char for AGP vs DRM startup
diff --git a/drivers/char/.gitignore b/drivers/char/.gitignore
deleted file mode 100644 (file)
index 83683a2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-consolemap_deftbl.c
-defkeymap.c
index 3a9c01416839ebc785abcdec1405135fce3df817..ba53ec956c95627ff03695a3bbb363f9f5f2f400 100644 (file)
@@ -2,24 +2,10 @@
 # Makefile for the kernel character device drivers.
 #
 
-#
-# This file contains the font map for the default (hardware) font
-#
-FONTMAPFILE = cp437.uni
-
-obj-y   += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o tty_port.o
-
-obj-y                          += tty_mutex.o
-obj-$(CONFIG_LEGACY_PTYS)      += pty.o
-obj-$(CONFIG_UNIX98_PTYS)      += pty.o
+obj-y                          += mem.o random.o
 obj-$(CONFIG_TTY_PRINTK)       += ttyprintk.o
 obj-y                          += misc.o
-obj-$(CONFIG_VT)               += vt_ioctl.o vc_screen.o selection.o keyboard.o
 obj-$(CONFIG_BFIN_JTAG_COMM)   += bfin_jtag_comm.o
-obj-$(CONFIG_CONSOLE_TRANSLATIONS) += consolemap.o consolemap_deftbl.o
-obj-$(CONFIG_HW_CONSOLE)       += vt.o defkeymap.o
-obj-$(CONFIG_AUDIT)            += tty_audit.o
-obj-$(CONFIG_MAGIC_SYSRQ)      += sysrq.o
 obj-$(CONFIG_MVME147_SCC)      += generic_serial.o vme_scc.o
 obj-$(CONFIG_MVME162_SCC)      += generic_serial.o vme_scc.o
 obj-$(CONFIG_BVME6000_SCC)     += generic_serial.o vme_scc.o
@@ -41,8 +27,6 @@ obj-$(CONFIG_ISI)             += isicom.o
 obj-$(CONFIG_SYNCLINK)         += synclink.o
 obj-$(CONFIG_SYNCLINKMP)       += synclinkmp.o
 obj-$(CONFIG_SYNCLINK_GT)      += synclink_gt.o
-obj-$(CONFIG_N_HDLC)           += n_hdlc.o
-obj-$(CONFIG_N_GSM)            += n_gsm.o
 obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
 obj-$(CONFIG_SX)               += sx.o generic_serial.o
 obj-$(CONFIG_RIO)              += rio/ generic_serial.o
@@ -74,7 +58,6 @@ obj-$(CONFIG_PRINTER)         += lp.o
 obj-$(CONFIG_APM_EMULATION)    += apm-emulation.o
 
 obj-$(CONFIG_DTLK)             += dtlk.o
-obj-$(CONFIG_R3964)            += n_r3964.o
 obj-$(CONFIG_APPLICOM)         += applicom.o
 obj-$(CONFIG_SONYPI)           += sonypi.o
 obj-$(CONFIG_RTC)              += rtc.o
@@ -115,28 +98,3 @@ obj-$(CONFIG_RAMOOPS)               += ramoops.o
 
 obj-$(CONFIG_JS_RTC)           += js-rtc.o
 js-rtc-y = rtc.o
-
-# Files generated that shall be removed upon make clean
-clean-files := consolemap_deftbl.c defkeymap.c
-
-quiet_cmd_conmk = CONMK   $@
-      cmd_conmk = scripts/conmakehash $< > $@
-
-$(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE)
-       $(call cmd,conmk)
-
-$(obj)/defkeymap.o:  $(obj)/defkeymap.c
-
-# Uncomment if you're changing the keymap and have an appropriate
-# loadkeys version for the map. By default, we'll use the shipped
-# versions.
-# GENERATE_KEYMAP := 1
-
-ifdef GENERATE_KEYMAP
-
-$(obj)/defkeymap.c: $(obj)/%.c: $(src)/%.map
-       loadkeys --mktable $< > $@.tmp
-       sed -e 's/^static *//' $@.tmp > $@
-       rm $@.tmp
-
-endif
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c
deleted file mode 100644 (file)
index 45d3e80..0000000
+++ /dev/null
@@ -1,745 +0,0 @@
-/*
- * consolemap.c
- *
- * Mapping from internal code (such as Latin-1 or Unicode or IBM PC code)
- * to font positions.
- *
- * aeb, 950210
- *
- * Support for multiple unimaps by Jakub Jelinek <jj@ultra.linux.cz>, July 1998
- *
- * Fix bug in inverse translation. Stanislav Voronyi <stas@cnti.uanet.kharkov.ua>, Dec 1998
- */
-
-#include <linux/module.h>
-#include <linux/kd.h>
-#include <linux/errno.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/tty.h>
-#include <asm/uaccess.h>
-#include <linux/consolemap.h>
-#include <linux/vt_kern.h>
-
-static unsigned short translations[][256] = {
-  /* 8-bit Latin-1 mapped to Unicode -- trivial mapping */
-  {
-    0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
-    0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
-    0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
-    0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
-    0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
-    0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
-    0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-    0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
-    0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
-    0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-    0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
-    0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
-    0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
-    0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
-    0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
-    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
-    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
-    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
-    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
-    0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
-    0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
-    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
-    0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
-    0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
-    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
-    0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
-    0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
-    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
-    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
-    0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
-    0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
-  }, 
-  /* VT100 graphics mapped to Unicode */
-  {
-    0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
-    0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
-    0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
-    0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
-    0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
-    0x0028, 0x0029, 0x002a, 0x2192, 0x2190, 0x2191, 0x2193, 0x002f,
-    0x2588, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-    0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
-    0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
-    0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-    0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x00a0,
-    0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1,
-    0x2591, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba,
-    0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c,
-    0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, 0x007f,
-    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
-    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
-    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
-    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
-    0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
-    0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
-    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
-    0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
-    0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
-    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
-    0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
-    0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
-    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
-    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
-    0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
-    0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
-  },
-  /* IBM Codepage 437 mapped to Unicode */
-  {
-    0x0000, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, 
-    0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c,
-    0x25b6, 0x25c0, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25ac, 0x21a8,
-    0x2191, 0x2193, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc,
-    0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
-    0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
-    0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-    0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
-    0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
-    0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-    0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
-    0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
-    0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
-    0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
-    0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x2302,
-    0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
-    0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
-    0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
-    0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
-    0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
-    0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
-    0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
-    0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
-    0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
-    0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
-    0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
-    0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
-    0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
-    0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
-    0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
-    0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
-  }, 
-  /* User mapping -- default to codes for direct font mapping */
-  {
-    0xf000, 0xf001, 0xf002, 0xf003, 0xf004, 0xf005, 0xf006, 0xf007,
-    0xf008, 0xf009, 0xf00a, 0xf00b, 0xf00c, 0xf00d, 0xf00e, 0xf00f,
-    0xf010, 0xf011, 0xf012, 0xf013, 0xf014, 0xf015, 0xf016, 0xf017,
-    0xf018, 0xf019, 0xf01a, 0xf01b, 0xf01c, 0xf01d, 0xf01e, 0xf01f,
-    0xf020, 0xf021, 0xf022, 0xf023, 0xf024, 0xf025, 0xf026, 0xf027,
-    0xf028, 0xf029, 0xf02a, 0xf02b, 0xf02c, 0xf02d, 0xf02e, 0xf02f,
-    0xf030, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037,
-    0xf038, 0xf039, 0xf03a, 0xf03b, 0xf03c, 0xf03d, 0xf03e, 0xf03f,
-    0xf040, 0xf041, 0xf042, 0xf043, 0xf044, 0xf045, 0xf046, 0xf047,
-    0xf048, 0xf049, 0xf04a, 0xf04b, 0xf04c, 0xf04d, 0xf04e, 0xf04f,
-    0xf050, 0xf051, 0xf052, 0xf053, 0xf054, 0xf055, 0xf056, 0xf057,
-    0xf058, 0xf059, 0xf05a, 0xf05b, 0xf05c, 0xf05d, 0xf05e, 0xf05f,
-    0xf060, 0xf061, 0xf062, 0xf063, 0xf064, 0xf065, 0xf066, 0xf067,
-    0xf068, 0xf069, 0xf06a, 0xf06b, 0xf06c, 0xf06d, 0xf06e, 0xf06f,
-    0xf070, 0xf071, 0xf072, 0xf073, 0xf074, 0xf075, 0xf076, 0xf077,
-    0xf078, 0xf079, 0xf07a, 0xf07b, 0xf07c, 0xf07d, 0xf07e, 0xf07f,
-    0xf080, 0xf081, 0xf082, 0xf083, 0xf084, 0xf085, 0xf086, 0xf087,
-    0xf088, 0xf089, 0xf08a, 0xf08b, 0xf08c, 0xf08d, 0xf08e, 0xf08f,
-    0xf090, 0xf091, 0xf092, 0xf093, 0xf094, 0xf095, 0xf096, 0xf097,
-    0xf098, 0xf099, 0xf09a, 0xf09b, 0xf09c, 0xf09d, 0xf09e, 0xf09f,
-    0xf0a0, 0xf0a1, 0xf0a2, 0xf0a3, 0xf0a4, 0xf0a5, 0xf0a6, 0xf0a7,
-    0xf0a8, 0xf0a9, 0xf0aa, 0xf0ab, 0xf0ac, 0xf0ad, 0xf0ae, 0xf0af,
-    0xf0b0, 0xf0b1, 0xf0b2, 0xf0b3, 0xf0b4, 0xf0b5, 0xf0b6, 0xf0b7,
-    0xf0b8, 0xf0b9, 0xf0ba, 0xf0bb, 0xf0bc, 0xf0bd, 0xf0be, 0xf0bf,
-    0xf0c0, 0xf0c1, 0xf0c2, 0xf0c3, 0xf0c4, 0xf0c5, 0xf0c6, 0xf0c7,
-    0xf0c8, 0xf0c9, 0xf0ca, 0xf0cb, 0xf0cc, 0xf0cd, 0xf0ce, 0xf0cf,
-    0xf0d0, 0xf0d1, 0xf0d2, 0xf0d3, 0xf0d4, 0xf0d5, 0xf0d6, 0xf0d7,
-    0xf0d8, 0xf0d9, 0xf0da, 0xf0db, 0xf0dc, 0xf0dd, 0xf0de, 0xf0df,
-    0xf0e0, 0xf0e1, 0xf0e2, 0xf0e3, 0xf0e4, 0xf0e5, 0xf0e6, 0xf0e7,
-    0xf0e8, 0xf0e9, 0xf0ea, 0xf0eb, 0xf0ec, 0xf0ed, 0xf0ee, 0xf0ef,
-    0xf0f0, 0xf0f1, 0xf0f2, 0xf0f3, 0xf0f4, 0xf0f5, 0xf0f6, 0xf0f7,
-    0xf0f8, 0xf0f9, 0xf0fa, 0xf0fb, 0xf0fc, 0xf0fd, 0xf0fe, 0xf0ff
-  }
-};
-
-/* The standard kernel character-to-font mappings are not invertible
-   -- this is just a best effort. */
-
-#define MAX_GLYPH 512          /* Max possible glyph value */
-
-static int inv_translate[MAX_NR_CONSOLES];
-
-struct uni_pagedir {
-       u16             **uni_pgdir[32];
-       unsigned long   refcount;
-       unsigned long   sum;
-       unsigned char   *inverse_translations[4];
-       u16             *inverse_trans_unicode;
-       int             readonly;
-};
-
-static struct uni_pagedir *dflt;
-
-static void set_inverse_transl(struct vc_data *conp, struct uni_pagedir *p, int i)
-{
-       int j, glyph;
-       unsigned short *t = translations[i];
-       unsigned char *q;
-       
-       if (!p) return;
-       q = p->inverse_translations[i];
-
-       if (!q) {
-               q = p->inverse_translations[i] = (unsigned char *) 
-                       kmalloc(MAX_GLYPH, GFP_KERNEL);
-               if (!q) return;
-       }
-       memset(q, 0, MAX_GLYPH);
-
-       for (j = 0; j < E_TABSZ; j++) {
-               glyph = conv_uni_to_pc(conp, t[j]);
-               if (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) {
-                       /* prefer '-' above SHY etc. */
-                       q[glyph] = j;
-               }
-       }
-}
-
-static void set_inverse_trans_unicode(struct vc_data *conp,
-                                     struct uni_pagedir *p)
-{
-       int i, j, k, glyph;
-       u16 **p1, *p2;
-       u16 *q;
-
-       if (!p) return;
-       q = p->inverse_trans_unicode;
-       if (!q) {
-               q = p->inverse_trans_unicode =
-                       kmalloc(MAX_GLYPH * sizeof(u16), GFP_KERNEL);
-               if (!q)
-                       return;
-       }
-       memset(q, 0, MAX_GLYPH * sizeof(u16));
-
-       for (i = 0; i < 32; i++) {
-               p1 = p->uni_pgdir[i];
-               if (!p1)
-                       continue;
-               for (j = 0; j < 32; j++) {
-                       p2 = p1[j];
-                       if (!p2)
-                               continue;
-                       for (k = 0; k < 64; k++) {
-                               glyph = p2[k];
-                               if (glyph >= 0 && glyph < MAX_GLYPH
-                                              && q[glyph] < 32)
-                                       q[glyph] = (i << 11) + (j << 6) + k;
-                       }
-               }
-       }
-}
-
-unsigned short *set_translate(int m, struct vc_data *vc)
-{
-       inv_translate[vc->vc_num] = m;
-       return translations[m];
-}
-
-/*
- * Inverse translation is impossible for several reasons:
- * 1. The font<->character maps are not 1-1.
- * 2. The text may have been written while a different translation map
- *    was active.
- * Still, it is now possible to a certain extent to cut and paste non-ASCII.
- */
-u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode)
-{
-       struct uni_pagedir *p;
-       int m;
-       if (glyph < 0 || glyph >= MAX_GLYPH)
-               return 0;
-       else if (!(p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc))
-               return glyph;
-       else if (use_unicode) {
-               if (!p->inverse_trans_unicode)
-                       return glyph;
-               else
-                       return p->inverse_trans_unicode[glyph];
-       } else {
-               m = inv_translate[conp->vc_num];
-               if (!p->inverse_translations[m])
-                       return glyph;
-               else
-                       return p->inverse_translations[m][glyph];
-       }
-}
-EXPORT_SYMBOL_GPL(inverse_translate);
-
-static void update_user_maps(void)
-{
-       int i;
-       struct uni_pagedir *p, *q = NULL;
-       
-       for (i = 0; i < MAX_NR_CONSOLES; i++) {
-               if (!vc_cons_allocated(i))
-                       continue;
-               p = (struct uni_pagedir *)*vc_cons[i].d->vc_uni_pagedir_loc;
-               if (p && p != q) {
-                       set_inverse_transl(vc_cons[i].d, p, USER_MAP);
-                       set_inverse_trans_unicode(vc_cons[i].d, p);
-                       q = p;
-               }
-       }
-}
-
-/*
- * Load customizable translation table
- * arg points to a 256 byte translation table.
- *
- * The "old" variants are for translation directly to font (using the
- * 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set
- * Unicodes explicitly.
- */
-int con_set_trans_old(unsigned char __user * arg)
-{
-       int i;
-       unsigned short *p = translations[USER_MAP];
-
-       if (!access_ok(VERIFY_READ, arg, E_TABSZ))
-               return -EFAULT;
-
-       for (i=0; i<E_TABSZ ; i++) {
-               unsigned char uc;
-               __get_user(uc, arg+i);
-               p[i] = UNI_DIRECT_BASE | uc;
-       }
-
-       update_user_maps();
-       return 0;
-}
-
-int con_get_trans_old(unsigned char __user * arg)
-{
-       int i, ch;
-       unsigned short *p = translations[USER_MAP];
-
-       if (!access_ok(VERIFY_WRITE, arg, E_TABSZ))
-               return -EFAULT;
-
-       for (i=0; i<E_TABSZ ; i++)
-         {
-           ch = conv_uni_to_pc(vc_cons[fg_console].d, p[i]);
-           __put_user((ch & ~0xff) ? 0 : ch, arg+i);
-         }
-       return 0;
-}
-
-int con_set_trans_new(ushort __user * arg)
-{
-       int i;
-       unsigned short *p = translations[USER_MAP];
-
-       if (!access_ok(VERIFY_READ, arg, E_TABSZ*sizeof(unsigned short)))
-               return -EFAULT;
-
-       for (i=0; i<E_TABSZ ; i++) {
-               unsigned short us;
-               __get_user(us, arg+i);
-               p[i] = us;
-       }
-
-       update_user_maps();
-       return 0;
-}
-
-int con_get_trans_new(ushort __user * arg)
-{
-       int i;
-       unsigned short *p = translations[USER_MAP];
-
-       if (!access_ok(VERIFY_WRITE, arg, E_TABSZ*sizeof(unsigned short)))
-               return -EFAULT;
-
-       for (i=0; i<E_TABSZ ; i++)
-         __put_user(p[i], arg+i);
-       
-       return 0;
-}
-
-/*
- * Unicode -> current font conversion 
- *
- * A font has at most 512 chars, usually 256.
- * But one font position may represent several Unicode chars.
- * A hashtable is somewhat of a pain to deal with, so use a
- * "paged table" instead.  Simulation has shown the memory cost of
- * this 3-level paged table scheme to be comparable to a hash table.
- */
-
-extern u8 dfont_unicount[];    /* Defined in console_defmap.c */
-extern u16 dfont_unitable[];
-
-static void con_release_unimap(struct uni_pagedir *p)
-{
-       u16 **p1;
-       int i, j;
-
-       if (p == dflt) dflt = NULL;  
-       for (i = 0; i < 32; i++) {
-               if ((p1 = p->uni_pgdir[i]) != NULL) {
-                       for (j = 0; j < 32; j++)
-                               kfree(p1[j]);
-                       kfree(p1);
-               }
-               p->uni_pgdir[i] = NULL;
-       }
-       for (i = 0; i < 4; i++) {
-               kfree(p->inverse_translations[i]);
-               p->inverse_translations[i] = NULL;
-       }
-       if (p->inverse_trans_unicode) {
-               kfree(p->inverse_trans_unicode);
-               p->inverse_trans_unicode = NULL;
-       }
-}
-
-void con_free_unimap(struct vc_data *vc)
-{
-       struct uni_pagedir *p;
-
-       p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-       if (!p)
-               return;
-       *vc->vc_uni_pagedir_loc = 0;
-       if (--p->refcount)
-               return;
-       con_release_unimap(p);
-       kfree(p);
-}
-  
-static int con_unify_unimap(struct vc_data *conp, struct uni_pagedir *p)
-{
-       int i, j, k;
-       struct uni_pagedir *q;
-       
-       for (i = 0; i < MAX_NR_CONSOLES; i++) {
-               if (!vc_cons_allocated(i))
-                       continue;
-               q = (struct uni_pagedir *)*vc_cons[i].d->vc_uni_pagedir_loc;
-               if (!q || q == p || q->sum != p->sum)
-                       continue;
-               for (j = 0; j < 32; j++) {
-                       u16 **p1, **q1;
-                       p1 = p->uni_pgdir[j]; q1 = q->uni_pgdir[j];
-                       if (!p1 && !q1)
-                               continue;
-                       if (!p1 || !q1)
-                               break;
-                       for (k = 0; k < 32; k++) {
-                               if (!p1[k] && !q1[k])
-                                       continue;
-                               if (!p1[k] || !q1[k])
-                                       break;
-                               if (memcmp(p1[k], q1[k], 64*sizeof(u16)))
-                                       break;
-                       }
-                       if (k < 32)
-                               break;
-               }
-               if (j == 32) {
-                       q->refcount++;
-                       *conp->vc_uni_pagedir_loc = (unsigned long)q;
-                       con_release_unimap(p);
-                       kfree(p);
-                       return 1;
-               }
-       }
-       return 0;
-}
-
-static int
-con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
-{
-       int i, n;
-       u16 **p1, *p2;
-
-       if (!(p1 = p->uni_pgdir[n = unicode >> 11])) {
-               p1 = p->uni_pgdir[n] = kmalloc(32*sizeof(u16 *), GFP_KERNEL);
-               if (!p1) return -ENOMEM;
-               for (i = 0; i < 32; i++)
-                       p1[i] = NULL;
-       }
-
-       if (!(p2 = p1[n = (unicode >> 6) & 0x1f])) {
-               p2 = p1[n] = kmalloc(64*sizeof(u16), GFP_KERNEL);
-               if (!p2) return -ENOMEM;
-               memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */
-       }
-
-       p2[unicode & 0x3f] = fontpos;
-       
-       p->sum += (fontpos << 20) + unicode;
-
-       return 0;
-}
-
-/* ui is a leftover from using a hashtable, but might be used again */
-int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui)
-{
-       struct uni_pagedir *p, *q;
-  
-       p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-       if (p && p->readonly) return -EIO;
-       if (!p || --p->refcount) {
-               q = kzalloc(sizeof(*p), GFP_KERNEL);
-               if (!q) {
-                       if (p) p->refcount++;
-                       return -ENOMEM;
-               }
-               q->refcount=1;
-               *vc->vc_uni_pagedir_loc = (unsigned long)q;
-       } else {
-               if (p == dflt) dflt = NULL;
-               p->refcount++;
-               p->sum = 0;
-               con_release_unimap(p);
-       }
-       return 0;
-}
-
-int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
-{
-       int err = 0, err1, i;
-       struct uni_pagedir *p, *q;
-
-       p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-       if (p->readonly) return -EIO;
-       
-       if (!ct) return 0;
-       
-       if (p->refcount > 1) {
-               int j, k;
-               u16 **p1, *p2, l;
-               
-               err1 = con_clear_unimap(vc, NULL);
-               if (err1) return err1;
-               
-               q = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-               for (i = 0, l = 0; i < 32; i++)
-               if ((p1 = p->uni_pgdir[i]))
-                       for (j = 0; j < 32; j++)
-                       if ((p2 = p1[j]))
-                               for (k = 0; k < 64; k++, l++)
-                               if (p2[k] != 0xffff) {
-                                       err1 = con_insert_unipair(q, l, p2[k]);
-                                       if (err1) {
-                                               p->refcount++;
-                                               *vc->vc_uni_pagedir_loc = (unsigned long)p;
-                                               con_release_unimap(q);
-                                               kfree(q);
-                                               return err1; 
-                                       }
-                               }
-               p = q;
-       } else if (p == dflt)
-               dflt = NULL;
-       
-       while (ct--) {
-               unsigned short unicode, fontpos;
-               __get_user(unicode, &list->unicode);
-               __get_user(fontpos, &list->fontpos);
-               if ((err1 = con_insert_unipair(p, unicode,fontpos)) != 0)
-                       err = err1;
-               list++;
-       }
-       
-       if (con_unify_unimap(vc, p))
-               return err;
-
-       for (i = 0; i <= 3; i++)
-               set_inverse_transl(vc, p, i); /* Update all inverse translations */
-       set_inverse_trans_unicode(vc, p);
-  
-       return err;
-}
-
-/* Loads the unimap for the hardware font, as defined in uni_hash.tbl.
-   The representation used was the most compact I could come up
-   with.  This routine is executed at sys_setup time, and when the
-   PIO_FONTRESET ioctl is called. */
-
-int con_set_default_unimap(struct vc_data *vc)
-{
-       int i, j, err = 0, err1;
-       u16 *q;
-       struct uni_pagedir *p;
-
-       if (dflt) {
-               p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-               if (p == dflt)
-                       return 0;
-               dflt->refcount++;
-               *vc->vc_uni_pagedir_loc = (unsigned long)dflt;
-               if (p && --p->refcount) {
-                       con_release_unimap(p);
-                       kfree(p);
-               }
-               return 0;
-       }
-       
-       /* The default font is always 256 characters */
-
-       err = con_clear_unimap(vc, NULL);
-       if (err) return err;
-    
-       p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-       q = dfont_unitable;
-       
-       for (i = 0; i < 256; i++)
-               for (j = dfont_unicount[i]; j; j--) {
-                       err1 = con_insert_unipair(p, *(q++), i);
-                       if (err1)
-                               err = err1;
-               }
-                       
-       if (con_unify_unimap(vc, p)) {
-               dflt = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-               return err;
-       }
-
-       for (i = 0; i <= 3; i++)
-               set_inverse_transl(vc, p, i);   /* Update all inverse translations */
-       set_inverse_trans_unicode(vc, p);
-       dflt = p;
-       return err;
-}
-EXPORT_SYMBOL(con_set_default_unimap);
-
-int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc)
-{
-       struct uni_pagedir *q;
-
-       if (!*src_vc->vc_uni_pagedir_loc)
-               return -EINVAL;
-       if (*dst_vc->vc_uni_pagedir_loc == *src_vc->vc_uni_pagedir_loc)
-               return 0;
-       con_free_unimap(dst_vc);
-       q = (struct uni_pagedir *)*src_vc->vc_uni_pagedir_loc;
-       q->refcount++;
-       *dst_vc->vc_uni_pagedir_loc = (long)q;
-       return 0;
-}
-
-int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list)
-{
-       int i, j, k, ect;
-       u16 **p1, *p2;
-       struct uni_pagedir *p;
-
-       ect = 0;
-       if (*vc->vc_uni_pagedir_loc) {
-               p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-               for (i = 0; i < 32; i++)
-               if ((p1 = p->uni_pgdir[i]))
-                       for (j = 0; j < 32; j++)
-                       if ((p2 = *(p1++)))
-                               for (k = 0; k < 64; k++) {
-                                       if (*p2 < MAX_GLYPH && ect++ < ct) {
-                                               __put_user((u_short)((i<<11)+(j<<6)+k),
-                                                          &list->unicode);
-                                               __put_user((u_short) *p2, 
-                                                          &list->fontpos);
-                                               list++;
-                                       }
-                                       p2++;
-                               }
-       }
-       __put_user(ect, uct);
-       return ((ect <= ct) ? 0 : -ENOMEM);
-}
-
-void con_protect_unimap(struct vc_data *vc, int rdonly)
-{
-       struct uni_pagedir *p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
-       
-       if (p)
-               p->readonly = rdonly;
-}
-
-/*
- * Always use USER_MAP. These functions are used by the keyboard,
- * which shouldn't be affected by G0/G1 switching, etc.
- * If the user map still contains default values, i.e. the
- * direct-to-font mapping, then assume user is using Latin1.
- */
-/* may be called during an interrupt */
-u32 conv_8bit_to_uni(unsigned char c)
-{
-       unsigned short uni = translations[USER_MAP][c];
-       return uni == (0xf000 | c) ? c : uni;
-}
-
-int conv_uni_to_8bit(u32 uni)
-{
-       int c;
-       for (c = 0; c < 0x100; c++)
-               if (translations[USER_MAP][c] == uni ||
-                  (translations[USER_MAP][c] == (c | 0xf000) && uni == c))
-                       return c;
-       return -1;
-}
-
-int
-conv_uni_to_pc(struct vc_data *conp, long ucs) 
-{
-       int h;
-       u16 **p1, *p2;
-       struct uni_pagedir *p;
-  
-       /* Only 16-bit codes supported at this time */
-       if (ucs > 0xffff)
-               return -4;              /* Not found */
-       else if (ucs < 0x20)
-               return -1;              /* Not a printable character */
-       else if (ucs == 0xfeff || (ucs >= 0x200b && ucs <= 0x200f))
-               return -2;                      /* Zero-width space */
-       /*
-        * UNI_DIRECT_BASE indicates the start of the region in the User Zone
-        * which always has a 1:1 mapping to the currently loaded font.  The
-        * UNI_DIRECT_MASK indicates the bit span of the region.
-        */
-       else if ((ucs & ~UNI_DIRECT_MASK) == UNI_DIRECT_BASE)
-               return ucs & UNI_DIRECT_MASK;
-  
-       if (!*conp->vc_uni_pagedir_loc)
-               return -3;
-
-       p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;  
-       if ((p1 = p->uni_pgdir[ucs >> 11]) &&
-           (p2 = p1[(ucs >> 6) & 0x1f]) &&
-           (h = p2[ucs & 0x3f]) < MAX_GLYPH)
-               return h;
-
-       return -4;              /* not found */
-}
-
-/*
- * This is called at sys_setup time, after memory and the console are
- * initialized.  It must be possible to call kmalloc(..., GFP_KERNEL)
- * from this function, hence the call from sys_setup.
- */
-void __init 
-console_map_init(void)
-{
-       int i;
-       
-       for (i = 0; i < MAX_NR_CONSOLES; i++)
-               if (vc_cons_allocated(i) && !*vc_cons[i].d->vc_uni_pagedir_loc)
-                       con_set_default_unimap(vc_cons[i].d);
-}
-
-EXPORT_SYMBOL(con_copy_unimap);
diff --git a/drivers/char/cp437.uni b/drivers/char/cp437.uni
deleted file mode 100644 (file)
index bc61634..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-#
-# Unicode table for IBM Codepage 437.  Note that there are many more
-# substitutions that could be conceived (for example, thick-line
-# graphs probably should be replaced with double-line ones, accented
-# Latin characters should replaced with their nonaccented versions,
-# and some upper case Greek characters could be replaced by Latin), however,
-# I have limited myself to the Unicodes used by the kernel ISO 8859-1,
-# DEC VT, and IBM CP 437 tables.
-#
-# --------------------------------
-#
-# Basic IBM dingbats, some of which will never have a purpose clear
-# to mankind
-#
-0x00   U+0000
-0x01   U+263a
-0x02   U+263b
-0x03   U+2665
-0x04   U+2666 U+25c6
-0x05   U+2663
-0x06   U+2660
-0x07   U+2022
-0x08   U+25d8
-0x09   U+25cb
-0x0a   U+25d9
-0x0b   U+2642
-0x0c   U+2640
-0x0d   U+266a
-0x0e   U+266b
-0x0f   U+263c U+00a4
-0x10   U+25b6 U+25ba
-0x11   U+25c0 U+25c4
-0x12   U+2195
-0x13   U+203c
-0x14   U+00b6
-0x15   U+00a7
-0x16   U+25ac
-0x17   U+21a8
-0x18   U+2191
-0x19   U+2193
-0x1a   U+2192
-0x1b   U+2190
-0x1c   U+221f
-0x1d   U+2194
-0x1e   U+25b2
-0x1f   U+25bc
-#
-# The ASCII range is identity-mapped, but some of the characters also
-# have to act as substitutes, especially the upper-case characters.
-#
-0x20   U+0020
-0x21   U+0021
-0x22   U+0022 U+00a8
-0x23   U+0023
-0x24   U+0024
-0x25   U+0025
-0x26   U+0026
-0x27   U+0027 U+00b4
-0x28   U+0028
-0x29   U+0029
-0x2a   U+002a
-0x2b   U+002b
-0x2c   U+002c U+00b8
-0x2d   U+002d U+00ad
-0x2e   U+002e
-0x2f   U+002f
-0x30   U+0030
-0x31   U+0031
-0x32   U+0032
-0x33   U+0033
-0x34   U+0034
-0x35   U+0035
-0x36   U+0036
-0x37   U+0037
-0x38   U+0038
-0x39   U+0039
-0x3a   U+003a
-0x3b   U+003b
-0x3c   U+003c
-0x3d   U+003d
-0x3e   U+003e
-0x3f   U+003f
-0x40   U+0040
-0x41   U+0041 U+00c0 U+00c1 U+00c2 U+00c3
-0x42   U+0042
-0x43   U+0043 U+00a9
-0x44   U+0044 U+00d0
-0x45   U+0045 U+00c8 U+00ca U+00cb
-0x46   U+0046
-0x47   U+0047
-0x48   U+0048
-0x49   U+0049 U+00cc U+00cd U+00ce U+00cf
-0x4a   U+004a
-0x4b   U+004b U+212a
-0x4c   U+004c
-0x4d   U+004d
-0x4e   U+004e
-0x4f   U+004f U+00d2 U+00d3 U+00d4 U+00d5
-0x50   U+0050
-0x51   U+0051
-0x52   U+0052 U+00ae
-0x53   U+0053
-0x54   U+0054
-0x55   U+0055 U+00d9 U+00da U+00db
-0x56   U+0056
-0x57   U+0057
-0x58   U+0058
-0x59   U+0059 U+00dd
-0x5a   U+005a
-0x5b   U+005b
-0x5c   U+005c
-0x5d   U+005d
-0x5e   U+005e
-0x5f   U+005f U+23bd U+f804
-0x60   U+0060
-0x61   U+0061 U+00e3
-0x62   U+0062
-0x63   U+0063
-0x64   U+0064
-0x65   U+0065
-0x66   U+0066
-0x67   U+0067
-0x68   U+0068
-0x69   U+0069
-0x6a   U+006a
-0x6b   U+006b
-0x6c   U+006c
-0x6d   U+006d
-0x6e   U+006e
-0x6f   U+006f U+00f5
-0x70   U+0070
-0x71   U+0071
-0x72   U+0072
-0x73   U+0073
-0x74   U+0074
-0x75   U+0075
-0x76   U+0076
-0x77   U+0077
-0x78   U+0078 U+00d7
-0x79   U+0079 U+00fd
-0x7a   U+007a
-0x7b   U+007b
-0x7c   U+007c U+00a6
-0x7d   U+007d
-0x7e   U+007e
-#
-# Okay, what on Earth is this one supposed to be used for?
-#
-0x7f   U+2302
-#
-# Non-English characters, mostly lower case letters...
-#
-0x80   U+00c7
-0x81   U+00fc
-0x82   U+00e9
-0x83   U+00e2
-0x84   U+00e4
-0x85   U+00e0
-0x86   U+00e5
-0x87   U+00e7
-0x88   U+00ea
-0x89   U+00eb
-0x8a   U+00e8
-0x8b   U+00ef
-0x8c   U+00ee
-0x8d   U+00ec
-0x8e   U+00c4
-0x8f   U+00c5 U+212b
-0x90   U+00c9
-0x91   U+00e6
-0x92   U+00c6
-0x93   U+00f4
-0x94   U+00f6
-0x95   U+00f2
-0x96   U+00fb
-0x97   U+00f9
-0x98   U+00ff
-0x99   U+00d6
-0x9a   U+00dc
-0x9b   U+00a2
-0x9c   U+00a3
-0x9d   U+00a5
-0x9e   U+20a7
-0x9f   U+0192
-0xa0   U+00e1
-0xa1   U+00ed
-0xa2   U+00f3
-0xa3   U+00fa
-0xa4   U+00f1
-0xa5   U+00d1
-0xa6   U+00aa
-0xa7   U+00ba
-0xa8   U+00bf
-0xa9   U+2310
-0xaa   U+00ac
-0xab   U+00bd
-0xac   U+00bc
-0xad   U+00a1
-0xae   U+00ab
-0xaf   U+00bb
-#
-# Block graphics
-#
-0xb0   U+2591
-0xb1   U+2592
-0xb2   U+2593
-0xb3   U+2502
-0xb4   U+2524
-0xb5   U+2561
-0xb6   U+2562
-0xb7   U+2556
-0xb8   U+2555
-0xb9   U+2563
-0xba   U+2551
-0xbb   U+2557
-0xbc   U+255d
-0xbd   U+255c
-0xbe   U+255b
-0xbf   U+2510
-0xc0   U+2514
-0xc1   U+2534
-0xc2   U+252c
-0xc3   U+251c
-0xc4   U+2500
-0xc5   U+253c
-0xc6   U+255e
-0xc7   U+255f
-0xc8   U+255a
-0xc9   U+2554
-0xca   U+2569
-0xcb   U+2566
-0xcc   U+2560
-0xcd   U+2550
-0xce   U+256c
-0xcf   U+2567
-0xd0   U+2568
-0xd1   U+2564
-0xd2   U+2565
-0xd3   U+2559
-0xd4   U+2558
-0xd5   U+2552
-0xd6   U+2553
-0xd7   U+256b
-0xd8   U+256a
-0xd9   U+2518
-0xda   U+250c
-0xdb   U+2588
-0xdc   U+2584
-0xdd   U+258c
-0xde   U+2590
-0xdf   U+2580
-#
-# Greek letters and mathematical symbols
-#
-0xe0   U+03b1
-0xe1   U+03b2 U+00df
-0xe2   U+0393
-0xe3   U+03c0
-0xe4   U+03a3
-0xe5   U+03c3
-0xe6   U+00b5 U+03bc
-0xe7   U+03c4
-0xe8   U+03a6 U+00d8
-0xe9   U+0398
-0xea   U+03a9 U+2126
-0xeb   U+03b4 U+00f0
-0xec   U+221e
-0xed   U+03c6 U+00f8
-0xee   U+03b5 U+2208
-0xef   U+2229
-0xf0   U+2261
-0xf1   U+00b1
-0xf2   U+2265
-0xf3   U+2264
-0xf4   U+2320
-0xf5   U+2321
-0xf6   U+00f7
-0xf7   U+2248
-0xf8   U+00b0
-0xf9   U+2219
-0xfa   U+00b7
-0xfb   U+221a
-0xfc   U+207f
-0xfd   U+00b2
-#
-# Square bullet, non-spacing blank
-# Mapping U+fffd to the square bullet means it is the substitution
-# character
-# 
-0xfe   U+25a0 U+fffd
-0xff   U+00a0
diff --git a/drivers/char/defkeymap.c_shipped b/drivers/char/defkeymap.c_shipped
deleted file mode 100644 (file)
index d2208df..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/* Do not edit this file! It was automatically generated by   */
-/*    loadkeys --mktable defkeymap.map > defkeymap.c          */
-
-#include <linux/types.h>
-#include <linux/keyboard.h>
-#include <linux/kd.h>
-
-u_short plain_map[NR_KEYS] = {
-       0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,
-       0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009,
-       0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
-       0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73,
-       0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b,
-       0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76,
-       0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c,
-       0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
-       0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307,
-       0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
-       0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a,
-       0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-u_short shift_map[NR_KEYS] = {
-       0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e,
-       0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009,
-       0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49,
-       0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53,
-       0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a,
-       0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56,
-       0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c,
-       0xf703, 0xf020, 0xf207, 0xf10a, 0xf10b, 0xf10c, 0xf10d, 0xf10e,
-       0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf213, 0xf203, 0xf307,
-       0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
-       0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf10a,
-       0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-u_short altgr_map[NR_KEYS] = {
-       0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200,
-       0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200,
-       0xfb71, 0xfb77, 0xf918, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
-       0xfb6f, 0xfb70, 0xf200, 0xf07e, 0xf201, 0xf702, 0xf914, 0xfb73,
-       0xf917, 0xf919, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf200,
-       0xf200, 0xf200, 0xf700, 0xf200, 0xfb7a, 0xfb78, 0xf916, 0xfb76,
-       0xf915, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
-       0xf703, 0xf200, 0xf207, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510,
-       0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf202, 0xf911,
-       0xf912, 0xf913, 0xf30b, 0xf90e, 0xf90f, 0xf910, 0xf30a, 0xf90b,
-       0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516,
-       0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-u_short ctrl_map[NR_KEYS] = {
-       0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e,
-       0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200,
-       0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009,
-       0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf201, 0xf702, 0xf001, 0xf013,
-       0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
-       0xf007, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016,
-       0xf002, 0xf00e, 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c,
-       0xf703, 0xf000, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
-       0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf204, 0xf307,
-       0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
-       0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf10a,
-       0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-u_short shift_ctrl_map[NR_KEYS] = {
-       0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200,
-       0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009,
-       0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013,
-       0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
-       0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016,
-       0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
-       0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307,
-       0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
-       0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-u_short alt_map[NR_KEYS] = {
-       0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836,
-       0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809,
-       0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869,
-       0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873,
-       0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b,
-       0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876,
-       0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c,
-       0xf703, 0xf820, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504,
-       0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf907,
-       0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901,
-       0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a,
-       0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-u_short ctrl_alt_map[NR_KEYS] = {
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809,
-       0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813,
-       0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200,
-       0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816,
-       0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
-       0xf703, 0xf200, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504,
-       0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf200, 0xf307,
-       0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
-       0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a,
-       0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-       0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
-       0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c,
-       0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
-       0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
-};
-
-ushort *key_maps[MAX_NR_KEYMAPS] = {
-       plain_map, shift_map, altgr_map, NULL,
-       ctrl_map, shift_ctrl_map, NULL, NULL,
-       alt_map, NULL, NULL, NULL,
-       ctrl_alt_map, NULL
-};
-
-unsigned int keymap_count = 7;
-
-/*
- * Philosophy: most people do not define more strings, but they who do
- * often want quite a lot of string space. So, we statically allocate
- * the default and allocate dynamically in chunks of 512 bytes.
- */
-
-char func_buf[] = {
-       '\033', '[', '[', 'A', 0, 
-       '\033', '[', '[', 'B', 0, 
-       '\033', '[', '[', 'C', 0, 
-       '\033', '[', '[', 'D', 0, 
-       '\033', '[', '[', 'E', 0, 
-       '\033', '[', '1', '7', '~', 0, 
-       '\033', '[', '1', '8', '~', 0, 
-       '\033', '[', '1', '9', '~', 0, 
-       '\033', '[', '2', '0', '~', 0, 
-       '\033', '[', '2', '1', '~', 0, 
-       '\033', '[', '2', '3', '~', 0, 
-       '\033', '[', '2', '4', '~', 0, 
-       '\033', '[', '2', '5', '~', 0, 
-       '\033', '[', '2', '6', '~', 0, 
-       '\033', '[', '2', '8', '~', 0, 
-       '\033', '[', '2', '9', '~', 0, 
-       '\033', '[', '3', '1', '~', 0, 
-       '\033', '[', '3', '2', '~', 0, 
-       '\033', '[', '3', '3', '~', 0, 
-       '\033', '[', '3', '4', '~', 0, 
-       '\033', '[', '1', '~', 0, 
-       '\033', '[', '2', '~', 0, 
-       '\033', '[', '3', '~', 0, 
-       '\033', '[', '4', '~', 0, 
-       '\033', '[', '5', '~', 0, 
-       '\033', '[', '6', '~', 0, 
-       '\033', '[', 'M', 0, 
-       '\033', '[', 'P', 0, 
-};
-
-char *funcbufptr = func_buf;
-int funcbufsize = sizeof(func_buf);
-int funcbufleft = 0;          /* space left */
-
-char *func_table[MAX_NR_FUNC] = {
-       func_buf + 0,
-       func_buf + 5,
-       func_buf + 10,
-       func_buf + 15,
-       func_buf + 20,
-       func_buf + 25,
-       func_buf + 31,
-       func_buf + 37,
-       func_buf + 43,
-       func_buf + 49,
-       func_buf + 55,
-       func_buf + 61,
-       func_buf + 67,
-       func_buf + 73,
-       func_buf + 79,
-       func_buf + 85,
-       func_buf + 91,
-       func_buf + 97,
-       func_buf + 103,
-       func_buf + 109,
-       func_buf + 115,
-       func_buf + 120,
-       func_buf + 125,
-       func_buf + 130,
-       func_buf + 135,
-       func_buf + 140,
-       func_buf + 145,
-       NULL,
-       NULL,
-       func_buf + 149,
-       NULL,
-};
-
-struct kbdiacruc accent_table[MAX_DIACR] = {
-       {'`', 'A', 0300},       {'`', 'a', 0340},
-       {'\'', 'A', 0301},      {'\'', 'a', 0341},
-       {'^', 'A', 0302},       {'^', 'a', 0342},
-       {'~', 'A', 0303},       {'~', 'a', 0343},
-       {'"', 'A', 0304},       {'"', 'a', 0344},
-       {'O', 'A', 0305},       {'o', 'a', 0345},
-       {'0', 'A', 0305},       {'0', 'a', 0345},
-       {'A', 'A', 0305},       {'a', 'a', 0345},
-       {'A', 'E', 0306},       {'a', 'e', 0346},
-       {',', 'C', 0307},       {',', 'c', 0347},
-       {'`', 'E', 0310},       {'`', 'e', 0350},
-       {'\'', 'E', 0311},      {'\'', 'e', 0351},
-       {'^', 'E', 0312},       {'^', 'e', 0352},
-       {'"', 'E', 0313},       {'"', 'e', 0353},
-       {'`', 'I', 0314},       {'`', 'i', 0354},
-       {'\'', 'I', 0315},      {'\'', 'i', 0355},
-       {'^', 'I', 0316},       {'^', 'i', 0356},
-       {'"', 'I', 0317},       {'"', 'i', 0357},
-       {'-', 'D', 0320},       {'-', 'd', 0360},
-       {'~', 'N', 0321},       {'~', 'n', 0361},
-       {'`', 'O', 0322},       {'`', 'o', 0362},
-       {'\'', 'O', 0323},      {'\'', 'o', 0363},
-       {'^', 'O', 0324},       {'^', 'o', 0364},
-       {'~', 'O', 0325},       {'~', 'o', 0365},
-       {'"', 'O', 0326},       {'"', 'o', 0366},
-       {'/', 'O', 0330},       {'/', 'o', 0370},
-       {'`', 'U', 0331},       {'`', 'u', 0371},
-       {'\'', 'U', 0332},      {'\'', 'u', 0372},
-       {'^', 'U', 0333},       {'^', 'u', 0373},
-       {'"', 'U', 0334},       {'"', 'u', 0374},
-       {'\'', 'Y', 0335},      {'\'', 'y', 0375},
-       {'T', 'H', 0336},       {'t', 'h', 0376},
-       {'s', 's', 0337},       {'"', 'y', 0377},
-       {'s', 'z', 0337},       {'i', 'j', 0377},
-};
-
-unsigned int accent_table_size = 68;
diff --git a/drivers/char/defkeymap.map b/drivers/char/defkeymap.map
deleted file mode 100644 (file)
index 50b30ca..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-# Default kernel keymap. This uses 7 modifier combinations.
-keymaps 0-2,4-5,8,12
-# Change the above line into
-#      keymaps 0-2,4-6,8,12
-# in case you want the entries
-#      altgr   control keycode  83 = Boot            
-#      altgr   control keycode 111 = Boot            
-# below.
-#
-# In fact AltGr is used very little, and one more keymap can
-# be saved by mapping AltGr to Alt (and adapting a few entries):
-# keycode 100 = Alt
-#
-keycode   1 = Escape           Escape          
-       alt     keycode   1 = Meta_Escape     
-keycode   2 = one              exclam          
-       alt     keycode   2 = Meta_one        
-keycode   3 = two              at               at              
-       control keycode   3 = nul             
-       shift   control keycode   3 = nul             
-       alt     keycode   3 = Meta_two        
-keycode   4 = three            numbersign      
-       control keycode   4 = Escape          
-       alt     keycode   4 = Meta_three      
-keycode   5 = four             dollar           dollar          
-       control keycode   5 = Control_backslash
-       alt     keycode   5 = Meta_four       
-keycode   6 = five             percent         
-       control keycode   6 = Control_bracketright
-       alt     keycode   6 = Meta_five       
-keycode   7 = six              asciicircum     
-       control keycode   7 = Control_asciicircum
-       alt     keycode   7 = Meta_six        
-keycode   8 = seven            ampersand        braceleft       
-       control keycode   8 = Control_underscore
-       alt     keycode   8 = Meta_seven      
-keycode   9 = eight            asterisk         bracketleft     
-       control keycode   9 = Delete          
-       alt     keycode   9 = Meta_eight      
-keycode  10 = nine             parenleft        bracketright    
-       alt     keycode  10 = Meta_nine       
-keycode  11 = zero             parenright       braceright      
-       alt     keycode  11 = Meta_zero       
-keycode  12 = minus            underscore       backslash       
-       control keycode  12 = Control_underscore
-       shift   control keycode  12 = Control_underscore
-       alt     keycode  12 = Meta_minus      
-keycode  13 = equal            plus            
-       alt     keycode  13 = Meta_equal      
-keycode  14 = Delete           Delete          
-       control keycode  14 = BackSpace
-       alt     keycode  14 = Meta_Delete     
-keycode  15 = Tab              Tab             
-       alt     keycode  15 = Meta_Tab        
-keycode  16 = q               
-keycode  17 = w               
-keycode  18 = e
-       altgr   keycode  18 = Hex_E   
-keycode  19 = r               
-keycode  20 = t               
-keycode  21 = y               
-keycode  22 = u               
-keycode  23 = i               
-keycode  24 = o               
-keycode  25 = p               
-keycode  26 = bracketleft      braceleft       
-       control keycode  26 = Escape          
-       alt     keycode  26 = Meta_bracketleft
-keycode  27 = bracketright     braceright       asciitilde      
-       control keycode  27 = Control_bracketright
-       alt     keycode  27 = Meta_bracketright
-keycode  28 = Return          
-       alt     keycode  28 = Meta_Control_m  
-keycode  29 = Control         
-keycode  30 = a
-       altgr   keycode  30 = Hex_A
-keycode  31 = s               
-keycode  32 = d
-       altgr   keycode  32 = Hex_D   
-keycode  33 = f
-       altgr   keycode  33 = Hex_F               
-keycode  34 = g               
-keycode  35 = h               
-keycode  36 = j               
-keycode  37 = k               
-keycode  38 = l               
-keycode  39 = semicolon        colon           
-       alt     keycode  39 = Meta_semicolon  
-keycode  40 = apostrophe       quotedbl        
-       control keycode  40 = Control_g       
-       alt     keycode  40 = Meta_apostrophe 
-keycode  41 = grave            asciitilde      
-       control keycode  41 = nul             
-       alt     keycode  41 = Meta_grave      
-keycode  42 = Shift           
-keycode  43 = backslash        bar             
-       control keycode  43 = Control_backslash
-       alt     keycode  43 = Meta_backslash  
-keycode  44 = z               
-keycode  45 = x               
-keycode  46 = c
-       altgr   keycode  46 = Hex_C   
-keycode  47 = v               
-keycode  48 = b
-       altgr   keycode  48 = Hex_B
-keycode  49 = n               
-keycode  50 = m               
-keycode  51 = comma            less            
-       alt     keycode  51 = Meta_comma      
-keycode  52 = period           greater         
-       control keycode  52 = Compose         
-       alt     keycode  52 = Meta_period     
-keycode  53 = slash            question        
-       control keycode  53 = Delete          
-       alt     keycode  53 = Meta_slash      
-keycode  54 = Shift           
-keycode  55 = KP_Multiply     
-keycode  56 = Alt             
-keycode  57 = space            space           
-       control keycode  57 = nul             
-       alt     keycode  57 = Meta_space      
-keycode  58 = Caps_Lock       
-keycode  59 = F1               F11              Console_13      
-       control keycode  59 = F1              
-       alt     keycode  59 = Console_1       
-       control alt     keycode  59 = Console_1       
-keycode  60 = F2               F12              Console_14      
-       control keycode  60 = F2              
-       alt     keycode  60 = Console_2       
-       control alt     keycode  60 = Console_2       
-keycode  61 = F3               F13              Console_15      
-       control keycode  61 = F3              
-       alt     keycode  61 = Console_3       
-       control alt     keycode  61 = Console_3       
-keycode  62 = F4               F14              Console_16      
-       control keycode  62 = F4              
-       alt     keycode  62 = Console_4       
-       control alt     keycode  62 = Console_4       
-keycode  63 = F5               F15              Console_17      
-       control keycode  63 = F5              
-       alt     keycode  63 = Console_5       
-       control alt     keycode  63 = Console_5       
-keycode  64 = F6               F16              Console_18      
-       control keycode  64 = F6              
-       alt     keycode  64 = Console_6       
-       control alt     keycode  64 = Console_6       
-keycode  65 = F7               F17              Console_19      
-       control keycode  65 = F7              
-       alt     keycode  65 = Console_7       
-       control alt     keycode  65 = Console_7       
-keycode  66 = F8               F18              Console_20      
-       control keycode  66 = F8              
-       alt     keycode  66 = Console_8       
-       control alt     keycode  66 = Console_8       
-keycode  67 = F9               F19              Console_21      
-       control keycode  67 = F9              
-       alt     keycode  67 = Console_9       
-       control alt     keycode  67 = Console_9       
-keycode  68 = F10              F20              Console_22      
-       control keycode  68 = F10             
-       alt     keycode  68 = Console_10      
-       control alt     keycode  68 = Console_10      
-keycode  69 = Num_Lock
-       shift   keycode  69 = Bare_Num_Lock
-keycode  70 = Scroll_Lock      Show_Memory      Show_Registers  
-       control keycode  70 = Show_State      
-       alt     keycode  70 = Scroll_Lock     
-keycode  71 = KP_7            
-       alt     keycode  71 = Ascii_7         
-       altgr   keycode  71 = Hex_7         
-keycode  72 = KP_8            
-       alt     keycode  72 = Ascii_8         
-       altgr   keycode  72 = Hex_8         
-keycode  73 = KP_9            
-       alt     keycode  73 = Ascii_9         
-       altgr   keycode  73 = Hex_9         
-keycode  74 = KP_Subtract     
-keycode  75 = KP_4            
-       alt     keycode  75 = Ascii_4         
-       altgr   keycode  75 = Hex_4         
-keycode  76 = KP_5            
-       alt     keycode  76 = Ascii_5         
-       altgr   keycode  76 = Hex_5         
-keycode  77 = KP_6            
-       alt     keycode  77 = Ascii_6         
-       altgr   keycode  77 = Hex_6         
-keycode  78 = KP_Add          
-keycode  79 = KP_1            
-       alt     keycode  79 = Ascii_1         
-       altgr   keycode  79 = Hex_1         
-keycode  80 = KP_2            
-       alt     keycode  80 = Ascii_2         
-       altgr   keycode  80 = Hex_2         
-keycode  81 = KP_3            
-       alt     keycode  81 = Ascii_3         
-       altgr   keycode  81 = Hex_3         
-keycode  82 = KP_0            
-       alt     keycode  82 = Ascii_0         
-       altgr   keycode  82 = Hex_0         
-keycode  83 = KP_Period       
-#      altgr   control keycode  83 = Boot            
-       control alt     keycode  83 = Boot            
-keycode  84 = Last_Console    
-keycode  85 =
-keycode  86 = less             greater          bar             
-       alt     keycode  86 = Meta_less       
-keycode  87 = F11              F11              Console_23      
-       control keycode  87 = F11             
-       alt     keycode  87 = Console_11      
-       control alt     keycode  87 = Console_11      
-keycode  88 = F12              F12              Console_24      
-       control keycode  88 = F12             
-       alt     keycode  88 = Console_12      
-       control alt     keycode  88 = Console_12      
-keycode  89 =
-keycode  90 =
-keycode  91 =
-keycode  92 =
-keycode  93 =
-keycode  94 =
-keycode  95 =
-keycode  96 = KP_Enter        
-keycode  97 = Control         
-keycode  98 = KP_Divide       
-keycode  99 = Control_backslash
-       control keycode  99 = Control_backslash
-       alt     keycode  99 = Control_backslash
-keycode 100 = AltGr           
-keycode 101 = Break           
-keycode 102 = Find            
-keycode 103 = Up              
-keycode 104 = Prior           
-       shift   keycode 104 = Scroll_Backward 
-keycode 105 = Left            
-       alt     keycode 105 = Decr_Console
-keycode 106 = Right           
-       alt     keycode 106 = Incr_Console
-keycode 107 = Select          
-keycode 108 = Down            
-keycode 109 = Next            
-       shift   keycode 109 = Scroll_Forward  
-keycode 110 = Insert          
-keycode 111 = Remove          
-#      altgr   control keycode 111 = Boot            
-       control alt     keycode 111 = Boot            
-keycode 112 = Macro           
-keycode 113 = F13             
-keycode 114 = F14             
-keycode 115 = Help            
-keycode 116 = Do              
-keycode 117 = F17             
-keycode 118 = KP_MinPlus      
-keycode 119 = Pause           
-keycode 120 =
-keycode 121 =
-keycode 122 =
-keycode 123 =
-keycode 124 =
-keycode 125 =
-keycode 126 =
-keycode 127 =
-string F1 = "\033[[A"
-string F2 = "\033[[B"
-string F3 = "\033[[C"
-string F4 = "\033[[D"
-string F5 = "\033[[E"
-string F6 = "\033[17~"
-string F7 = "\033[18~"
-string F8 = "\033[19~"
-string F9 = "\033[20~"
-string F10 = "\033[21~"
-string F11 = "\033[23~"
-string F12 = "\033[24~"
-string F13 = "\033[25~"
-string F14 = "\033[26~"
-string F15 = "\033[28~"
-string F16 = "\033[29~"
-string F17 = "\033[31~"
-string F18 = "\033[32~"
-string F19 = "\033[33~"
-string F20 = "\033[34~"
-string Find = "\033[1~"
-string Insert = "\033[2~"
-string Remove = "\033[3~"
-string Select = "\033[4~"
-string Prior = "\033[5~"
-string Next = "\033[6~"
-string Macro = "\033[M"
-string Pause = "\033[P"
-compose '`' 'A' to 'À'
-compose '`' 'a' to 'à'
-compose '\'' 'A' to 'Á'
-compose '\'' 'a' to 'á'
-compose '^' 'A' to 'Â'
-compose '^' 'a' to 'â'
-compose '~' 'A' to 'Ã'
-compose '~' 'a' to 'ã'
-compose '"' 'A' to 'Ä'
-compose '"' 'a' to 'ä'
-compose 'O' 'A' to 'Å'
-compose 'o' 'a' to 'å'
-compose '0' 'A' to 'Å'
-compose '0' 'a' to 'å'
-compose 'A' 'A' to 'Å'
-compose 'a' 'a' to 'å'
-compose 'A' 'E' to 'Æ'
-compose 'a' 'e' to 'æ'
-compose ',' 'C' to 'Ç'
-compose ',' 'c' to 'ç'
-compose '`' 'E' to 'È'
-compose '`' 'e' to 'è'
-compose '\'' 'E' to 'É'
-compose '\'' 'e' to 'é'
-compose '^' 'E' to 'Ê'
-compose '^' 'e' to 'ê'
-compose '"' 'E' to 'Ë'
-compose '"' 'e' to 'ë'
-compose '`' 'I' to 'Ì'
-compose '`' 'i' to 'ì'
-compose '\'' 'I' to 'Í'
-compose '\'' 'i' to 'í'
-compose '^' 'I' to 'Î'
-compose '^' 'i' to 'î'
-compose '"' 'I' to 'Ï'
-compose '"' 'i' to 'ï'
-compose '-' 'D' to 'Ð'
-compose '-' 'd' to 'ð'
-compose '~' 'N' to 'Ñ'
-compose '~' 'n' to 'ñ'
-compose '`' 'O' to 'Ò'
-compose '`' 'o' to 'ò'
-compose '\'' 'O' to 'Ó'
-compose '\'' 'o' to 'ó'
-compose '^' 'O' to 'Ô'
-compose '^' 'o' to 'ô'
-compose '~' 'O' to 'Õ'
-compose '~' 'o' to 'õ'
-compose '"' 'O' to 'Ö'
-compose '"' 'o' to 'ö'
-compose '/' 'O' to 'Ø'
-compose '/' 'o' to 'ø'
-compose '`' 'U' to 'Ù'
-compose '`' 'u' to 'ù'
-compose '\'' 'U' to 'Ú'
-compose '\'' 'u' to 'ú'
-compose '^' 'U' to 'Û'
-compose '^' 'u' to 'û'
-compose '"' 'U' to 'Ü'
-compose '"' 'u' to 'ü'
-compose '\'' 'Y' to 'Ý'
-compose '\'' 'y' to 'ý'
-compose 'T' 'H' to 'Þ'
-compose 't' 'h' to 'þ'
-compose 's' 's' to 'ß'
-compose '"' 'y' to 'ÿ'
-compose 's' 'z' to 'ß'
-compose 'i' 'j' to 'ÿ'
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
deleted file mode 100644 (file)
index e95d787..0000000
+++ /dev/null
@@ -1,1454 +0,0 @@
-/*
- * linux/drivers/char/keyboard.c
- *
- * Written for linux by Johan Myreen as a translation from
- * the assembly version by Linus (with diacriticals added)
- *
- * Some additional features added by Christoph Niemann (ChN), March 1993
- *
- * Loadable keymaps by Risto Kankkunen, May 1993
- *
- * Diacriticals redone & other small changes, aeb@cwi.nl, June 1993
- * Added decr/incr_console, dynamic keymaps, Unicode support,
- * dynamic function/string keys, led setting,  Sept 1994
- * `Sticky' modifier keys, 951006.
- *
- * 11-11-96: SAK should now work in the raw mode (Martin Mares)
- *
- * Modified to provide 'generic' keyboard support by Hamish Macdonald
- * Merge with the m68k keyboard driver and split-off of the PC low-level
- * parts by Geert Uytterhoeven, May 1997
- *
- * 27-05-97: Added support for the Magic SysRq Key (Martin Mares)
- * 30-07-98: Dead keys redone, aeb@cwi.nl.
- * 21-08-02: Converted to input API, major cleanup. (Vojtech Pavlik)
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/consolemap.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/irq.h>
-
-#include <linux/kbd_kern.h>
-#include <linux/kbd_diacr.h>
-#include <linux/vt_kern.h>
-#include <linux/input.h>
-#include <linux/reboot.h>
-#include <linux/notifier.h>
-#include <linux/jiffies.h>
-
-extern void ctrl_alt_del(void);
-
-/*
- * Exported functions/variables
- */
-
-#define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
-
-/*
- * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
- * This seems a good reason to start with NumLock off. On HIL keyboards
- * of PARISC machines however there is no NumLock key and everyone expects the keypad
- * to be used for numbers.
- */
-
-#if defined(CONFIG_PARISC) && (defined(CONFIG_KEYBOARD_HIL) || defined(CONFIG_KEYBOARD_HIL_OLD))
-#define KBD_DEFLEDS (1 << VC_NUMLOCK)
-#else
-#define KBD_DEFLEDS 0
-#endif
-
-#define KBD_DEFLOCK 0
-
-void compute_shiftstate(void);
-
-/*
- * Handler Tables.
- */
-
-#define K_HANDLERS\
-       k_self,         k_fn,           k_spec,         k_pad,\
-       k_dead,         k_cons,         k_cur,          k_shift,\
-       k_meta,         k_ascii,        k_lock,         k_lowercase,\
-       k_slock,        k_dead2,        k_brl,          k_ignore
-
-typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value,
-                           char up_flag);
-static k_handler_fn K_HANDLERS;
-static k_handler_fn *k_handler[16] = { K_HANDLERS };
-
-#define FN_HANDLERS\
-       fn_null,        fn_enter,       fn_show_ptregs, fn_show_mem,\
-       fn_show_state,  fn_send_intr,   fn_lastcons,    fn_caps_toggle,\
-       fn_num,         fn_hold,        fn_scroll_forw, fn_scroll_back,\
-       fn_boot_it,     fn_caps_on,     fn_compose,     fn_SAK,\
-       fn_dec_console, fn_inc_console, fn_spawn_con,   fn_bare_num
-
-typedef void (fn_handler_fn)(struct vc_data *vc);
-static fn_handler_fn FN_HANDLERS;
-static fn_handler_fn *fn_handler[] = { FN_HANDLERS };
-
-/*
- * Variables exported for vt_ioctl.c
- */
-
-/* maximum values each key_handler can handle */
-const int max_vals[] = {
-       255, ARRAY_SIZE(func_table) - 1, ARRAY_SIZE(fn_handler) - 1, NR_PAD - 1,
-       NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1,
-       255, NR_LOCK - 1, 255, NR_BRL - 1
-};
-
-const int NR_TYPES = ARRAY_SIZE(max_vals);
-
-struct kbd_struct kbd_table[MAX_NR_CONSOLES];
-EXPORT_SYMBOL_GPL(kbd_table);
-static struct kbd_struct *kbd = kbd_table;
-
-struct vt_spawn_console vt_spawn_con = {
-       .lock = __SPIN_LOCK_UNLOCKED(vt_spawn_con.lock),
-       .pid  = NULL,
-       .sig  = 0,
-};
-
-/*
- * Variables exported for vt.c
- */
-
-int shift_state = 0;
-
-/*
- * Internal Data.
- */
-
-static struct input_handler kbd_handler;
-static DEFINE_SPINLOCK(kbd_event_lock);
-static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */
-static unsigned char shift_down[NR_SHIFT];             /* shift state counters.. */
-static bool dead_key_next;
-static int npadch = -1;                                        /* -1 or number assembled on pad */
-static unsigned int diacr;
-static char rep;                                       /* flag telling character repeat */
-
-static unsigned char ledstate = 0xff;                  /* undefined */
-static unsigned char ledioctl;
-
-static struct ledptr {
-       unsigned int *addr;
-       unsigned int mask;
-       unsigned char valid:1;
-} ledptrs[3];
-
-/*
- * Notifier list for console keyboard events
- */
-static ATOMIC_NOTIFIER_HEAD(keyboard_notifier_list);
-
-int register_keyboard_notifier(struct notifier_block *nb)
-{
-       return atomic_notifier_chain_register(&keyboard_notifier_list, nb);
-}
-EXPORT_SYMBOL_GPL(register_keyboard_notifier);
-
-int unregister_keyboard_notifier(struct notifier_block *nb)
-{
-       return atomic_notifier_chain_unregister(&keyboard_notifier_list, nb);
-}
-EXPORT_SYMBOL_GPL(unregister_keyboard_notifier);
-
-/*
- * Translation of scancodes to keycodes. We set them on only the first
- * keyboard in the list that accepts the scancode and keycode.
- * Explanation for not choosing the first attached keyboard anymore:
- *  USB keyboards for example have two event devices: one for all "normal"
- *  keys and one for extra function keys (like "volume up", "make coffee",
- *  etc.). So this means that scancodes for the extra function keys won't
- *  be valid for the first event device, but will be for the second.
- */
-
-struct getset_keycode_data {
-       struct input_keymap_entry ke;
-       int error;
-};
-
-static int getkeycode_helper(struct input_handle *handle, void *data)
-{
-       struct getset_keycode_data *d = data;
-
-       d->error = input_get_keycode(handle->dev, &d->ke);
-
-       return d->error == 0; /* stop as soon as we successfully get one */
-}
-
-int getkeycode(unsigned int scancode)
-{
-       struct getset_keycode_data d = {
-               .ke     = {
-                       .flags          = 0,
-                       .len            = sizeof(scancode),
-                       .keycode        = 0,
-               },
-               .error  = -ENODEV,
-       };
-
-       memcpy(d.ke.scancode, &scancode, sizeof(scancode));
-
-       input_handler_for_each_handle(&kbd_handler, &d, getkeycode_helper);
-
-       return d.error ?: d.ke.keycode;
-}
-
-static int setkeycode_helper(struct input_handle *handle, void *data)
-{
-       struct getset_keycode_data *d = data;
-
-       d->error = input_set_keycode(handle->dev, &d->ke);
-
-       return d->error == 0; /* stop as soon as we successfully set one */
-}
-
-int setkeycode(unsigned int scancode, unsigned int keycode)
-{
-       struct getset_keycode_data d = {
-               .ke     = {
-                       .flags          = 0,
-                       .len            = sizeof(scancode),
-                       .keycode        = keycode,
-               },
-               .error  = -ENODEV,
-       };
-
-       memcpy(d.ke.scancode, &scancode, sizeof(scancode));
-
-       input_handler_for_each_handle(&kbd_handler, &d, setkeycode_helper);
-
-       return d.error;
-}
-
-/*
- * Making beeps and bells. Note that we prefer beeps to bells, but when
- * shutting the sound off we do both.
- */
-
-static int kd_sound_helper(struct input_handle *handle, void *data)
-{
-       unsigned int *hz = data;
-       struct input_dev *dev = handle->dev;
-
-       if (test_bit(EV_SND, dev->evbit)) {
-               if (test_bit(SND_TONE, dev->sndbit)) {
-                       input_inject_event(handle, EV_SND, SND_TONE, *hz);
-                       if (*hz)
-                               return 0;
-               }
-               if (test_bit(SND_BELL, dev->sndbit))
-                       input_inject_event(handle, EV_SND, SND_BELL, *hz ? 1 : 0);
-       }
-
-       return 0;
-}
-
-static void kd_nosound(unsigned long ignored)
-{
-       static unsigned int zero;
-
-       input_handler_for_each_handle(&kbd_handler, &zero, kd_sound_helper);
-}
-
-static DEFINE_TIMER(kd_mksound_timer, kd_nosound, 0, 0);
-
-void kd_mksound(unsigned int hz, unsigned int ticks)
-{
-       del_timer_sync(&kd_mksound_timer);
-
-       input_handler_for_each_handle(&kbd_handler, &hz, kd_sound_helper);
-
-       if (hz && ticks)
-               mod_timer(&kd_mksound_timer, jiffies + ticks);
-}
-EXPORT_SYMBOL(kd_mksound);
-
-/*
- * Setting the keyboard rate.
- */
-
-static int kbd_rate_helper(struct input_handle *handle, void *data)
-{
-       struct input_dev *dev = handle->dev;
-       struct kbd_repeat *rep = data;
-
-       if (test_bit(EV_REP, dev->evbit)) {
-
-               if (rep[0].delay > 0)
-                       input_inject_event(handle,
-                                          EV_REP, REP_DELAY, rep[0].delay);
-               if (rep[0].period > 0)
-                       input_inject_event(handle,
-                                          EV_REP, REP_PERIOD, rep[0].period);
-
-               rep[1].delay = dev->rep[REP_DELAY];
-               rep[1].period = dev->rep[REP_PERIOD];
-       }
-
-       return 0;
-}
-
-int kbd_rate(struct kbd_repeat *rep)
-{
-       struct kbd_repeat data[2] = { *rep };
-
-       input_handler_for_each_handle(&kbd_handler, data, kbd_rate_helper);
-       *rep = data[1]; /* Copy currently used settings */
-
-       return 0;
-}
-
-/*
- * Helper Functions.
- */
-static void put_queue(struct vc_data *vc, int ch)
-{
-       struct tty_struct *tty = vc->port.tty;
-
-       if (tty) {
-               tty_insert_flip_char(tty, ch, 0);
-               con_schedule_flip(tty);
-       }
-}
-
-static void puts_queue(struct vc_data *vc, char *cp)
-{
-       struct tty_struct *tty = vc->port.tty;
-
-       if (!tty)
-               return;
-
-       while (*cp) {
-               tty_insert_flip_char(tty, *cp, 0);
-               cp++;
-       }
-       con_schedule_flip(tty);
-}
-
-static void applkey(struct vc_data *vc, int key, char mode)
-{
-       static char buf[] = { 0x1b, 'O', 0x00, 0x00 };
-
-       buf[1] = (mode ? 'O' : '[');
-       buf[2] = key;
-       puts_queue(vc, buf);
-}
-
-/*
- * Many other routines do put_queue, but I think either
- * they produce ASCII, or they produce some user-assigned
- * string, and in both cases we might assume that it is
- * in utf-8 already.
- */
-static void to_utf8(struct vc_data *vc, uint c)
-{
-       if (c < 0x80)
-               /*  0******* */
-               put_queue(vc, c);
-       else if (c < 0x800) {
-               /* 110***** 10****** */
-               put_queue(vc, 0xc0 | (c >> 6));
-               put_queue(vc, 0x80 | (c & 0x3f));
-       } else if (c < 0x10000) {
-               if (c >= 0xD800 && c < 0xE000)
-                       return;
-               if (c == 0xFFFF)
-                       return;
-               /* 1110**** 10****** 10****** */
-               put_queue(vc, 0xe0 | (c >> 12));
-               put_queue(vc, 0x80 | ((c >> 6) & 0x3f));
-               put_queue(vc, 0x80 | (c & 0x3f));
-       } else if (c < 0x110000) {
-               /* 11110*** 10****** 10****** 10****** */
-               put_queue(vc, 0xf0 | (c >> 18));
-               put_queue(vc, 0x80 | ((c >> 12) & 0x3f));
-               put_queue(vc, 0x80 | ((c >> 6) & 0x3f));
-               put_queue(vc, 0x80 | (c & 0x3f));
-       }
-}
-
-/*
- * Called after returning from RAW mode or when changing consoles - recompute
- * shift_down[] and shift_state from key_down[] maybe called when keymap is
- * undefined, so that shiftkey release is seen
- */
-void compute_shiftstate(void)
-{
-       unsigned int i, j, k, sym, val;
-
-       shift_state = 0;
-       memset(shift_down, 0, sizeof(shift_down));
-
-       for (i = 0; i < ARRAY_SIZE(key_down); i++) {
-
-               if (!key_down[i])
-                       continue;
-
-               k = i * BITS_PER_LONG;
-
-               for (j = 0; j < BITS_PER_LONG; j++, k++) {
-
-                       if (!test_bit(k, key_down))
-                               continue;
-
-                       sym = U(key_maps[0][k]);
-                       if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
-                               continue;
-
-                       val = KVAL(sym);
-                       if (val == KVAL(K_CAPSSHIFT))
-                               val = KVAL(K_SHIFT);
-
-                       shift_down[val]++;
-                       shift_state |= (1 << val);
-               }
-       }
-}
-
-/*
- * We have a combining character DIACR here, followed by the character CH.
- * If the combination occurs in the table, return the corresponding value.
- * Otherwise, if CH is a space or equals DIACR, return DIACR.
- * Otherwise, conclude that DIACR was not combining after all,
- * queue it and return CH.
- */
-static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
-{
-       unsigned int d = diacr;
-       unsigned int i;
-
-       diacr = 0;
-
-       if ((d & ~0xff) == BRL_UC_ROW) {
-               if ((ch & ~0xff) == BRL_UC_ROW)
-                       return d | ch;
-       } else {
-               for (i = 0; i < accent_table_size; i++)
-                       if (accent_table[i].diacr == d && accent_table[i].base == ch)
-                               return accent_table[i].result;
-       }
-
-       if (ch == ' ' || ch == (BRL_UC_ROW|0) || ch == d)
-               return d;
-
-       if (kbd->kbdmode == VC_UNICODE)
-               to_utf8(vc, d);
-       else {
-               int c = conv_uni_to_8bit(d);
-               if (c != -1)
-                       put_queue(vc, c);
-       }
-
-       return ch;
-}
-
-/*
- * Special function handlers
- */
-static void fn_enter(struct vc_data *vc)
-{
-       if (diacr) {
-               if (kbd->kbdmode == VC_UNICODE)
-                       to_utf8(vc, diacr);
-               else {
-                       int c = conv_uni_to_8bit(diacr);
-                       if (c != -1)
-                               put_queue(vc, c);
-               }
-               diacr = 0;
-       }
-
-       put_queue(vc, 13);
-       if (vc_kbd_mode(kbd, VC_CRLF))
-               put_queue(vc, 10);
-}
-
-static void fn_caps_toggle(struct vc_data *vc)
-{
-       if (rep)
-               return;
-
-       chg_vc_kbd_led(kbd, VC_CAPSLOCK);
-}
-
-static void fn_caps_on(struct vc_data *vc)
-{
-       if (rep)
-               return;
-
-       set_vc_kbd_led(kbd, VC_CAPSLOCK);
-}
-
-static void fn_show_ptregs(struct vc_data *vc)
-{
-       struct pt_regs *regs = get_irq_regs();
-
-       if (regs)
-               show_regs(regs);
-}
-
-static void fn_hold(struct vc_data *vc)
-{
-       struct tty_struct *tty = vc->port.tty;
-
-       if (rep || !tty)
-               return;
-
-       /*
-        * Note: SCROLLOCK will be set (cleared) by stop_tty (start_tty);
-        * these routines are also activated by ^S/^Q.
-        * (And SCROLLOCK can also be set by the ioctl KDSKBLED.)
-        */
-       if (tty->stopped)
-               start_tty(tty);
-       else
-               stop_tty(tty);
-}
-
-static void fn_num(struct vc_data *vc)
-{
-       if (vc_kbd_mode(kbd, VC_APPLIC))
-               applkey(vc, 'P', 1);
-       else
-               fn_bare_num(vc);
-}
-
-/*
- * Bind this to Shift-NumLock if you work in application keypad mode
- * but want to be able to change the NumLock flag.
- * Bind this to NumLock if you prefer that the NumLock key always
- * changes the NumLock flag.
- */
-static void fn_bare_num(struct vc_data *vc)
-{
-       if (!rep)
-               chg_vc_kbd_led(kbd, VC_NUMLOCK);
-}
-
-static void fn_lastcons(struct vc_data *vc)
-{
-       /* switch to the last used console, ChN */
-       set_console(last_console);
-}
-
-static void fn_dec_console(struct vc_data *vc)
-{
-       int i, cur = fg_console;
-
-       /* Currently switching?  Queue this next switch relative to that. */
-       if (want_console != -1)
-               cur = want_console;
-
-       for (i = cur - 1; i != cur; i--) {
-               if (i == -1)
-                       i = MAX_NR_CONSOLES - 1;
-               if (vc_cons_allocated(i))
-                       break;
-       }
-       set_console(i);
-}
-
-static void fn_inc_console(struct vc_data *vc)
-{
-       int i, cur = fg_console;
-
-       /* Currently switching?  Queue this next switch relative to that. */
-       if (want_console != -1)
-               cur = want_console;
-
-       for (i = cur+1; i != cur; i++) {
-               if (i == MAX_NR_CONSOLES)
-                       i = 0;
-               if (vc_cons_allocated(i))
-                       break;
-       }
-       set_console(i);
-}
-
-static void fn_send_intr(struct vc_data *vc)
-{
-       struct tty_struct *tty = vc->port.tty;
-
-       if (!tty)
-               return;
-       tty_insert_flip_char(tty, 0, TTY_BREAK);
-       con_schedule_flip(tty);
-}
-
-static void fn_scroll_forw(struct vc_data *vc)
-{
-       scrollfront(vc, 0);
-}
-
-static void fn_scroll_back(struct vc_data *vc)
-{
-       scrollback(vc, 0);
-}
-
-static void fn_show_mem(struct vc_data *vc)
-{
-       show_mem();
-}
-
-static void fn_show_state(struct vc_data *vc)
-{
-       show_state();
-}
-
-static void fn_boot_it(struct vc_data *vc)
-{
-       ctrl_alt_del();
-}
-
-static void fn_compose(struct vc_data *vc)
-{
-       dead_key_next = true;
-}
-
-static void fn_spawn_con(struct vc_data *vc)
-{
-       spin_lock(&vt_spawn_con.lock);
-       if (vt_spawn_con.pid)
-               if (kill_pid(vt_spawn_con.pid, vt_spawn_con.sig, 1)) {
-                       put_pid(vt_spawn_con.pid);
-                       vt_spawn_con.pid = NULL;
-               }
-       spin_unlock(&vt_spawn_con.lock);
-}
-
-static void fn_SAK(struct vc_data *vc)
-{
-       struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work;
-       schedule_work(SAK_work);
-}
-
-static void fn_null(struct vc_data *vc)
-{
-       compute_shiftstate();
-}
-
-/*
- * Special key handlers
- */
-static void k_ignore(struct vc_data *vc, unsigned char value, char up_flag)
-{
-}
-
-static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       if (up_flag)
-               return;
-       if (value >= ARRAY_SIZE(fn_handler))
-               return;
-       if ((kbd->kbdmode == VC_RAW ||
-            kbd->kbdmode == VC_MEDIUMRAW) &&
-            value != KVAL(K_SAK))
-               return;         /* SAK is allowed even in raw mode */
-       fn_handler[value](vc);
-}
-
-static void k_lowercase(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       pr_err("k_lowercase was called - impossible\n");
-}
-
-static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag)
-{
-       if (up_flag)
-               return;         /* no action, if this is a key release */
-
-       if (diacr)
-               value = handle_diacr(vc, value);
-
-       if (dead_key_next) {
-               dead_key_next = false;
-               diacr = value;
-               return;
-       }
-       if (kbd->kbdmode == VC_UNICODE)
-               to_utf8(vc, value);
-       else {
-               int c = conv_uni_to_8bit(value);
-               if (c != -1)
-                       put_queue(vc, c);
-       }
-}
-
-/*
- * Handle dead key. Note that we now may have several
- * dead keys modifying the same character. Very useful
- * for Vietnamese.
- */
-static void k_deadunicode(struct vc_data *vc, unsigned int value, char up_flag)
-{
-       if (up_flag)
-               return;
-
-       diacr = (diacr ? handle_diacr(vc, value) : value);
-}
-
-static void k_self(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       k_unicode(vc, conv_8bit_to_uni(value), up_flag);
-}
-
-static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       k_deadunicode(vc, value, up_flag);
-}
-
-/*
- * Obsolete - for backwards compatibility only
- */
-static void k_dead(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       static const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
-
-       k_deadunicode(vc, ret_diacr[value], up_flag);
-}
-
-static void k_cons(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       if (up_flag)
-               return;
-
-       set_console(value);
-}
-
-static void k_fn(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       if (up_flag)
-               return;
-
-       if ((unsigned)value < ARRAY_SIZE(func_table)) {
-               if (func_table[value])
-                       puts_queue(vc, func_table[value]);
-       } else
-               pr_err("k_fn called with value=%d\n", value);
-}
-
-static void k_cur(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       static const char cur_chars[] = "BDCA";
-
-       if (up_flag)
-               return;
-
-       applkey(vc, cur_chars[value], vc_kbd_mode(kbd, VC_CKMODE));
-}
-
-static void k_pad(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       static const char pad_chars[] = "0123456789+-*/\015,.?()#";
-       static const char app_map[] = "pqrstuvwxylSRQMnnmPQS";
-
-       if (up_flag)
-               return;         /* no action, if this is a key release */
-
-       /* kludge... shift forces cursor/number keys */
-       if (vc_kbd_mode(kbd, VC_APPLIC) && !shift_down[KG_SHIFT]) {
-               applkey(vc, app_map[value], 1);
-               return;
-       }
-
-       if (!vc_kbd_led(kbd, VC_NUMLOCK)) {
-
-               switch (value) {
-               case KVAL(K_PCOMMA):
-               case KVAL(K_PDOT):
-                       k_fn(vc, KVAL(K_REMOVE), 0);
-                       return;
-               case KVAL(K_P0):
-                       k_fn(vc, KVAL(K_INSERT), 0);
-                       return;
-               case KVAL(K_P1):
-                       k_fn(vc, KVAL(K_SELECT), 0);
-                       return;
-               case KVAL(K_P2):
-                       k_cur(vc, KVAL(K_DOWN), 0);
-                       return;
-               case KVAL(K_P3):
-                       k_fn(vc, KVAL(K_PGDN), 0);
-                       return;
-               case KVAL(K_P4):
-                       k_cur(vc, KVAL(K_LEFT), 0);
-                       return;
-               case KVAL(K_P6):
-                       k_cur(vc, KVAL(K_RIGHT), 0);
-                       return;
-               case KVAL(K_P7):
-                       k_fn(vc, KVAL(K_FIND), 0);
-                       return;
-               case KVAL(K_P8):
-                       k_cur(vc, KVAL(K_UP), 0);
-                       return;
-               case KVAL(K_P9):
-                       k_fn(vc, KVAL(K_PGUP), 0);
-                       return;
-               case KVAL(K_P5):
-                       applkey(vc, 'G', vc_kbd_mode(kbd, VC_APPLIC));
-                       return;
-               }
-       }
-
-       put_queue(vc, pad_chars[value]);
-       if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF))
-               put_queue(vc, 10);
-}
-
-static void k_shift(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       int old_state = shift_state;
-
-       if (rep)
-               return;
-       /*
-        * Mimic typewriter:
-        * a CapsShift key acts like Shift but undoes CapsLock
-        */
-       if (value == KVAL(K_CAPSSHIFT)) {
-               value = KVAL(K_SHIFT);
-               if (!up_flag)
-                       clr_vc_kbd_led(kbd, VC_CAPSLOCK);
-       }
-
-       if (up_flag) {
-               /*
-                * handle the case that two shift or control
-                * keys are depressed simultaneously
-                */
-               if (shift_down[value])
-                       shift_down[value]--;
-       } else
-               shift_down[value]++;
-
-       if (shift_down[value])
-               shift_state |= (1 << value);
-       else
-               shift_state &= ~(1 << value);
-
-       /* kludge */
-       if (up_flag && shift_state != old_state && npadch != -1) {
-               if (kbd->kbdmode == VC_UNICODE)
-                       to_utf8(vc, npadch);
-               else
-                       put_queue(vc, npadch & 0xff);
-               npadch = -1;
-       }
-}
-
-static void k_meta(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       if (up_flag)
-               return;
-
-       if (vc_kbd_mode(kbd, VC_META)) {
-               put_queue(vc, '\033');
-               put_queue(vc, value);
-       } else
-               put_queue(vc, value | 0x80);
-}
-
-static void k_ascii(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       int base;
-
-       if (up_flag)
-               return;
-
-       if (value < 10) {
-               /* decimal input of code, while Alt depressed */
-               base = 10;
-       } else {
-               /* hexadecimal input of code, while AltGr depressed */
-               value -= 10;
-               base = 16;
-       }
-
-       if (npadch == -1)
-               npadch = value;
-       else
-               npadch = npadch * base + value;
-}
-
-static void k_lock(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       if (up_flag || rep)
-               return;
-
-       chg_vc_kbd_lock(kbd, value);
-}
-
-static void k_slock(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       k_shift(vc, value, up_flag);
-       if (up_flag || rep)
-               return;
-
-       chg_vc_kbd_slock(kbd, value);
-       /* try to make Alt, oops, AltGr and such work */
-       if (!key_maps[kbd->lockstate ^ kbd->slockstate]) {
-               kbd->slockstate = 0;
-               chg_vc_kbd_slock(kbd, value);
-       }
-}
-
-/* by default, 300ms interval for combination release */
-static unsigned brl_timeout = 300;
-MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for commit on first key release)");
-module_param(brl_timeout, uint, 0644);
-
-static unsigned brl_nbchords = 1;
-MODULE_PARM_DESC(brl_nbchords, "Number of chords that produce a braille pattern (0 for dead chords)");
-module_param(brl_nbchords, uint, 0644);
-
-static void k_brlcommit(struct vc_data *vc, unsigned int pattern, char up_flag)
-{
-       static unsigned long chords;
-       static unsigned committed;
-
-       if (!brl_nbchords)
-               k_deadunicode(vc, BRL_UC_ROW | pattern, up_flag);
-       else {
-               committed |= pattern;
-               chords++;
-               if (chords == brl_nbchords) {
-                       k_unicode(vc, BRL_UC_ROW | committed, up_flag);
-                       chords = 0;
-                       committed = 0;
-               }
-       }
-}
-
-static void k_brl(struct vc_data *vc, unsigned char value, char up_flag)
-{
-       static unsigned pressed, committing;
-       static unsigned long releasestart;
-
-       if (kbd->kbdmode != VC_UNICODE) {
-               if (!up_flag)
-                       pr_warning("keyboard mode must be unicode for braille patterns\n");
-               return;
-       }
-
-       if (!value) {
-               k_unicode(vc, BRL_UC_ROW, up_flag);
-               return;
-       }
-
-       if (value > 8)
-               return;
-
-       if (!up_flag) {
-               pressed |= 1 << (value - 1);
-               if (!brl_timeout)
-                       committing = pressed;
-       } else if (brl_timeout) {
-               if (!committing ||
-                   time_after(jiffies,
-                              releasestart + msecs_to_jiffies(brl_timeout))) {
-                       committing = pressed;
-                       releasestart = jiffies;
-               }
-               pressed &= ~(1 << (value - 1));
-               if (!pressed && committing) {
-                       k_brlcommit(vc, committing, 0);
-                       committing = 0;
-               }
-       } else {
-               if (committing) {
-                       k_brlcommit(vc, committing, 0);
-                       committing = 0;
-               }
-               pressed &= ~(1 << (value - 1));
-       }
-}
-
-/*
- * The leds display either (i) the status of NumLock, CapsLock, ScrollLock,
- * or (ii) whatever pattern of lights people want to show using KDSETLED,
- * or (iii) specified bits of specified words in kernel memory.
- */
-unsigned char getledstate(void)
-{
-       return ledstate;
-}
-
-void setledstate(struct kbd_struct *kbd, unsigned int led)
-{
-       if (!(led & ~7)) {
-               ledioctl = led;
-               kbd->ledmode = LED_SHOW_IOCTL;
-       } else
-               kbd->ledmode = LED_SHOW_FLAGS;
-
-       set_leds();
-}
-
-static inline unsigned char getleds(void)
-{
-       struct kbd_struct *kbd = kbd_table + fg_console;
-       unsigned char leds;
-       int i;
-
-       if (kbd->ledmode == LED_SHOW_IOCTL)
-               return ledioctl;
-
-       leds = kbd->ledflagstate;
-
-       if (kbd->ledmode == LED_SHOW_MEM) {
-               for (i = 0; i < 3; i++)
-                       if (ledptrs[i].valid) {
-                               if (*ledptrs[i].addr & ledptrs[i].mask)
-                                       leds |= (1 << i);
-                               else
-                                       leds &= ~(1 << i);
-                       }
-       }
-       return leds;
-}
-
-static int kbd_update_leds_helper(struct input_handle *handle, void *data)
-{
-       unsigned char leds = *(unsigned char *)data;
-
-       if (test_bit(EV_LED, handle->dev->evbit)) {
-               input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
-               input_inject_event(handle, EV_LED, LED_NUML,    !!(leds & 0x02));
-               input_inject_event(handle, EV_LED, LED_CAPSL,   !!(leds & 0x04));
-               input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
-       }
-
-       return 0;
-}
-
-/*
- * This is the tasklet that updates LED state on all keyboards
- * attached to the box. The reason we use tasklet is that we
- * need to handle the scenario when keyboard handler is not
- * registered yet but we already getting updates form VT to
- * update led state.
- */
-static void kbd_bh(unsigned long dummy)
-{
-       unsigned char leds = getleds();
-
-       if (leds != ledstate) {
-               input_handler_for_each_handle(&kbd_handler, &leds,
-                                             kbd_update_leds_helper);
-               ledstate = leds;
-       }
-}
-
-DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
-
-#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
-    defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
-    defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
-    (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) ||\
-    defined(CONFIG_AVR32)
-
-#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
-                       ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
-
-static const unsigned short x86_keycodes[256] =
-       { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
-        16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
-        32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
-        48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-        64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-        80, 81, 82, 83, 84,118, 86, 87, 88,115,120,119,121,112,123, 92,
-       284,285,309,  0,312, 91,327,328,329,331,333,335,336,337,338,339,
-       367,288,302,304,350, 89,334,326,267,126,268,269,125,347,348,349,
-       360,261,262,263,268,376,100,101,321,316,373,286,289,102,351,355,
-       103,104,105,275,287,279,258,106,274,107,294,364,358,363,362,361,
-       291,108,381,281,290,272,292,305,280, 99,112,257,306,359,113,114,
-       264,117,271,374,379,265,266, 93, 94, 95, 85,259,375,260, 90,116,
-       377,109,111,277,278,282,283,295,296,297,299,300,301,293,303,307,
-       308,310,313,314,315,317,318,319,320,357,322,323,324,325,276,330,
-       332,340,365,342,343,344,345,346,356,270,341,368,369,370,371,372 };
-
-#ifdef CONFIG_SPARC
-static int sparc_l1_a_state;
-extern void sun_do_break(void);
-#endif
-
-static int emulate_raw(struct vc_data *vc, unsigned int keycode,
-                      unsigned char up_flag)
-{
-       int code;
-
-       switch (keycode) {
-
-       case KEY_PAUSE:
-               put_queue(vc, 0xe1);
-               put_queue(vc, 0x1d | up_flag);
-               put_queue(vc, 0x45 | up_flag);
-               break;
-
-       case KEY_HANGEUL:
-               if (!up_flag)
-                       put_queue(vc, 0xf2);
-               break;
-
-       case KEY_HANJA:
-               if (!up_flag)
-                       put_queue(vc, 0xf1);
-               break;
-
-       case KEY_SYSRQ:
-               /*
-                * Real AT keyboards (that's what we're trying
-                * to emulate here emit 0xe0 0x2a 0xe0 0x37 when
-                * pressing PrtSc/SysRq alone, but simply 0x54
-                * when pressing Alt+PrtSc/SysRq.
-                */
-               if (test_bit(KEY_LEFTALT, key_down) ||
-                   test_bit(KEY_RIGHTALT, key_down)) {
-                       put_queue(vc, 0x54 | up_flag);
-               } else {
-                       put_queue(vc, 0xe0);
-                       put_queue(vc, 0x2a | up_flag);
-                       put_queue(vc, 0xe0);
-                       put_queue(vc, 0x37 | up_flag);
-               }
-               break;
-
-       default:
-               if (keycode > 255)
-                       return -1;
-
-               code = x86_keycodes[keycode];
-               if (!code)
-                       return -1;
-
-               if (code & 0x100)
-                       put_queue(vc, 0xe0);
-               put_queue(vc, (code & 0x7f) | up_flag);
-
-               break;
-       }
-
-       return 0;
-}
-
-#else
-
-#define HW_RAW(dev)    0
-
-static int emulate_raw(struct vc_data *vc, unsigned int keycode, unsigned char up_flag)
-{
-       if (keycode > 127)
-               return -1;
-
-       put_queue(vc, keycode | up_flag);
-       return 0;
-}
-#endif
-
-static void kbd_rawcode(unsigned char data)
-{
-       struct vc_data *vc = vc_cons[fg_console].d;
-
-       kbd = kbd_table + vc->vc_num;
-       if (kbd->kbdmode == VC_RAW)
-               put_queue(vc, data);
-}
-
-static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
-{
-       struct vc_data *vc = vc_cons[fg_console].d;
-       unsigned short keysym, *key_map;
-       unsigned char type;
-       bool raw_mode;
-       struct tty_struct *tty;
-       int shift_final;
-       struct keyboard_notifier_param param = { .vc = vc, .value = keycode, .down = down };
-       int rc;
-
-       tty = vc->port.tty;
-
-       if (tty && (!tty->driver_data)) {
-               /* No driver data? Strange. Okay we fix it then. */
-               tty->driver_data = vc;
-       }
-
-       kbd = kbd_table + vc->vc_num;
-
-#ifdef CONFIG_SPARC
-       if (keycode == KEY_STOP)
-               sparc_l1_a_state = down;
-#endif
-
-       rep = (down == 2);
-
-       raw_mode = (kbd->kbdmode == VC_RAW);
-       if (raw_mode && !hw_raw)
-               if (emulate_raw(vc, keycode, !down << 7))
-                       if (keycode < BTN_MISC && printk_ratelimit())
-                               pr_warning("can't emulate rawmode for keycode %d\n",
-                                          keycode);
-
-#ifdef CONFIG_SPARC
-       if (keycode == KEY_A && sparc_l1_a_state) {
-               sparc_l1_a_state = false;
-               sun_do_break();
-       }
-#endif
-
-       if (kbd->kbdmode == VC_MEDIUMRAW) {
-               /*
-                * This is extended medium raw mode, with keys above 127
-                * encoded as 0, high 7 bits, low 7 bits, with the 0 bearing
-                * the 'up' flag if needed. 0 is reserved, so this shouldn't
-                * interfere with anything else. The two bytes after 0 will
-                * always have the up flag set not to interfere with older
-                * applications. This allows for 16384 different keycodes,
-                * which should be enough.
-                */
-               if (keycode < 128) {
-                       put_queue(vc, keycode | (!down << 7));
-               } else {
-                       put_queue(vc, !down << 7);
-                       put_queue(vc, (keycode >> 7) | 0x80);
-                       put_queue(vc, keycode | 0x80);
-               }
-               raw_mode = true;
-       }
-
-       if (down)
-               set_bit(keycode, key_down);
-       else
-               clear_bit(keycode, key_down);
-
-       if (rep &&
-           (!vc_kbd_mode(kbd, VC_REPEAT) ||
-            (tty && !L_ECHO(tty) && tty_chars_in_buffer(tty)))) {
-               /*
-                * Don't repeat a key if the input buffers are not empty and the
-                * characters get aren't echoed locally. This makes key repeat
-                * usable with slow applications and under heavy loads.
-                */
-               return;
-       }
-
-       param.shift = shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate;
-       param.ledstate = kbd->ledflagstate;
-       key_map = key_maps[shift_final];
-
-       rc = atomic_notifier_call_chain(&keyboard_notifier_list,
-                                       KBD_KEYCODE, &param);
-       if (rc == NOTIFY_STOP || !key_map) {
-               atomic_notifier_call_chain(&keyboard_notifier_list,
-                                          KBD_UNBOUND_KEYCODE, &param);
-               compute_shiftstate();
-               kbd->slockstate = 0;
-               return;
-       }
-
-       if (keycode < NR_KEYS)
-               keysym = key_map[keycode];
-       else if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
-               keysym = U(K(KT_BRL, keycode - KEY_BRL_DOT1 + 1));
-       else
-               return;
-
-       type = KTYP(keysym);
-
-       if (type < 0xf0) {
-               param.value = keysym;
-               rc = atomic_notifier_call_chain(&keyboard_notifier_list,
-                                               KBD_UNICODE, &param);
-               if (rc != NOTIFY_STOP)
-                       if (down && !raw_mode)
-                               to_utf8(vc, keysym);
-               return;
-       }
-
-       type -= 0xf0;
-
-       if (type == KT_LETTER) {
-               type = KT_LATIN;
-               if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
-                       key_map = key_maps[shift_final ^ (1 << KG_SHIFT)];
-                       if (key_map)
-                               keysym = key_map[keycode];
-               }
-       }
-
-       param.value = keysym;
-       rc = atomic_notifier_call_chain(&keyboard_notifier_list,
-                                       KBD_KEYSYM, &param);
-       if (rc == NOTIFY_STOP)
-               return;
-
-       if (raw_mode && type != KT_SPEC && type != KT_SHIFT)
-               return;
-
-       (*k_handler[type])(vc, keysym & 0xff, !down);
-
-       param.ledstate = kbd->ledflagstate;
-       atomic_notifier_call_chain(&keyboard_notifier_list, KBD_POST_KEYSYM, &param);
-
-       if (type != KT_SLOCK)
-               kbd->slockstate = 0;
-}
-
-static void kbd_event(struct input_handle *handle, unsigned int event_type,
-                     unsigned int event_code, int value)
-{
-       /* We are called with interrupts disabled, just take the lock */
-       spin_lock(&kbd_event_lock);
-
-       if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev))
-               kbd_rawcode(value);
-       if (event_type == EV_KEY)
-               kbd_keycode(event_code, value, HW_RAW(handle->dev));
-
-       spin_unlock(&kbd_event_lock);
-
-       tasklet_schedule(&keyboard_tasklet);
-       do_poke_blanked_console = 1;
-       schedule_console_callback();
-}
-
-static bool kbd_match(struct input_handler *handler, struct input_dev *dev)
-{
-       int i;
-
-       if (test_bit(EV_SND, dev->evbit))
-               return true;
-
-       if (test_bit(EV_KEY, dev->evbit)) {
-               for (i = KEY_RESERVED; i < BTN_MISC; i++)
-                       if (test_bit(i, dev->keybit))
-                               return true;
-               for (i = KEY_BRL_DOT1; i <= KEY_BRL_DOT10; i++)
-                       if (test_bit(i, dev->keybit))
-                               return true;
-       }
-
-       return false;
-}
-
-/*
- * When a keyboard (or other input device) is found, the kbd_connect
- * function is called. The function then looks at the device, and if it
- * likes it, it can open it and get events from it. In this (kbd_connect)
- * function, we should decide which VT to bind that keyboard to initially.
- */
-static int kbd_connect(struct input_handler *handler, struct input_dev *dev,
-                       const struct input_device_id *id)
-{
-       struct input_handle *handle;
-       int error;
-
-       handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
-       if (!handle)
-               return -ENOMEM;
-
-       handle->dev = dev;
-       handle->handler = handler;
-       handle->name = "kbd";
-
-       error = input_register_handle(handle);
-       if (error)
-               goto err_free_handle;
-
-       error = input_open_device(handle);
-       if (error)
-               goto err_unregister_handle;
-
-       return 0;
-
- err_unregister_handle:
-       input_unregister_handle(handle);
- err_free_handle:
-       kfree(handle);
-       return error;
-}
-
-static void kbd_disconnect(struct input_handle *handle)
-{
-       input_close_device(handle);
-       input_unregister_handle(handle);
-       kfree(handle);
-}
-
-/*
- * Start keyboard handler on the new keyboard by refreshing LED state to
- * match the rest of the system.
- */
-static void kbd_start(struct input_handle *handle)
-{
-       tasklet_disable(&keyboard_tasklet);
-
-       if (ledstate != 0xff)
-               kbd_update_leds_helper(handle, &ledstate);
-
-       tasklet_enable(&keyboard_tasklet);
-}
-
-static const struct input_device_id kbd_ids[] = {
-       {
-                .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
-                .evbit = { BIT_MASK(EV_KEY) },
-        },
-
-       {
-                .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
-                .evbit = { BIT_MASK(EV_SND) },
-        },
-
-       { },    /* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(input, kbd_ids);
-
-static struct input_handler kbd_handler = {
-       .event          = kbd_event,
-       .match          = kbd_match,
-       .connect        = kbd_connect,
-       .disconnect     = kbd_disconnect,
-       .start          = kbd_start,
-       .name           = "kbd",
-       .id_table       = kbd_ids,
-};
-
-int __init kbd_init(void)
-{
-       int i;
-       int error;
-
-        for (i = 0; i < MAX_NR_CONSOLES; i++) {
-               kbd_table[i].ledflagstate = KBD_DEFLEDS;
-               kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
-               kbd_table[i].ledmode = LED_SHOW_FLAGS;
-               kbd_table[i].lockstate = KBD_DEFLOCK;
-               kbd_table[i].slockstate = 0;
-               kbd_table[i].modeflags = KBD_DEFMODE;
-               kbd_table[i].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
-       }
-
-       error = input_register_handler(&kbd_handler);
-       if (error)
-               return error;
-
-       tasklet_enable(&keyboard_tasklet);
-       tasklet_schedule(&keyboard_tasklet);
-
-       return 0;
-}
diff --git a/drivers/char/n_gsm.c b/drivers/char/n_gsm.c
deleted file mode 100644 (file)
index 04ef3ef..0000000
+++ /dev/null
@@ -1,2763 +0,0 @@
-/*
- * n_gsm.c GSM 0710 tty multiplexor
- * Copyright (c) 2009/10 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *     * THIS IS A DEVELOPMENT SNAPSHOT IT IS NOT A FINAL RELEASE *
- *
- * TO DO:
- *     Mostly done:    ioctls for setting modes/timing
- *     Partly done:    hooks so you can pull off frames to non tty devs
- *     Restart DLCI 0 when it closes ?
- *     Test basic encoding
- *     Improve the tx engine
- *     Resolve tx side locking by adding a queue_head and routing
- *             all control traffic via it
- *     General tidy/document
- *     Review the locking/move to refcounts more (mux now moved to an
- *             alloc/free model ready)
- *     Use newest tty open/close port helpers and install hooks
- *     What to do about power functions ?
- *     Termios setting and negotiation
- *     Do we need a 'which mux are you' ioctl to correlate mux and tty sets
- *
- */
-
-#include <linux/types.h>
-#include <linux/major.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/fcntl.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/ctype.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/bitops.h>
-#include <linux/file.h>
-#include <linux/uaccess.h>
-#include <linux/module.h>
-#include <linux/timer.h>
-#include <linux/tty_flip.h>
-#include <linux/tty_driver.h>
-#include <linux/serial.h>
-#include <linux/kfifo.h>
-#include <linux/skbuff.h>
-#include <linux/gsmmux.h>
-
-static int debug;
-module_param(debug, int, 0600);
-
-#define T1     (HZ/10)
-#define T2     (HZ/3)
-#define N2     3
-
-/* Use long timers for testing at low speed with debug on */
-#ifdef DEBUG_TIMING
-#define T1     HZ
-#define T2     (2 * HZ)
-#endif
-
-/* Semi-arbitary buffer size limits. 0710 is normally run with 32-64 byte
-   limits so this is plenty */
-#define MAX_MRU 512
-#define MAX_MTU 512
-
-/*
- *     Each block of data we have queued to go out is in the form of
- *     a gsm_msg which holds everything we need in a link layer independant
- *     format
- */
-
-struct gsm_msg {
-       struct gsm_msg *next;
-       u8 addr;                /* DLCI address + flags */
-       u8 ctrl;                /* Control byte + flags */
-       unsigned int len;       /* Length of data block (can be zero) */
-       unsigned char *data;    /* Points into buffer but not at the start */
-       unsigned char buffer[0];
-};
-
-/*
- *     Each active data link has a gsm_dlci structure associated which ties
- *     the link layer to an optional tty (if the tty side is open). To avoid
- *     complexity right now these are only ever freed up when the mux is
- *     shut down.
- *
- *     At the moment we don't free DLCI objects until the mux is torn down
- *     this avoid object life time issues but might be worth review later.
- */
-
-struct gsm_dlci {
-       struct gsm_mux *gsm;
-       int addr;
-       int state;
-#define DLCI_CLOSED            0
-#define DLCI_OPENING           1       /* Sending SABM not seen UA */
-#define DLCI_OPEN              2       /* SABM/UA complete */
-#define DLCI_CLOSING           3       /* Sending DISC not seen UA/DM */
-
-       /* Link layer */
-       spinlock_t lock;        /* Protects the internal state */
-       struct timer_list t1;   /* Retransmit timer for SABM and UA */
-       int retries;
-       /* Uplink tty if active */
-       struct tty_port port;   /* The tty bound to this DLCI if there is one */
-       struct kfifo *fifo;     /* Queue fifo for the DLCI */
-       struct kfifo _fifo;     /* For new fifo API porting only */
-       int adaption;           /* Adaption layer in use */
-       u32 modem_rx;           /* Our incoming virtual modem lines */
-       u32 modem_tx;           /* Our outgoing modem lines */
-       int dead;               /* Refuse re-open */
-       /* Flow control */
-       int throttled;          /* Private copy of throttle state */
-       int constipated;        /* Throttle status for outgoing */
-       /* Packetised I/O */
-       struct sk_buff *skb;    /* Frame being sent */
-       struct sk_buff_head skb_list;   /* Queued frames */
-       /* Data handling callback */
-       void (*data)(struct gsm_dlci *dlci, u8 *data, int len);
-};
-
-/* DLCI 0, 62/63 are special or reseved see gsmtty_open */
-
-#define NUM_DLCI               64
-
-/*
- *     DLCI 0 is used to pass control blocks out of band of the data
- *     flow (and with a higher link priority). One command can be outstanding
- *     at a time and we use this structure to manage them. They are created
- *     and destroyed by the user context, and updated by the receive paths
- *     and timers
- */
-
-struct gsm_control {
-       u8 cmd;         /* Command we are issuing */
-       u8 *data;       /* Data for the command in case we retransmit */
-       int len;        /* Length of block for retransmission */
-       int done;       /* Done flag */
-       int error;      /* Error if any */
-};
-
-/*
- *     Each GSM mux we have is represented by this structure. If we are
- *     operating as an ldisc then we use this structure as our ldisc
- *     state. We need to sort out lifetimes and locking with respect
- *     to the gsm mux array. For now we don't free DLCI objects that
- *     have been instantiated until the mux itself is terminated.
- *
- *     To consider further: tty open versus mux shutdown.
- */
-
-struct gsm_mux {
-       struct tty_struct *tty;         /* The tty our ldisc is bound to */
-       spinlock_t lock;
-
-       /* Events on the GSM channel */
-       wait_queue_head_t event;
-
-       /* Bits for GSM mode decoding */
-
-       /* Framing Layer */
-       unsigned char *buf;
-       int state;
-#define GSM_SEARCH             0
-#define GSM_START              1
-#define GSM_ADDRESS            2
-#define GSM_CONTROL            3
-#define GSM_LEN                        4
-#define GSM_DATA               5
-#define GSM_FCS                        6
-#define GSM_OVERRUN            7
-       unsigned int len;
-       unsigned int address;
-       unsigned int count;
-       int escape;
-       int encoding;
-       u8 control;
-       u8 fcs;
-       u8 *txframe;                    /* TX framing buffer */
-
-       /* Methods for the receiver side */
-       void (*receive)(struct gsm_mux *gsm, u8 ch);
-       void (*error)(struct gsm_mux *gsm, u8 ch, u8 flag);
-       /* And transmit side */
-       int (*output)(struct gsm_mux *mux, u8 *data, int len);
-
-       /* Link Layer */
-       unsigned int mru;
-       unsigned int mtu;
-       int initiator;                  /* Did we initiate connection */
-       int dead;                       /* Has the mux been shut down */
-       struct gsm_dlci *dlci[NUM_DLCI];
-       int constipated;                /* Asked by remote to shut up */
-
-       spinlock_t tx_lock;
-       unsigned int tx_bytes;          /* TX data outstanding */
-#define TX_THRESH_HI           8192
-#define TX_THRESH_LO           2048
-       struct gsm_msg *tx_head;        /* Pending data packets */
-       struct gsm_msg *tx_tail;
-
-       /* Control messages */
-       struct timer_list t2_timer;     /* Retransmit timer for commands */
-       int cretries;                   /* Command retry counter */
-       struct gsm_control *pending_cmd;/* Our current pending command */
-       spinlock_t control_lock;        /* Protects the pending command */
-
-       /* Configuration */
-       int adaption;           /* 1 or 2 supported */
-       u8 ftype;               /* UI or UIH */
-       int t1, t2;             /* Timers in 1/100th of a sec */
-       int n2;                 /* Retry count */
-
-       /* Statistics (not currently exposed) */
-       unsigned long bad_fcs;
-       unsigned long malformed;
-       unsigned long io_error;
-       unsigned long bad_size;
-       unsigned long unsupported;
-};
-
-
-/*
- *     Mux objects - needed so that we can translate a tty index into the
- *     relevant mux and DLCI.
- */
-
-#define MAX_MUX                4                       /* 256 minors */
-static struct gsm_mux *gsm_mux[MAX_MUX];       /* GSM muxes */
-static spinlock_t gsm_mux_lock;
-
-/*
- *     This section of the driver logic implements the GSM encodings
- *     both the basic and the 'advanced'. Reliable transport is not
- *     supported.
- */
-
-#define CR                     0x02
-#define EA                     0x01
-#define        PF                      0x10
-
-/* I is special: the rest are ..*/
-#define RR                     0x01
-#define UI                     0x03
-#define RNR                    0x05
-#define REJ                    0x09
-#define DM                     0x0F
-#define SABM                   0x2F
-#define DISC                   0x43
-#define UA                     0x63
-#define        UIH                     0xEF
-
-/* Channel commands */
-#define CMD_NSC                        0x09
-#define CMD_TEST               0x11
-#define CMD_PSC                        0x21
-#define CMD_RLS                        0x29
-#define CMD_FCOFF              0x31
-#define CMD_PN                 0x41
-#define CMD_RPN                        0x49
-#define CMD_FCON               0x51
-#define CMD_CLD                        0x61
-#define CMD_SNC                        0x69
-#define CMD_MSC                        0x71
-
-/* Virtual modem bits */
-#define MDM_FC                 0x01
-#define MDM_RTC                        0x02
-#define MDM_RTR                        0x04
-#define MDM_IC                 0x20
-#define MDM_DV                 0x40
-
-#define GSM0_SOF               0xF9
-#define GSM1_SOF               0x7E
-#define GSM1_ESCAPE            0x7D
-#define GSM1_ESCAPE_BITS       0x20
-#define XON                    0x11
-#define XOFF                   0x13
-
-static const struct tty_port_operations gsm_port_ops;
-
-/*
- *     CRC table for GSM 0710
- */
-
-static const u8 gsm_fcs8[256] = {
-       0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75,
-       0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B,
-       0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69,
-       0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67,
-       0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D,
-       0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43,
-       0x24, 0xB5, 0xC7, 0x56, 0x23, 0xB2, 0xC0, 0x51,
-       0x2A, 0xBB, 0xC9, 0x58, 0x2D, 0xBC, 0xCE, 0x5F,
-       0x70, 0xE1, 0x93, 0x02, 0x77, 0xE6, 0x94, 0x05,
-       0x7E, 0xEF, 0x9D, 0x0C, 0x79, 0xE8, 0x9A, 0x0B,
-       0x6C, 0xFD, 0x8F, 0x1E, 0x6B, 0xFA, 0x88, 0x19,
-       0x62, 0xF3, 0x81, 0x10, 0x65, 0xF4, 0x86, 0x17,
-       0x48, 0xD9, 0xAB, 0x3A, 0x4F, 0xDE, 0xAC, 0x3D,
-       0x46, 0xD7, 0xA5, 0x34, 0x41, 0xD0, 0xA2, 0x33,
-       0x54, 0xC5, 0xB7, 0x26, 0x53, 0xC2, 0xB0, 0x21,
-       0x5A, 0xCB, 0xB9, 0x28, 0x5D, 0xCC, 0xBE, 0x2F,
-       0xE0, 0x71, 0x03, 0x92, 0xE7, 0x76, 0x04, 0x95,
-       0xEE, 0x7F, 0x0D, 0x9C, 0xE9, 0x78, 0x0A, 0x9B,
-       0xFC, 0x6D, 0x1F, 0x8E, 0xFB, 0x6A, 0x18, 0x89,
-       0xF2, 0x63, 0x11, 0x80, 0xF5, 0x64, 0x16, 0x87,
-       0xD8, 0x49, 0x3B, 0xAA, 0xDF, 0x4E, 0x3C, 0xAD,
-       0xD6, 0x47, 0x35, 0xA4, 0xD1, 0x40, 0x32, 0xA3,
-       0xC4, 0x55, 0x27, 0xB6, 0xC3, 0x52, 0x20, 0xB1,
-       0xCA, 0x5B, 0x29, 0xB8, 0xCD, 0x5C, 0x2E, 0xBF,
-       0x90, 0x01, 0x73, 0xE2, 0x97, 0x06, 0x74, 0xE5,
-       0x9E, 0x0F, 0x7D, 0xEC, 0x99, 0x08, 0x7A, 0xEB,
-       0x8C, 0x1D, 0x6F, 0xFE, 0x8B, 0x1A, 0x68, 0xF9,
-       0x82, 0x13, 0x61, 0xF0, 0x85, 0x14, 0x66, 0xF7,
-       0xA8, 0x39, 0x4B, 0xDA, 0xAF, 0x3E, 0x4C, 0xDD,
-       0xA6, 0x37, 0x45, 0xD4, 0xA1, 0x30, 0x42, 0xD3,
-       0xB4, 0x25, 0x57, 0xC6, 0xB3, 0x22, 0x50, 0xC1,
-       0xBA, 0x2B, 0x59, 0xC8, 0xBD, 0x2C, 0x5E, 0xCF
-};
-
-#define INIT_FCS       0xFF
-#define GOOD_FCS       0xCF
-
-/**
- *     gsm_fcs_add     -       update FCS
- *     @fcs: Current FCS
- *     @c: Next data
- *
- *     Update the FCS to include c. Uses the algorithm in the specification
- *     notes.
- */
-
-static inline u8 gsm_fcs_add(u8 fcs, u8 c)
-{
-       return gsm_fcs8[fcs ^ c];
-}
-
-/**
- *     gsm_fcs_add_block       -       update FCS for a block
- *     @fcs: Current FCS
- *     @c: buffer of data
- *     @len: length of buffer
- *
- *     Update the FCS to include c. Uses the algorithm in the specification
- *     notes.
- */
-
-static inline u8 gsm_fcs_add_block(u8 fcs, u8 *c, int len)
-{
-       while (len--)
-               fcs = gsm_fcs8[fcs ^ *c++];
-       return fcs;
-}
-
-/**
- *     gsm_read_ea             -       read a byte into an EA
- *     @val: variable holding value
- *     c: byte going into the EA
- *
- *     Processes one byte of an EA. Updates the passed variable
- *     and returns 1 if the EA is now completely read
- */
-
-static int gsm_read_ea(unsigned int *val, u8 c)
-{
-       /* Add the next 7 bits into the value */
-       *val <<= 7;
-       *val |= c >> 1;
-       /* Was this the last byte of the EA 1 = yes*/
-       return c & EA;
-}
-
-/**
- *     gsm_encode_modem        -       encode modem data bits
- *     @dlci: DLCI to encode from
- *
- *     Returns the correct GSM encoded modem status bits (6 bit field) for
- *     the current status of the DLCI and attached tty object
- */
-
-static u8 gsm_encode_modem(const struct gsm_dlci *dlci)
-{
-       u8 modembits = 0;
-       /* FC is true flow control not modem bits */
-       if (dlci->throttled)
-               modembits |= MDM_FC;
-       if (dlci->modem_tx & TIOCM_DTR)
-               modembits |= MDM_RTC;
-       if (dlci->modem_tx & TIOCM_RTS)
-               modembits |= MDM_RTR;
-       if (dlci->modem_tx & TIOCM_RI)
-               modembits |= MDM_IC;
-       if (dlci->modem_tx & TIOCM_CD)
-               modembits |= MDM_DV;
-       return modembits;
-}
-
-/**
- *     gsm_print_packet        -       display a frame for debug
- *     @hdr: header to print before decode
- *     @addr: address EA from the frame
- *     @cr: C/R bit from the frame
- *     @control: control including PF bit
- *     @data: following data bytes
- *     @dlen: length of data
- *
- *     Displays a packet in human readable format for debugging purposes. The
- *     style is based on amateur radio LAP-B dump display.
- */
-
-static void gsm_print_packet(const char *hdr, int addr, int cr,
-                                       u8 control, const u8 *data, int dlen)
-{
-       if (!(debug & 1))
-               return;
-
-       printk(KERN_INFO "%s %d) %c: ", hdr, addr, "RC"[cr]);
-
-       switch (control & ~PF) {
-       case SABM:
-               printk(KERN_CONT "SABM");
-               break;
-       case UA:
-               printk(KERN_CONT "UA");
-               break;
-       case DISC:
-               printk(KERN_CONT "DISC");
-               break;
-       case DM:
-               printk(KERN_CONT "DM");
-               break;
-       case UI:
-               printk(KERN_CONT "UI");
-               break;
-       case UIH:
-               printk(KERN_CONT "UIH");
-               break;
-       default:
-               if (!(control & 0x01)) {
-                       printk(KERN_CONT "I N(S)%d N(R)%d",
-                               (control & 0x0E) >> 1, (control & 0xE)>> 5);
-               } else switch (control & 0x0F) {
-               case RR:
-                       printk("RR(%d)", (control & 0xE0) >> 5);
-                       break;
-               case RNR:
-                       printk("RNR(%d)", (control & 0xE0) >> 5);
-                       break;
-               case REJ:
-                       printk("REJ(%d)", (control & 0xE0) >> 5);
-                       break;
-               default:
-                       printk(KERN_CONT "[%02X]", control);
-               }
-       }
-
-       if (control & PF)
-               printk(KERN_CONT "(P)");
-       else
-               printk(KERN_CONT "(F)");
-
-       if (dlen) {
-               int ct = 0;
-               while (dlen--) {
-                       if (ct % 8 == 0)
-                               printk(KERN_CONT "\n    ");
-                       printk(KERN_CONT "%02X ", *data++);
-                       ct++;
-               }
-       }
-       printk(KERN_CONT "\n");
-}
-
-
-/*
- *     Link level transmission side
- */
-
-/**
- *     gsm_stuff_packet        -       bytestuff a packet
- *     @ibuf: input
- *     @obuf: output
- *     @len: length of input
- *
- *     Expand a buffer by bytestuffing it. The worst case size change
- *     is doubling and the caller is responsible for handing out
- *     suitable sized buffers.
- */
-
-static int gsm_stuff_frame(const u8 *input, u8 *output, int len)
-{
-       int olen = 0;
-       while (len--) {
-               if (*input == GSM1_SOF || *input == GSM1_ESCAPE
-                   || *input == XON || *input == XOFF) {
-                       *output++ = GSM1_ESCAPE;
-                       *output++ = *input++ ^ GSM1_ESCAPE_BITS;
-                       olen++;
-               } else
-                       *output++ = *input++;
-               olen++;
-       }
-       return olen;
-}
-
-static void hex_packet(const unsigned char *p, int len)
-{
-       int i;
-       for (i = 0; i < len; i++) {
-               if (i && (i % 16) == 0)
-                       printk("\n");
-               printk("%02X ", *p++);
-       }
-       printk("\n");
-}
-
-/**
- *     gsm_send        -       send a control frame
- *     @gsm: our GSM mux
- *     @addr: address for control frame
- *     @cr: command/response bit
- *     @control:  control byte including PF bit
- *
- *     Format up and transmit a control frame. These do not go via the
- *     queueing logic as they should be transmitted ahead of data when
- *     they are needed.
- *
- *     FIXME: Lock versus data TX path
- */
-
-static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
-{
-       int len;
-       u8 cbuf[10];
-       u8 ibuf[3];
-
-       switch (gsm->encoding) {
-       case 0:
-               cbuf[0] = GSM0_SOF;
-               cbuf[1] = (addr << 2) | (cr << 1) | EA;
-               cbuf[2] = control;
-               cbuf[3] = EA;   /* Length of data = 0 */
-               cbuf[4] = 0xFF - gsm_fcs_add_block(INIT_FCS, cbuf + 1, 3);
-               cbuf[5] = GSM0_SOF;
-               len = 6;
-               break;
-       case 1:
-       case 2:
-               /* Control frame + packing (but not frame stuffing) in mode 1 */
-               ibuf[0] = (addr << 2) | (cr << 1) | EA;
-               ibuf[1] = control;
-               ibuf[2] = 0xFF - gsm_fcs_add_block(INIT_FCS, ibuf, 2);
-               /* Stuffing may double the size worst case */
-               len = gsm_stuff_frame(ibuf, cbuf + 1, 3);
-               /* Now add the SOF markers */
-               cbuf[0] = GSM1_SOF;
-               cbuf[len + 1] = GSM1_SOF;
-               /* FIXME: we can omit the lead one in many cases */
-               len += 2;
-               break;
-       default:
-               WARN_ON(1);
-               return;
-       }
-       gsm->output(gsm, cbuf, len);
-       gsm_print_packet("-->", addr, cr, control, NULL, 0);
-}
-
-/**
- *     gsm_response    -       send a control response
- *     @gsm: our GSM mux
- *     @addr: address for control frame
- *     @control:  control byte including PF bit
- *
- *     Format up and transmit a link level response frame.
- */
-
-static inline void gsm_response(struct gsm_mux *gsm, int addr, int control)
-{
-       gsm_send(gsm, addr, 0, control);
-}
-
-/**
- *     gsm_command     -       send a control command
- *     @gsm: our GSM mux
- *     @addr: address for control frame
- *     @control:  control byte including PF bit
- *
- *     Format up and transmit a link level command frame.
- */
-
-static inline void gsm_command(struct gsm_mux *gsm, int addr, int control)
-{
-       gsm_send(gsm, addr, 1, control);
-}
-
-/* Data transmission */
-
-#define HDR_LEN                6       /* ADDR CTRL [LEN.2] DATA FCS */
-
-/**
- *     gsm_data_alloc          -       allocate data frame
- *     @gsm: GSM mux
- *     @addr: DLCI address
- *     @len: length excluding header and FCS
- *     @ctrl: control byte
- *
- *     Allocate a new data buffer for sending frames with data. Space is left
- *     at the front for header bytes but that is treated as an implementation
- *     detail and not for the high level code to use
- */
-
-static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
-                                                               u8 ctrl)
-{
-       struct gsm_msg *m = kmalloc(sizeof(struct gsm_msg) + len + HDR_LEN,
-                                                               GFP_ATOMIC);
-       if (m == NULL)
-               return NULL;
-       m->data = m->buffer + HDR_LEN - 1;      /* Allow for FCS */
-       m->len = len;
-       m->addr = addr;
-       m->ctrl = ctrl;
-       m->next = NULL;
-       return m;
-}
-
-/**
- *     gsm_data_kick           -       poke the queue
- *     @gsm: GSM Mux
- *
- *     The tty device has called us to indicate that room has appeared in
- *     the transmit queue. Ram more data into the pipe if we have any
- *
- *     FIXME: lock against link layer control transmissions
- */
-
-static void gsm_data_kick(struct gsm_mux *gsm)
-{
-       struct gsm_msg *msg = gsm->tx_head;
-       int len;
-       int skip_sof = 0;
-
-       /* FIXME: We need to apply this solely to data messages */
-       if (gsm->constipated)
-               return;
-
-       while (gsm->tx_head != NULL) {
-               msg = gsm->tx_head;
-               if (gsm->encoding != 0) {
-                       gsm->txframe[0] = GSM1_SOF;
-                       len = gsm_stuff_frame(msg->data,
-                                               gsm->txframe + 1, msg->len);
-                       gsm->txframe[len + 1] = GSM1_SOF;
-                       len += 2;
-               } else {
-                       gsm->txframe[0] = GSM0_SOF;
-                       memcpy(gsm->txframe + 1 , msg->data, msg->len);
-                       gsm->txframe[msg->len + 1] = GSM0_SOF;
-                       len = msg->len + 2;
-               }
-
-               if (debug & 4) {
-                       printk("gsm_data_kick: \n");
-                       hex_packet(gsm->txframe, len);
-               }
-
-               if (gsm->output(gsm, gsm->txframe + skip_sof,
-                                               len - skip_sof) < 0)
-                       break;
-               /* FIXME: Can eliminate one SOF in many more cases */
-               gsm->tx_head = msg->next;
-               if (gsm->tx_head == NULL)
-                       gsm->tx_tail = NULL;
-               gsm->tx_bytes -= msg->len;
-               kfree(msg);
-               /* For a burst of frames skip the extra SOF within the
-                  burst */
-               skip_sof = 1;
-       }
-}
-
-/**
- *     __gsm_data_queue                -       queue a UI or UIH frame
- *     @dlci: DLCI sending the data
- *     @msg: message queued
- *
- *     Add data to the transmit queue and try and get stuff moving
- *     out of the mux tty if not already doing so. The Caller must hold
- *     the gsm tx lock.
- */
-
-static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
-{
-       struct gsm_mux *gsm = dlci->gsm;
-       u8 *dp = msg->data;
-       u8 *fcs = dp + msg->len;
-
-       /* Fill in the header */
-       if (gsm->encoding == 0) {
-               if (msg->len < 128)
-                       *--dp = (msg->len << 1) | EA;
-               else {
-                       *--dp = (msg->len >> 6) | EA;
-                       *--dp = (msg->len & 127) << 1;
-               }
-       }
-
-       *--dp = msg->ctrl;
-       if (gsm->initiator)
-               *--dp = (msg->addr << 2) | 2 | EA;
-       else
-               *--dp = (msg->addr << 2) | EA;
-       *fcs = gsm_fcs_add_block(INIT_FCS, dp , msg->data - dp);
-       /* Ugly protocol layering violation */
-       if (msg->ctrl == UI || msg->ctrl == (UI|PF))
-               *fcs = gsm_fcs_add_block(*fcs, msg->data, msg->len);
-       *fcs = 0xFF - *fcs;
-
-       gsm_print_packet("Q> ", msg->addr, gsm->initiator, msg->ctrl,
-                                                       msg->data, msg->len);
-
-       /* Move the header back and adjust the length, also allow for the FCS
-          now tacked on the end */
-       msg->len += (msg->data - dp) + 1;
-       msg->data = dp;
-
-       /* Add to the actual output queue */
-       if (gsm->tx_tail)
-               gsm->tx_tail->next = msg;
-       else
-               gsm->tx_head = msg;
-       gsm->tx_tail = msg;
-       gsm->tx_bytes += msg->len;
-       gsm_data_kick(gsm);
-}
-
-/**
- *     gsm_data_queue          -       queue a UI or UIH frame
- *     @dlci: DLCI sending the data
- *     @msg: message queued
- *
- *     Add data to the transmit queue and try and get stuff moving
- *     out of the mux tty if not already doing so. Take the
- *     the gsm tx lock and dlci lock.
- */
-
-static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
-       __gsm_data_queue(dlci, msg);
-       spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
-}
-
-/**
- *     gsm_dlci_data_output    -       try and push data out of a DLCI
- *     @gsm: mux
- *     @dlci: the DLCI to pull data from
- *
- *     Pull data from a DLCI and send it into the transmit queue if there
- *     is data. Keep to the MRU of the mux. This path handles the usual tty
- *     interface which is a byte stream with optional modem data.
- *
- *     Caller must hold the tx_lock of the mux.
- */
-
-static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
-{
-       struct gsm_msg *msg;
-       u8 *dp;
-       int len, size;
-       int h = dlci->adaption - 1;
-
-       len = kfifo_len(dlci->fifo);
-       if (len == 0)
-               return 0;
-
-       /* MTU/MRU count only the data bits */
-       if (len > gsm->mtu)
-               len = gsm->mtu;
-
-       size = len + h;
-
-       msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
-       /* FIXME: need a timer or something to kick this so it can't
-          get stuck with no work outstanding and no buffer free */
-       if (msg == NULL)
-               return -ENOMEM;
-       dp = msg->data;
-       switch (dlci->adaption) {
-       case 1: /* Unstructured */
-               break;
-       case 2: /* Unstructed with modem bits. Always one byte as we never
-                  send inline break data */
-               *dp += gsm_encode_modem(dlci);
-               len--;
-               break;
-       }
-       WARN_ON(kfifo_out_locked(dlci->fifo, dp , len, &dlci->lock) != len);
-       __gsm_data_queue(dlci, msg);
-       /* Bytes of data we used up */
-       return size;
-}
-
-/**
- *     gsm_dlci_data_output_framed  -  try and push data out of a DLCI
- *     @gsm: mux
- *     @dlci: the DLCI to pull data from
- *
- *     Pull data from a DLCI and send it into the transmit queue if there
- *     is data. Keep to the MRU of the mux. This path handles framed data
- *     queued as skbuffs to the DLCI.
- *
- *     Caller must hold the tx_lock of the mux.
- */
-
-static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
-                                               struct gsm_dlci *dlci)
-{
-       struct gsm_msg *msg;
-       u8 *dp;
-       int len, size;
-       int last = 0, first = 0;
-       int overhead = 0;
-
-       /* One byte per frame is used for B/F flags */
-       if (dlci->adaption == 4)
-               overhead = 1;
-
-       /* dlci->skb is locked by tx_lock */
-       if (dlci->skb == NULL) {
-               dlci->skb = skb_dequeue(&dlci->skb_list);
-               if (dlci->skb == NULL)
-                       return 0;
-               first = 1;
-       }
-       len = dlci->skb->len + overhead;
-
-       /* MTU/MRU count only the data bits */
-       if (len > gsm->mtu) {
-               if (dlci->adaption == 3) {
-                       /* Over long frame, bin it */
-                       kfree_skb(dlci->skb);
-                       dlci->skb = NULL;
-                       return 0;
-               }
-               len = gsm->mtu;
-       } else
-               last = 1;
-
-       size = len + overhead;
-       msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
-
-       /* FIXME: need a timer or something to kick this so it can't
-          get stuck with no work outstanding and no buffer free */
-       if (msg == NULL)
-               return -ENOMEM;
-       dp = msg->data;
-
-       if (dlci->adaption == 4) { /* Interruptible framed (Packetised Data) */
-               /* Flag byte to carry the start/end info */
-               *dp++ = last << 7 | first << 6 | 1;     /* EA */
-               len--;
-       }
-       memcpy(dp, skb_pull(dlci->skb, len), len);
-       __gsm_data_queue(dlci, msg);
-       if (last)
-               dlci->skb = NULL;
-       return size;
-}
-
-/**
- *     gsm_dlci_data_sweep             -       look for data to send
- *     @gsm: the GSM mux
- *
- *     Sweep the GSM mux channels in priority order looking for ones with
- *     data to send. We could do with optimising this scan a bit. We aim
- *     to fill the queue totally or up to TX_THRESH_HI bytes. Once we hit
- *     TX_THRESH_LO we get called again
- *
- *     FIXME: We should round robin between groups and in theory you can
- *     renegotiate DLCI priorities with optional stuff. Needs optimising.
- */
-
-static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
-{
-       int len;
-       /* Priority ordering: We should do priority with RR of the groups */
-       int i = 1;
-
-       while (i < NUM_DLCI) {
-               struct gsm_dlci *dlci;
-
-               if (gsm->tx_bytes > TX_THRESH_HI)
-                       break;
-               dlci = gsm->dlci[i];
-               if (dlci == NULL || dlci->constipated) {
-                       i++;
-                       continue;
-               }
-               if (dlci->adaption < 3)
-                       len = gsm_dlci_data_output(gsm, dlci);
-               else
-                       len = gsm_dlci_data_output_framed(gsm, dlci);
-               if (len < 0)
-                       break;
-               /* DLCI empty - try the next */
-               if (len == 0)
-                       i++;
-       }
-}
-
-/**
- *     gsm_dlci_data_kick      -       transmit if possible
- *     @dlci: DLCI to kick
- *
- *     Transmit data from this DLCI if the queue is empty. We can't rely on
- *     a tty wakeup except when we filled the pipe so we need to fire off
- *     new data ourselves in other cases.
- */
-
-static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
-       /* If we have nothing running then we need to fire up */
-       if (dlci->gsm->tx_bytes == 0)
-               gsm_dlci_data_output(dlci->gsm, dlci);
-       else if (dlci->gsm->tx_bytes < TX_THRESH_LO)
-               gsm_dlci_data_sweep(dlci->gsm);
-       spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
-}
-
-/*
- *     Control message processing
- */
-
-
-/**
- *     gsm_control_reply       -       send a response frame to a control
- *     @gsm: gsm channel
- *     @cmd: the command to use
- *     @data: data to follow encoded info
- *     @dlen: length of data
- *
- *     Encode up and queue a UI/UIH frame containing our response.
- */
-
-static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data,
-                                       int dlen)
-{
-       struct gsm_msg *msg;
-       msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype);
-       msg->data[0] = (cmd & 0xFE) << 1 | EA;  /* Clear C/R */
-       msg->data[1] = (dlen << 1) | EA;
-       memcpy(msg->data + 2, data, dlen);
-       gsm_data_queue(gsm->dlci[0], msg);
-}
-
-/**
- *     gsm_process_modem       -       process received modem status
- *     @tty: virtual tty bound to the DLCI
- *     @dlci: DLCI to affect
- *     @modem: modem bits (full EA)
- *
- *     Used when a modem control message or line state inline in adaption
- *     layer 2 is processed. Sort out the local modem state and throttles
- */
-
-static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
-                                                       u32 modem)
-{
-       int  mlines = 0;
-       u8 brk = modem >> 6;
-
-       /* Flow control/ready to communicate */
-       if (modem & MDM_FC) {
-               /* Need to throttle our output on this device */
-               dlci->constipated = 1;
-       }
-       if (modem & MDM_RTC) {
-               mlines |= TIOCM_DSR | TIOCM_DTR;
-               dlci->constipated = 0;
-               gsm_dlci_data_kick(dlci);
-       }
-       /* Map modem bits */
-       if (modem & MDM_RTR)
-               mlines |= TIOCM_RTS | TIOCM_CTS;
-       if (modem & MDM_IC)
-               mlines |= TIOCM_RI;
-       if (modem & MDM_DV)
-               mlines |= TIOCM_CD;
-
-       /* Carrier drop -> hangup */
-       if (tty) {
-               if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD))
-                       if (!(tty->termios->c_cflag & CLOCAL))
-                               tty_hangup(tty);
-               if (brk & 0x01)
-                       tty_insert_flip_char(tty, 0, TTY_BREAK);
-       }
-       dlci->modem_rx = mlines;
-}
-
-/**
- *     gsm_control_modem       -       modem status received
- *     @gsm: GSM channel
- *     @data: data following command
- *     @clen: command length
- *
- *     We have received a modem status control message. This is used by
- *     the GSM mux protocol to pass virtual modem line status and optionally
- *     to indicate break signals. Unpack it, convert to Linux representation
- *     and if need be stuff a break message down the tty.
- */
-
-static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen)
-{
-       unsigned int addr = 0;
-       unsigned int modem = 0;
-       struct gsm_dlci *dlci;
-       int len = clen;
-       u8 *dp = data;
-       struct tty_struct *tty;
-
-       while (gsm_read_ea(&addr, *dp++) == 0) {
-               len--;
-               if (len == 0)
-                       return;
-       }
-       /* Must be at least one byte following the EA */
-       len--;
-       if (len <= 0)
-               return;
-
-       addr >>= 1;
-       /* Closed port, or invalid ? */
-       if (addr == 0 || addr >= NUM_DLCI || gsm->dlci[addr] == NULL)
-               return;
-       dlci = gsm->dlci[addr];
-
-       while (gsm_read_ea(&modem, *dp++) == 0) {
-               len--;
-               if (len == 0)
-                       return;
-       }
-       tty = tty_port_tty_get(&dlci->port);
-       gsm_process_modem(tty, dlci, modem);
-       if (tty) {
-               tty_wakeup(tty);
-               tty_kref_put(tty);
-       }
-       gsm_control_reply(gsm, CMD_MSC, data, clen);
-}
-
-/**
- *     gsm_control_rls         -       remote line status
- *     @gsm: GSM channel
- *     @data: data bytes
- *     @clen: data length
- *
- *     The modem sends us a two byte message on the control channel whenever
- *     it wishes to send us an error state from the virtual link. Stuff
- *     this into the uplink tty if present
- */
-
-static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen)
-{
-       struct tty_struct *tty;
-       unsigned int addr = 0 ;
-       u8 bits;
-       int len = clen;
-       u8 *dp = data;
-
-       while (gsm_read_ea(&addr, *dp++) == 0) {
-               len--;
-               if (len == 0)
-                       return;
-       }
-       /* Must be at least one byte following ea */
-       len--;
-       if (len <= 0)
-               return;
-       addr >>= 1;
-       /* Closed port, or invalid ? */
-       if (addr == 0 || addr >= NUM_DLCI || gsm->dlci[addr] == NULL)
-               return;
-       /* No error ? */
-       bits = *dp;
-       if ((bits & 1) == 0)
-               return;
-       /* See if we have an uplink tty */
-       tty = tty_port_tty_get(&gsm->dlci[addr]->port);
-
-       if (tty) {
-               if (bits & 2)
-                       tty_insert_flip_char(tty, 0, TTY_OVERRUN);
-               if (bits & 4)
-                       tty_insert_flip_char(tty, 0, TTY_PARITY);
-               if (bits & 8)
-                       tty_insert_flip_char(tty, 0, TTY_FRAME);
-               tty_flip_buffer_push(tty);
-               tty_kref_put(tty);
-       }
-       gsm_control_reply(gsm, CMD_RLS, data, clen);
-}
-
-static void gsm_dlci_begin_close(struct gsm_dlci *dlci);
-
-/**
- *     gsm_control_message     -       DLCI 0 control processing
- *     @gsm: our GSM mux
- *     @command:  the command EA
- *     @data: data beyond the command/length EAs
- *     @clen: length
- *
- *     Input processor for control messages from the other end of the link.
- *     Processes the incoming request and queues a response frame or an
- *     NSC response if not supported
- */
-
-static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
-                                                       u8 *data, int clen)
-{
-       u8 buf[1];
-       switch (command) {
-       case CMD_CLD: {
-               struct gsm_dlci *dlci = gsm->dlci[0];
-               /* Modem wishes to close down */
-               if (dlci) {
-                       dlci->dead = 1;
-                       gsm->dead = 1;
-                       gsm_dlci_begin_close(dlci);
-               }
-               }
-               break;
-       case CMD_TEST:
-               /* Modem wishes to test, reply with the data */
-               gsm_control_reply(gsm, CMD_TEST, data, clen);
-               break;
-       case CMD_FCON:
-               /* Modem wants us to STFU */
-               gsm->constipated = 1;
-               gsm_control_reply(gsm, CMD_FCON, NULL, 0);
-               break;
-       case CMD_FCOFF:
-               /* Modem can accept data again */
-               gsm->constipated = 0;
-               gsm_control_reply(gsm, CMD_FCOFF, NULL, 0);
-               /* Kick the link in case it is idling */
-               gsm_data_kick(gsm);
-               break;
-       case CMD_MSC:
-               /* Out of band modem line change indicator for a DLCI */
-               gsm_control_modem(gsm, data, clen);
-               break;
-       case CMD_RLS:
-               /* Out of band error reception for a DLCI */
-               gsm_control_rls(gsm, data, clen);
-               break;
-       case CMD_PSC:
-               /* Modem wishes to enter power saving state */
-               gsm_control_reply(gsm, CMD_PSC, NULL, 0);
-               break;
-               /* Optional unsupported commands */
-       case CMD_PN:    /* Parameter negotiation */
-       case CMD_RPN:   /* Remote port negotation */
-       case CMD_SNC:   /* Service negotation command */
-       default:
-               /* Reply to bad commands with an NSC */
-               buf[0] = command;
-               gsm_control_reply(gsm, CMD_NSC, buf, 1);
-               break;
-       }
-}
-
-/**
- *     gsm_control_response    -       process a response to our control
- *     @gsm: our GSM mux
- *     @command: the command (response) EA
- *     @data: data beyond the command/length EA
- *     @clen: length
- *
- *     Process a response to an outstanding command. We only allow a single
- *     control message in flight so this is fairly easy. All the clean up
- *     is done by the caller, we just update the fields, flag it as done
- *     and return
- */
-
-static void gsm_control_response(struct gsm_mux *gsm, unsigned int command,
-                                                       u8 *data, int clen)
-{
-       struct gsm_control *ctrl;
-       unsigned long flags;
-
-       spin_lock_irqsave(&gsm->control_lock, flags);
-
-       ctrl = gsm->pending_cmd;
-       /* Does the reply match our command */
-       command |= 1;
-       if (ctrl != NULL && (command == ctrl->cmd || command == CMD_NSC)) {
-               /* Our command was replied to, kill the retry timer */
-               del_timer(&gsm->t2_timer);
-               gsm->pending_cmd = NULL;
-               /* Rejected by the other end */
-               if (command == CMD_NSC)
-                       ctrl->error = -EOPNOTSUPP;
-               ctrl->done = 1;
-               wake_up(&gsm->event);
-       }
-       spin_unlock_irqrestore(&gsm->control_lock, flags);
-}
-
-/**
- *     gsm_control_transmit    -       send control packet
- *     @gsm: gsm mux
- *     @ctrl: frame to send
- *
- *     Send out a pending control command (called under control lock)
- */
-
-static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl)
-{
-       struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 1,
-                                                       gsm->ftype|PF);
-       if (msg == NULL)
-               return;
-       msg->data[0] = (ctrl->cmd << 1) | 2 | EA;       /* command */
-       memcpy(msg->data + 1, ctrl->data, ctrl->len);
-       gsm_data_queue(gsm->dlci[0], msg);
-}
-
-/**
- *     gsm_control_retransmit  -       retransmit a control frame
- *     @data: pointer to our gsm object
- *
- *     Called off the T2 timer expiry in order to retransmit control frames
- *     that have been lost in the system somewhere. The control_lock protects
- *     us from colliding with another sender or a receive completion event.
- *     In that situation the timer may still occur in a small window but
- *     gsm->pending_cmd will be NULL and we just let the timer expire.
- */
-
-static void gsm_control_retransmit(unsigned long data)
-{
-       struct gsm_mux *gsm = (struct gsm_mux *)data;
-       struct gsm_control *ctrl;
-       unsigned long flags;
-       spin_lock_irqsave(&gsm->control_lock, flags);
-       ctrl = gsm->pending_cmd;
-       if (ctrl) {
-               gsm->cretries--;
-               if (gsm->cretries == 0) {
-                       gsm->pending_cmd = NULL;
-                       ctrl->error = -ETIMEDOUT;
-                       ctrl->done = 1;
-                       spin_unlock_irqrestore(&gsm->control_lock, flags);
-                       wake_up(&gsm->event);
-                       return;
-               }
-               gsm_control_transmit(gsm, ctrl);
-               mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
-       }
-       spin_unlock_irqrestore(&gsm->control_lock, flags);
-}
-
-/**
- *     gsm_control_send        -       send a control frame on DLCI 0
- *     @gsm: the GSM channel
- *     @command: command  to send including CR bit
- *     @data: bytes of data (must be kmalloced)
- *     @len: length of the block to send
- *
- *     Queue and dispatch a control command. Only one command can be
- *     active at a time. In theory more can be outstanding but the matching
- *     gets really complicated so for now stick to one outstanding.
- */
-
-static struct gsm_control *gsm_control_send(struct gsm_mux *gsm,
-               unsigned int command, u8 *data, int clen)
-{
-       struct gsm_control *ctrl = kzalloc(sizeof(struct gsm_control),
-                                               GFP_KERNEL);
-       unsigned long flags;
-       if (ctrl == NULL)
-               return NULL;
-retry:
-       wait_event(gsm->event, gsm->pending_cmd == NULL);
-       spin_lock_irqsave(&gsm->control_lock, flags);
-       if (gsm->pending_cmd != NULL) {
-               spin_unlock_irqrestore(&gsm->control_lock, flags);
-               goto retry;
-       }
-       ctrl->cmd = command;
-       ctrl->data = data;
-       ctrl->len = clen;
-       gsm->pending_cmd = ctrl;
-       gsm->cretries = gsm->n2;
-       mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
-       gsm_control_transmit(gsm, ctrl);
-       spin_unlock_irqrestore(&gsm->control_lock, flags);
-       return ctrl;
-}
-
-/**
- *     gsm_control_wait        -       wait for a control to finish
- *     @gsm: GSM mux
- *     @control: control we are waiting on
- *
- *     Waits for the control to complete or time out. Frees any used
- *     resources and returns 0 for success, or an error if the remote
- *     rejected or ignored the request.
- */
-
-static int gsm_control_wait(struct gsm_mux *gsm, struct gsm_control *control)
-{
-       int err;
-       wait_event(gsm->event, control->done == 1);
-       err = control->error;
-       kfree(control);
-       return err;
-}
-
-
-/*
- *     DLCI level handling: Needs krefs
- */
-
-/*
- *     State transitions and timers
- */
-
-/**
- *     gsm_dlci_close          -       a DLCI has closed
- *     @dlci: DLCI that closed
- *
- *     Perform processing when moving a DLCI into closed state. If there
- *     is an attached tty this is hung up
- */
-
-static void gsm_dlci_close(struct gsm_dlci *dlci)
-{
-       del_timer(&dlci->t1);
-       if (debug & 8)
-               printk("DLCI %d goes closed.\n", dlci->addr);
-       dlci->state = DLCI_CLOSED;
-       if (dlci->addr != 0) {
-               struct tty_struct  *tty = tty_port_tty_get(&dlci->port);
-               if (tty) {
-                       tty_hangup(tty);
-                       tty_kref_put(tty);
-               }
-               kfifo_reset(dlci->fifo);
-       } else
-               dlci->gsm->dead = 1;
-       wake_up(&dlci->gsm->event);
-       /* A DLCI 0 close is a MUX termination so we need to kick that
-          back to userspace somehow */
-}
-
-/**
- *     gsm_dlci_open           -       a DLCI has opened
- *     @dlci: DLCI that opened
- *
- *     Perform processing when moving a DLCI into open state.
- */
-
-static void gsm_dlci_open(struct gsm_dlci *dlci)
-{
-       /* Note that SABM UA .. SABM UA first UA lost can mean that we go
-          open -> open */
-       del_timer(&dlci->t1);
-       /* This will let a tty open continue */
-       dlci->state = DLCI_OPEN;
-       if (debug & 8)
-               printk("DLCI %d goes open.\n", dlci->addr);
-       wake_up(&dlci->gsm->event);
-}
-
-/**
- *     gsm_dlci_t1             -       T1 timer expiry
- *     @dlci: DLCI that opened
- *
- *     The T1 timer handles retransmits of control frames (essentially of
- *     SABM and DISC). We resend the command until the retry count runs out
- *     in which case an opening port goes back to closed and a closing port
- *     is simply put into closed state (any further frames from the other
- *     end will get a DM response)
- */
-
-static void gsm_dlci_t1(unsigned long data)
-{
-       struct gsm_dlci *dlci = (struct gsm_dlci *)data;
-       struct gsm_mux *gsm = dlci->gsm;
-
-       switch (dlci->state) {
-       case DLCI_OPENING:
-               dlci->retries--;
-               if (dlci->retries) {
-                       gsm_command(dlci->gsm, dlci->addr, SABM|PF);
-                       mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
-               } else
-                       gsm_dlci_close(dlci);
-               break;
-       case DLCI_CLOSING:
-               dlci->retries--;
-               if (dlci->retries) {
-                       gsm_command(dlci->gsm, dlci->addr, DISC|PF);
-                       mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
-               } else
-                       gsm_dlci_close(dlci);
-               break;
-       }
-}
-
-/**
- *     gsm_dlci_begin_open     -       start channel open procedure
- *     @dlci: DLCI to open
- *
- *     Commence opening a DLCI from the Linux side. We issue SABM messages
- *     to the modem which should then reply with a UA, at which point we
- *     will move into open state. Opening is done asynchronously with retry
- *     running off timers and the responses.
- */
-
-static void gsm_dlci_begin_open(struct gsm_dlci *dlci)
-{
-       struct gsm_mux *gsm = dlci->gsm;
-       if (dlci->state == DLCI_OPEN || dlci->state == DLCI_OPENING)
-               return;
-       dlci->retries = gsm->n2;
-       dlci->state = DLCI_OPENING;
-       gsm_command(dlci->gsm, dlci->addr, SABM|PF);
-       mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
-}
-
-/**
- *     gsm_dlci_begin_close    -       start channel open procedure
- *     @dlci: DLCI to open
- *
- *     Commence closing a DLCI from the Linux side. We issue DISC messages
- *     to the modem which should then reply with a UA, at which point we
- *     will move into closed state. Closing is done asynchronously with retry
- *     off timers. We may also receive a DM reply from the other end which
- *     indicates the channel was already closed.
- */
-
-static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
-{
-       struct gsm_mux *gsm = dlci->gsm;
-       if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING)
-               return;
-       dlci->retries = gsm->n2;
-       dlci->state = DLCI_CLOSING;
-       gsm_command(dlci->gsm, dlci->addr, DISC|PF);
-       mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
-}
-
-/**
- *     gsm_dlci_data           -       data arrived
- *     @dlci: channel
- *     @data: block of bytes received
- *     @len: length of received block
- *
- *     A UI or UIH frame has arrived which contains data for a channel
- *     other than the control channel. If the relevant virtual tty is
- *     open we shovel the bits down it, if not we drop them.
- */
-
-static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int len)
-{
-       /* krefs .. */
-       struct tty_port *port = &dlci->port;
-       struct tty_struct *tty = tty_port_tty_get(port);
-       unsigned int modem = 0;
-
-       if (debug & 16)
-               printk("%d bytes for tty %p\n", len, tty);
-       if (tty) {
-               switch (dlci->adaption)  {
-                       /* Unsupported types */
-                       /* Packetised interruptible data */
-                       case 4:
-                               break;
-                       /* Packetised uininterruptible voice/data */
-                       case 3:
-                               break;
-                       /* Asynchronous serial with line state in each frame */
-                       case 2:
-                               while (gsm_read_ea(&modem, *data++) == 0) {
-                                       len--;
-                                       if (len == 0)
-                                               return;
-                               }
-                               gsm_process_modem(tty, dlci, modem);
-                       /* Line state will go via DLCI 0 controls only */
-                       case 1:
-                       default:
-                               tty_insert_flip_string(tty, data, len);
-                               tty_flip_buffer_push(tty);
-               }
-               tty_kref_put(tty);
-       }
-}
-
-/**
- *     gsm_dlci_control        -       data arrived on control channel
- *     @dlci: channel
- *     @data: block of bytes received
- *     @len: length of received block
- *
- *     A UI or UIH frame has arrived which contains data for DLCI 0 the
- *     control channel. This should contain a command EA followed by
- *     control data bytes. The command EA contains a command/response bit
- *     and we divide up the work accordingly.
- */
-
-static void gsm_dlci_command(struct gsm_dlci *dlci, u8 *data, int len)
-{
-       /* See what command is involved */
-       unsigned int command = 0;
-       while (len-- > 0) {
-               if (gsm_read_ea(&command, *data++) == 1) {
-                       int clen = *data++;
-                       len--;
-                       /* FIXME: this is properly an EA */
-                       clen >>= 1;
-                       /* Malformed command ? */
-                       if (clen > len)
-                               return;
-                       if (command & 1)
-                               gsm_control_message(dlci->gsm, command,
-                                                               data, clen);
-                       else
-                               gsm_control_response(dlci->gsm, command,
-                                                               data, clen);
-                       return;
-               }
-       }
-}
-
-/*
- *     Allocate/Free DLCI channels
- */
-
-/**
- *     gsm_dlci_alloc          -       allocate a DLCI
- *     @gsm: GSM mux
- *     @addr: address of the DLCI
- *
- *     Allocate and install a new DLCI object into the GSM mux.
- *
- *     FIXME: review locking races
- */
-
-static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
-{
-       struct gsm_dlci *dlci = kzalloc(sizeof(struct gsm_dlci), GFP_ATOMIC);
-       if (dlci == NULL)
-               return NULL;
-       spin_lock_init(&dlci->lock);
-       dlci->fifo = &dlci->_fifo;
-       if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
-               kfree(dlci);
-               return NULL;
-       }
-
-       skb_queue_head_init(&dlci->skb_list);
-       init_timer(&dlci->t1);
-       dlci->t1.function = gsm_dlci_t1;
-       dlci->t1.data = (unsigned long)dlci;
-       tty_port_init(&dlci->port);
-       dlci->port.ops = &gsm_port_ops;
-       dlci->gsm = gsm;
-       dlci->addr = addr;
-       dlci->adaption = gsm->adaption;
-       dlci->state = DLCI_CLOSED;
-       if (addr)
-               dlci->data = gsm_dlci_data;
-       else
-               dlci->data = gsm_dlci_command;
-       gsm->dlci[addr] = dlci;
-       return dlci;
-}
-
-/**
- *     gsm_dlci_free           -       release DLCI
- *     @dlci: DLCI to destroy
- *
- *     Free up a DLCI. Currently to keep the lifetime rules sane we only
- *     clean up DLCI objects when the MUX closes rather than as the port
- *     is closed down on both the tty and mux levels.
- *
- *     Can sleep.
- */
-static void gsm_dlci_free(struct gsm_dlci *dlci)
-{
-       struct tty_struct *tty = tty_port_tty_get(&dlci->port);
-       if (tty) {
-               tty_vhangup(tty);
-               tty_kref_put(tty);
-       }
-       del_timer_sync(&dlci->t1);
-       dlci->gsm->dlci[dlci->addr] = NULL;
-       kfifo_free(dlci->fifo);
-       kfree(dlci);
-}
-
-
-/*
- *     LAPBish link layer logic
- */
-
-/**
- *     gsm_queue               -       a GSM frame is ready to process
- *     @gsm: pointer to our gsm mux
- *
- *     At this point in time a frame has arrived and been demangled from
- *     the line encoding. All the differences between the encodings have
- *     been handled below us and the frame is unpacked into the structures.
- *     The fcs holds the header FCS but any data FCS must be added here.
- */
-
-static void gsm_queue(struct gsm_mux *gsm)
-{
-       struct gsm_dlci *dlci;
-       u8 cr;
-       int address;
-       /* We have to sneak a look at the packet body to do the FCS.
-          A somewhat layering violation in the spec */
-
-       if ((gsm->control & ~PF) == UI)
-               gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->len);
-       if (gsm->fcs != GOOD_FCS) {
-               gsm->bad_fcs++;
-               if (debug & 4)
-                       printk("BAD FCS %02x\n", gsm->fcs);
-               return;
-       }
-       address = gsm->address >> 1;
-       if (address >= NUM_DLCI)
-               goto invalid;
-
-       cr = gsm->address & 1;          /* C/R bit */
-
-       gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);
-
-       cr ^= 1 - gsm->initiator;       /* Flip so 1 always means command */
-       dlci = gsm->dlci[address];
-
-       switch (gsm->control) {
-       case SABM|PF:
-               if (cr == 0)
-                       goto invalid;
-               if (dlci == NULL)
-                       dlci = gsm_dlci_alloc(gsm, address);
-               if (dlci == NULL)
-                       return;
-               if (dlci->dead)
-                       gsm_response(gsm, address, DM);
-               else {
-                       gsm_response(gsm, address, UA);
-                       gsm_dlci_open(dlci);
-               }
-               break;
-       case DISC|PF:
-               if (cr == 0)
-                       goto invalid;
-               if (dlci == NULL || dlci->state == DLCI_CLOSED) {
-                       gsm_response(gsm, address, DM);
-                       return;
-               }
-               /* Real close complete */
-               gsm_response(gsm, address, UA);
-               gsm_dlci_close(dlci);
-               break;
-       case UA:
-       case UA|PF:
-               if (cr == 0 || dlci == NULL)
-                       break;
-               switch (dlci->state) {
-               case DLCI_CLOSING:
-                       gsm_dlci_close(dlci);
-                       break;
-               case DLCI_OPENING:
-                       gsm_dlci_open(dlci);
-                       break;
-               }
-               break;
-       case DM:        /* DM can be valid unsolicited */
-       case DM|PF:
-               if (cr)
-                       goto invalid;
-               if (dlci == NULL)
-                       return;
-               gsm_dlci_close(dlci);
-               break;
-       case UI:
-       case UI|PF:
-       case UIH:
-       case UIH|PF:
-#if 0
-               if (cr)
-                       goto invalid;
-#endif
-               if (dlci == NULL || dlci->state != DLCI_OPEN) {
-                       gsm_command(gsm, address, DM|PF);
-                       return;
-               }
-               dlci->data(dlci, gsm->buf, gsm->len);
-               break;
-       default:
-               goto invalid;
-       }
-       return;
-invalid:
-       gsm->malformed++;
-       return;
-}
-
-
-/**
- *     gsm0_receive    -       perform processing for non-transparency
- *     @gsm: gsm data for this ldisc instance
- *     @c: character
- *
- *     Receive bytes in gsm mode 0
- */
-
-static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
-{
-       switch (gsm->state) {
-       case GSM_SEARCH:        /* SOF marker */
-               if (c == GSM0_SOF) {
-                       gsm->state = GSM_ADDRESS;
-                       gsm->address = 0;
-                       gsm->len = 0;
-                       gsm->fcs = INIT_FCS;
-               }
-               break;          /* Address EA */
-       case GSM_ADDRESS:
-               gsm->fcs = gsm_fcs_add(gsm->fcs, c);
-               if (gsm_read_ea(&gsm->address, c))
-                       gsm->state = GSM_CONTROL;
-               break;
-       case GSM_CONTROL:       /* Control Byte */
-               gsm->fcs = gsm_fcs_add(gsm->fcs, c);
-               gsm->control = c;
-               gsm->state = GSM_LEN;
-               break;
-       case GSM_LEN:           /* Length EA */
-               gsm->fcs = gsm_fcs_add(gsm->fcs, c);
-               if (gsm_read_ea(&gsm->len, c)) {
-                       if (gsm->len > gsm->mru) {
-                               gsm->bad_size++;
-                               gsm->state = GSM_SEARCH;
-                               break;
-                       }
-                       gsm->count = 0;
-                       gsm->state = GSM_DATA;
-               }
-               break;
-       case GSM_DATA:          /* Data */
-               gsm->buf[gsm->count++] = c;
-               if (gsm->count == gsm->len)
-                       gsm->state = GSM_FCS;
-               break;
-       case GSM_FCS:           /* FCS follows the packet */
-               gsm->fcs = c;
-               gsm_queue(gsm);
-               /* And then back for the next frame */
-               gsm->state = GSM_SEARCH;
-               break;
-       }
-}
-
-/**
- *     gsm0_receive    -       perform processing for non-transparency
- *     @gsm: gsm data for this ldisc instance
- *     @c: character
- *
- *     Receive bytes in mode 1 (Advanced option)
- */
-
-static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
-{
-       if (c == GSM1_SOF) {
-               /* EOF is only valid in frame if we have got to the data state
-                  and received at least one byte (the FCS) */
-               if (gsm->state == GSM_DATA && gsm->count) {
-                       /* Extract the FCS */
-                       gsm->count--;
-                       gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->buf[gsm->count]);
-                       gsm->len = gsm->count;
-                       gsm_queue(gsm);
-                       gsm->state  = GSM_START;
-                       return;
-               }
-               /* Any partial frame was a runt so go back to start */
-               if (gsm->state != GSM_START) {
-                       gsm->malformed++;
-                       gsm->state = GSM_START;
-               }
-               /* A SOF in GSM_START means we are still reading idling or
-                  framing bytes */
-               return;
-       }
-
-       if (c == GSM1_ESCAPE) {
-               gsm->escape = 1;
-               return;
-       }
-
-       /* Only an unescaped SOF gets us out of GSM search */
-       if (gsm->state == GSM_SEARCH)
-               return;
-
-       if (gsm->escape) {
-               c ^= GSM1_ESCAPE_BITS;
-               gsm->escape = 0;
-       }
-       switch (gsm->state) {
-       case GSM_START:         /* First byte after SOF */
-               gsm->address = 0;
-               gsm->state = GSM_ADDRESS;
-               gsm->fcs = INIT_FCS;
-               /* Drop through */
-       case GSM_ADDRESS:       /* Address continuation */
-               gsm->fcs = gsm_fcs_add(gsm->fcs, c);
-               if (gsm_read_ea(&gsm->address, c))
-                       gsm->state = GSM_CONTROL;
-               break;
-       case GSM_CONTROL:       /* Control Byte */
-               gsm->fcs = gsm_fcs_add(gsm->fcs, c);
-               gsm->control = c;
-               gsm->count = 0;
-               gsm->state = GSM_DATA;
-               break;
-       case GSM_DATA:          /* Data */
-               if (gsm->count > gsm->mru ) {   /* Allow one for the FCS */
-                       gsm->state = GSM_OVERRUN;
-                       gsm->bad_size++;
-               } else
-                       gsm->buf[gsm->count++] = c;
-               break;
-       case GSM_OVERRUN:       /* Over-long - eg a dropped SOF */
-               break;
-       }
-}
-
-/**
- *     gsm_error               -       handle tty error
- *     @gsm: ldisc data
- *     @data: byte received (may be invalid)
- *     @flag: error received
- *
- *     Handle an error in the receipt of data for a frame. Currently we just
- *     go back to hunting for a SOF.
- *
- *     FIXME: better diagnostics ?
- */
-
-static void gsm_error(struct gsm_mux *gsm,
-                               unsigned char data, unsigned char flag)
-{
-       gsm->state = GSM_SEARCH;
-       gsm->io_error++;
-}
-
-/**
- *     gsm_cleanup_mux         -       generic GSM protocol cleanup
- *     @gsm: our mux
- *
- *     Clean up the bits of the mux which are the same for all framing
- *     protocols. Remove the mux from the mux table, stop all the timers
- *     and then shut down each device hanging up the channels as we go.
- */
-
-void gsm_cleanup_mux(struct gsm_mux *gsm)
-{
-       int i;
-       struct gsm_dlci *dlci = gsm->dlci[0];
-       struct gsm_msg *txq;
-
-       gsm->dead = 1;
-
-       spin_lock(&gsm_mux_lock);
-       for (i = 0; i < MAX_MUX; i++) {
-               if (gsm_mux[i] == gsm) {
-                       gsm_mux[i] = NULL;
-                       break;
-               }
-       }
-       spin_unlock(&gsm_mux_lock);
-       WARN_ON(i == MAX_MUX);
-
-       del_timer_sync(&gsm->t2_timer);
-       /* Now we are sure T2 has stopped */
-       if (dlci) {
-               dlci->dead = 1;
-               gsm_dlci_begin_close(dlci);
-               wait_event_interruptible(gsm->event,
-                                       dlci->state == DLCI_CLOSED);
-       }
-       /* Free up any link layer users */
-       for (i = 0; i < NUM_DLCI; i++)
-               if (gsm->dlci[i])
-                       gsm_dlci_free(gsm->dlci[i]);
-       /* Now wipe the queues */
-       for (txq = gsm->tx_head; txq != NULL; txq = gsm->tx_head) {
-               gsm->tx_head = txq->next;
-               kfree(txq);
-       }
-       gsm->tx_tail = NULL;
-}
-EXPORT_SYMBOL_GPL(gsm_cleanup_mux);
-
-/**
- *     gsm_activate_mux        -       generic GSM setup
- *     @gsm: our mux
- *
- *     Set up the bits of the mux which are the same for all framing
- *     protocols. Add the mux to the mux table so it can be opened and
- *     finally kick off connecting to DLCI 0 on the modem.
- */
-
-int gsm_activate_mux(struct gsm_mux *gsm)
-{
-       struct gsm_dlci *dlci;
-       int i = 0;
-
-       init_timer(&gsm->t2_timer);
-       gsm->t2_timer.function = gsm_control_retransmit;
-       gsm->t2_timer.data = (unsigned long)gsm;
-       init_waitqueue_head(&gsm->event);
-       spin_lock_init(&gsm->control_lock);
-       spin_lock_init(&gsm->tx_lock);
-
-       if (gsm->encoding == 0)
-               gsm->receive = gsm0_receive;
-       else
-               gsm->receive = gsm1_receive;
-       gsm->error = gsm_error;
-
-       spin_lock(&gsm_mux_lock);
-       for (i = 0; i < MAX_MUX; i++) {
-               if (gsm_mux[i] == NULL) {
-                       gsm_mux[i] = gsm;
-                       break;
-               }
-       }
-       spin_unlock(&gsm_mux_lock);
-       if (i == MAX_MUX)
-               return -EBUSY;
-
-       dlci = gsm_dlci_alloc(gsm, 0);
-       if (dlci == NULL)
-               return -ENOMEM;
-       gsm->dead = 0;          /* Tty opens are now permissible */
-       return 0;
-}
-EXPORT_SYMBOL_GPL(gsm_activate_mux);
-
-/**
- *     gsm_free_mux            -       free up a mux
- *     @mux: mux to free
- *
- *     Dispose of allocated resources for a dead mux. No refcounting
- *     at present so the mux must be truely dead.
- */
-void gsm_free_mux(struct gsm_mux *gsm)
-{
-       kfree(gsm->txframe);
-       kfree(gsm->buf);
-       kfree(gsm);
-}
-EXPORT_SYMBOL_GPL(gsm_free_mux);
-
-/**
- *     gsm_alloc_mux           -       allocate a mux
- *
- *     Creates a new mux ready for activation.
- */
-
-struct gsm_mux *gsm_alloc_mux(void)
-{
-       struct gsm_mux *gsm = kzalloc(sizeof(struct gsm_mux), GFP_KERNEL);
-       if (gsm == NULL)
-               return NULL;
-       gsm->buf = kmalloc(MAX_MRU + 1, GFP_KERNEL);
-       if (gsm->buf == NULL) {
-               kfree(gsm);
-               return NULL;
-       }
-       gsm->txframe = kmalloc(2 * MAX_MRU + 2, GFP_KERNEL);
-       if (gsm->txframe == NULL) {
-               kfree(gsm->buf);
-               kfree(gsm);
-               return NULL;
-       }
-       spin_lock_init(&gsm->lock);
-
-       gsm->t1 = T1;
-       gsm->t2 = T2;
-       gsm->n2 = N2;
-       gsm->ftype = UIH;
-       gsm->initiator = 0;
-       gsm->adaption = 1;
-       gsm->encoding = 1;
-       gsm->mru = 64;  /* Default to encoding 1 so these should be 64 */
-       gsm->mtu = 64;
-       gsm->dead = 1;  /* Avoid early tty opens */
-
-       return gsm;
-}
-EXPORT_SYMBOL_GPL(gsm_alloc_mux);
-
-
-
-
-/**
- *     gsmld_output            -       write to link
- *     @gsm: our mux
- *     @data: bytes to output
- *     @len: size
- *
- *     Write a block of data from the GSM mux to the data channel. This
- *     will eventually be serialized from above but at the moment isn't.
- */
-
-static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)
-{
-       if (tty_write_room(gsm->tty) < len) {
-               set_bit(TTY_DO_WRITE_WAKEUP, &gsm->tty->flags);
-               return -ENOSPC;
-       }
-       if (debug & 4) {
-               printk("-->%d bytes out\n", len);
-               hex_packet(data, len);
-       }
-       gsm->tty->ops->write(gsm->tty, data, len);
-       return len;
-}
-
-/**
- *     gsmld_attach_gsm        -       mode set up
- *     @tty: our tty structure
- *     @gsm: our mux
- *
- *     Set up the MUX for basic mode and commence connecting to the
- *     modem. Currently called from the line discipline set up but
- *     will need moving to an ioctl path.
- */
-
-static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
-{
-       int ret;
-
-       gsm->tty = tty_kref_get(tty);
-       gsm->output = gsmld_output;
-       ret =  gsm_activate_mux(gsm);
-       if (ret != 0)
-               tty_kref_put(gsm->tty);
-       return ret;
-}
-
-
-/**
- *     gsmld_detach_gsm        -       stop doing 0710 mux
- *     @tty: tty atttached to the mux
- *     @gsm: mux
- *
- *     Shutdown and then clean up the resources used by the line discipline
- */
-
-static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
-{
-       WARN_ON(tty != gsm->tty);
-       gsm_cleanup_mux(gsm);
-       tty_kref_put(gsm->tty);
-       gsm->tty = NULL;
-}
-
-static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                             char *fp, int count)
-{
-       struct gsm_mux *gsm = tty->disc_data;
-       const unsigned char *dp;
-       char *f;
-       int i;
-       char buf[64];
-       char flags;
-
-       if (debug & 4) {
-               printk("Inbytes %dd\n", count);
-               hex_packet(cp, count);
-       }
-
-       for (i = count, dp = cp, f = fp; i; i--, dp++) {
-               flags = *f++;
-               switch (flags) {
-               case TTY_NORMAL:
-                       gsm->receive(gsm, *dp);
-                       break;
-               case TTY_OVERRUN:
-               case TTY_BREAK:
-               case TTY_PARITY:
-               case TTY_FRAME:
-                       gsm->error(gsm, *dp, flags);
-                       break;
-               default:
-                       printk(KERN_ERR "%s: unknown flag %d\n",
-                              tty_name(tty, buf), flags);
-                       break;
-               }
-       }
-       /* FASYNC if needed ? */
-       /* If clogged call tty_throttle(tty); */
-}
-
-/**
- *     gsmld_chars_in_buffer   -       report available bytes
- *     @tty: tty device
- *
- *     Report the number of characters buffered to be delivered to user
- *     at this instant in time.
- *
- *     Locking: gsm lock
- */
-
-static ssize_t gsmld_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0;
-}
-
-/**
- *     gsmld_flush_buffer      -       clean input queue
- *     @tty:   terminal device
- *
- *     Flush the input buffer. Called when the line discipline is
- *     being closed, when the tty layer wants the buffer flushed (eg
- *     at hangup).
- */
-
-static void gsmld_flush_buffer(struct tty_struct *tty)
-{
-}
-
-/**
- *     gsmld_close             -       close the ldisc for this tty
- *     @tty: device
- *
- *     Called from the terminal layer when this line discipline is
- *     being shut down, either because of a close or becsuse of a
- *     discipline change. The function will not be called while other
- *     ldisc methods are in progress.
- */
-
-static void gsmld_close(struct tty_struct *tty)
-{
-       struct gsm_mux *gsm = tty->disc_data;
-
-       gsmld_detach_gsm(tty, gsm);
-
-       gsmld_flush_buffer(tty);
-       /* Do other clean up here */
-       gsm_free_mux(gsm);
-}
-
-/**
- *     gsmld_open              -       open an ldisc
- *     @tty: terminal to open
- *
- *     Called when this line discipline is being attached to the
- *     terminal device. Can sleep. Called serialized so that no
- *     other events will occur in parallel. No further open will occur
- *     until a close.
- */
-
-static int gsmld_open(struct tty_struct *tty)
-{
-       struct gsm_mux *gsm;
-
-       if (tty->ops->write == NULL)
-               return -EINVAL;
-
-       /* Attach our ldisc data */
-       gsm = gsm_alloc_mux();
-       if (gsm == NULL)
-               return -ENOMEM;
-
-       tty->disc_data = gsm;
-       tty->receive_room = 65536;
-
-       /* Attach the initial passive connection */
-       gsm->encoding = 1;
-       return gsmld_attach_gsm(tty, gsm);
-}
-
-/**
- *     gsmld_write_wakeup      -       asynchronous I/O notifier
- *     @tty: tty device
- *
- *     Required for the ptys, serial driver etc. since processes
- *     that attach themselves to the master and rely on ASYNC
- *     IO must be woken up
- */
-
-static void gsmld_write_wakeup(struct tty_struct *tty)
-{
-       struct gsm_mux *gsm = tty->disc_data;
-       unsigned long flags;
-
-       /* Queue poll */
-       clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-       gsm_data_kick(gsm);
-       if (gsm->tx_bytes < TX_THRESH_LO) {
-               spin_lock_irqsave(&gsm->tx_lock, flags);
-               gsm_dlci_data_sweep(gsm);
-               spin_unlock_irqrestore(&gsm->tx_lock, flags);
-       }
-}
-
-/**
- *     gsmld_read              -       read function for tty
- *     @tty: tty device
- *     @file: file object
- *     @buf: userspace buffer pointer
- *     @nr: size of I/O
- *
- *     Perform reads for the line discipline. We are guaranteed that the
- *     line discipline will not be closed under us but we may get multiple
- *     parallel readers and must handle this ourselves. We may also get
- *     a hangup. Always called in user context, may sleep.
- *
- *     This code must be sure never to sleep through a hangup.
- */
-
-static ssize_t gsmld_read(struct tty_struct *tty, struct file *file,
-                        unsigned char __user *buf, size_t nr)
-{
-       return -EOPNOTSUPP;
-}
-
-/**
- *     gsmld_write             -       write function for tty
- *     @tty: tty device
- *     @file: file object
- *     @buf: userspace buffer pointer
- *     @nr: size of I/O
- *
- *     Called when the owner of the device wants to send a frame
- *     itself (or some other control data). The data is transferred
- *     as-is and must be properly framed and checksummed as appropriate
- *     by userspace. Frames are either sent whole or not at all as this
- *     avoids pain user side.
- */
-
-static ssize_t gsmld_write(struct tty_struct *tty, struct file *file,
-                          const unsigned char *buf, size_t nr)
-{
-       int space = tty_write_room(tty);
-       if (space >= nr)
-               return tty->ops->write(tty, buf, nr);
-       set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-       return -ENOBUFS;
-}
-
-/**
- *     gsmld_poll              -       poll method for N_GSM0710
- *     @tty: terminal device
- *     @file: file accessing it
- *     @wait: poll table
- *
- *     Called when the line discipline is asked to poll() for data or
- *     for special events. This code is not serialized with respect to
- *     other events save open/close.
- *
- *     This code must be sure never to sleep through a hangup.
- *     Called without the kernel lock held - fine
- */
-
-static unsigned int gsmld_poll(struct tty_struct *tty, struct file *file,
-                                                       poll_table *wait)
-{
-       unsigned int mask = 0;
-       struct gsm_mux *gsm = tty->disc_data;
-
-       poll_wait(file, &tty->read_wait, wait);
-       poll_wait(file, &tty->write_wait, wait);
-       if (tty_hung_up_p(file))
-               mask |= POLLHUP;
-       if (!tty_is_writelocked(tty) && tty_write_room(tty) > 0)
-               mask |= POLLOUT | POLLWRNORM;
-       if (gsm->dead)
-               mask |= POLLHUP;
-       return mask;
-}
-
-static int gsmld_config(struct tty_struct *tty, struct gsm_mux *gsm,
-                                                       struct gsm_config *c)
-{
-       int need_close = 0;
-       int need_restart = 0;
-
-       /* Stuff we don't support yet - UI or I frame transport, windowing */
-       if ((c->adaption !=1 && c->adaption != 2) || c->k)
-               return -EOPNOTSUPP;
-       /* Check the MRU/MTU range looks sane */
-       if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8)
-               return -EINVAL;
-       if (c->n2 < 3)
-               return -EINVAL;
-       if (c->encapsulation > 1)       /* Basic, advanced, no I */
-               return -EINVAL;
-       if (c->initiator > 1)
-               return -EINVAL;
-       if (c->i == 0 || c->i > 2)      /* UIH and UI only */
-               return -EINVAL;
-       /*
-        *      See what is needed for reconfiguration
-        */
-
-       /* Timing fields */
-       if (c->t1 != 0 && c->t1 != gsm->t1)
-               need_restart = 1;
-       if (c->t2 != 0 && c->t2 != gsm->t2)
-               need_restart = 1;
-       if (c->encapsulation != gsm->encoding)
-               need_restart = 1;
-       if (c->adaption != gsm->adaption)
-               need_restart = 1;
-       /* Requires care */
-       if (c->initiator != gsm->initiator)
-               need_close = 1;
-       if (c->mru != gsm->mru)
-               need_restart = 1;
-       if (c->mtu != gsm->mtu)
-               need_restart = 1;
-
-       /*
-        *      Close down what is needed, restart and initiate the new
-        *      configuration
-        */
-
-       if (need_close || need_restart) {
-               gsm_dlci_begin_close(gsm->dlci[0]);
-               /* This will timeout if the link is down due to N2 expiring */
-               wait_event_interruptible(gsm->event,
-                               gsm->dlci[0]->state == DLCI_CLOSED);
-               if (signal_pending(current))
-                       return -EINTR;
-       }
-       if (need_restart)
-               gsm_cleanup_mux(gsm);
-
-       gsm->initiator = c->initiator;
-       gsm->mru = c->mru;
-       gsm->encoding = c->encapsulation;
-       gsm->adaption = c->adaption;
-
-       if (c->i == 1)
-               gsm->ftype = UIH;
-       else if (c->i == 2)
-               gsm->ftype = UI;
-
-       if (c->t1)
-               gsm->t1 = c->t1;
-       if (c->t2)
-               gsm->t2 = c->t2;
-
-       /* FIXME: We need to separate activation/deactivation from adding
-          and removing from the mux array */
-       if (need_restart)
-               gsm_activate_mux(gsm);
-       if (gsm->initiator && need_close)
-               gsm_dlci_begin_open(gsm->dlci[0]);
-       return 0;
-}
-
-static int gsmld_ioctl(struct tty_struct *tty, struct file *file,
-                      unsigned int cmd, unsigned long arg)
-{
-       struct gsm_config c;
-       struct gsm_mux *gsm = tty->disc_data;
-
-       switch (cmd) {
-       case GSMIOC_GETCONF:
-               memset(&c, 0, sizeof(c));
-               c.adaption = gsm->adaption;
-               c.encapsulation = gsm->encoding;
-               c.initiator = gsm->initiator;
-               c.t1 = gsm->t1;
-               c.t2 = gsm->t2;
-               c.t3 = 0;       /* Not supported */
-               c.n2 = gsm->n2;
-               if (gsm->ftype == UIH)
-                       c.i = 1;
-               else
-                       c.i = 2;
-               printk("Ftype %d i %d\n", gsm->ftype, c.i);
-               c.mru = gsm->mru;
-               c.mtu = gsm->mtu;
-               c.k = 0;
-               if (copy_to_user((void *)arg, &c, sizeof(c)))
-                       return -EFAULT;
-               return 0;
-       case GSMIOC_SETCONF:
-               if (copy_from_user(&c, (void *)arg, sizeof(c)))
-                       return -EFAULT;
-               return gsmld_config(tty, gsm, &c);
-       default:
-               return n_tty_ioctl_helper(tty, file, cmd, arg);
-       }
-}
-
-
-/* Line discipline for real tty */
-struct tty_ldisc_ops tty_ldisc_packet = {
-       .owner           = THIS_MODULE,
-       .magic           = TTY_LDISC_MAGIC,
-       .name            = "n_gsm",
-       .open            = gsmld_open,
-       .close           = gsmld_close,
-       .flush_buffer    = gsmld_flush_buffer,
-       .chars_in_buffer = gsmld_chars_in_buffer,
-       .read            = gsmld_read,
-       .write           = gsmld_write,
-       .ioctl           = gsmld_ioctl,
-       .poll            = gsmld_poll,
-       .receive_buf     = gsmld_receive_buf,
-       .write_wakeup    = gsmld_write_wakeup
-};
-
-/*
- *     Virtual tty side
- */
-
-#define TX_SIZE                512
-
-static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 brk)
-{
-       u8 modembits[5];
-       struct gsm_control *ctrl;
-       int len = 2;
-
-       if (brk)
-               len++;
-
-       modembits[0] = len << 1 | EA;           /* Data bytes */
-       modembits[1] = dlci->addr << 2 | 3;     /* DLCI, EA, 1 */
-       modembits[2] = gsm_encode_modem(dlci) << 1 | EA;
-       if (brk)
-               modembits[3] = brk << 4 | 2 | EA;       /* Valid, EA */
-       ctrl = gsm_control_send(dlci->gsm, CMD_MSC, modembits, len + 1);
-       if (ctrl == NULL)
-               return -ENOMEM;
-       return gsm_control_wait(dlci->gsm, ctrl);
-}
-
-static int gsm_carrier_raised(struct tty_port *port)
-{
-       struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
-       /* Not yet open so no carrier info */
-       if (dlci->state != DLCI_OPEN)
-               return 0;
-       if (debug & 2)
-               return 1;
-       return dlci->modem_rx & TIOCM_CD;
-}
-
-static void gsm_dtr_rts(struct tty_port *port, int onoff)
-{
-       struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
-       unsigned int modem_tx = dlci->modem_tx;
-       if (onoff)
-               modem_tx |= TIOCM_DTR | TIOCM_RTS;
-       else
-               modem_tx &= ~(TIOCM_DTR | TIOCM_RTS);
-       if (modem_tx != dlci->modem_tx) {
-               dlci->modem_tx = modem_tx;
-               gsmtty_modem_update(dlci, 0);
-       }
-}
-
-static const struct tty_port_operations gsm_port_ops = {
-       .carrier_raised = gsm_carrier_raised,
-       .dtr_rts = gsm_dtr_rts,
-};
-
-
-static int gsmtty_open(struct tty_struct *tty, struct file *filp)
-{
-       struct gsm_mux *gsm;
-       struct gsm_dlci *dlci;
-       struct tty_port *port;
-       unsigned int line = tty->index;
-       unsigned int mux = line >> 6;
-
-       line = line & 0x3F;
-
-       if (mux >= MAX_MUX)
-               return -ENXIO;
-       /* FIXME: we need to lock gsm_mux for lifetimes of ttys eventually */
-       if (gsm_mux[mux] == NULL)
-               return -EUNATCH;
-       if (line == 0 || line > 61)     /* 62/63 reserved */
-               return -ECHRNG;
-       gsm = gsm_mux[mux];
-       if (gsm->dead)
-               return -EL2HLT;
-       dlci = gsm->dlci[line];
-       if (dlci == NULL)
-               dlci = gsm_dlci_alloc(gsm, line);
-       if (dlci == NULL)
-               return -ENOMEM;
-       port = &dlci->port;
-       port->count++;
-       tty->driver_data = dlci;
-       tty_port_tty_set(port, tty);
-
-       dlci->modem_rx = 0;
-       /* We could in theory open and close before we wait - eg if we get
-          a DM straight back. This is ok as that will have caused a hangup */
-       set_bit(ASYNCB_INITIALIZED, &port->flags);
-       /* Start sending off SABM messages */
-       gsm_dlci_begin_open(dlci);
-       /* And wait for virtual carrier */
-       return tty_port_block_til_ready(port, tty, filp);
-}
-
-static void gsmtty_close(struct tty_struct *tty, struct file *filp)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       if (dlci == NULL)
-               return;
-       if (tty_port_close_start(&dlci->port, tty, filp) == 0)
-               return;
-       gsm_dlci_begin_close(dlci);
-       tty_port_close_end(&dlci->port, tty);
-       tty_port_tty_set(&dlci->port, NULL);
-}
-
-static void gsmtty_hangup(struct tty_struct *tty)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       tty_port_hangup(&dlci->port);
-       gsm_dlci_begin_close(dlci);
-}
-
-static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
-                                                                   int len)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       /* Stuff the bytes into the fifo queue */
-       int sent = kfifo_in_locked(dlci->fifo, buf, len, &dlci->lock);
-       /* Need to kick the channel */
-       gsm_dlci_data_kick(dlci);
-       return sent;
-}
-
-static int gsmtty_write_room(struct tty_struct *tty)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       return TX_SIZE - kfifo_len(dlci->fifo);
-}
-
-static int gsmtty_chars_in_buffer(struct tty_struct *tty)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       return kfifo_len(dlci->fifo);
-}
-
-static void gsmtty_flush_buffer(struct tty_struct *tty)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       /* Caution needed: If we implement reliable transport classes
-          then the data being transmitted can't simply be junked once
-          it has first hit the stack. Until then we can just blow it
-          away */
-       kfifo_reset(dlci->fifo);
-       /* Need to unhook this DLCI from the transmit queue logic */
-}
-
-static void gsmtty_wait_until_sent(struct tty_struct *tty, int timeout)
-{
-       /* The FIFO handles the queue so the kernel will do the right
-          thing waiting on chars_in_buffer before calling us. No work
-          to do here */
-}
-
-static int gsmtty_tiocmget(struct tty_struct *tty, struct file *filp)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       return dlci->modem_rx;
-}
-
-static int gsmtty_tiocmset(struct tty_struct *tty, struct file *filp,
-       unsigned int set, unsigned int clear)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       unsigned int modem_tx = dlci->modem_tx;
-
-       modem_tx &= clear;
-       modem_tx |= set;
-
-       if (modem_tx != dlci->modem_tx) {
-               dlci->modem_tx = modem_tx;
-               return gsmtty_modem_update(dlci, 0);
-       }
-       return 0;
-}
-
-
-static int gsmtty_ioctl(struct tty_struct *tty, struct file *filp,
-                       unsigned int cmd, unsigned long arg)
-{
-       return -ENOIOCTLCMD;
-}
-
-static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old)
-{
-       /* For the moment its fixed. In actual fact the speed information
-          for the virtual channel can be propogated in both directions by
-          the RPN control message. This however rapidly gets nasty as we
-          then have to remap modem signals each way according to whether
-          our virtual cable is null modem etc .. */
-       tty_termios_copy_hw(tty->termios, old);
-}
-
-static void gsmtty_throttle(struct tty_struct *tty)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       if (tty->termios->c_cflag & CRTSCTS)
-               dlci->modem_tx &= ~TIOCM_DTR;
-       dlci->throttled = 1;
-       /* Send an MSC with DTR cleared */
-       gsmtty_modem_update(dlci, 0);
-}
-
-static void gsmtty_unthrottle(struct tty_struct *tty)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       if (tty->termios->c_cflag & CRTSCTS)
-               dlci->modem_tx |= TIOCM_DTR;
-       dlci->throttled = 0;
-       /* Send an MSC with DTR set */
-       gsmtty_modem_update(dlci, 0);
-}
-
-static int gsmtty_break_ctl(struct tty_struct *tty, int state)
-{
-       struct gsm_dlci *dlci = tty->driver_data;
-       int encode = 0; /* Off */
-
-       if (state == -1)        /* "On indefinitely" - we can't encode this
-                                   properly */
-               encode = 0x0F;
-       else if (state > 0) {
-               encode = state / 200;   /* mS to encoding */
-               if (encode > 0x0F)
-                       encode = 0x0F;  /* Best effort */
-       }
-       return gsmtty_modem_update(dlci, encode);
-}
-
-static struct tty_driver *gsm_tty_driver;
-
-/* Virtual ttys for the demux */
-static const struct tty_operations gsmtty_ops = {
-       .open                   = gsmtty_open,
-       .close                  = gsmtty_close,
-       .write                  = gsmtty_write,
-       .write_room             = gsmtty_write_room,
-       .chars_in_buffer        = gsmtty_chars_in_buffer,
-       .flush_buffer           = gsmtty_flush_buffer,
-       .ioctl                  = gsmtty_ioctl,
-       .throttle               = gsmtty_throttle,
-       .unthrottle             = gsmtty_unthrottle,
-       .set_termios            = gsmtty_set_termios,
-       .hangup                 = gsmtty_hangup,
-       .wait_until_sent        = gsmtty_wait_until_sent,
-       .tiocmget               = gsmtty_tiocmget,
-       .tiocmset               = gsmtty_tiocmset,
-       .break_ctl              = gsmtty_break_ctl,
-};
-
-
-
-static int __init gsm_init(void)
-{
-       /* Fill in our line protocol discipline, and register it */
-       int status = tty_register_ldisc(N_GSM0710, &tty_ldisc_packet);
-       if (status != 0) {
-               printk(KERN_ERR "n_gsm: can't register line discipline (err = %d)\n", status);
-               return status;
-       }
-
-       gsm_tty_driver = alloc_tty_driver(256);
-       if (!gsm_tty_driver) {
-               tty_unregister_ldisc(N_GSM0710);
-               printk(KERN_ERR "gsm_init: tty allocation failed.\n");
-               return -EINVAL;
-       }
-       gsm_tty_driver->owner   = THIS_MODULE;
-       gsm_tty_driver->driver_name     = "gsmtty";
-       gsm_tty_driver->name            = "gsmtty";
-       gsm_tty_driver->major           = 0;    /* Dynamic */
-       gsm_tty_driver->minor_start     = 0;
-       gsm_tty_driver->type            = TTY_DRIVER_TYPE_SERIAL;
-       gsm_tty_driver->subtype = SERIAL_TYPE_NORMAL;
-       gsm_tty_driver->flags   = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV
-                                                       | TTY_DRIVER_HARDWARE_BREAK;
-       gsm_tty_driver->init_termios    = tty_std_termios;
-       /* Fixme */
-       gsm_tty_driver->init_termios.c_lflag &= ~ECHO;
-       tty_set_operations(gsm_tty_driver, &gsmtty_ops);
-
-       spin_lock_init(&gsm_mux_lock);
-
-       if (tty_register_driver(gsm_tty_driver)) {
-               put_tty_driver(gsm_tty_driver);
-               tty_unregister_ldisc(N_GSM0710);
-               printk(KERN_ERR "gsm_init: tty registration failed.\n");
-               return -EBUSY;
-       }
-       printk(KERN_INFO "gsm_init: loaded as %d,%d.\n", gsm_tty_driver->major, gsm_tty_driver->minor_start);
-       return 0;
-}
-
-static void __exit gsm_exit(void)
-{
-       int status = tty_unregister_ldisc(N_GSM0710);
-       if (status != 0)
-               printk(KERN_ERR "n_gsm: can't unregister line discipline (err = %d)\n", status);
-       tty_unregister_driver(gsm_tty_driver);
-       put_tty_driver(gsm_tty_driver);
-       printk(KERN_INFO "gsm_init: unloaded.\n");
-}
-
-module_init(gsm_init);
-module_exit(gsm_exit);
-
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_LDISC(N_GSM0710);
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
deleted file mode 100644 (file)
index 47d3228..0000000
+++ /dev/null
@@ -1,1007 +0,0 @@
-/* generic HDLC line discipline for Linux
- *
- * Written by Paul Fulghum paulkf@microgate.com
- * for Microgate Corporation
- *
- * Microgate and SyncLink are registered trademarks of Microgate Corporation
- *
- * Adapted from ppp.c, written by Michael Callahan <callahan@maths.ox.ac.uk>,
- *     Al Longyear <longyear@netcom.com>,
- *     Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
- *
- * Original release 01/11/99
- *
- * This code is released under the GNU General Public License (GPL)
- *
- * This module implements the tty line discipline N_HDLC for use with
- * tty device drivers that support bit-synchronous HDLC communications.
- *
- * All HDLC data is frame oriented which means:
- *
- * 1. tty write calls represent one complete transmit frame of data
- *    The device driver should accept the complete frame or none of 
- *    the frame (busy) in the write method. Each write call should have
- *    a byte count in the range of 2-65535 bytes (2 is min HDLC frame
- *    with 1 addr byte and 1 ctrl byte). The max byte count of 65535
- *    should include any crc bytes required. For example, when using
- *    CCITT CRC32, 4 crc bytes are required, so the maximum size frame
- *    the application may transmit is limited to 65531 bytes. For CCITT
- *    CRC16, the maximum application frame size would be 65533.
- *
- *
- * 2. receive callbacks from the device driver represents
- *    one received frame. The device driver should bypass
- *    the tty flip buffer and call the line discipline receive
- *    callback directly to avoid fragmenting or concatenating
- *    multiple frames into a single receive callback.
- *
- *    The HDLC line discipline queues the receive frames in separate
- *    buffers so complete receive frames can be returned by the
- *    tty read calls.
- *
- * 3. tty read calls returns an entire frame of data or nothing.
- *    
- * 4. all send and receive data is considered raw. No processing
- *    or translation is performed by the line discipline, regardless
- *    of the tty flags
- *
- * 5. When line discipline is queried for the amount of receive
- *    data available (FIOC), 0 is returned if no data available,
- *    otherwise the count of the next available frame is returned.
- *    (instead of the sum of all received frame counts).
- *
- * These conventions allow the standard tty programming interface
- * to be used for synchronous HDLC applications when used with
- * this line discipline (or another line discipline that is frame
- * oriented such as N_PPP).
- *
- * The SyncLink driver (synclink.c) implements both asynchronous
- * (using standard line discipline N_TTY) and synchronous HDLC
- * (using N_HDLC) communications, with the latter using the above
- * conventions.
- *
- * This implementation is very basic and does not maintain
- * any statistics. The main point is to enforce the raw data
- * and frame orientation of HDLC communications.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define HDLC_MAGIC 0x239e
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/ptrace.h>
-
-#undef VERSION
-#define VERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
-
-#include <linux/poll.h>
-#include <linux/in.h>
-#include <linux/ioctl.h>
-#include <linux/slab.h>
-#include <linux/tty.h>
-#include <linux/errno.h>
-#include <linux/smp_lock.h>
-#include <linux/string.h>      /* used in new tty drivers */
-#include <linux/signal.h>      /* used in new tty drivers */
-#include <linux/if.h>
-#include <linux/bitops.h>
-
-#include <asm/system.h>
-#include <asm/termios.h>
-#include <asm/uaccess.h>
-
-/*
- * Buffers for individual HDLC frames
- */
-#define MAX_HDLC_FRAME_SIZE 65535 
-#define DEFAULT_RX_BUF_COUNT 10
-#define MAX_RX_BUF_COUNT 60
-#define DEFAULT_TX_BUF_COUNT 3
-
-struct n_hdlc_buf {
-       struct n_hdlc_buf *link;
-       int               count;
-       char              buf[1];
-};
-
-#define        N_HDLC_BUF_SIZE (sizeof(struct n_hdlc_buf) + maxframe)
-
-struct n_hdlc_buf_list {
-       struct n_hdlc_buf *head;
-       struct n_hdlc_buf *tail;
-       int               count;
-       spinlock_t        spinlock;
-};
-
-/**
- * struct n_hdlc - per device instance data structure
- * @magic - magic value for structure
- * @flags - miscellaneous control flags
- * @tty - ptr to TTY structure
- * @backup_tty - TTY to use if tty gets closed
- * @tbusy - reentrancy flag for tx wakeup code
- * @woke_up - FIXME: describe this field
- * @tbuf - currently transmitting tx buffer
- * @tx_buf_list - list of pending transmit frame buffers
- * @rx_buf_list - list of received frame buffers
- * @tx_free_buf_list - list unused transmit frame buffers
- * @rx_free_buf_list - list unused received frame buffers
- */
-struct n_hdlc {
-       int                     magic;
-       __u32                   flags;
-       struct tty_struct       *tty;
-       struct tty_struct       *backup_tty;
-       int                     tbusy;
-       int                     woke_up;
-       struct n_hdlc_buf       *tbuf;
-       struct n_hdlc_buf_list  tx_buf_list;
-       struct n_hdlc_buf_list  rx_buf_list;
-       struct n_hdlc_buf_list  tx_free_buf_list;
-       struct n_hdlc_buf_list  rx_free_buf_list;
-};
-
-/*
- * HDLC buffer list manipulation functions
- */
-static void n_hdlc_buf_list_init(struct n_hdlc_buf_list *list);
-static void n_hdlc_buf_put(struct n_hdlc_buf_list *list,
-                          struct n_hdlc_buf *buf);
-static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *list);
-
-/* Local functions */
-
-static struct n_hdlc *n_hdlc_alloc (void);
-
-/* debug level can be set by insmod for debugging purposes */
-#define DEBUG_LEVEL_INFO       1
-static int debuglevel;
-
-/* max frame size for memory allocations */
-static int maxframe = 4096;
-
-/* TTY callbacks */
-
-static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
-                          __u8 __user *buf, size_t nr);
-static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
-                           const unsigned char *buf, size_t nr);
-static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
-                           unsigned int cmd, unsigned long arg);
-static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
-                                   poll_table *wait);
-static int n_hdlc_tty_open(struct tty_struct *tty);
-static void n_hdlc_tty_close(struct tty_struct *tty);
-static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp,
-                              char *fp, int count);
-static void n_hdlc_tty_wakeup(struct tty_struct *tty);
-
-#define bset(p,b)      ((p)[(b) >> 5] |= (1 << ((b) & 0x1f)))
-
-#define tty2n_hdlc(tty)        ((struct n_hdlc *) ((tty)->disc_data))
-#define n_hdlc2tty(n_hdlc)     ((n_hdlc)->tty)
-
-static void flush_rx_queue(struct tty_struct *tty)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
-       struct n_hdlc_buf *buf;
-
-       while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list)))
-               n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf);
-}
-
-static void flush_tx_queue(struct tty_struct *tty)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
-       struct n_hdlc_buf *buf;
-       unsigned long flags;
-
-       while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list)))
-               n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf);
-       spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags);
-       if (n_hdlc->tbuf) {
-               n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, n_hdlc->tbuf);
-               n_hdlc->tbuf = NULL;
-       }
-       spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
-}
-
-static struct tty_ldisc_ops n_hdlc_ldisc = {
-       .owner          = THIS_MODULE,
-       .magic          = TTY_LDISC_MAGIC,
-       .name           = "hdlc",
-       .open           = n_hdlc_tty_open,
-       .close          = n_hdlc_tty_close,
-       .read           = n_hdlc_tty_read,
-       .write          = n_hdlc_tty_write,
-       .ioctl          = n_hdlc_tty_ioctl,
-       .poll           = n_hdlc_tty_poll,
-       .receive_buf    = n_hdlc_tty_receive,
-       .write_wakeup   = n_hdlc_tty_wakeup,
-       .flush_buffer   = flush_rx_queue,
-};
-
-/**
- * n_hdlc_release - release an n_hdlc per device line discipline info structure
- * @n_hdlc - per device line discipline info structure
- */
-static void n_hdlc_release(struct n_hdlc *n_hdlc)
-{
-       struct tty_struct *tty = n_hdlc2tty (n_hdlc);
-       struct n_hdlc_buf *buf;
-       
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_release() called\n",__FILE__,__LINE__);
-               
-       /* Ensure that the n_hdlcd process is not hanging on select()/poll() */
-       wake_up_interruptible (&tty->read_wait);
-       wake_up_interruptible (&tty->write_wait);
-
-       if (tty->disc_data == n_hdlc)
-               tty->disc_data = NULL;  /* Break the tty->n_hdlc link */
-
-       /* Release transmit and receive buffers */
-       for(;;) {
-               buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list);
-               if (buf) {
-                       kfree(buf);
-               } else
-                       break;
-       }
-       for(;;) {
-               buf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list);
-               if (buf) {
-                       kfree(buf);
-               } else
-                       break;
-       }
-       for(;;) {
-               buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);
-               if (buf) {
-                       kfree(buf);
-               } else
-                       break;
-       }
-       for(;;) {
-               buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
-               if (buf) {
-                       kfree(buf);
-               } else
-                       break;
-       }
-       kfree(n_hdlc->tbuf);
-       kfree(n_hdlc);
-       
-}      /* end of n_hdlc_release() */
-
-/**
- * n_hdlc_tty_close - line discipline close
- * @tty - pointer to tty info structure
- *
- * Called when the line discipline is changed to something
- * else, the tty is closed, or the tty detects a hangup.
- */
-static void n_hdlc_tty_close(struct tty_struct *tty)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_close() called\n",__FILE__,__LINE__);
-               
-       if (n_hdlc != NULL) {
-               if (n_hdlc->magic != HDLC_MAGIC) {
-                       printk (KERN_WARNING"n_hdlc: trying to close unopened tty!\n");
-                       return;
-               }
-#if defined(TTY_NO_WRITE_SPLIT)
-               clear_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
-#endif
-               tty->disc_data = NULL;
-               if (tty == n_hdlc->backup_tty)
-                       n_hdlc->backup_tty = NULL;
-               if (tty != n_hdlc->tty)
-                       return;
-               if (n_hdlc->backup_tty) {
-                       n_hdlc->tty = n_hdlc->backup_tty;
-               } else {
-                       n_hdlc_release (n_hdlc);
-               }
-       }
-       
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_close() success\n",__FILE__,__LINE__);
-               
-}      /* end of n_hdlc_tty_close() */
-
-/**
- * n_hdlc_tty_open - called when line discipline changed to n_hdlc
- * @tty - pointer to tty info structure
- *
- * Returns 0 if success, otherwise error code
- */
-static int n_hdlc_tty_open (struct tty_struct *tty)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_open() called (device=%s)\n",
-               __FILE__,__LINE__,
-               tty->name);
-               
-       /* There should not be an existing table for this slot. */
-       if (n_hdlc) {
-               printk (KERN_ERR"n_hdlc_tty_open:tty already associated!\n" );
-               return -EEXIST;
-       }
-       
-       n_hdlc = n_hdlc_alloc();
-       if (!n_hdlc) {
-               printk (KERN_ERR "n_hdlc_alloc failed\n");
-               return -ENFILE;
-       }
-               
-       tty->disc_data = n_hdlc;
-       n_hdlc->tty    = tty;
-       tty->receive_room = 65536;
-       
-#if defined(TTY_NO_WRITE_SPLIT)
-       /* change tty_io write() to not split large writes into 8K chunks */
-       set_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
-#endif
-       
-       /* flush receive data from driver */
-       tty_driver_flush_buffer(tty);
-               
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__);
-               
-       return 0;
-       
-}      /* end of n_tty_hdlc_open() */
-
-/**
- * n_hdlc_send_frames - send frames on pending send buffer list
- * @n_hdlc - pointer to ldisc instance data
- * @tty - pointer to tty instance data
- *
- * Send frames on pending send buffer list until the driver does not accept a
- * frame (busy) this function is called after adding a frame to the send buffer
- * list and by the tty wakeup callback.
- */
-static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
-{
-       register int actual;
-       unsigned long flags;
-       struct n_hdlc_buf *tbuf;
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_send_frames() called\n",__FILE__,__LINE__);
- check_again:
-               
-       spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags);
-       if (n_hdlc->tbusy) {
-               n_hdlc->woke_up = 1;
-               spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
-               return;
-       }
-       n_hdlc->tbusy = 1;
-       n_hdlc->woke_up = 0;
-       spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
-
-       /* get current transmit buffer or get new transmit */
-       /* buffer from list of pending transmit buffers */
-               
-       tbuf = n_hdlc->tbuf;
-       if (!tbuf)
-               tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
-               
-       while (tbuf) {
-               if (debuglevel >= DEBUG_LEVEL_INFO)     
-                       printk("%s(%d)sending frame %p, count=%d\n",
-                               __FILE__,__LINE__,tbuf,tbuf->count);
-                       
-               /* Send the next block of data to device */
-               tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-               actual = tty->ops->write(tty, tbuf->buf, tbuf->count);
-
-               /* rollback was possible and has been done */
-               if (actual == -ERESTARTSYS) {
-                       n_hdlc->tbuf = tbuf;
-                       break;
-               }
-               /* if transmit error, throw frame away by */
-               /* pretending it was accepted by driver */
-               if (actual < 0)
-                       actual = tbuf->count;
-               
-               if (actual == tbuf->count) {
-                       if (debuglevel >= DEBUG_LEVEL_INFO)     
-                               printk("%s(%d)frame %p completed\n",
-                                       __FILE__,__LINE__,tbuf);
-                                       
-                       /* free current transmit buffer */
-                       n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf);
-                       
-                       /* this tx buffer is done */
-                       n_hdlc->tbuf = NULL;
-                       
-                       /* wait up sleeping writers */
-                       wake_up_interruptible(&tty->write_wait);
-       
-                       /* get next pending transmit buffer */
-                       tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
-               } else {
-                       if (debuglevel >= DEBUG_LEVEL_INFO)     
-                               printk("%s(%d)frame %p pending\n",
-                                       __FILE__,__LINE__,tbuf);
-                                       
-                       /* buffer not accepted by driver */
-                       /* set this buffer as pending buffer */
-                       n_hdlc->tbuf = tbuf;
-                       break;
-               }
-       }
-       
-       if (!tbuf)
-               tty->flags  &= ~(1 << TTY_DO_WRITE_WAKEUP);
-       
-       /* Clear the re-entry flag */
-       spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags);
-       n_hdlc->tbusy = 0;
-       spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); 
-       
-        if (n_hdlc->woke_up)
-         goto check_again;
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_send_frames() exit\n",__FILE__,__LINE__);
-               
-}      /* end of n_hdlc_send_frames() */
-
-/**
- * n_hdlc_tty_wakeup - Callback for transmit wakeup
- * @tty        - pointer to associated tty instance data
- *
- * Called when low level device driver can accept more send data.
- */
-static void n_hdlc_tty_wakeup(struct tty_struct *tty)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_wakeup() called\n",__FILE__,__LINE__);
-               
-       if (!n_hdlc)
-               return;
-
-       if (tty != n_hdlc->tty) {
-               tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
-               return;
-       }
-
-       n_hdlc_send_frames (n_hdlc, tty);
-               
-}      /* end of n_hdlc_tty_wakeup() */
-
-/**
- * n_hdlc_tty_receive - Called by tty driver when receive data is available
- * @tty        - pointer to tty instance data
- * @data - pointer to received data
- * @flags - pointer to flags for data
- * @count - count of received data in bytes
- *
- * Called by tty low level driver when receive data is available. Data is
- * interpreted as one HDLC frame.
- */
-static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
-                              char *flags, int count)
-{
-       register struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
-       register struct n_hdlc_buf *buf;
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_receive() called count=%d\n",
-                       __FILE__,__LINE__, count);
-               
-       /* This can happen if stuff comes in on the backup tty */
-       if (!n_hdlc || tty != n_hdlc->tty)
-               return;
-               
-       /* verify line is using HDLC discipline */
-       if (n_hdlc->magic != HDLC_MAGIC) {
-               printk("%s(%d) line not using HDLC discipline\n",
-                       __FILE__,__LINE__);
-               return;
-       }
-       
-       if ( count>maxframe ) {
-               if (debuglevel >= DEBUG_LEVEL_INFO)     
-                       printk("%s(%d) rx count>maxframesize, data discarded\n",
-                              __FILE__,__LINE__);
-               return;
-       }
-
-       /* get a free HDLC buffer */    
-       buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list);
-       if (!buf) {
-               /* no buffers in free list, attempt to allocate another rx buffer */
-               /* unless the maximum count has been reached */
-               if (n_hdlc->rx_buf_list.count < MAX_RX_BUF_COUNT)
-                       buf = kmalloc(N_HDLC_BUF_SIZE, GFP_ATOMIC);
-       }
-       
-       if (!buf) {
-               if (debuglevel >= DEBUG_LEVEL_INFO)     
-                       printk("%s(%d) no more rx buffers, data discarded\n",
-                              __FILE__,__LINE__);
-               return;
-       }
-               
-       /* copy received data to HDLC buffer */
-       memcpy(buf->buf,data,count);
-       buf->count=count;
-
-       /* add HDLC buffer to list of received frames */
-       n_hdlc_buf_put(&n_hdlc->rx_buf_list, buf);
-       
-       /* wake up any blocked reads and perform async signalling */
-       wake_up_interruptible (&tty->read_wait);
-       if (n_hdlc->tty->fasync != NULL)
-               kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN);
-
-}      /* end of n_hdlc_tty_receive() */
-
-/**
- * n_hdlc_tty_read - Called to retrieve one frame of data (if available)
- * @tty - pointer to tty instance data
- * @file - pointer to open file object
- * @buf - pointer to returned data buffer
- * @nr - size of returned data buffer
- *     
- * Returns the number of bytes returned or error code.
- */
-static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
-                          __u8 __user *buf, size_t nr)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
-       int ret;
-       struct n_hdlc_buf *rbuf;
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_read() called\n",__FILE__,__LINE__);
-               
-       /* Validate the pointers */
-       if (!n_hdlc)
-               return -EIO;
-
-       /* verify user access to buffer */
-       if (!access_ok(VERIFY_WRITE, buf, nr)) {
-               printk(KERN_WARNING "%s(%d) n_hdlc_tty_read() can't verify user "
-               "buffer\n", __FILE__, __LINE__);
-               return -EFAULT;
-       }
-
-       tty_lock();
-
-       for (;;) {
-               if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
-                       tty_unlock();
-                       return -EIO;
-               }
-
-               n_hdlc = tty2n_hdlc (tty);
-               if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
-                        tty != n_hdlc->tty) {
-                       tty_unlock();
-                       return 0;
-               }
-
-               rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);
-               if (rbuf)
-                       break;
-                       
-               /* no data */
-               if (file->f_flags & O_NONBLOCK) {
-                       tty_unlock();
-                       return -EAGAIN;
-               }
-                       
-               interruptible_sleep_on (&tty->read_wait);
-               if (signal_pending(current)) {
-                       tty_unlock();
-                       return -EINTR;
-               }
-       }
-               
-       if (rbuf->count > nr)
-               /* frame too large for caller's buffer (discard frame) */
-               ret = -EOVERFLOW;
-       else {
-               /* Copy the data to the caller's buffer */
-               if (copy_to_user(buf, rbuf->buf, rbuf->count))
-                       ret = -EFAULT;
-               else
-                       ret = rbuf->count;
-       }
-       
-       /* return HDLC buffer to free list unless the free list */
-       /* count has exceeded the default value, in which case the */
-       /* buffer is freed back to the OS to conserve memory */
-       if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT)
-               kfree(rbuf);
-       else    
-               n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
-       tty_unlock();
-       return ret;
-       
-}      /* end of n_hdlc_tty_read() */
-
-/**
- * n_hdlc_tty_write - write a single frame of data to device
- * @tty        - pointer to associated tty device instance data
- * @file - pointer to file object data
- * @data - pointer to transmit data (one frame)
- * @count - size of transmit frame in bytes
- *             
- * Returns the number of bytes written (or error code).
- */
-static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
-                           const unsigned char *data, size_t count)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
-       int error = 0;
-       DECLARE_WAITQUEUE(wait, current);
-       struct n_hdlc_buf *tbuf;
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_write() called count=%Zd\n",
-                       __FILE__,__LINE__,count);
-               
-       /* Verify pointers */
-       if (!n_hdlc)
-               return -EIO;
-
-       if (n_hdlc->magic != HDLC_MAGIC)
-               return -EIO;
-
-       /* verify frame size */
-       if (count > maxframe ) {
-               if (debuglevel & DEBUG_LEVEL_INFO)
-                       printk (KERN_WARNING
-                               "n_hdlc_tty_write: truncating user packet "
-                               "from %lu to %d\n", (unsigned long) count,
-                               maxframe );
-               count = maxframe;
-       }
-       
-       tty_lock();
-
-       add_wait_queue(&tty->write_wait, &wait);
-       set_current_state(TASK_INTERRUPTIBLE);
-       
-       /* Allocate transmit buffer */
-       /* sleep until transmit buffer available */             
-       while (!(tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list))) {
-               if (file->f_flags & O_NONBLOCK) {
-                       error = -EAGAIN;
-                       break;
-               }
-               schedule();
-                       
-               n_hdlc = tty2n_hdlc (tty);
-               if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || 
-                   tty != n_hdlc->tty) {
-                       printk("n_hdlc_tty_write: %p invalid after wait!\n", n_hdlc);
-                       error = -EIO;
-                       break;
-               }
-                       
-               if (signal_pending(current)) {
-                       error = -EINTR;
-                       break;
-               }
-       }
-
-       set_current_state(TASK_RUNNING);
-       remove_wait_queue(&tty->write_wait, &wait);
-
-       if (!error) {           
-               /* Retrieve the user's buffer */
-               memcpy(tbuf->buf, data, count);
-
-               /* Send the data */
-               tbuf->count = error = count;
-               n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
-               n_hdlc_send_frames(n_hdlc,tty);
-       }
-       tty_unlock();
-       return error;
-       
-}      /* end of n_hdlc_tty_write() */
-
-/**
- * n_hdlc_tty_ioctl - process IOCTL system call for the tty device.
- * @tty - pointer to tty instance data
- * @file - pointer to open file object for device
- * @cmd - IOCTL command code
- * @arg - argument for IOCTL call (cmd dependent)
- *
- * Returns command dependent result.
- */
-static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
-                           unsigned int cmd, unsigned long arg)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
-       int error = 0;
-       int count;
-       unsigned long flags;
-       
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_ioctl() called %d\n",
-                       __FILE__,__LINE__,cmd);
-               
-       /* Verify the status of the device */
-       if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC)
-               return -EBADF;
-
-       switch (cmd) {
-       case FIONREAD:
-               /* report count of read data available */
-               /* in next available frame (if any) */
-               spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags);
-               if (n_hdlc->rx_buf_list.head)
-                       count = n_hdlc->rx_buf_list.head->count;
-               else
-                       count = 0;
-               spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags);
-               error = put_user(count, (int __user *)arg);
-               break;
-
-       case TIOCOUTQ:
-               /* get the pending tx byte count in the driver */
-               count = tty_chars_in_buffer(tty);
-               /* add size of next output frame in queue */
-               spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags);
-               if (n_hdlc->tx_buf_list.head)
-                       count += n_hdlc->tx_buf_list.head->count;
-               spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags);
-               error = put_user(count, (int __user *)arg);
-               break;
-
-       case TCFLSH:
-               switch (arg) {
-               case TCIOFLUSH:
-               case TCOFLUSH:
-                       flush_tx_queue(tty);
-               }
-               /* fall through to default */
-
-       default:
-               error = n_tty_ioctl_helper(tty, file, cmd, arg);
-               break;
-       }
-       return error;
-       
-}      /* end of n_hdlc_tty_ioctl() */
-
-/**
- * n_hdlc_tty_poll - TTY callback for poll system call
- * @tty - pointer to tty instance data
- * @filp - pointer to open file object for device
- * @poll_table - wait queue for operations
- * 
- * Determine which operations (read/write) will not block and return info
- * to caller.
- * Returns a bit mask containing info on which ops will not block.
- */
-static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
-                                   poll_table *wait)
-{
-       struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
-       unsigned int mask = 0;
-
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_poll() called\n",__FILE__,__LINE__);
-               
-       if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) {
-               /* queue current process into any wait queue that */
-               /* may awaken in the future (read and write) */
-
-               poll_wait(filp, &tty->read_wait, wait);
-               poll_wait(filp, &tty->write_wait, wait);
-
-               /* set bits for operations that won't block */
-               if (n_hdlc->rx_buf_list.head)
-                       mask |= POLLIN | POLLRDNORM;    /* readable */
-               if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
-                       mask |= POLLHUP;
-               if (tty_hung_up_p(filp))
-                       mask |= POLLHUP;
-               if (!tty_is_writelocked(tty) &&
-                               n_hdlc->tx_free_buf_list.head)
-                       mask |= POLLOUT | POLLWRNORM;   /* writable */
-       }
-       return mask;
-}      /* end of n_hdlc_tty_poll() */
-
-/**
- * n_hdlc_alloc - allocate an n_hdlc instance data structure
- *
- * Returns a pointer to newly created structure if success, otherwise %NULL
- */
-static struct n_hdlc *n_hdlc_alloc(void)
-{
-       struct n_hdlc_buf *buf;
-       int i;
-       struct n_hdlc *n_hdlc = kmalloc(sizeof(*n_hdlc), GFP_KERNEL);
-
-       if (!n_hdlc)
-               return NULL;
-
-       memset(n_hdlc, 0, sizeof(*n_hdlc));
-
-       n_hdlc_buf_list_init(&n_hdlc->rx_free_buf_list);
-       n_hdlc_buf_list_init(&n_hdlc->tx_free_buf_list);
-       n_hdlc_buf_list_init(&n_hdlc->rx_buf_list);
-       n_hdlc_buf_list_init(&n_hdlc->tx_buf_list);
-       
-       /* allocate free rx buffer list */
-       for(i=0;i<DEFAULT_RX_BUF_COUNT;i++) {
-               buf = kmalloc(N_HDLC_BUF_SIZE, GFP_KERNEL);
-               if (buf)
-                       n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,buf);
-               else if (debuglevel >= DEBUG_LEVEL_INFO)        
-                       printk("%s(%d)n_hdlc_alloc(), kalloc() failed for rx buffer %d\n",__FILE__,__LINE__, i);
-       }
-       
-       /* allocate free tx buffer list */
-       for(i=0;i<DEFAULT_TX_BUF_COUNT;i++) {
-               buf = kmalloc(N_HDLC_BUF_SIZE, GFP_KERNEL);
-               if (buf)
-                       n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,buf);
-               else if (debuglevel >= DEBUG_LEVEL_INFO)        
-                       printk("%s(%d)n_hdlc_alloc(), kalloc() failed for tx buffer %d\n",__FILE__,__LINE__, i);
-       }
-       
-       /* Initialize the control block */
-       n_hdlc->magic  = HDLC_MAGIC;
-       n_hdlc->flags  = 0;
-       
-       return n_hdlc;
-       
-}      /* end of n_hdlc_alloc() */
-
-/**
- * n_hdlc_buf_list_init - initialize specified HDLC buffer list
- * @list - pointer to buffer list
- */
-static void n_hdlc_buf_list_init(struct n_hdlc_buf_list *list)
-{
-       memset(list, 0, sizeof(*list));
-       spin_lock_init(&list->spinlock);
-}      /* end of n_hdlc_buf_list_init() */
-
-/**
- * n_hdlc_buf_put - add specified HDLC buffer to tail of specified list
- * @list - pointer to buffer list
- * @buf        - pointer to buffer
- */
-static void n_hdlc_buf_put(struct n_hdlc_buf_list *list,
-                          struct n_hdlc_buf *buf)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&list->spinlock,flags);
-       
-       buf->link=NULL;
-       if (list->tail)
-               list->tail->link = buf;
-       else
-               list->head = buf;
-       list->tail = buf;
-       (list->count)++;
-       
-       spin_unlock_irqrestore(&list->spinlock,flags);
-       
-}      /* end of n_hdlc_buf_put() */
-
-/**
- * n_hdlc_buf_get - remove and return an HDLC buffer from list
- * @list - pointer to HDLC buffer list
- * 
- * Remove and return an HDLC buffer from the head of the specified HDLC buffer
- * list.
- * Returns a pointer to HDLC buffer if available, otherwise %NULL.
- */
-static struct n_hdlc_buf* n_hdlc_buf_get(struct n_hdlc_buf_list *list)
-{
-       unsigned long flags;
-       struct n_hdlc_buf *buf;
-       spin_lock_irqsave(&list->spinlock,flags);
-       
-       buf = list->head;
-       if (buf) {
-               list->head = buf->link;
-               (list->count)--;
-       }
-       if (!list->head)
-               list->tail = NULL;
-       
-       spin_unlock_irqrestore(&list->spinlock,flags);
-       return buf;
-       
-}      /* end of n_hdlc_buf_get() */
-
-static char hdlc_banner[] __initdata =
-       KERN_INFO "HDLC line discipline maxframe=%u\n";
-static char hdlc_register_ok[] __initdata =
-       KERN_INFO "N_HDLC line discipline registered.\n";
-static char hdlc_register_fail[] __initdata =
-       KERN_ERR "error registering line discipline: %d\n";
-static char hdlc_init_fail[] __initdata =
-       KERN_INFO "N_HDLC: init failure %d\n";
-
-static int __init n_hdlc_init(void)
-{
-       int status;
-
-       /* range check maxframe arg */
-       if (maxframe < 4096)
-               maxframe = 4096;
-       else if (maxframe > 65535)
-               maxframe = 65535;
-
-       printk(hdlc_banner, maxframe);
-
-       status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc);
-       if (!status)
-               printk(hdlc_register_ok);
-       else
-               printk(hdlc_register_fail, status);
-
-       if (status)
-               printk(hdlc_init_fail, status);
-       return status;
-       
-}      /* end of init_module() */
-
-static char hdlc_unregister_ok[] __exitdata =
-       KERN_INFO "N_HDLC: line discipline unregistered\n";
-static char hdlc_unregister_fail[] __exitdata =
-       KERN_ERR "N_HDLC: can't unregister line discipline (err = %d)\n";
-
-static void __exit n_hdlc_exit(void)
-{
-       /* Release tty registration of line discipline */
-       int status = tty_unregister_ldisc(N_HDLC);
-
-       if (status)
-               printk(hdlc_unregister_fail, status);
-       else
-               printk(hdlc_unregister_ok);
-}
-
-module_init(n_hdlc_init);
-module_exit(n_hdlc_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Paul Fulghum paulkf@microgate.com");
-module_param(debuglevel, int, 0);
-module_param(maxframe, int, 0);
-MODULE_ALIAS_LDISC(N_HDLC);
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
deleted file mode 100644 (file)
index 88dda0c..0000000
+++ /dev/null
@@ -1,1264 +0,0 @@
-/* r3964 linediscipline for linux
- *
- * -----------------------------------------------------------
- * Copyright by 
- * Philips Automation Projects
- * Kassel (Germany)
- * -----------------------------------------------------------
- * This software may be used and distributed according to the terms of
- * the GNU General Public License, incorporated herein by reference.
- *
- * Author:
- * L. Haag
- *
- * $Log: n_r3964.c,v $
- * Revision 1.10  2001/03/18 13:02:24  dwmw2
- * Fix timer usage, use spinlocks properly.
- *
- * Revision 1.9  2001/03/18 12:52:14  dwmw2
- * Merge changes in 2.4.2
- *
- * Revision 1.8  2000/03/23 14:14:54  dwmw2
- * Fix race in sleeping in r3964_read()
- *
- * Revision 1.7  1999/28/08 11:41:50  dwmw2
- * Port to 2.3 kernel
- *
- * Revision 1.6  1998/09/30 00:40:40  dwmw2
- * Fixed compilation on 2.0.x kernels
- * Updated to newly registered tty-ldisc number 9
- *
- * Revision 1.5  1998/09/04 21:57:36  dwmw2
- * Signal handling bug fixes, port to 2.1.x.
- *
- * Revision 1.4  1998/04/02 20:26:59  lhaag
- * select, blocking, ...
- *
- * Revision 1.3  1998/02/12 18:58:43  root
- * fixed some memory leaks
- * calculation of checksum characters
- *
- * Revision 1.2  1998/02/07 13:03:34  root
- * ioctl read_telegram
- *
- * Revision 1.1  1998/02/06 19:21:03  root
- * Initial revision
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/in.h>
-#include <linux/slab.h>
-#include <linux/smp_lock.h>
-#include <linux/tty.h>
-#include <linux/errno.h>
-#include <linux/string.h>      /* used in new tty drivers */
-#include <linux/signal.h>      /* used in new tty drivers */
-#include <linux/ioctl.h>
-#include <linux/n_r3964.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
-
-/*#define DEBUG_QUEUE*/
-
-/* Log successful handshake and protocol operations  */
-/*#define DEBUG_PROTO_S*/
-
-/* Log handshake and protocol errors: */
-/*#define DEBUG_PROTO_E*/
-
-/* Log Linediscipline operations (open, close, read, write...): */
-/*#define DEBUG_LDISC*/
-
-/* Log module and memory operations (init, cleanup; kmalloc, kfree): */
-/*#define DEBUG_MODUL*/
-
-/* Macro helpers for debug output: */
-#define TRACE(format, args...) printk("r3964: " format "\n" , ## args)
-
-#ifdef DEBUG_MODUL
-#define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_M(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_PROTO_S
-#define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_PS(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_PROTO_E
-#define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_PE(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_LDISC
-#define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_L(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_QUEUE
-#define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_Q(fmt, arg...) do {} while (0)
-#endif
-static void add_tx_queue(struct r3964_info *, struct r3964_block_header *);
-static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code);
-static void put_char(struct r3964_info *pInfo, unsigned char ch);
-static void trigger_transmit(struct r3964_info *pInfo);
-static void retry_transmit(struct r3964_info *pInfo);
-static void transmit_block(struct r3964_info *pInfo);
-static void receive_char(struct r3964_info *pInfo, const unsigned char c);
-static void receive_error(struct r3964_info *pInfo, const char flag);
-static void on_timeout(unsigned long priv);
-static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg);
-static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
-               unsigned char __user * buf);
-static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
-               int error_code, struct r3964_block_header *pBlock);
-static struct r3964_message *remove_msg(struct r3964_info *pInfo,
-               struct r3964_client_info *pClient);
-static void remove_client_block(struct r3964_info *pInfo,
-               struct r3964_client_info *pClient);
-
-static int r3964_open(struct tty_struct *tty);
-static void r3964_close(struct tty_struct *tty);
-static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
-               unsigned char __user * buf, size_t nr);
-static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
-               const unsigned char *buf, size_t nr);
-static int r3964_ioctl(struct tty_struct *tty, struct file *file,
-               unsigned int cmd, unsigned long arg);
-static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
-static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
-               struct poll_table_struct *wait);
-static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-               char *fp, int count);
-
-static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
-       .owner = THIS_MODULE,
-       .magic = TTY_LDISC_MAGIC,
-       .name = "R3964",
-       .open = r3964_open,
-       .close = r3964_close,
-       .read = r3964_read,
-       .write = r3964_write,
-       .ioctl = r3964_ioctl,
-       .set_termios = r3964_set_termios,
-       .poll = r3964_poll,
-       .receive_buf = r3964_receive_buf,
-};
-
-static void dump_block(const unsigned char *block, unsigned int length)
-{
-       unsigned int i, j;
-       char linebuf[16 * 3 + 1];
-
-       for (i = 0; i < length; i += 16) {
-               for (j = 0; (j < 16) && (j + i < length); j++) {
-                       sprintf(linebuf + 3 * j, "%02x ", block[i + j]);
-               }
-               linebuf[3 * j] = '\0';
-               TRACE_PS("%s", linebuf);
-       }
-}
-
-/*************************************************************
- * Driver initialisation
- *************************************************************/
-
-/*************************************************************
- * Module support routines
- *************************************************************/
-
-static void __exit r3964_exit(void)
-{
-       int status;
-
-       TRACE_M("cleanup_module()");
-
-       status = tty_unregister_ldisc(N_R3964);
-
-       if (status != 0) {
-               printk(KERN_ERR "r3964: error unregistering linediscipline: "
-                               "%d\n", status);
-       } else {
-               TRACE_L("linediscipline successfully unregistered");
-       }
-}
-
-static int __init r3964_init(void)
-{
-       int status;
-
-       printk("r3964: Philips r3964 Driver $Revision: 1.10 $\n");
-
-       /*
-        * Register the tty line discipline
-        */
-
-       status = tty_register_ldisc(N_R3964, &tty_ldisc_N_R3964);
-       if (status == 0) {
-               TRACE_L("line discipline %d registered", N_R3964);
-               TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags,
-                       tty_ldisc_N_R3964.num);
-               TRACE_L("open=%p", tty_ldisc_N_R3964.open);
-               TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
-       } else {
-               printk(KERN_ERR "r3964: error registering line discipline: "
-                               "%d\n", status);
-       }
-       return status;
-}
-
-module_init(r3964_init);
-module_exit(r3964_exit);
-
-/*************************************************************
- * Protocol implementation routines
- *************************************************************/
-
-static void add_tx_queue(struct r3964_info *pInfo,
-                        struct r3964_block_header *pHeader)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       pHeader->next = NULL;
-
-       if (pInfo->tx_last == NULL) {
-               pInfo->tx_first = pInfo->tx_last = pHeader;
-       } else {
-               pInfo->tx_last->next = pHeader;
-               pInfo->tx_last = pHeader;
-       }
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       TRACE_Q("add_tx_queue %p, length %d, tx_first = %p",
-               pHeader, pHeader->length, pInfo->tx_first);
-}
-
-static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
-{
-       struct r3964_block_header *pHeader;
-       unsigned long flags;
-#ifdef DEBUG_QUEUE
-       struct r3964_block_header *pDump;
-#endif
-
-       pHeader = pInfo->tx_first;
-
-       if (pHeader == NULL)
-               return;
-
-#ifdef DEBUG_QUEUE
-       printk("r3964: remove_from_tx_queue: %p, length %u - ",
-               pHeader, pHeader->length);
-       for (pDump = pHeader; pDump; pDump = pDump->next)
-               printk("%p ", pDump);
-       printk("\n");
-#endif
-
-       if (pHeader->owner) {
-               if (error_code) {
-                       add_msg(pHeader->owner, R3964_MSG_ACK, 0,
-                               error_code, NULL);
-               } else {
-                       add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length,
-                               error_code, NULL);
-               }
-               wake_up_interruptible(&pInfo->read_wait);
-       }
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       pInfo->tx_first = pHeader->next;
-       if (pInfo->tx_first == NULL) {
-               pInfo->tx_last = NULL;
-       }
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       kfree(pHeader);
-       TRACE_M("remove_from_tx_queue - kfree %p", pHeader);
-
-       TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
-               pInfo->tx_first, pInfo->tx_last);
-}
-
-static void add_rx_queue(struct r3964_info *pInfo,
-                        struct r3964_block_header *pHeader)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       pHeader->next = NULL;
-
-       if (pInfo->rx_last == NULL) {
-               pInfo->rx_first = pInfo->rx_last = pHeader;
-       } else {
-               pInfo->rx_last->next = pHeader;
-               pInfo->rx_last = pHeader;
-       }
-       pInfo->blocks_in_rx_queue++;
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
-               pHeader, pHeader->length,
-               pInfo->rx_first, pInfo->blocks_in_rx_queue);
-}
-
-static void remove_from_rx_queue(struct r3964_info *pInfo,
-                                struct r3964_block_header *pHeader)
-{
-       unsigned long flags;
-       struct r3964_block_header *pFind;
-
-       if (pHeader == NULL)
-               return;
-
-       TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
-               pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
-       TRACE_Q("remove_from_rx_queue: %p, length %u",
-               pHeader, pHeader->length);
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       if (pInfo->rx_first == pHeader) {
-               /* Remove the first block in the linked list: */
-               pInfo->rx_first = pHeader->next;
-
-               if (pInfo->rx_first == NULL) {
-                       pInfo->rx_last = NULL;
-               }
-               pInfo->blocks_in_rx_queue--;
-       } else {
-               /* Find block to remove: */
-               for (pFind = pInfo->rx_first; pFind; pFind = pFind->next) {
-                       if (pFind->next == pHeader) {
-                               /* Got it. */
-                               pFind->next = pHeader->next;
-                               pInfo->blocks_in_rx_queue--;
-                               if (pFind->next == NULL) {
-                                       /* Oh, removed the last one! */
-                                       pInfo->rx_last = pFind;
-                               }
-                               break;
-                       }
-               }
-       }
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       kfree(pHeader);
-       TRACE_M("remove_from_rx_queue - kfree %p", pHeader);
-
-       TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
-               pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
-}
-
-static void put_char(struct r3964_info *pInfo, unsigned char ch)
-{
-       struct tty_struct *tty = pInfo->tty;
-       /* FIXME: put_char should not be called from an IRQ */
-       tty_put_char(tty, ch);
-       pInfo->bcc ^= ch;
-}
-
-static void flush(struct r3964_info *pInfo)
-{
-       struct tty_struct *tty = pInfo->tty;
-
-       if (tty == NULL || tty->ops->flush_chars == NULL)
-               return;
-       tty->ops->flush_chars(tty);
-}
-
-static void trigger_transmit(struct r3964_info *pInfo)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       if ((pInfo->state == R3964_IDLE) && (pInfo->tx_first != NULL)) {
-               pInfo->state = R3964_TX_REQUEST;
-               pInfo->nRetry = 0;
-               pInfo->flags &= ~R3964_ERROR;
-               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-
-               spin_unlock_irqrestore(&pInfo->lock, flags);
-
-               TRACE_PS("trigger_transmit - sent STX");
-
-               put_char(pInfo, STX);
-               flush(pInfo);
-
-               pInfo->bcc = 0;
-       } else {
-               spin_unlock_irqrestore(&pInfo->lock, flags);
-       }
-}
-
-static void retry_transmit(struct r3964_info *pInfo)
-{
-       if (pInfo->nRetry < R3964_MAX_RETRIES) {
-               TRACE_PE("transmission failed. Retry #%d", pInfo->nRetry);
-               pInfo->bcc = 0;
-               put_char(pInfo, STX);
-               flush(pInfo);
-               pInfo->state = R3964_TX_REQUEST;
-               pInfo->nRetry++;
-               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-       } else {
-               TRACE_PE("transmission failed after %d retries",
-                        R3964_MAX_RETRIES);
-
-               remove_from_tx_queue(pInfo, R3964_TX_FAIL);
-
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-
-               trigger_transmit(pInfo);
-       }
-}
-
-static void transmit_block(struct r3964_info *pInfo)
-{
-       struct tty_struct *tty = pInfo->tty;
-       struct r3964_block_header *pBlock = pInfo->tx_first;
-       int room = 0;
-
-       if (tty == NULL || pBlock == NULL) {
-               return;
-       }
-
-       room = tty_write_room(tty);
-
-       TRACE_PS("transmit_block %p, room %d, length %d",
-                pBlock, room, pBlock->length);
-
-       while (pInfo->tx_position < pBlock->length) {
-               if (room < 2)
-                       break;
-
-               if (pBlock->data[pInfo->tx_position] == DLE) {
-                       /* send additional DLE char: */
-                       put_char(pInfo, DLE);
-               }
-               put_char(pInfo, pBlock->data[pInfo->tx_position++]);
-
-               room--;
-       }
-
-       if ((pInfo->tx_position == pBlock->length) && (room >= 3)) {
-               put_char(pInfo, DLE);
-               put_char(pInfo, ETX);
-               if (pInfo->flags & R3964_BCC) {
-                       put_char(pInfo, pInfo->bcc);
-               }
-               pInfo->state = R3964_WAIT_FOR_TX_ACK;
-               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-       }
-       flush(pInfo);
-}
-
-static void on_receive_block(struct r3964_info *pInfo)
-{
-       unsigned int length;
-       struct r3964_client_info *pClient;
-       struct r3964_block_header *pBlock;
-
-       length = pInfo->rx_position;
-
-       /* compare byte checksum characters: */
-       if (pInfo->flags & R3964_BCC) {
-               if (pInfo->bcc != pInfo->last_rx) {
-                       TRACE_PE("checksum error - got %x but expected %x",
-                                pInfo->last_rx, pInfo->bcc);
-                       pInfo->flags |= R3964_CHECKSUM;
-               }
-       }
-
-       /* check for errors (parity, overrun,...): */
-       if (pInfo->flags & R3964_ERROR) {
-               TRACE_PE("on_receive_block - transmission failed error %x",
-                        pInfo->flags & R3964_ERROR);
-
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               if (pInfo->nRetry < R3964_MAX_RETRIES) {
-                       pInfo->state = R3964_WAIT_FOR_RX_REPEAT;
-                       pInfo->nRetry++;
-                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC);
-               } else {
-                       TRACE_PE("on_receive_block - failed after max retries");
-                       pInfo->state = R3964_IDLE;
-               }
-               return;
-       }
-
-       /* received block; submit DLE: */
-       put_char(pInfo, DLE);
-       flush(pInfo);
-       del_timer_sync(&pInfo->tmr);
-       TRACE_PS(" rx success: got %d chars", length);
-
-       /* prepare struct r3964_block_header: */
-       pBlock = kmalloc(length + sizeof(struct r3964_block_header),
-                       GFP_KERNEL);
-       TRACE_M("on_receive_block - kmalloc %p", pBlock);
-
-       if (pBlock == NULL)
-               return;
-
-       pBlock->length = length;
-       pBlock->data = ((unsigned char *)pBlock) +
-                       sizeof(struct r3964_block_header);
-       pBlock->locks = 0;
-       pBlock->next = NULL;
-       pBlock->owner = NULL;
-
-       memcpy(pBlock->data, pInfo->rx_buf, length);
-
-       /* queue block into rx_queue: */
-       add_rx_queue(pInfo, pBlock);
-
-       /* notify attached client processes: */
-       for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
-               if (pClient->sig_flags & R3964_SIG_DATA) {
-                       add_msg(pClient, R3964_MSG_DATA, length, R3964_OK,
-                               pBlock);
-               }
-       }
-       wake_up_interruptible(&pInfo->read_wait);
-
-       pInfo->state = R3964_IDLE;
-
-       trigger_transmit(pInfo);
-}
-
-static void receive_char(struct r3964_info *pInfo, const unsigned char c)
-{
-       switch (pInfo->state) {
-       case R3964_TX_REQUEST:
-               if (c == DLE) {
-                       TRACE_PS("TX_REQUEST - got DLE");
-
-                       pInfo->state = R3964_TRANSMITTING;
-                       pInfo->tx_position = 0;
-
-                       transmit_block(pInfo);
-               } else if (c == STX) {
-                       if (pInfo->nRetry == 0) {
-                               TRACE_PE("TX_REQUEST - init conflict");
-                               if (pInfo->priority == R3964_SLAVE) {
-                                       goto start_receiving;
-                               }
-                       } else {
-                               TRACE_PE("TX_REQUEST - secondary init "
-                                       "conflict!? Switching to SLAVE mode "
-                                       "for next rx.");
-                               goto start_receiving;
-                       }
-               } else {
-                       TRACE_PE("TX_REQUEST - char != DLE: %x", c);
-                       retry_transmit(pInfo);
-               }
-               break;
-       case R3964_TRANSMITTING:
-               if (c == NAK) {
-                       TRACE_PE("TRANSMITTING - got NAK");
-                       retry_transmit(pInfo);
-               } else {
-                       TRACE_PE("TRANSMITTING - got invalid char");
-
-                       pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY;
-                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-               }
-               break;
-       case R3964_WAIT_FOR_TX_ACK:
-               if (c == DLE) {
-                       TRACE_PS("WAIT_FOR_TX_ACK - got DLE");
-                       remove_from_tx_queue(pInfo, R3964_OK);
-
-                       pInfo->state = R3964_IDLE;
-                       trigger_transmit(pInfo);
-               } else {
-                       retry_transmit(pInfo);
-               }
-               break;
-       case R3964_WAIT_FOR_RX_REPEAT:
-               /* FALLTHROUGH */
-       case R3964_IDLE:
-               if (c == STX) {
-                       /* Prevent rx_queue from overflow: */
-                       if (pInfo->blocks_in_rx_queue >=
-                           R3964_MAX_BLOCKS_IN_RX_QUEUE) {
-                               TRACE_PE("IDLE - got STX but no space in "
-                                               "rx_queue!");
-                               pInfo->state = R3964_WAIT_FOR_RX_BUF;
-                               mod_timer(&pInfo->tmr,
-                                         jiffies + R3964_TO_NO_BUF);
-                               break;
-                       }
-start_receiving:
-                       /* Ok, start receiving: */
-                       TRACE_PS("IDLE - got STX");
-                       pInfo->rx_position = 0;
-                       pInfo->last_rx = 0;
-                       pInfo->flags &= ~R3964_ERROR;
-                       pInfo->state = R3964_RECEIVING;
-                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-                       pInfo->nRetry = 0;
-                       put_char(pInfo, DLE);
-                       flush(pInfo);
-                       pInfo->bcc = 0;
-               }
-               break;
-       case R3964_RECEIVING:
-               if (pInfo->rx_position < RX_BUF_SIZE) {
-                       pInfo->bcc ^= c;
-
-                       if (c == DLE) {
-                               if (pInfo->last_rx == DLE) {
-                                       pInfo->last_rx = 0;
-                                       goto char_to_buf;
-                               }
-                               pInfo->last_rx = DLE;
-                               break;
-                       } else if ((c == ETX) && (pInfo->last_rx == DLE)) {
-                               if (pInfo->flags & R3964_BCC) {
-                                       pInfo->state = R3964_WAIT_FOR_BCC;
-                                       mod_timer(&pInfo->tmr,
-                                                 jiffies + R3964_TO_ZVZ);
-                               } else {
-                                       on_receive_block(pInfo);
-                               }
-                       } else {
-                               pInfo->last_rx = c;
-char_to_buf:
-                               pInfo->rx_buf[pInfo->rx_position++] = c;
-                               mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-                       }
-               }
-               /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */
-               break;
-       case R3964_WAIT_FOR_BCC:
-               pInfo->last_rx = c;
-               on_receive_block(pInfo);
-               break;
-       }
-}
-
-static void receive_error(struct r3964_info *pInfo, const char flag)
-{
-       switch (flag) {
-       case TTY_NORMAL:
-               break;
-       case TTY_BREAK:
-               TRACE_PE("received break");
-               pInfo->flags |= R3964_BREAK;
-               break;
-       case TTY_PARITY:
-               TRACE_PE("parity error");
-               pInfo->flags |= R3964_PARITY;
-               break;
-       case TTY_FRAME:
-               TRACE_PE("frame error");
-               pInfo->flags |= R3964_FRAME;
-               break;
-       case TTY_OVERRUN:
-               TRACE_PE("frame overrun");
-               pInfo->flags |= R3964_OVERRUN;
-               break;
-       default:
-               TRACE_PE("receive_error - unknown flag %d", flag);
-               pInfo->flags |= R3964_UNKNOWN;
-               break;
-       }
-}
-
-static void on_timeout(unsigned long priv)
-{
-       struct r3964_info *pInfo = (void *)priv;
-
-       switch (pInfo->state) {
-       case R3964_TX_REQUEST:
-               TRACE_PE("TX_REQUEST - timeout");
-               retry_transmit(pInfo);
-               break;
-       case R3964_WAIT_ZVZ_BEFORE_TX_RETRY:
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               retry_transmit(pInfo);
-               break;
-       case R3964_WAIT_FOR_TX_ACK:
-               TRACE_PE("WAIT_FOR_TX_ACK - timeout");
-               retry_transmit(pInfo);
-               break;
-       case R3964_WAIT_FOR_RX_BUF:
-               TRACE_PE("WAIT_FOR_RX_BUF - timeout");
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-               break;
-       case R3964_RECEIVING:
-               TRACE_PE("RECEIVING - timeout after %d chars",
-                        pInfo->rx_position);
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-               break;
-       case R3964_WAIT_FOR_RX_REPEAT:
-               TRACE_PE("WAIT_FOR_RX_REPEAT - timeout");
-               pInfo->state = R3964_IDLE;
-               break;
-       case R3964_WAIT_FOR_BCC:
-               TRACE_PE("WAIT_FOR_BCC - timeout");
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-               break;
-       }
-}
-
-static struct r3964_client_info *findClient(struct r3964_info *pInfo,
-               struct pid *pid)
-{
-       struct r3964_client_info *pClient;
-
-       for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
-               if (pClient->pid == pid) {
-                       return pClient;
-               }
-       }
-       return NULL;
-}
-
-static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
-{
-       struct r3964_client_info *pClient;
-       struct r3964_client_info **ppClient;
-       struct r3964_message *pMsg;
-
-       if ((arg & R3964_SIG_ALL) == 0) {
-               /* Remove client from client list */
-               for (ppClient = &pInfo->firstClient; *ppClient;
-                    ppClient = &(*ppClient)->next) {
-                       pClient = *ppClient;
-
-                       if (pClient->pid == pid) {
-                               TRACE_PS("removing client %d from client list",
-                                        pid_nr(pid));
-                               *ppClient = pClient->next;
-                               while (pClient->msg_count) {
-                                       pMsg = remove_msg(pInfo, pClient);
-                                       if (pMsg) {
-                                               kfree(pMsg);
-                                               TRACE_M("enable_signals - msg "
-                                                       "kfree %p", pMsg);
-                                       }
-                               }
-                               put_pid(pClient->pid);
-                               kfree(pClient);
-                               TRACE_M("enable_signals - kfree %p", pClient);
-                               return 0;
-                       }
-               }
-               return -EINVAL;
-       } else {
-               pClient = findClient(pInfo, pid);
-               if (pClient) {
-                       /* update signal options */
-                       pClient->sig_flags = arg;
-               } else {
-                       /* add client to client list */
-                       pClient = kmalloc(sizeof(struct r3964_client_info),
-                                       GFP_KERNEL);
-                       TRACE_M("enable_signals - kmalloc %p", pClient);
-                       if (pClient == NULL)
-                               return -ENOMEM;
-
-                       TRACE_PS("add client %d to client list", pid_nr(pid));
-                       spin_lock_init(&pClient->lock);
-                       pClient->sig_flags = arg;
-                       pClient->pid = get_pid(pid);
-                       pClient->next = pInfo->firstClient;
-                       pClient->first_msg = NULL;
-                       pClient->last_msg = NULL;
-                       pClient->next_block_to_read = NULL;
-                       pClient->msg_count = 0;
-                       pInfo->firstClient = pClient;
-               }
-       }
-
-       return 0;
-}
-
-static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
-                        unsigned char __user * buf)
-{
-       struct r3964_client_info *pClient;
-       struct r3964_block_header *block;
-
-       if (!buf) {
-               return -EINVAL;
-       }
-
-       pClient = findClient(pInfo, pid);
-       if (pClient == NULL) {
-               return -EINVAL;
-       }
-
-       block = pClient->next_block_to_read;
-       if (!block) {
-               return 0;
-       } else {
-               if (copy_to_user(buf, block->data, block->length))
-                       return -EFAULT;
-
-               remove_client_block(pInfo, pClient);
-               return block->length;
-       }
-
-       return -EINVAL;
-}
-
-static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
-               int error_code, struct r3964_block_header *pBlock)
-{
-       struct r3964_message *pMsg;
-       unsigned long flags;
-
-       if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) {
-queue_the_message:
-
-               pMsg = kmalloc(sizeof(struct r3964_message),
-                               error_code ? GFP_ATOMIC : GFP_KERNEL);
-               TRACE_M("add_msg - kmalloc %p", pMsg);
-               if (pMsg == NULL) {
-                       return;
-               }
-
-               spin_lock_irqsave(&pClient->lock, flags);
-
-               pMsg->msg_id = msg_id;
-               pMsg->arg = arg;
-               pMsg->error_code = error_code;
-               pMsg->block = pBlock;
-               pMsg->next = NULL;
-
-               if (pClient->last_msg == NULL) {
-                       pClient->first_msg = pClient->last_msg = pMsg;
-               } else {
-                       pClient->last_msg->next = pMsg;
-                       pClient->last_msg = pMsg;
-               }
-
-               pClient->msg_count++;
-
-               if (pBlock != NULL) {
-                       pBlock->locks++;
-               }
-               spin_unlock_irqrestore(&pClient->lock, flags);
-       } else {
-               if ((pClient->last_msg->msg_id == R3964_MSG_ACK)
-                   && (pClient->last_msg->error_code == R3964_OVERFLOW)) {
-                       pClient->last_msg->arg++;
-                       TRACE_PE("add_msg - inc prev OVERFLOW-msg");
-               } else {
-                       msg_id = R3964_MSG_ACK;
-                       arg = 0;
-                       error_code = R3964_OVERFLOW;
-                       pBlock = NULL;
-                       TRACE_PE("add_msg - queue OVERFLOW-msg");
-                       goto queue_the_message;
-               }
-       }
-       /* Send SIGIO signal to client process: */
-       if (pClient->sig_flags & R3964_USE_SIGIO) {
-               kill_pid(pClient->pid, SIGIO, 1);
-       }
-}
-
-static struct r3964_message *remove_msg(struct r3964_info *pInfo,
-                                       struct r3964_client_info *pClient)
-{
-       struct r3964_message *pMsg = NULL;
-       unsigned long flags;
-
-       if (pClient->first_msg) {
-               spin_lock_irqsave(&pClient->lock, flags);
-
-               pMsg = pClient->first_msg;
-               pClient->first_msg = pMsg->next;
-               if (pClient->first_msg == NULL) {
-                       pClient->last_msg = NULL;
-               }
-
-               pClient->msg_count--;
-               if (pMsg->block) {
-                       remove_client_block(pInfo, pClient);
-                       pClient->next_block_to_read = pMsg->block;
-               }
-               spin_unlock_irqrestore(&pClient->lock, flags);
-       }
-       return pMsg;
-}
-
-static void remove_client_block(struct r3964_info *pInfo,
-                               struct r3964_client_info *pClient)
-{
-       struct r3964_block_header *block;
-
-       TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
-
-       block = pClient->next_block_to_read;
-       if (block) {
-               block->locks--;
-               if (block->locks == 0) {
-                       remove_from_rx_queue(pInfo, block);
-               }
-       }
-       pClient->next_block_to_read = NULL;
-}
-
-/*************************************************************
- * Line discipline routines
- *************************************************************/
-
-static int r3964_open(struct tty_struct *tty)
-{
-       struct r3964_info *pInfo;
-
-       TRACE_L("open");
-       TRACE_L("tty=%p, PID=%d, disc_data=%p",
-               tty, current->pid, tty->disc_data);
-
-       pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
-       TRACE_M("r3964_open - info kmalloc %p", pInfo);
-
-       if (!pInfo) {
-               printk(KERN_ERR "r3964: failed to alloc info structure\n");
-               return -ENOMEM;
-       }
-
-       pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
-       TRACE_M("r3964_open - rx_buf kmalloc %p", pInfo->rx_buf);
-
-       if (!pInfo->rx_buf) {
-               printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
-               kfree(pInfo);
-               TRACE_M("r3964_open - info kfree %p", pInfo);
-               return -ENOMEM;
-       }
-
-       pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
-       TRACE_M("r3964_open - tx_buf kmalloc %p", pInfo->tx_buf);
-
-       if (!pInfo->tx_buf) {
-               printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
-               kfree(pInfo->rx_buf);
-               TRACE_M("r3964_open - rx_buf kfree %p", pInfo->rx_buf);
-               kfree(pInfo);
-               TRACE_M("r3964_open - info kfree %p", pInfo);
-               return -ENOMEM;
-       }
-
-       spin_lock_init(&pInfo->lock);
-       pInfo->tty = tty;
-       init_waitqueue_head(&pInfo->read_wait);
-       pInfo->priority = R3964_MASTER;
-       pInfo->rx_first = pInfo->rx_last = NULL;
-       pInfo->tx_first = pInfo->tx_last = NULL;
-       pInfo->rx_position = 0;
-       pInfo->tx_position = 0;
-       pInfo->last_rx = 0;
-       pInfo->blocks_in_rx_queue = 0;
-       pInfo->firstClient = NULL;
-       pInfo->state = R3964_IDLE;
-       pInfo->flags = R3964_DEBUG;
-       pInfo->nRetry = 0;
-
-       tty->disc_data = pInfo;
-       tty->receive_room = 65536;
-
-       setup_timer(&pInfo->tmr, on_timeout, (unsigned long)pInfo);
-
-       return 0;
-}
-
-static void r3964_close(struct tty_struct *tty)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_client_info *pClient, *pNext;
-       struct r3964_message *pMsg;
-       struct r3964_block_header *pHeader, *pNextHeader;
-       unsigned long flags;
-
-       TRACE_L("close");
-
-       /*
-        * Make sure that our task queue isn't activated.  If it
-        * is, take it out of the linked list.
-        */
-       del_timer_sync(&pInfo->tmr);
-
-       /* Remove client-structs and message queues: */
-       pClient = pInfo->firstClient;
-       while (pClient) {
-               pNext = pClient->next;
-               while (pClient->msg_count) {
-                       pMsg = remove_msg(pInfo, pClient);
-                       if (pMsg) {
-                               kfree(pMsg);
-                               TRACE_M("r3964_close - msg kfree %p", pMsg);
-                       }
-               }
-               put_pid(pClient->pid);
-               kfree(pClient);
-               TRACE_M("r3964_close - client kfree %p", pClient);
-               pClient = pNext;
-       }
-       /* Remove jobs from tx_queue: */
-       spin_lock_irqsave(&pInfo->lock, flags);
-       pHeader = pInfo->tx_first;
-       pInfo->tx_first = pInfo->tx_last = NULL;
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       while (pHeader) {
-               pNextHeader = pHeader->next;
-               kfree(pHeader);
-               pHeader = pNextHeader;
-       }
-
-       /* Free buffers: */
-       wake_up_interruptible(&pInfo->read_wait);
-       kfree(pInfo->rx_buf);
-       TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf);
-       kfree(pInfo->tx_buf);
-       TRACE_M("r3964_close - tx_buf kfree %p", pInfo->tx_buf);
-       kfree(pInfo);
-       TRACE_M("r3964_close - info kfree %p", pInfo);
-}
-
-static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
-                         unsigned char __user * buf, size_t nr)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_client_info *pClient;
-       struct r3964_message *pMsg;
-       struct r3964_client_message theMsg;
-       int ret;
-
-       TRACE_L("read()");
-
-       tty_lock();
-
-       pClient = findClient(pInfo, task_pid(current));
-       if (pClient) {
-               pMsg = remove_msg(pInfo, pClient);
-               if (pMsg == NULL) {
-                       /* no messages available. */
-                       if (file->f_flags & O_NONBLOCK) {
-                               ret = -EAGAIN;
-                               goto unlock;
-                       }
-                       /* block until there is a message: */
-                       wait_event_interruptible_tty(pInfo->read_wait,
-                                       (pMsg = remove_msg(pInfo, pClient)));
-               }
-
-               /* If we still haven't got a message, we must have been signalled */
-
-               if (!pMsg) {
-                       ret = -EINTR;
-                       goto unlock;
-               }
-
-               /* deliver msg to client process: */
-               theMsg.msg_id = pMsg->msg_id;
-               theMsg.arg = pMsg->arg;
-               theMsg.error_code = pMsg->error_code;
-               ret = sizeof(struct r3964_client_message);
-
-               kfree(pMsg);
-               TRACE_M("r3964_read - msg kfree %p", pMsg);
-
-               if (copy_to_user(buf, &theMsg, ret)) {
-                       ret = -EFAULT;
-                       goto unlock;
-               }
-
-               TRACE_PS("read - return %d", ret);
-               goto unlock;
-       }
-       ret = -EPERM;
-unlock:
-       tty_unlock();
-       return ret;
-}
-
-static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
-                          const unsigned char *data, size_t count)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_block_header *pHeader;
-       struct r3964_client_info *pClient;
-       unsigned char *new_data;
-
-       TRACE_L("write request, %d characters", count);
-/* 
- * Verify the pointers 
- */
-
-       if (!pInfo)
-               return -EIO;
-
-/*
- * Ensure that the caller does not wish to send too much.
- */
-       if (count > R3964_MTU) {
-               if (pInfo->flags & R3964_DEBUG) {
-                       TRACE_L(KERN_WARNING "r3964_write: truncating user "
-                               "packet from %u to mtu %d", count, R3964_MTU);
-               }
-               count = R3964_MTU;
-       }
-/*
- * Allocate a buffer for the data and copy it from the buffer with header prepended
- */
-       new_data = kmalloc(count + sizeof(struct r3964_block_header),
-                       GFP_KERNEL);
-       TRACE_M("r3964_write - kmalloc %p", new_data);
-       if (new_data == NULL) {
-               if (pInfo->flags & R3964_DEBUG) {
-                       printk(KERN_ERR "r3964_write: no memory\n");
-               }
-               return -ENOSPC;
-       }
-
-       pHeader = (struct r3964_block_header *)new_data;
-       pHeader->data = new_data + sizeof(struct r3964_block_header);
-       pHeader->length = count;
-       pHeader->locks = 0;
-       pHeader->owner = NULL;
-
-       tty_lock();
-
-       pClient = findClient(pInfo, task_pid(current));
-       if (pClient) {
-               pHeader->owner = pClient;
-       }
-
-       memcpy(pHeader->data, data, count);     /* We already verified this */
-
-       if (pInfo->flags & R3964_DEBUG) {
-               dump_block(pHeader->data, count);
-       }
-
-/*
- * Add buffer to transmit-queue:
- */
-       add_tx_queue(pInfo, pHeader);
-       trigger_transmit(pInfo);
-
-       tty_unlock();
-
-       return 0;
-}
-
-static int r3964_ioctl(struct tty_struct *tty, struct file *file,
-               unsigned int cmd, unsigned long arg)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       if (pInfo == NULL)
-               return -EINVAL;
-       switch (cmd) {
-       case R3964_ENABLE_SIGNALS:
-               return enable_signals(pInfo, task_pid(current), arg);
-       case R3964_SETPRIORITY:
-               if (arg < R3964_MASTER || arg > R3964_SLAVE)
-                       return -EINVAL;
-               pInfo->priority = arg & 0xff;
-               return 0;
-       case R3964_USE_BCC:
-               if (arg)
-                       pInfo->flags |= R3964_BCC;
-               else
-                       pInfo->flags &= ~R3964_BCC;
-               return 0;
-       case R3964_READ_TELEGRAM:
-               return read_telegram(pInfo, task_pid(current),
-                               (unsigned char __user *)arg);
-       default:
-               return -ENOIOCTLCMD;
-       }
-}
-
-static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
-{
-       TRACE_L("set_termios");
-}
-
-/* Called without the kernel lock held - fine */
-static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
-                       struct poll_table_struct *wait)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_client_info *pClient;
-       struct r3964_message *pMsg = NULL;
-       unsigned long flags;
-       int result = POLLOUT;
-
-       TRACE_L("POLL");
-
-       pClient = findClient(pInfo, task_pid(current));
-       if (pClient) {
-               poll_wait(file, &pInfo->read_wait, wait);
-               spin_lock_irqsave(&pInfo->lock, flags);
-               pMsg = pClient->first_msg;
-               spin_unlock_irqrestore(&pInfo->lock, flags);
-               if (pMsg)
-                       result |= POLLIN | POLLRDNORM;
-       } else {
-               result = -EINVAL;
-       }
-       return result;
-}
-
-static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                       char *fp, int count)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       const unsigned char *p;
-       char *f, flags = 0;
-       int i;
-
-       for (i = count, p = cp, f = fp; i; i--, p++) {
-               if (f)
-                       flags = *f++;
-               if (flags == TTY_NORMAL) {
-                       receive_char(pInfo, *p);
-               } else {
-                       receive_error(pInfo, flags);
-               }
-
-       }
-}
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_LDISC(N_R3964);
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
deleted file mode 100644 (file)
index 428f4fe..0000000
+++ /dev/null
@@ -1,2121 +0,0 @@
-/*
- * n_tty.c --- implements the N_TTY line discipline.
- *
- * This code used to be in tty_io.c, but things are getting hairy
- * enough that it made sense to split things off.  (The N_TTY
- * processing has changed so much that it's hardly recognizable,
- * anyway...)
- *
- * Note that the open routine for N_TTY is guaranteed never to return
- * an error.  This is because Linux will fall back to setting a line
- * to N_TTY if it can not switch to any other line discipline.
- *
- * Written by Theodore Ts'o, Copyright 1994.
- *
- * This file also contains code originally written by Linus Torvalds,
- * Copyright 1991, 1992, 1993, and by Julian Cowley, Copyright 1994.
- *
- * This file may be redistributed under the terms of the GNU General Public
- * License.
- *
- * Reduced memory usage for older ARM systems  - Russell King.
- *
- * 2000/01/20   Fixed SMP locking on put_tty_queue using bits of
- *             the patch by Andrew J. Kroll <ag784@freenet.buffalo.edu>
- *             who actually finally proved there really was a race.
- *
- * 2002/03/18   Implemented n_tty_wakeup to send SIGIO POLL_OUTs to
- *             waiting writing processes-Sapan Bhatia <sapan@corewars.org>.
- *             Also fixed a bug in BLOCKING mode where n_tty_write returns
- *             EAGAIN
- */
-
-#include <linux/types.h>
-#include <linux/major.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/fcntl.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/timer.h>
-#include <linux/ctype.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/bitops.h>
-#include <linux/audit.h>
-#include <linux/file.h>
-#include <linux/uaccess.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-
-/* number of characters left in xmit buffer before select has we have room */
-#define WAKEUP_CHARS 256
-
-/*
- * This defines the low- and high-watermarks for throttling and
- * unthrottling the TTY driver.  These watermarks are used for
- * controlling the space in the read buffer.
- */
-#define TTY_THRESHOLD_THROTTLE         128 /* now based on remaining room */
-#define TTY_THRESHOLD_UNTHROTTLE       128
-
-/*
- * Special byte codes used in the echo buffer to represent operations
- * or special handling of characters.  Bytes in the echo buffer that
- * are not part of such special blocks are treated as normal character
- * codes.
- */
-#define ECHO_OP_START 0xff
-#define ECHO_OP_MOVE_BACK_COL 0x80
-#define ECHO_OP_SET_CANON_COL 0x81
-#define ECHO_OP_ERASE_TAB 0x82
-
-static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
-                              unsigned char __user *ptr)
-{
-       tty_audit_add_data(tty, &x, 1);
-       return put_user(x, ptr);
-}
-
-/**
- *     n_tty_set__room -       receive space
- *     @tty: terminal
- *
- *     Called by the driver to find out how much data it is
- *     permitted to feed to the line discipline without any being lost
- *     and thus to manage flow control. Not serialized. Answers for the
- *     "instant".
- */
-
-static void n_tty_set_room(struct tty_struct *tty)
-{
-       /* tty->read_cnt is not read locked ? */
-       int     left = N_TTY_BUF_SIZE - tty->read_cnt - 1;
-
-       /*
-        * If we are doing input canonicalization, and there are no
-        * pending newlines, let characters through without limit, so
-        * that erase characters will be handled.  Other excess
-        * characters will be beeped.
-        */
-       if (left <= 0)
-               left = tty->icanon && !tty->canon_data;
-       tty->receive_room = left;
-}
-
-static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
-{
-       if (tty->read_cnt < N_TTY_BUF_SIZE) {
-               tty->read_buf[tty->read_head] = c;
-               tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1);
-               tty->read_cnt++;
-       }
-}
-
-/**
- *     put_tty_queue           -       add character to tty
- *     @c: character
- *     @tty: tty device
- *
- *     Add a character to the tty read_buf queue. This is done under the
- *     read_lock to serialize character addition and also to protect us
- *     against parallel reads or flushes
- */
-
-static void put_tty_queue(unsigned char c, struct tty_struct *tty)
-{
-       unsigned long flags;
-       /*
-        *      The problem of stomping on the buffers ends here.
-        *      Why didn't anyone see this one coming? --AJK
-       */
-       spin_lock_irqsave(&tty->read_lock, flags);
-       put_tty_queue_nolock(c, tty);
-       spin_unlock_irqrestore(&tty->read_lock, flags);
-}
-
-/**
- *     check_unthrottle        -       allow new receive data
- *     @tty; tty device
- *
- *     Check whether to call the driver unthrottle functions
- *
- *     Can sleep, may be called under the atomic_read_lock mutex but
- *     this is not guaranteed.
- */
-static void check_unthrottle(struct tty_struct *tty)
-{
-       if (tty->count)
-               tty_unthrottle(tty);
-}
-
-/**
- *     reset_buffer_flags      -       reset buffer state
- *     @tty: terminal to reset
- *
- *     Reset the read buffer counters, clear the flags,
- *     and make sure the driver is unthrottled. Called
- *     from n_tty_open() and n_tty_flush_buffer().
- *
- *     Locking: tty_read_lock for read fields.
- */
-
-static void reset_buffer_flags(struct tty_struct *tty)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&tty->read_lock, flags);
-       tty->read_head = tty->read_tail = tty->read_cnt = 0;
-       spin_unlock_irqrestore(&tty->read_lock, flags);
-
-       mutex_lock(&tty->echo_lock);
-       tty->echo_pos = tty->echo_cnt = tty->echo_overrun = 0;
-       mutex_unlock(&tty->echo_lock);
-
-       tty->canon_head = tty->canon_data = tty->erasing = 0;
-       memset(&tty->read_flags, 0, sizeof tty->read_flags);
-       n_tty_set_room(tty);
-       check_unthrottle(tty);
-}
-
-/**
- *     n_tty_flush_buffer      -       clean input queue
- *     @tty:   terminal device
- *
- *     Flush the input buffer. Called when the line discipline is
- *     being closed, when the tty layer wants the buffer flushed (eg
- *     at hangup) or when the N_TTY line discipline internally has to
- *     clean the pending queue (for example some signals).
- *
- *     Locking: ctrl_lock, read_lock.
- */
-
-static void n_tty_flush_buffer(struct tty_struct *tty)
-{
-       unsigned long flags;
-       /* clear everything and unthrottle the driver */
-       reset_buffer_flags(tty);
-
-       if (!tty->link)
-               return;
-
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
-       if (tty->link->packet) {
-               tty->ctrl_status |= TIOCPKT_FLUSHREAD;
-               wake_up_interruptible(&tty->link->read_wait);
-       }
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
-}
-
-/**
- *     n_tty_chars_in_buffer   -       report available bytes
- *     @tty: tty device
- *
- *     Report the number of characters buffered to be delivered to user
- *     at this instant in time.
- *
- *     Locking: read_lock
- */
-
-static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
-{
-       unsigned long flags;
-       ssize_t n = 0;
-
-       spin_lock_irqsave(&tty->read_lock, flags);
-       if (!tty->icanon) {
-               n = tty->read_cnt;
-       } else if (tty->canon_data) {
-               n = (tty->canon_head > tty->read_tail) ?
-                       tty->canon_head - tty->read_tail :
-                       tty->canon_head + (N_TTY_BUF_SIZE - tty->read_tail);
-       }
-       spin_unlock_irqrestore(&tty->read_lock, flags);
-       return n;
-}
-
-/**
- *     is_utf8_continuation    -       utf8 multibyte check
- *     @c: byte to check
- *
- *     Returns true if the utf8 character 'c' is a multibyte continuation
- *     character. We use this to correctly compute the on screen size
- *     of the character when printing
- */
-
-static inline int is_utf8_continuation(unsigned char c)
-{
-       return (c & 0xc0) == 0x80;
-}
-
-/**
- *     is_continuation         -       multibyte check
- *     @c: byte to check
- *
- *     Returns true if the utf8 character 'c' is a multibyte continuation
- *     character and the terminal is in unicode mode.
- */
-
-static inline int is_continuation(unsigned char c, struct tty_struct *tty)
-{
-       return I_IUTF8(tty) && is_utf8_continuation(c);
-}
-
-/**
- *     do_output_char                  -       output one character
- *     @c: character (or partial unicode symbol)
- *     @tty: terminal device
- *     @space: space available in tty driver write buffer
- *
- *     This is a helper function that handles one output character
- *     (including special characters like TAB, CR, LF, etc.),
- *     doing OPOST processing and putting the results in