aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArve Hjønnevåg2013-01-15 17:10:31 -0600
committerArve Hjønnevåg2013-02-22 17:27:47 -0600
commite0b721361db3128b57e741c3e21b774f58502bba (patch)
tree1d7c26eb2e0d1d47818c9fc9f32e6136eb999906
parent503df62b4b21d1aff8748b134a2ab60b36ad1da9 (diff)
downloadkernel-common-e0b721361db3128b57e741c3e21b774f58502bba.tar.gz
kernel-common-e0b721361db3128b57e741c3e21b774f58502bba.tar.xz
kernel-common-e0b721361db3128b57e741c3e21b774f58502bba.zip
ARM: fiq_debugger: Update tty code for 3.8
Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r--arch/arm/common/fiq_debugger.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/arch/arm/common/fiq_debugger.c b/arch/arm/common/fiq_debugger.c
index eabd94b98f4..fa5812897a4 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,38 @@ 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 struct tty_struct *tty;
774
775 tty = tty_port_tty_get(&state->tty_port);
776 if (tty) {
784 int i; 777 int i;
785 int count = fiq_debugger_ringbuf_level(state->tty_rbuf); 778 int count = fiq_debugger_ringbuf_level(state->tty_rbuf);
786 for (i = 0; i < count; i++) { 779 for (i = 0; i < count; i++) {
787 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0); 780 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0);
788 tty_insert_flip_char(state->tty, c, TTY_NORMAL); 781 tty_insert_flip_char(tty, c, TTY_NORMAL);
789 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1)) 782 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1))
790 pr_warn("fiq tty failed to consume byte\n"); 783 pr_warn("fiq tty failed to consume byte\n");
791 } 784 }
792 tty_flip_buffer_push(state->tty); 785 tty_flip_buffer_push(tty);
786 tty_kref_put(tty);
793 } 787 }
794#endif 788#endif
789}
790
791static void debug_handle_irq_context(struct fiq_debugger_state *state)
792{
793 if (!state->no_sleep) {
794 unsigned long flags;
795
796 spin_lock_irqsave(&state->sleep_timer_lock, flags);
797 wake_lock(&state->debugger_wake_lock);
798 mod_timer(&state->sleep_timer, jiffies + HZ * 5);
799 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
800 }
801 debug_handle_console_irq_context(state);
795 if (state->debug_busy) { 802 if (state->debug_busy) {
796 debug_irq_exec(state, state->debug_cmd); 803 debug_irq_exec(state, state->debug_cmd);
797 if (!state->console_enable) 804 if (!state->console_enable)
@@ -995,26 +1002,21 @@ int fiq_tty_open(struct tty_struct *tty, struct file *filp)
995 int line = tty->index; 1002 int line = tty->index;
996 struct fiq_debugger_state **states = tty->driver->driver_state; 1003 struct fiq_debugger_state **states = tty->driver->driver_state;
997 struct fiq_debugger_state *state = states[line]; 1004 struct fiq_debugger_state *state = states[line];
998 if (state->tty_open_count++)
999 return 0;
1000 1005
1001 tty->driver_data = state; 1006 return tty_port_open(&state->tty_port, tty, filp);
1002 state->tty = tty;
1003 return 0;
1004} 1007}
1005 1008
1006void fiq_tty_close(struct tty_struct *tty, struct file *filp) 1009void fiq_tty_close(struct tty_struct *tty, struct file *filp)
1007{ 1010{
1008 struct fiq_debugger_state *state = tty->driver_data; 1011 tty_port_close(tty->port, tty, filp);
1009 if (--state->tty_open_count)
1010 return;
1011 state->tty = NULL;
1012} 1012}
1013 1013
1014int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) 1014int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
1015{ 1015{
1016 int i; 1016 int i;
1017 struct fiq_debugger_state *state = tty->driver_data; 1017 int line = tty->index;
1018 struct fiq_debugger_state **states = tty->driver->driver_state;
1019 struct fiq_debugger_state *state = states[line];
1018 1020
1019 if (!state->console_enable) 1021 if (!state->console_enable)
1020 return count; 1022 return count;
@@ -1042,7 +1044,8 @@ static int fiq_tty_poll_init(struct tty_driver *driver, int line, char *options)
1042 1044
1043static int fiq_tty_poll_get_char(struct tty_driver *driver, int line) 1045static int fiq_tty_poll_get_char(struct tty_driver *driver, int line)
1044{ 1046{
1045 struct fiq_debugger_state *state = driver->ttys[line]->driver_data; 1047 struct fiq_debugger_state **states = driver->driver_state;
1048 struct fiq_debugger_state *state = states[line];
1046 int c = NO_POLL_CHAR; 1049 int c = NO_POLL_CHAR;
1047 1050
1048 debug_uart_enable(state); 1051 debug_uart_enable(state);
@@ -1064,13 +1067,16 @@ static int fiq_tty_poll_get_char(struct tty_driver *driver, int line)
1064 1067
1065static void fiq_tty_poll_put_char(struct tty_driver *driver, int line, char ch) 1068static void fiq_tty_poll_put_char(struct tty_driver *driver, int line, char ch)
1066{ 1069{
1067 struct fiq_debugger_state *state = driver->ttys[line]->driver_data; 1070 struct fiq_debugger_state **states = driver->driver_state;
1071 struct fiq_debugger_state *state = states[line];
1068 debug_uart_enable(state); 1072 debug_uart_enable(state);
1069 debug_putc(state, ch); 1073 debug_putc(state, ch);
1070 debug_uart_disable(state); 1074 debug_uart_disable(state);
1071} 1075}
1072#endif 1076#endif
1073 1077
1078static const struct tty_port_operations fiq_tty_port_ops;
1079
1074static const struct tty_operations fiq_tty_driver_ops = { 1080static const struct tty_operations fiq_tty_driver_ops = {
1075 .write = fiq_tty_write, 1081 .write = fiq_tty_write,
1076 .write_room = fiq_tty_write_room, 1082 .write_room = fiq_tty_write_room,
@@ -1150,8 +1156,11 @@ static int fiq_debugger_tty_init_one(struct fiq_debugger_state *state)
1150 goto err; 1156 goto err;
1151 } 1157 }
1152 1158
1153 tty_dev = tty_register_device(fiq_tty_driver, state->pdev->id, 1159 tty_port_init(&state->tty_port);
1154 &state->pdev->dev); 1160 state->tty_port.ops = &fiq_tty_port_ops;
1161
1162 tty_dev = tty_port_register_device(&state->tty_port, fiq_tty_driver,
1163 state->pdev->id, &state->pdev->dev);
1155 if (IS_ERR(tty_dev)) { 1164 if (IS_ERR(tty_dev)) {
1156 pr_err("Failed to register fiq debugger tty device\n"); 1165 pr_err("Failed to register fiq debugger tty device\n");
1157 ret = PTR_ERR(tty_dev); 1166 ret = PTR_ERR(tty_dev);