aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArve Hjønnevåg2013-01-15 17:10:31 -0600
committerArve Hjønnevåg2013-07-01 17:51:50 -0500
commit4b4559062472f7e81d0a6831538686d989226864 (patch)
treeb5091b6738c2d8bdde55888590d2791ed8486f86
parentc2b48c1f48e187445f6e868e8838a87f783a1e25 (diff)
downloadkernel-common-4b4559062472f7e81d0a6831538686d989226864.tar.gz
kernel-common-4b4559062472f7e81d0a6831538686d989226864.tar.xz
kernel-common-4b4559062472f7e81d0a6831538686d989226864.zip
ARM: fiq_debugger: Update tty code for 3.9
Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r--arch/arm/common/fiq_debugger.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/arch/arm/common/fiq_debugger.c b/arch/arm/common/fiq_debugger.c
index eabd94b98f4..65b943c7630 100644
--- a/arch/arm/common/fiq_debugger.c
+++ b/arch/arm/common/fiq_debugger.c
@@ -89,8 +89,7 @@ struct fiq_debugger_state {
89#ifdef CONFIG_FIQ_DEBUGGER_CONSOLE 89#ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
90 spinlock_t console_lock; 90 spinlock_t console_lock;
91 struct console console; 91 struct console console;
92 struct tty_struct *tty; 92 struct tty_port tty_port;
93 int tty_open_count;
94 struct fiq_debugger_ringbuf *tty_rbuf; 93 struct fiq_debugger_ringbuf *tty_rbuf;
95 bool syslog_dumping; 94 bool syslog_dumping;
96#endif 95#endif
@@ -768,30 +767,34 @@ static irqreturn_t wakeup_irq_handler(int irq, void *dev)
768 return IRQ_HANDLED; 767 return IRQ_HANDLED;
769} 768}
770 769
771 770static void debug_handle_console_irq_context(struct fiq_debugger_state *state)
772static void debug_handle_irq_context(struct fiq_debugger_state *state)
773{ 771{
774 if (!state->no_sleep) {
775 unsigned long flags;
776
777 spin_lock_irqsave(&state->sleep_timer_lock, flags);
778 wake_lock(&state->debugger_wake_lock);
779 mod_timer(&state->sleep_timer, jiffies + HZ * 5);
780 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
781 }
782#if defined(CONFIG_FIQ_DEBUGGER_CONSOLE) 772#if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
783 if (state->tty) { 773 if (state->tty_port.ops) {
784 int i; 774 int i;
785 int count = fiq_debugger_ringbuf_level(state->tty_rbuf); 775 int count = fiq_debugger_ringbuf_level(state->tty_rbuf);
786 for (i = 0; i < count; i++) { 776 for (i = 0; i < count; i++) {
787 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0); 777 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0);
788 tty_insert_flip_char(state->tty, c, TTY_NORMAL); 778 tty_insert_flip_char(&state->tty_port, c, TTY_NORMAL);
789 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1)) 779 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1))
790 pr_warn("fiq tty failed to consume byte\n"); 780 pr_warn("fiq tty failed to consume byte\n");
791 } 781 }
792 tty_flip_buffer_push(state->tty); 782 tty_flip_buffer_push(&state->tty_port);
793 } 783 }
794#endif 784#endif
785}
786
787static void debug_handle_irq_context(struct fiq_debugger_state *state)
788{
789 if (!state->no_sleep) {
790 unsigned long flags;
791
792 spin_lock_irqsave(&state->sleep_timer_lock, flags);
793 wake_lock(&state->debugger_wake_lock);
794 mod_timer(&state->sleep_timer, jiffies + HZ * 5);
795 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
796 }
797 debug_handle_console_irq_context(state);
795 if (state->debug_busy) { 798 if (state->debug_busy) {
796 debug_irq_exec(state, state->debug_cmd); 799 debug_irq_exec(state, state->debug_cmd);
797 if (!state->console_enable) 800 if (!state->console_enable)
@@ -995,26 +998,21 @@ int fiq_tty_open(struct tty_struct *tty, struct file *filp)
995 int line = tty->index; 998 int line = tty->index;
996 struct fiq_debugger_state **states = tty->driver->driver_state; 999 struct fiq_debugger_state **states = tty->driver->driver_state;
997 struct fiq_debugger_state *state = states[line]; 1000 struct fiq_debugger_state *state = states[line];
998 if (state->tty_open_count++)
999 return 0;
1000 1001
1001 tty->driver_data = state; 1002 return tty_port_open(&state->tty_port, tty, filp);
1002 state->tty = tty;
1003 return 0;
1004} 1003}
1005 1004
1006void fiq_tty_close(struct tty_struct *tty, struct file *filp) 1005void fiq_tty_close(struct tty_struct *tty, struct file *filp)
1007{ 1006{
1008 struct fiq_debugger_state *state = tty->driver_data; 1007 tty_port_close(tty->port, tty, filp);
1009 if (--state->tty_open_count)
1010 return;
1011 state->tty = NULL;
1012} 1008}
1013 1009
1014int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) 1010int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
1015{ 1011{
1016 int i; 1012 int i;
1017 struct fiq_debugger_state *state = tty->driver_data; 1013 int line = tty->index;
1014 struct fiq_debugger_state **states = tty->driver->driver_state;
1015 struct fiq_debugger_state *state = states[line];
1018 1016
1019 if (!state->console_enable) 1017 if (!state->console_enable)
1020 return count; 1018 return count;
@@ -1042,7 +1040,8 @@ static int fiq_tty_poll_init(struct tty_driver *driver, int line, char *options)
1042 1040
1043static int fiq_tty_poll_get_char(struct tty_driver *driver, int line) 1041static int fiq_tty_poll_get_char(struct tty_driver *driver, int line)
1044{ 1042{
1045 struct fiq_debugger_state *state = driver->ttys[line]->driver_data; 1043 struct fiq_debugger_state **states = driver->driver_state;
1044 struct fiq_debugger_state *state = states[line];
1046 int c = NO_POLL_CHAR; 1045 int c = NO_POLL_CHAR;
1047 1046
1048 debug_uart_enable(state); 1047 debug_uart_enable(state);
@@ -1064,13 +1063,16 @@ static int fiq_tty_poll_get_char(struct tty_driver *driver, int line)
1064 1063
1065static void fiq_tty_poll_put_char(struct tty_driver *driver, int line, char ch) 1064static void fiq_tty_poll_put_char(struct tty_driver *driver, int line, char ch)
1066{ 1065{
1067 struct fiq_debugger_state *state = driver->ttys[line]->driver_data; 1066 struct fiq_debugger_state **states = driver->driver_state;
1067 struct fiq_debugger_state *state = states[line];
1068 debug_uart_enable(state); 1068 debug_uart_enable(state);
1069 debug_putc(state, ch); 1069 debug_putc(state, ch);
1070 debug_uart_disable(state); 1070 debug_uart_disable(state);
1071} 1071}
1072#endif 1072#endif
1073 1073
1074static const struct tty_port_operations fiq_tty_port_ops;
1075
1074static const struct tty_operations fiq_tty_driver_ops = { 1076static const struct tty_operations fiq_tty_driver_ops = {
1075 .write = fiq_tty_write, 1077 .write = fiq_tty_write,
1076 .write_room = fiq_tty_write_room, 1078 .write_room = fiq_tty_write_room,
@@ -1150,8 +1152,11 @@ static int fiq_debugger_tty_init_one(struct fiq_debugger_state *state)
1150 goto err; 1152 goto err;
1151 } 1153 }
1152 1154
1153 tty_dev = tty_register_device(fiq_tty_driver, state->pdev->id, 1155 tty_port_init(&state->tty_port);
1154 &state->pdev->dev); 1156 state->tty_port.ops = &fiq_tty_port_ops;
1157
1158 tty_dev = tty_port_register_device(&state->tty_port, fiq_tty_driver,
1159 state->pdev->id, &state->pdev->dev);
1155 if (IS_ERR(tty_dev)) { 1160 if (IS_ERR(tty_dev)) {
1156 pr_err("Failed to register fiq debugger tty device\n"); 1161 pr_err("Failed to register fiq debugger tty device\n");
1157 ret = PTR_ERR(tty_dev); 1162 ret = PTR_ERR(tty_dev);