From 593a27c4b212e2afdf772a1f8dcb894e91bda0fa Mon Sep 17 00:00:00 2001 From: Konstantin Khlebnikov Date: Thu, 5 Jan 2012 13:04:21 +0400 Subject: tty: cleanup prohibition of direct opening for unix98 pty master cleanup hack added in v2.6.27-3203-g15582d3 comment from that patch: : pty: If the administrator creates a device for a ptmx slave we should not error : : The open path for ptmx slaves is via the ptmx device. Opening them any : other way is not allowed. Vegard Nossum found that previously this was not : the case and mknod foo c 128 42; cat foo would produce nasty diagnostics : : Signed-off-by: Alan Cox : Signed-off-by: Linus Torvalds devpts_get_tty() returns non-null only for inodes on devpts, but there is no inodes for master-devices, /dev/ptmx (/dev/pts/ptmx) is the only way to open them. Thus we can completely forbid lookup for master-devices and eliminate that hack in tty_init_dev() because tty_open() will get EIO from tty_driver_lookup_tty(). Signed-off-by: Konstantin Khlebnikov Signed-off-by: Greg Kroah-Hartman --- include/linux/tty.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/tty.h b/include/linux/tty.h index 5dbb3cb05a8..d3ebd765b54 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -480,8 +480,7 @@ extern void free_tty_struct(struct tty_struct *tty); extern void initialize_tty_struct(struct tty_struct *tty, struct tty_driver *driver, int idx); extern void deinitialize_tty_struct(struct tty_struct *tty); -extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, - int first_ok); +extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); extern int tty_release(struct inode *inode, struct file *filp); extern int tty_init_termios(struct tty_struct *tty); -- cgit v1.2.3-18-g5258 From e9aba5158a80098447ff207a452a3418ae7ee386 Mon Sep 17 00:00:00 2001 From: Konstantin Khlebnikov Date: Thu, 5 Jan 2012 13:06:11 +0400 Subject: tty: rework pty count limiting After adding devpts multiple-insrances sysctl kernel.pty.max limit pty count for each devpts instance independently, while kernel.pty.nr shows total pty count. This patch restores sysctl kernel.pty.max as global limit (4096 by default), adds pty reseve for main devpts (mounted without "newinstance" argument), and new sysctl to tune it: kernel.pty.reserve (1024 by default) Also it adds devpts mount option "max=%d" to limit pty count for each devpts instance independently. (by default NR_UNIX98_PTY_MAX == 2^20) Thus devpts instances in containers cannot eat up all available pty even if we didn't set any limits, while with "max" argument we can adjust limits more precisely. Plus, now open("/dev/ptmx") return -ENOSPC in case lack of pty indexes, this is more informative than -EIO. Signed-off-by: Konstantin Khlebnikov Signed-off-by: Greg Kroah-Hartman --- include/linux/tty.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/tty.h b/include/linux/tty.h index d3ebd765b54..d4077418820 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -52,6 +52,7 @@ * hardcoded at present.) */ #define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */ +#define NR_UNIX98_PTY_RESERVE 1024 /* Default reserve for main devpts */ #define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */ /* -- cgit v1.2.3-18-g5258 From 3afbd89c9639c344300dcdd7d4e5e18dda559fd4 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Wed, 25 Jan 2012 09:05:04 +0100 Subject: serial/efm32: add new driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- include/linux/platform_data/efm32-uart.h | 18 ++++++++++++++++++ include/linux/serial_core.h | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 include/linux/platform_data/efm32-uart.h (limited to 'include') diff --git a/include/linux/platform_data/efm32-uart.h b/include/linux/platform_data/efm32-uart.h new file mode 100644 index 00000000000..ed0e975b3c5 --- /dev/null +++ b/include/linux/platform_data/efm32-uart.h @@ -0,0 +1,18 @@ +/* + * + * + */ +#ifndef __LINUX_PLATFORM_DATA_EFM32_UART_H__ +#define __LINUX_PLATFORM_DATA_EFM32_UART_H__ + +#include + +/** + * struct efm32_uart_pdata + * @location: pinmux location for the I/O pins (to be written to the ROUTE + * register) + */ +struct efm32_uart_pdata { + u8 location; +}; +#endif /* ifndef __LINUX_PLATFORM_DATA_EFM32_UART_H__ */ diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index c91ace70c21..585bfd03d2e 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -210,6 +210,8 @@ /* Atheros AR933X SoC */ #define PORT_AR933X 99 +/* Energy Micro efm32 SoC */ +#define PORT_EFMUART 100 #ifdef __KERNEL__ -- cgit v1.2.3-18-g5258 From 66d450e84ec656ec4b774c41cd8d46b3e48d51df Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 30 Jan 2012 21:14:28 +0100 Subject: TTY: provide tty_standard_install helper There are currently many cut&paste copies of what tty_driver_install_tty does when custom ->install method is not provided. Let's get rid of the copies and create a helper with this setup code. Signed-off-by: Jiri Slaby Cc: Havard Skinnemoen Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- include/linux/tty.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/tty.h b/include/linux/tty.h index d4077418820..a91ff403b3b 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -484,6 +484,8 @@ extern void deinitialize_tty_struct(struct tty_struct *tty); extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); extern int tty_release(struct inode *inode, struct file *filp); extern int tty_init_termios(struct tty_struct *tty); +extern int tty_standard_install(struct tty_driver *driver, + struct tty_struct *tty); extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty); -- cgit v1.2.3-18-g5258 From 3f5dc70721af68b76ad544b0c61fea365d67c041 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 8 Feb 2012 14:35:46 +0100 Subject: tty: serial: altera_uart: remove early_altera_uart_setup The function has no users inside the tree and the nios2 (out-of-mainline) port doesn't use it either (anymore). Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- include/linux/altera_uart.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/linux/altera_uart.h b/include/linux/altera_uart.h index a10a9079197..c022c82db7c 100644 --- a/include/linux/altera_uart.h +++ b/include/linux/altera_uart.h @@ -5,8 +5,6 @@ #ifndef __ALTUART_H #define __ALTUART_H -#include - struct altera_uart_platform_uart { unsigned long mapbase; /* Physical address base */ unsigned int irq; /* Interrupt vector */ @@ -14,6 +12,4 @@ struct altera_uart_platform_uart { unsigned int bus_shift; /* Bus shift (address stride) */ }; -int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp); - #endif /* __ALTUART_H */ -- cgit v1.2.3-18-g5258 From 6816383a09b5be8d35f14f4c25dedb64498e4959 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 9 Feb 2012 18:48:19 -0500 Subject: tty: sparc: rename drivers/tty/serial/suncore.h -> include/linux/sunserialcore.h There are multiple users of this file from different source paths now, and rather than have ../ paths in include statements, just move the file to the linux header dir. Suggested-by: David S. Miller Signed-off-by: Paul Gortmaker Acked-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/sunserialcore.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/linux/sunserialcore.h (limited to 'include') diff --git a/include/linux/sunserialcore.h b/include/linux/sunserialcore.h new file mode 100644 index 00000000000..68e7430bb0f --- /dev/null +++ b/include/linux/sunserialcore.h @@ -0,0 +1,33 @@ +/* sunserialcore.h + * + * Generic SUN serial/kbd/ms layer. Based entirely + * upon drivers/sbus/char/sunserial.h which is: + * + * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) + * + * Port to new UART layer is: + * + * Copyright (C) 2002 David S. Miller (davem@redhat.com) + */ + +#ifndef _SERIAL_SUN_H +#define _SERIAL_SUN_H + +/* Serial keyboard defines for L1-A processing... */ +#define SUNKBD_RESET 0xff +#define SUNKBD_L1 0x01 +#define SUNKBD_UP 0x80 +#define SUNKBD_A 0x4d + +extern unsigned int suncore_mouse_baud_cflag_next(unsigned int, int *); +extern int suncore_mouse_baud_detection(unsigned char, int); + +extern int sunserial_register_minors(struct uart_driver *, int); +extern void sunserial_unregister_minors(struct uart_driver *, int); + +extern int sunserial_console_match(struct console *, struct device_node *, + struct uart_driver *, int, bool); +extern void sunserial_console_termios(struct console *, + struct device_node *); + +#endif /* !(_SERIAL_SUN_H) */ -- cgit v1.2.3-18-g5258 From 247ff8e610cb63c015de19191db9666754c2ed79 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 24 Feb 2012 12:47:11 +0000 Subject: vt: lock the accent table First step to debletcherising the vt console layer - pick a victim and fix the locking This is a nice simple object with its own rules so lets pick it out for treatment. The user of the table already has a lock so we will also use the same lock for updates. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- include/linux/vt_kern.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index c2164fad008..5d8726ad572 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -167,4 +167,7 @@ extern int unregister_vt_notifier(struct notifier_block *nb); extern void hide_boot_cursor(bool hide); +/* keyboard provided interfaces */ +extern int vt_do_diacrit(unsigned int cmd, void __user *up, int eperm); + #endif /* _VT_KERN_H */ -- cgit v1.2.3-18-g5258 From 079c9534a96da9a85a2a2f9715851050fbfbf749 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 28 Feb 2012 14:49:23 +0000 Subject: vt:tackle kbd_table Keyboard struct lifetime is easy, but the locking is not and is completely ignored by the existing code. Tackle this one head on - Make the kbd_table private so we can run down all direct users - Hoick the relevant ioctl handlers into the keyboard layer - Lock them with the keyboard lock so they don't change mid keypress - Add helpers for things like console stop/start so we isolate the poking around properly - Tweak the braille console so it still builds There are a couple of FIXME locking cases left for ioctls that are so hideous they should be addressed in a later patch. After this patch the kbd_table is private and all the keyboard jiggery pokery is in one place. This update fixes speakup and also a memory leak in the original. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- include/linux/kbd_kern.h | 7 +------ include/linux/keyboard.h | 2 -- include/linux/vt_kern.h | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h index ec2d17bc1f1..daf4a3a40ee 100644 --- a/include/linux/kbd_kern.h +++ b/include/linux/kbd_kern.h @@ -7,8 +7,6 @@ extern struct tasklet_struct keyboard_tasklet; -extern int shift_state; - extern char *func_table[MAX_NR_FUNC]; extern char func_buf[]; extern char *funcbufptr; @@ -65,8 +63,6 @@ struct kbd_struct { #define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */ }; -extern struct kbd_struct kbd_table[]; - extern int kbd_init(void); extern unsigned char getledstate(void); @@ -79,6 +75,7 @@ extern void (*kbd_ledfunc)(unsigned int led); extern int set_console(int nr); extern void schedule_console_callback(void); +/* FIXME: review locking for vt.c callers */ static inline void set_leds(void) { tasklet_schedule(&keyboard_tasklet); @@ -142,8 +139,6 @@ static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag) struct console; -int getkeycode(unsigned int scancode); -int setkeycode(unsigned int scancode, unsigned int keycode); void compute_shiftstate(void); /* defkeymap.c */ diff --git a/include/linux/keyboard.h b/include/linux/keyboard.h index 33a63f62d57..86e5214ae73 100644 --- a/include/linux/keyboard.h +++ b/include/linux/keyboard.h @@ -24,8 +24,6 @@ #ifdef __KERNEL__ struct notifier_block; -extern const int NR_TYPES; -extern const int max_vals[]; extern unsigned short *key_maps[MAX_NR_KEYMAPS]; extern unsigned short plain_map[NR_KEYS]; diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index 5d8726ad572..e33d77f15bd 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -169,5 +169,28 @@ extern void hide_boot_cursor(bool hide); /* keyboard provided interfaces */ extern int vt_do_diacrit(unsigned int cmd, void __user *up, int eperm); +extern int vt_do_kdskbmode(int console, unsigned int arg); +extern int vt_do_kdskbmeta(int console, unsigned int arg); +extern int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, + int perm); +extern int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, + int perm, int console); +extern int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, + int perm); +extern int vt_do_kdskled(int console, int cmd, unsigned long arg, int perm); +extern int vt_do_kdgkbmode(int console); +extern int vt_do_kdgkbmeta(int console); +extern void vt_reset_unicode(int console); +extern int vt_get_shift_state(void); +extern void vt_reset_keyboard(int console); +extern int vt_get_leds(int console, int flag); +extern int vt_get_kbd_mode_bit(int console, int bit); +extern void vt_set_kbd_mode_bit(int console, int bit); +extern void vt_clr_kbd_mode_bit(int console, int bit); +extern void vt_set_led_state(int console, int leds); +extern void vt_set_led_state(int console, int leds); +extern void vt_kbd_con_start(int console); +extern void vt_kbd_con_stop(int console); + #endif /* _VT_KERN_H */ -- cgit v1.2.3-18-g5258 From 1a54a76d5171f3ffd89eb69f6f38d535724e3d05 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:51:50 +0100 Subject: TTY: let alloc_tty_driver deduce the owner automatically Like the rest of the kernel, make a stub from alloc_tty_driver which calls __alloc_tty_driver with proper owner. This will save us one more assignment on the driver side. Also this fixes some drivers which didn't set the owner. This allowed user to remove the module from the system even though a tty from the driver is still open. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- include/linux/tty_driver.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 5cf685086dd..6e65493a5e6 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -234,6 +234,7 @@ * if provided (otherwise EINVAL will be returned). */ +#include #include #include #include @@ -324,7 +325,7 @@ struct tty_driver { extern struct list_head tty_drivers; -extern struct tty_driver *alloc_tty_driver(int lines); +extern struct tty_driver *__alloc_tty_driver(int lines, struct module *owner); extern void put_tty_driver(struct tty_driver *driver); extern void tty_set_operations(struct tty_driver *driver, const struct tty_operations *op); @@ -332,6 +333,8 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line); extern void tty_driver_kref_put(struct tty_driver *driver); +#define alloc_tty_driver(lines) __alloc_tty_driver(lines, THIS_MODULE) + static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) { kref_get(&d->kref); -- cgit v1.2.3-18-g5258 From 87cab16beb882d3f9e61a2c0184fa7cf76de1f90 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:51:51 +0100 Subject: TTY: remove minor_num from tty_driver It was added back in 2004 and never used for anything real. Remove the only assignment in the tree as well. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- include/linux/tty_driver.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 6e65493a5e6..e064f1704e2 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -299,7 +299,6 @@ struct tty_driver { int name_base; /* offset of printed name */ int major; /* major device number */ int minor_start; /* start of minor device number */ - int minor_num; /* number of *possible* devices */ int num; /* number of devices allocated */ short type; /* type of tty driver */ short subtype; /* subtype of tty driver */ -- cgit v1.2.3-18-g5258 From 91cedcde1e5feede6c1e4c2086ec4f3c84c56d4f Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:51:55 +0100 Subject: TTY: serial, simplify ASYNC_USR_MASK By using ASYNC_SPD_MASK instead of the single speed bits. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- include/linux/serial.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/serial.h b/include/linux/serial.h index 3d86517fe7d..441980ecc4e 100644 --- a/include/linux/serial.h +++ b/include/linux/serial.h @@ -152,8 +152,8 @@ struct serial_uart_config { #define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE) #define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1) -#define ASYNC_USR_MASK (ASYNC_SPD_HI|ASYNC_SPD_VHI| \ - ASYNC_CALLOUT_NOHUP|ASYNC_SPD_SHI|ASYNC_LOW_LATENCY) +#define ASYNC_USR_MASK (ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \ + ASYNC_LOW_LATENCY) #define ASYNC_SPD_CUST (ASYNC_SPD_HI|ASYNC_SPD_VHI) #define ASYNC_SPD_WARP (ASYNC_SPD_HI|ASYNC_SPD_SHI) #define ASYNC_SPD_MASK (ASYNC_SPD_HI|ASYNC_SPD_VHI|ASYNC_SPD_SHI) -- cgit v1.2.3-18-g5258 From 26b23209c0ea5503824df60b8f218fb04b80cad0 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:51:56 +0100 Subject: TTY: tty_driver, document tty->ops->shutdown limitation Note that tty->ops->shutdown is called from whatever context the user drops the last tty reference from. E.g. if one takes a reference in an ISR, tty close happens on other CPU and the final tty put is from the ISR, tty->ops->shutdown will be called from that hard irq context. We would have a problem in vt if we start using tty refcounting from other contexts than user there. It is because vt's shutdown uses mutexes. This is yet to be fixed. Signed-off-by: Jiri Slaby Reported-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- include/linux/tty_driver.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index e064f1704e2..6e6dbb7447b 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -50,6 +50,8 @@ * Note that tty_shutdown() is not called if ops->shutdown is defined. * This means one is responsible to take care of calling ops->remove (e.g. * via tty_driver_remove_tty) and releasing tty->termios. + * Note that this hook may be called from *all* the contexts where one + * uses tty refcounting (e.g. tty_port_tty_get). * * * void (*cleanup)(struct tty_struct * tty); -- cgit v1.2.3-18-g5258 From 44a1bfd95d0a6c0096e79a883197596e1ce83cc3 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:00 +0100 Subject: TTY: serialP, remove DECLARE_WAITQUEUE check The macro is always defined now. This was there only for historical reasons. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index e811a615f69..ec27b34bbbd 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -79,15 +79,9 @@ struct async_struct { int io_type; struct work_struct work; struct tasklet_struct tlet; -#ifdef DECLARE_WAITQUEUE wait_queue_head_t open_wait; wait_queue_head_t close_wait; wait_queue_head_t delta_msr_wait; -#else - struct wait_queue *open_wait; - struct wait_queue *close_wait; - struct wait_queue *delta_msr_wait; -#endif struct async_struct *next_port; /* For the linked list */ struct async_struct *prev_port; }; -- cgit v1.2.3-18-g5258 From 9c8efecc91c02056340ae19612315f3225e6dbe2 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:12 +0100 Subject: TTY: serialP, remove unused material First, remove unused macro and rs_multiport_struct structure. Nobody uses them at all. Further, the 2 drivers (they are below) which use the rest of structures from serialP.h (async_struct and serial_state) do not use all the members. Remove the members: * which are unused or * which are only initialized and never used for something real. Everybody should avoid the structures with a looong distance. Finally, remove the ALPHA kludge MCR quirks. They are 1:1 copy from 8250.h. No need to redefine them here. The 2 promised users of the structures: arch/ia64/hp/sim/simserial.c drivers/tty/amiserial.c Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 59 ------------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index ec27b34bbbd..c1acdb2c858 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -26,32 +26,23 @@ #include struct serial_state { - int magic; int baud_base; unsigned long port; int irq; int flags; - int hub6; int type; int line; - int revision; /* Chip revision (950) */ int xmit_fifo_size; int custom_divisor; int count; - u8 *iomem_base; - u16 iomem_reg_shift; unsigned short close_delay; unsigned short closing_wait; /* time to wait before closing */ struct async_icount icount; - int io_type; struct async_struct *info; - struct pci_dev *dev; }; struct async_struct { - int magic; unsigned long port; - int hub6; int flags; int xmit_fifo_size; struct serial_state *state; @@ -63,21 +54,12 @@ struct async_struct { int x_char; /* xon/xoff character */ int close_delay; unsigned short closing_wait; - unsigned short closing_wait2; /* obsolete */ int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ - int LCR; /* Line control register */ - int ACR; /* 16950 Additional Control Reg. */ unsigned long event; - unsigned long last_active; int line; int blocked_open; /* # of blocked opens */ struct circ_buf xmit; - spinlock_t xmit_lock; - u8 *iomem_base; - u16 iomem_reg_shift; - int io_type; - struct work_struct work; struct tasklet_struct tlet; wait_queue_head_t open_wait; wait_queue_head_t close_wait; @@ -86,51 +68,10 @@ struct async_struct { struct async_struct *prev_port; }; -#define CONFIGURED_SERIAL_PORT(info) ((info)->port || ((info)->iomem_base)) - -#define SERIAL_MAGIC 0x5301 -#define SSTATE_MAGIC 0x5302 - /* * Events are used to schedule things to happen at timer-interrupt * time, instead of at rs interrupt time. */ #define RS_EVENT_WRITE_WAKEUP 0 -/* - * Multiport serial configuration structure --- internal structure - */ -struct rs_multiport_struct { - int port1; - unsigned char mask1, match1; - int port2; - unsigned char mask2, match2; - int port3; - unsigned char mask3, match3; - int port4; - unsigned char mask4, match4; - int port_monitor; -}; - -#if defined(__alpha__) && !defined(CONFIG_PCI) -/* - * Digital did something really horribly wrong with the OUT1 and OUT2 - * lines on at least some ALPHA's. The failure mode is that if either - * is cleared, the machine locks up with endless interrupts. - * - * This is still used by arch/mips/au1000/common/serial.c for some weird - * reason (mips != alpha!) - */ -#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1) -#elif defined(CONFIG_SBC8560) -/* - * WindRiver did something similarly broken on their SBC8560 board. The - * UART tristates its IRQ output while OUT2 is clear, but they pulled - * the interrupt line _up_ instead of down, so if we register the IRQ - * while the UART is in that state, we die in an IRQ storm. */ -#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2) -#else -#define ALPHA_KLUDGE_MCR 0 -#endif - #endif /* _LINUX_SERIAL_H */ -- cgit v1.2.3-18-g5258 From c5f0508b992ad081ba378a59b2404966f9f89429 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:13 +0100 Subject: TTY: amiserial, remove tasklet for tty_wakeup tty_wakeup is safe to be called from all contexts. No need to schedule a tasklet for that. Let's call it directly like in other drivers. This allows us to kill another member of async_struct structure. (If we remove the dummy uses in simserial.) Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index c1acdb2c858..beaf39f819d 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -56,11 +56,9 @@ struct async_struct { unsigned short closing_wait; int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ - unsigned long event; int line; int blocked_open; /* # of blocked opens */ struct circ_buf xmit; - struct tasklet_struct tlet; wait_queue_head_t open_wait; wait_queue_head_t close_wait; wait_queue_head_t delta_msr_wait; @@ -68,10 +66,4 @@ struct async_struct { struct async_struct *prev_port; }; -/* - * Events are used to schedule things to happen at timer-interrupt - * time, instead of at rs interrupt time. - */ -#define RS_EVENT_WRITE_WAKEUP 0 - #endif /* _LINUX_SERIAL_H */ -- cgit v1.2.3-18-g5258 From 979b6d89766ed573bca6a6e902193c4cad502909 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:15 +0100 Subject: TTY: simserial, use only one copy of async flags The same as for amiserial. Use only one instance of the flags. Also remove them from async_struct now. Nobody else uses them. Signed-off-by: Jiri Slaby Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index beaf39f819d..6741f57cc2a 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -43,7 +43,6 @@ struct serial_state { struct async_struct { unsigned long port; - int flags; int xmit_fifo_size; struct serial_state *state; struct tty_struct *tty; -- cgit v1.2.3-18-g5258 From d852256389f1bcf506710ea5de77debde40013b9 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:16 +0100 Subject: TTY: simserial/amiserial, use one instance of other members This means: * close_delay * closing_wait * line * port * xmit_fifo_size This actually fixes a bug in amiserial. It initializes one and uses the other of the close delays. Yes, duplicating structure members is evil. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index 6741f57cc2a..6ce488c4658 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -42,8 +42,6 @@ struct serial_state { }; struct async_struct { - unsigned long port; - int xmit_fifo_size; struct serial_state *state; struct tty_struct *tty; int read_status_mask; @@ -51,11 +49,8 @@ struct async_struct { int timeout; int quot; int x_char; /* xon/xoff character */ - int close_delay; - unsigned short closing_wait; int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ - int line; int blocked_open; /* # of blocked opens */ struct circ_buf xmit; wait_queue_head_t open_wait; -- cgit v1.2.3-18-g5258 From 964105b501071e8a0e9feb1d0e4b3e46508bc38e Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:17 +0100 Subject: TTY: simserial, remove support of shared interrupts It never worked there. The ISR was never written for that kind of stuff. So remove all that crap with a hash of linked lists and pass the pointer directly to the ISR. BTW this answers the question there: * I don't know exactly why they don't use the dev_id opaque data * pointer instead of this extra lookup table -> Because they thought they will support more devices bound to a single interrupt w/o IRQF_SHARED. They would need exactly the hash there. What I don't understand is rebinding of the interrupt in the shutdown path. They perhaps meant to do just synchronize_irq? In any case, this is all gone and free_irq there properly. By removing the hash we save some bits (exactly NR_IRQS * 8 bytes of .bss and over a kilo of .text): before: text data bss dec hex filename 19600 320 8227 28147 6df3 ../a/ia64/arch/ia64/hp/sim/simserial.o after: text data bss dec hex filename 18568 320 28 18916 49e4 ../a/ia64/arch/ia64/hp/sim/simserial.o Note that a shared interrupt could not work too. request_irq requires data parameter to be non-NULL. So the whole IRQ_T exercise was pointless. Finally, this helps us remove another two members of async_struct :). Signed-off-by: Jiri Slaby Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index 6ce488c4658..b8543f90245 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -56,8 +56,6 @@ struct async_struct { wait_queue_head_t open_wait; wait_queue_head_t close_wait; wait_queue_head_t delta_msr_wait; - struct async_struct *next_port; /* For the linked list */ - struct async_struct *prev_port; }; #endif /* _LINUX_SERIAL_H */ -- cgit v1.2.3-18-g5258 From 916b765675b7044bd5895b7430a2aa2c63ea4545 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:20 +0100 Subject: TTY: serialP, merge serial_state and async_struct This is the final step to get rid of the one of the structures. A further cleanup will follow. And I struct serial_state deserves cease to exist after a switch to tty_port too. While changing the lines, it removes also pointless tty->driver_data casts. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index b8543f90245..984f5ba8da4 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -38,24 +38,24 @@ struct serial_state { unsigned short close_delay; unsigned short closing_wait; /* time to wait before closing */ struct async_icount icount; - struct async_struct *info; -}; -struct async_struct { - struct serial_state *state; - struct tty_struct *tty; + /* amiserial */ int read_status_mask; int ignore_status_mask; int timeout; int quot; - int x_char; /* xon/xoff character */ int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ + wait_queue_head_t delta_msr_wait; + /* simserial */ + int x_char; /* xon/xoff character */ int blocked_open; /* # of blocked opens */ struct circ_buf xmit; wait_queue_head_t open_wait; wait_queue_head_t close_wait; - wait_queue_head_t delta_msr_wait; + struct tty_struct *tty; + /* /simserial */ + /* /amiserial */ }; #endif /* _LINUX_SERIAL_H */ -- cgit v1.2.3-18-g5258 From 87758791c99715433841f1c054b49166506513e4 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:24 +0100 Subject: TTY: amiserial/simserial, use tty_port Add tty_port to serial_state and start using common tty port members from tty_port in amiserial and simserial. The rest will follow one by one. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index 984f5ba8da4..32d45b869cb 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -23,6 +23,7 @@ #include #include #include +#include #include struct serial_state { @@ -38,6 +39,7 @@ struct serial_state { unsigned short close_delay; unsigned short closing_wait; /* time to wait before closing */ struct async_icount icount; + struct tty_port tport; /* amiserial */ int read_status_mask; @@ -46,14 +48,9 @@ struct serial_state { int quot; int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ - wait_queue_head_t delta_msr_wait; /* simserial */ int x_char; /* xon/xoff character */ - int blocked_open; /* # of blocked opens */ struct circ_buf xmit; - wait_queue_head_t open_wait; - wait_queue_head_t close_wait; - struct tty_struct *tty; /* /simserial */ /* /amiserial */ }; -- cgit v1.2.3-18-g5258 From 799be6ff2fd7294f428a9e68a7786490c862c1af Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:25 +0100 Subject: TTY: amiserial/simserial, use close delays from tty_port Note that previously simserial set the delay to 0. So we preserve that. BUT, is it correct? Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index 32d45b869cb..997edd008b9 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -36,8 +36,6 @@ struct serial_state { int xmit_fifo_size; int custom_divisor; int count; - unsigned short close_delay; - unsigned short closing_wait; /* time to wait before closing */ struct async_icount icount; struct tty_port tport; -- cgit v1.2.3-18-g5258 From 12c8035435fa16e3f6b18049bb1d7815c00a7a58 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:26 +0100 Subject: TTY: amiserial/simserial, use count from tty_port Nothing special. Just remove count from serial_state and change all users to use tty_port. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index 997edd008b9..a6612b9c7e8 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -35,7 +35,6 @@ struct serial_state { int line; int xmit_fifo_size; int custom_divisor; - int count; struct async_icount icount; struct tty_port tport; -- cgit v1.2.3-18-g5258 From 01bd730d92bd002adc3f3317d8e3328c629b436c Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:27 +0100 Subject: TTY: amiserial/simserial, use flags from tty_port This changes flags' type to ulong which is appropriate for all the set/clear_bits performed in the drivers.. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index a6612b9c7e8..e5e8442c08d 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -30,7 +30,6 @@ struct serial_state { int baud_base; unsigned long port; int irq; - int flags; int type; int line; int xmit_fifo_size; -- cgit v1.2.3-18-g5258 From 3c4782dcd9b8d02e79f0f0bd1fe6e30a79790526 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:31 +0100 Subject: TTY: simserial no longer needs serialP Let's do a spin-off of serial_state structure with only needed elements. And remove serialP crap from includes. Signed-off-by: Jiri Slaby Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index e5e8442c08d..9a04dec1589 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -44,10 +44,8 @@ struct serial_state { int quot; int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ - /* simserial */ int x_char; /* xon/xoff character */ struct circ_buf xmit; - /* /simserial */ /* /amiserial */ }; -- cgit v1.2.3-18-g5258 From ff169e5cbec29d33765687c7131673316011b328 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:44 +0100 Subject: TTY: amiserial, stop using serial_state->{irq,type,line} * instead of line, use tty->index or iterator... * irq and type are left unset. So get rid of them. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h index 9a04dec1589..77afbdb134a 100644 --- a/include/linux/serialP.h +++ b/include/linux/serialP.h @@ -29,9 +29,6 @@ struct serial_state { int baud_base; unsigned long port; - int irq; - int type; - int line; int xmit_fifo_size; int custom_divisor; struct async_icount icount; -- cgit v1.2.3-18-g5258 From 6fe18d26b1c33d5cb748f8694ee1a59dc5578da4 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:45 +0100 Subject: TTY: amiserial no longer needs serialP amiserial is the last user of serialP.h. Let's move struct serial_state directly to amiserial and remove serialP crap from includes. Finally, remove the header from the tree completely. Signed-off-by: Jiri Slaby Cc: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- include/linux/serialP.h | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 include/linux/serialP.h (limited to 'include') diff --git a/include/linux/serialP.h b/include/linux/serialP.h deleted file mode 100644 index 77afbdb134a..00000000000 --- a/include/linux/serialP.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Private header file for the (dumb) serial driver - * - * Copyright (C) 1997 by Theodore Ts'o. - * - * Redistribution of this file is permitted under the terms of the GNU - * Public License (GPL) - */ - -#ifndef _LINUX_SERIALP_H -#define _LINUX_SERIALP_H - -/* - * This is our internal structure for each serial port's state. - * - * Many fields are paralleled by the structure used by the serial_struct - * structure. - * - * For definitions of the flags field, see tty.h - */ - -#include -#include -#include -#include -#include -#include - -struct serial_state { - int baud_base; - unsigned long port; - int xmit_fifo_size; - int custom_divisor; - struct async_icount icount; - struct tty_port tport; - - /* amiserial */ - int read_status_mask; - int ignore_status_mask; - int timeout; - int quot; - int IER; /* Interrupt Enable Register */ - int MCR; /* Modem control register */ - int x_char; /* xon/xoff character */ - struct circ_buf xmit; - /* /amiserial */ -}; - -#endif /* _LINUX_SERIAL_H */ -- cgit v1.2.3-18-g5258 From 927353a75602dd97144352f53177e18093fdd198 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 8 Mar 2012 19:12:12 -0500 Subject: serial: introduce generic port in/out helpers Looking at the existing serial drivers (esp. the 8250 derived variants) we see a common trend. They create a hardware specific port struct, which in turn contains a generic serial_port struct. The other trend, is that they all create some sort of shortcut to go through the hardware specific struct, to the serial_port struct, which has the basic in/out operations within. Looking for the serial_in and serial_out in several drivers shows this. Rather than let this continue, lets create a generic set of similar helper wrappers that can be used on a struct port, so we can eliminate bouncing out through hardware specific struct pointers just to come back into struct port where possible. Signed-off-by: Paul Gortmaker Acked-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- include/linux/serial_core.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 585bfd03d2e..f51bf2e70c6 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -383,6 +383,16 @@ struct uart_port { void *private_data; /* generic platform data pointer */ }; +static inline int serial_port_in(struct uart_port *up, int offset) +{ + return up->serial_in(up, offset); +} + +static inline void serial_port_out(struct uart_port *up, int offset, int value) +{ + up->serial_out(up, offset, value); +} + /* * This is the state information which is persistent across opens. */ -- cgit v1.2.3-18-g5258