aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:41 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:48:28 -0500
commitf66279cd7d5cdf43686da0d9ed20378581b88d0f (patch)
tree7fcb97e028fa20c9e9c947e365de2351eb5e4232 /arch/ia64
parent8b916330567b0b788f35ded5d99a7ef7dc30b293 (diff)
TTY: simserial, reindent some code
Make the code to conform to the standard. Also make it readable. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/hp/sim/simserial.c120
1 files changed, 44 insertions, 76 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 24d6ca04de86..516ad09f3131 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -62,28 +62,25 @@ static void receive_chars(struct tty_struct *tty)
62 static unsigned char seen_esc = 0; 62 static unsigned char seen_esc = 0;
63 63
64 while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) { 64 while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
65 if ( ch == 27 && seen_esc == 0 ) { 65 if (ch == 27 && seen_esc == 0) {
66 seen_esc = 1; 66 seen_esc = 1;
67 continue; 67 continue;
68 } else { 68 } else if (seen_esc == 1 && ch == 'O') {
69 if ( seen_esc==1 && ch == 'O' ) { 69 seen_esc = 2;
70 seen_esc = 2; 70 continue;
71 continue; 71 } else if (seen_esc == 2) {
72 } else if ( seen_esc == 2 ) { 72 if (ch == 'P') /* F1 */
73 if ( ch == 'P' ) /* F1 */ 73 show_state();
74 show_state();
75#ifdef CONFIG_MAGIC_SYSRQ 74#ifdef CONFIG_MAGIC_SYSRQ
76 if ( ch == 'S' ) { /* F4 */ 75 if (ch == 'S') { /* F4 */
77 do 76 do {
78 ch = ia64_ssc(0, 0, 0, 0, 77 ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR);
79 SSC_GETCHAR); 78 } while (!ch);
80 while (!ch); 79 handle_sysrq(ch);
81 handle_sysrq(ch);
82 }
83#endif
84 seen_esc = 0;
85 continue;
86 } 80 }
81#endif
82 seen_esc = 0;
83 continue;
87 } 84 }
88 seen_esc = 0; 85 seen_esc = 0;
89 86
@@ -195,8 +192,8 @@ static void rs_flush_chars(struct tty_struct *tty)
195{ 192{
196 struct serial_state *info = tty->driver_data; 193 struct serial_state *info = tty->driver_data;
197 194
198 if (info->xmit.head == info->xmit.tail || tty->stopped || tty->hw_stopped || 195 if (info->xmit.head == info->xmit.tail || tty->stopped ||
199 !info->xmit.buf) 196 tty->hw_stopped || !info->xmit.buf)
200 return; 197 return;
201 198
202 transmit_chars(tty, info, NULL); 199 transmit_chars(tty, info, NULL);
@@ -232,10 +229,10 @@ static int rs_write(struct tty_struct * tty,
232 /* 229 /*
233 * Hey, we transmit directly from here in our case 230 * Hey, we transmit directly from here in our case
234 */ 231 */
235 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) 232 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) &&
236 && !tty->stopped && !tty->hw_stopped) { 233 !tty->stopped && !tty->hw_stopped)
237 transmit_chars(tty, info, NULL); 234 transmit_chars(tty, info, NULL);
238 } 235
239 return ret; 236 return ret;
240} 237}
241 238
@@ -293,7 +290,8 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
293 */ 290 */
294static void rs_throttle(struct tty_struct * tty) 291static void rs_throttle(struct tty_struct * tty)
295{ 292{
296 if (I_IXOFF(tty)) rs_send_xchar(tty, STOP_CHAR(tty)); 293 if (I_IXOFF(tty))
294 rs_send_xchar(tty, STOP_CHAR(tty));
297 295
298 printk(KERN_INFO "simrs_throttle called\n"); 296 printk(KERN_INFO "simrs_throttle called\n");
299} 297}
@@ -322,48 +320,21 @@ static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
322 } 320 }
323 321
324 switch (cmd) { 322 switch (cmd) {
325 case TIOCGSERIAL: 323 case TIOCGSERIAL:
326 printk(KERN_INFO "simrs_ioctl TIOCGSERIAL called\n"); 324 case TIOCSSERIAL:
327 return 0; 325 case TIOCSERGSTRUCT:
328 case TIOCSSERIAL: 326 case TIOCMIWAIT:
329 printk(KERN_INFO "simrs_ioctl TIOCSSERIAL called\n"); 327 return 0;
330 return 0; 328 case TIOCSERCONFIG:
331 case TIOCSERCONFIG: 329 case TIOCSERGETLSR: /* Get line status register */
332 printk(KERN_INFO "rs_ioctl: TIOCSERCONFIG called\n"); 330 return -EINVAL;
333 return -EINVAL; 331 case TIOCSERGWILD:
334 332 case TIOCSERSWILD:
335 case TIOCSERGETLSR: /* Get line status register */ 333 /* "setserial -W" is called in Debian boot */
336 printk(KERN_INFO "rs_ioctl: TIOCSERGETLSR called\n"); 334 printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
337 return -EINVAL; 335 return 0;
338 336 }
339 case TIOCSERGSTRUCT: 337 return -ENOIOCTLCMD;
340 printk(KERN_INFO "rs_ioctl: TIOCSERGSTRUCT called\n");
341#if 0
342 if (copy_to_user((struct async_struct *) arg,
343 info, sizeof(struct async_struct)))
344 return -EFAULT;
345#endif
346 return 0;
347
348 /*
349 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
350 * - mask passed in arg for lines of interest
351 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
352 * Caller should use TIOCGICOUNT to see which one it was
353 */
354 case TIOCMIWAIT:
355 printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n");
356 return 0;
357 case TIOCSERGWILD:
358 case TIOCSERSWILD:
359 /* "setserial -W" is called in Debian boot */
360 printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
361 return 0;
362
363 default:
364 return -ENOIOCTLCMD;
365 }
366 return 0;
367} 338}
368 339
369#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 340#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
@@ -387,14 +358,12 @@ static void shutdown(struct tty_port *port)
387 unsigned long flags; 358 unsigned long flags;
388 359
389 local_irq_save(flags); 360 local_irq_save(flags);
390 { 361 if (info->irq)
391 if (info->irq) 362 free_irq(info->irq, info);
392 free_irq(info->irq, info);
393 363
394 if (info->xmit.buf) { 364 if (info->xmit.buf) {
395 free_page((unsigned long) info->xmit.buf); 365 free_page((unsigned long) info->xmit.buf);
396 info->xmit.buf = NULL; 366 info->xmit.buf = NULL;
397 }
398 } 367 }
399 local_irq_restore(flags); 368 local_irq_restore(flags);
400} 369}
@@ -418,9 +387,8 @@ static int activate(struct tty_port *port, struct tty_struct *tty)
418{ 387{
419 struct serial_state *state = container_of(port, struct serial_state, 388 struct serial_state *state = container_of(port, struct serial_state,
420 port); 389 port);
421 unsigned long flags; 390 unsigned long flags, page;
422 int retval=0; 391 int retval = 0;
423 unsigned long page;
424 392
425 page = get_zeroed_page(GFP_KERNEL); 393 page = get_zeroed_page(GFP_KERNEL);
426 if (!page) 394 if (!page)