Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Char: serial167, cleanup

serial167, cleanup

- Lindent the code
- remove 3 pointers from paranoia_check

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jiri Slaby and committed by
Linus Torvalds
44bafdf3 30a063a9

+1651 -1683
+1651 -1683
drivers/char/serial167.c
··· 111 111 112 112 /* This is the per-port data structure */ 113 113 struct cyclades_port cy_port[] = { 114 - /* CARD# */ 115 - {-1 }, /* ttyS0 */ 116 - {-1 }, /* ttyS1 */ 117 - {-1 }, /* ttyS2 */ 118 - {-1 }, /* ttyS3 */ 114 + /* CARD# */ 115 + {-1}, /* ttyS0 */ 116 + {-1}, /* ttyS1 */ 117 + {-1}, /* ttyS2 */ 118 + {-1}, /* ttyS3 */ 119 119 }; 120 + 120 121 #define NR_PORTS ARRAY_SIZE(cy_port) 121 122 122 123 /* ··· 129 128 * HI VHI 130 129 */ 131 130 static int baud_table[] = { 132 - 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 133 - 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000, 134 - 0}; 131 + 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 132 + 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000, 133 + 0 134 + }; 135 135 136 136 #if 0 137 - static char baud_co[] = { /* 25 MHz clock option table */ 138 - /* value => 00 01 02 03 04 */ 139 - /* divide by 8 32 128 512 2048 */ 140 - 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 141 - 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 137 + static char baud_co[] = { /* 25 MHz clock option table */ 138 + /* value => 00 01 02 03 04 */ 139 + /* divide by 8 32 128 512 2048 */ 140 + 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 141 + 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 142 + }; 142 143 143 - static char baud_bpr[] = { /* 25 MHz baud rate period table */ 144 - 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3, 145 - 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15}; 144 + static char baud_bpr[] = { /* 25 MHz baud rate period table */ 145 + 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3, 146 + 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15 147 + }; 146 148 #endif 147 149 148 150 /* I think 166 brd clocks 2401 at 20MHz.... */ 149 151 150 152 /* These values are written directly to tcor, and >> 5 for writing to rcor */ 151 - static u_char baud_co[] = { /* 20 MHz clock option table */ 152 - 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40, 153 - 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 153 + static u_char baud_co[] = { /* 20 MHz clock option table */ 154 + 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40, 155 + 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 156 + }; 154 157 155 158 /* These values written directly to tbpr/rbpr */ 156 - static u_char baud_bpr[] = { /* 20 MHz baud rate period table */ 157 - 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81, 158 - 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10}; 159 + static u_char baud_bpr[] = { /* 20 MHz baud rate period table */ 160 + 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81, 161 + 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10 162 + }; 159 163 160 - static u_char baud_cor4[] = { /* receive threshold */ 161 - 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 162 - 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07}; 163 - 164 - 164 + static u_char baud_cor4[] = { /* receive threshold */ 165 + 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 166 + 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07 167 + }; 165 168 166 169 static void shutdown(struct cyclades_port *); 167 - static int startup (struct cyclades_port *); 170 + static int startup(struct cyclades_port *); 168 171 static void cy_throttle(struct tty_struct *); 169 172 static void cy_unthrottle(struct tty_struct *); 170 173 static void config_setup(struct cyclades_port *); ··· 179 174 180 175 #ifdef CONFIG_REMOTE_DEBUG 181 176 static void debug_setup(void); 182 - void queueDebugChar (int c); 177 + void queueDebugChar(int c); 183 178 int getDebugChar(void); 184 179 185 180 #define DEBUG_PORT 1 186 181 #define DEBUG_LEN 256 187 182 188 183 typedef struct { 189 - int in; 190 - int out; 191 - unsigned char buf[DEBUG_LEN]; 184 + int in; 185 + int out; 186 + unsigned char buf[DEBUG_LEN]; 192 187 } debugq; 193 188 194 189 debugq debugiq; ··· 201 196 * delay, but this wild guess will do for now. 202 197 */ 203 198 204 - void my_udelay (long us) 199 + void my_udelay(long us) 205 200 { 206 201 u_char x; 207 202 volatile u_char *p = &x; ··· 212 207 x |= *p; 213 208 } 214 209 215 - static inline int 216 - serial_paranoia_check(struct cyclades_port *info, char *name, 217 - const char *routine) 210 + static inline int serial_paranoia_check(struct cyclades_port *info, char *name, 211 + const char *routine) 218 212 { 219 213 #ifdef SERIAL_PARANOIA_CHECK 220 - static const char *badmagic = 221 - "Warning: bad magic number for serial struct (%s) in %s\n"; 222 - static const char *badinfo = 223 - "Warning: null cyclades_port for (%s) in %s\n"; 224 - static const char *badrange = 225 - "Warning: cyclades_port out of range for (%s) in %s\n"; 214 + if (!info) { 215 + printk("Warning: null cyclades_port for (%s) in %s\n", name, 216 + routine); 217 + return 1; 218 + } 226 219 227 - if (!info) { 228 - printk(badinfo, name, routine); 229 - return 1; 230 - } 220 + if ((long)info < (long)(&cy_port[0]) 221 + || (long)(&cy_port[NR_PORTS]) < (long)info) { 222 + printk("Warning: cyclades_port out of range for (%s) in %s\n", 223 + name, routine); 224 + return 1; 225 + } 231 226 232 - if( (long)info < (long)(&cy_port[0]) 233 - || (long)(&cy_port[NR_PORTS]) < (long)info ){ 234 - printk(badrange, name, routine); 235 - return 1; 236 - } 237 - 238 - if (info->magic != CYCLADES_MAGIC) { 239 - printk(badmagic, name, routine); 240 - return 1; 241 - } 227 + if (info->magic != CYCLADES_MAGIC) { 228 + printk("Warning: bad magic number for serial struct (%s) in " 229 + "%s\n", name, routine); 230 + return 1; 231 + } 242 232 #endif 243 233 return 0; 244 - } /* serial_paranoia_check */ 234 + } /* serial_paranoia_check */ 245 235 246 236 #if 0 247 237 /* The following diagnostic routines allow the driver to spew 248 238 information on the screen, even (especially!) during interrupts. 249 239 */ 250 - void 251 - SP(char *data){ 252 - unsigned long flags; 253 - local_irq_save(flags); 254 - console_print(data); 255 - local_irq_restore(flags); 240 + void SP(char *data) 241 + { 242 + unsigned long flags; 243 + local_irq_save(flags); 244 + console_print(data); 245 + local_irq_restore(flags); 256 246 } 257 - char scrn[2]; 258 - void 259 - CP(char data){ 260 - unsigned long flags; 261 - local_irq_save(flags); 262 - scrn[0] = data; 263 - console_print(scrn); 264 - local_irq_restore(flags); 265 - }/* CP */ 266 247 267 - void CP1(int data) { (data<10)? CP(data+'0'): CP(data+'A'-10); }/* CP1 */ 268 - void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */ 269 - void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */ 270 - void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */ 248 + char scrn[2]; 249 + void CP(char data) 250 + { 251 + unsigned long flags; 252 + local_irq_save(flags); 253 + scrn[0] = data; 254 + console_print(scrn); 255 + local_irq_restore(flags); 256 + } /* CP */ 257 + 258 + void CP1(int data) 259 + { 260 + (data < 10) ? CP(data + '0') : CP(data + 'A' - 10); 261 + } /* CP1 */ 262 + void CP2(int data) 263 + { 264 + CP1((data >> 4) & 0x0f); 265 + CP1(data & 0x0f); 266 + } /* CP2 */ 267 + void CP4(int data) 268 + { 269 + CP2((data >> 8) & 0xff); 270 + CP2(data & 0xff); 271 + } /* CP4 */ 272 + void CP8(long data) 273 + { 274 + CP4((data >> 16) & 0xffff); 275 + CP4(data & 0xffff); 276 + } /* CP8 */ 271 277 #endif 272 278 273 279 /* This routine waits up to 1000 micro-seconds for the previous ··· 286 270 new command. An error is returned if the previous command 287 271 didn't finish within the time limit. 288 272 */ 289 - u_short 290 - write_cy_cmd(volatile u_char *base_addr, u_char cmd) 273 + u_short write_cy_cmd(volatile u_char * base_addr, u_char cmd) 291 274 { 292 - unsigned long flags; 293 - volatile int i; 275 + unsigned long flags; 276 + volatile int i; 294 277 295 - local_irq_save(flags); 278 + local_irq_save(flags); 296 279 /* Check to see that the previous command has completed */ 297 - for(i = 0 ; i < 100 ; i++){ 298 - if (base_addr[CyCCR] == 0){ 299 - break; 300 - } 301 - my_udelay(10L); 280 + for (i = 0; i < 100; i++) { 281 + if (base_addr[CyCCR] == 0) { 282 + break; 283 + } 284 + my_udelay(10L); 302 285 } 303 286 /* if the CCR never cleared, the previous command 304 - didn't finish within the "reasonable time" */ 305 - if ( i == 10 ) { 306 - local_irq_restore(flags); 307 - return (-1); 287 + didn't finish within the "reasonable time" */ 288 + if (i == 10) { 289 + local_irq_restore(flags); 290 + return (-1); 308 291 } 309 292 310 293 /* Issue the new command */ 311 294 base_addr[CyCCR] = cmd; 312 - local_irq_restore(flags); 313 - return(0); 314 - } /* write_cy_cmd */ 315 - 295 + local_irq_restore(flags); 296 + return (0); 297 + } /* write_cy_cmd */ 316 298 317 299 /* cy_start and cy_stop provide software output flow control as a 318 300 function of XON/XOFF, software CTS, and other such stuff. */ 319 301 320 - static void 321 - cy_stop(struct tty_struct *tty) 302 + static void cy_stop(struct tty_struct *tty) 322 303 { 323 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 324 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 325 - int channel; 326 - unsigned long flags; 304 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 305 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 306 + int channel; 307 + unsigned long flags; 327 308 328 309 #ifdef SERIAL_DEBUG_OTHER 329 - printk("cy_stop %s\n", tty->name); /* */ 310 + printk("cy_stop %s\n", tty->name); /* */ 330 311 #endif 331 312 332 - if (serial_paranoia_check(info, tty->name, "cy_stop")) 333 - return; 334 - 335 - channel = info->line; 313 + if (serial_paranoia_check(info, tty->name, "cy_stop")) 314 + return; 336 315 337 - local_irq_save(flags); 338 - base_addr[CyCAR] = (u_char)(channel); /* index channel */ 339 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 340 - local_irq_restore(flags); 316 + channel = info->line; 341 317 342 - return; 343 - } /* cy_stop */ 318 + local_irq_save(flags); 319 + base_addr[CyCAR] = (u_char) (channel); /* index channel */ 320 + base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy); 321 + local_irq_restore(flags); 322 + } /* cy_stop */ 344 323 345 - static void 346 - cy_start(struct tty_struct *tty) 324 + static void cy_start(struct tty_struct *tty) 347 325 { 348 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 349 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 350 - int channel; 351 - unsigned long flags; 326 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 327 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 328 + int channel; 329 + unsigned long flags; 352 330 353 331 #ifdef SERIAL_DEBUG_OTHER 354 - printk("cy_start %s\n", tty->name); /* */ 332 + printk("cy_start %s\n", tty->name); /* */ 355 333 #endif 356 334 357 - if (serial_paranoia_check(info, tty->name, "cy_start")) 358 - return; 359 - 360 - channel = info->line; 335 + if (serial_paranoia_check(info, tty->name, "cy_start")) 336 + return; 361 337 362 - local_irq_save(flags); 363 - base_addr[CyCAR] = (u_char)(channel); 364 - base_addr[CyIER] |= CyTxMpty; 365 - local_irq_restore(flags); 338 + channel = info->line; 366 339 367 - return; 368 - } /* cy_start */ 369 - 340 + local_irq_save(flags); 341 + base_addr[CyCAR] = (u_char) (channel); 342 + base_addr[CyIER] |= CyTxMpty; 343 + local_irq_restore(flags); 344 + } /* cy_start */ 370 345 371 346 /* 372 347 * This routine is used by the interrupt handler to schedule ··· 365 358 * (also known as the "bottom half"). This can be called any 366 359 * number of times for any channel without harm. 367 360 */ 368 - static inline void 369 - cy_sched_event(struct cyclades_port *info, int event) 361 + static inline void cy_sched_event(struct cyclades_port *info, int event) 370 362 { 371 - info->event |= 1 << event; /* remember what kind of event and who */ 372 - schedule_work(&info->tqueue); 373 - } /* cy_sched_event */ 374 - 363 + info->event |= 1 << event; /* remember what kind of event and who */ 364 + schedule_work(&info->tqueue); 365 + } /* cy_sched_event */ 375 366 376 367 /* The real interrupt service routines are called 377 368 whenever the card wants its hand held--chars 378 369 received, out buffer empty, modem change, etc. 379 370 */ 380 - static irqreturn_t 381 - cd2401_rxerr_interrupt(int irq, void *dev_id) 371 + static irqreturn_t cd2401_rxerr_interrupt(int irq, void *dev_id) 382 372 { 383 - struct tty_struct *tty; 384 - struct cyclades_port *info; 385 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 386 - unsigned char err, rfoc; 387 - int channel; 388 - char data; 373 + struct tty_struct *tty; 374 + struct cyclades_port *info; 375 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 376 + unsigned char err, rfoc; 377 + int channel; 378 + char data; 389 379 390 - /* determine the channel and change to that context */ 391 - channel = (u_short ) (base_addr[CyLICR] >> 2); 392 - info = &cy_port[channel]; 393 - info->last_active = jiffies; 380 + /* determine the channel and change to that context */ 381 + channel = (u_short) (base_addr[CyLICR] >> 2); 382 + info = &cy_port[channel]; 383 + info->last_active = jiffies; 394 384 395 - if ((err = base_addr[CyRISR]) & CyTIMEOUT) { 396 - /* This is a receive timeout interrupt, ignore it */ 397 - base_addr[CyREOIR] = CyNOTRANS; 398 - return IRQ_HANDLED; 399 - } 385 + if ((err = base_addr[CyRISR]) & CyTIMEOUT) { 386 + /* This is a receive timeout interrupt, ignore it */ 387 + base_addr[CyREOIR] = CyNOTRANS; 388 + return IRQ_HANDLED; 389 + } 400 390 401 - /* Read a byte of data if there is any - assume the error 402 - * is associated with this character */ 391 + /* Read a byte of data if there is any - assume the error 392 + * is associated with this character */ 403 393 404 - if ((rfoc = base_addr[CyRFOC]) != 0) 405 - data = base_addr[CyRDR]; 406 - else 407 - data = 0; 394 + if ((rfoc = base_addr[CyRFOC]) != 0) 395 + data = base_addr[CyRDR]; 396 + else 397 + data = 0; 408 398 409 - /* if there is nowhere to put the data, discard it */ 410 - if(info->tty == 0) { 399 + /* if there is nowhere to put the data, discard it */ 400 + if (info->tty == 0) { 401 + base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; 402 + return IRQ_HANDLED; 403 + } else { /* there is an open port for this data */ 404 + tty = info->tty; 405 + if (err & info->ignore_status_mask) { 406 + base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; 407 + return IRQ_HANDLED; 408 + } 409 + if (tty_buffer_request_room(tty, 1) != 0) { 410 + if (err & info->read_status_mask) { 411 + if (err & CyBREAK) { 412 + tty_insert_flip_char(tty, data, 413 + TTY_BREAK); 414 + if (info->flags & ASYNC_SAK) { 415 + do_SAK(tty); 416 + } 417 + } else if (err & CyFRAME) { 418 + tty_insert_flip_char(tty, data, 419 + TTY_FRAME); 420 + } else if (err & CyPARITY) { 421 + tty_insert_flip_char(tty, data, 422 + TTY_PARITY); 423 + } else if (err & CyOVERRUN) { 424 + tty_insert_flip_char(tty, 0, 425 + TTY_OVERRUN); 426 + /* 427 + If the flip buffer itself is 428 + overflowing, we still loose 429 + the next incoming character. 430 + */ 431 + if (tty_buffer_request_room(tty, 1) != 432 + 0) { 433 + tty_insert_flip_char(tty, data, 434 + TTY_FRAME); 435 + } 436 + /* These two conditions may imply */ 437 + /* a normal read should be done. */ 438 + /* else if(data & CyTIMEOUT) */ 439 + /* else if(data & CySPECHAR) */ 440 + } else { 441 + tty_insert_flip_char(tty, 0, 442 + TTY_NORMAL); 443 + } 444 + } else { 445 + tty_insert_flip_char(tty, data, TTY_NORMAL); 446 + } 447 + } else { 448 + /* there was a software buffer overrun 449 + and nothing could be done about it!!! */ 450 + } 451 + } 452 + tty_schedule_flip(tty); 453 + /* end of service */ 411 454 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; 412 455 return IRQ_HANDLED; 413 - } 414 - else { /* there is an open port for this data */ 415 - tty = info->tty; 416 - if(err & info->ignore_status_mask){ 417 - base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; 418 - return IRQ_HANDLED; 419 - } 420 - if (tty_buffer_request_room(tty, 1) != 0){ 421 - if (err & info->read_status_mask){ 422 - if(err & CyBREAK){ 423 - tty_insert_flip_char(tty, data, TTY_BREAK); 424 - if (info->flags & ASYNC_SAK){ 425 - do_SAK(tty); 426 - } 427 - }else if(err & CyFRAME){ 428 - tty_insert_flip_char(tty, data, TTY_FRAME); 429 - }else if(err & CyPARITY){ 430 - tty_insert_flip_char(tty, data, TTY_PARITY); 431 - }else if(err & CyOVERRUN){ 432 - tty_insert_flip_char(tty, 0, TTY_OVERRUN); 433 - /* 434 - If the flip buffer itself is 435 - overflowing, we still loose 436 - the next incoming character. 437 - */ 438 - if (tty_buffer_request_room(tty, 1) != 0){ 439 - tty_insert_flip_char(tty, data, TTY_FRAME); 440 - } 441 - /* These two conditions may imply */ 442 - /* a normal read should be done. */ 443 - /* else if(data & CyTIMEOUT) */ 444 - /* else if(data & CySPECHAR) */ 445 - }else{ 446 - tty_insert_flip_char(tty, 0, TTY_NORMAL); 447 - } 448 - }else{ 449 - tty_insert_flip_char(tty, data, TTY_NORMAL); 450 - } 451 - }else{ 452 - /* there was a software buffer overrun 453 - and nothing could be done about it!!! */ 454 - } 455 - } 456 - tty_schedule_flip(tty); 457 - /* end of service */ 458 - base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; 459 - return IRQ_HANDLED; 460 - } /* cy_rxerr_interrupt */ 456 + } /* cy_rxerr_interrupt */ 461 457 462 - static irqreturn_t 463 - cd2401_modem_interrupt(int irq, void *dev_id) 458 + static irqreturn_t cd2401_modem_interrupt(int irq, void *dev_id) 464 459 { 465 - struct cyclades_port *info; 466 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 467 - int channel; 468 - int mdm_change; 469 - int mdm_status; 460 + struct cyclades_port *info; 461 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 462 + int channel; 463 + int mdm_change; 464 + int mdm_status; 470 465 466 + /* determine the channel and change to that context */ 467 + channel = (u_short) (base_addr[CyLICR] >> 2); 468 + info = &cy_port[channel]; 469 + info->last_active = jiffies; 471 470 472 - /* determine the channel and change to that context */ 473 - channel = (u_short ) (base_addr[CyLICR] >> 2); 474 - info = &cy_port[channel]; 475 - info->last_active = jiffies; 471 + mdm_change = base_addr[CyMISR]; 472 + mdm_status = base_addr[CyMSVR1]; 476 473 477 - mdm_change = base_addr[CyMISR]; 478 - mdm_status = base_addr[CyMSVR1]; 479 - 480 - if(info->tty == 0){ /* nowhere to put the data, ignore it */ 481 - ; 482 - }else{ 483 - if((mdm_change & CyDCD) 484 - && (info->flags & ASYNC_CHECK_CD)){ 485 - if(mdm_status & CyDCD){ 474 + if (info->tty == 0) { /* nowhere to put the data, ignore it */ 475 + ; 476 + } else { 477 + if ((mdm_change & CyDCD) 478 + && (info->flags & ASYNC_CHECK_CD)) { 479 + if (mdm_status & CyDCD) { 486 480 /* CP('!'); */ 487 - cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP); 488 - } else { 481 + cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP); 482 + } else { 489 483 /* CP('@'); */ 490 - cy_sched_event(info, Cy_EVENT_HANGUP); 491 - } 492 - } 493 - if((mdm_change & CyCTS) 494 - && (info->flags & ASYNC_CTS_FLOW)){ 495 - if(info->tty->stopped){ 496 - if(mdm_status & CyCTS){ 497 - /* !!! cy_start isn't used because... */ 498 - info->tty->stopped = 0; 499 - base_addr[CyIER] |= CyTxMpty; 500 - cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 484 + cy_sched_event(info, Cy_EVENT_HANGUP); 485 + } 501 486 } 502 - }else{ 503 - if(!(mdm_status & CyCTS)){ 504 - /* !!! cy_stop isn't used because... */ 505 - info->tty->stopped = 1; 506 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 487 + if ((mdm_change & CyCTS) 488 + && (info->flags & ASYNC_CTS_FLOW)) { 489 + if (info->tty->stopped) { 490 + if (mdm_status & CyCTS) { 491 + /* !!! cy_start isn't used because... */ 492 + info->tty->stopped = 0; 493 + base_addr[CyIER] |= CyTxMpty; 494 + cy_sched_event(info, 495 + Cy_EVENT_WRITE_WAKEUP); 496 + } 497 + } else { 498 + if (!(mdm_status & CyCTS)) { 499 + /* !!! cy_stop isn't used because... */ 500 + info->tty->stopped = 1; 501 + base_addr[CyIER] &= 502 + ~(CyTxMpty | CyTxRdy); 503 + } 504 + } 507 505 } 508 - } 506 + if (mdm_status & CyDSR) { 507 + } 509 508 } 510 - if(mdm_status & CyDSR){ 511 - } 512 - } 513 - base_addr[CyMEOIR] = 0; 514 - return IRQ_HANDLED; 515 - } /* cy_modem_interrupt */ 509 + base_addr[CyMEOIR] = 0; 510 + return IRQ_HANDLED; 511 + } /* cy_modem_interrupt */ 516 512 517 - static irqreturn_t 518 - cd2401_tx_interrupt(int irq, void *dev_id) 513 + static irqreturn_t cd2401_tx_interrupt(int irq, void *dev_id) 519 514 { 520 - struct cyclades_port *info; 521 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 522 - int channel; 523 - int char_count, saved_cnt; 524 - int outch; 515 + struct cyclades_port *info; 516 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 517 + int channel; 518 + int char_count, saved_cnt; 519 + int outch; 525 520 526 - /* determine the channel and change to that context */ 527 - channel = (u_short ) (base_addr[CyLICR] >> 2); 521 + /* determine the channel and change to that context */ 522 + channel = (u_short) (base_addr[CyLICR] >> 2); 528 523 529 524 #ifdef CONFIG_REMOTE_DEBUG 530 - if (channel == DEBUG_PORT) { 531 - panic ("TxInt on debug port!!!"); 532 - } 525 + if (channel == DEBUG_PORT) { 526 + panic("TxInt on debug port!!!"); 527 + } 533 528 #endif 534 529 535 - info = &cy_port[channel]; 530 + info = &cy_port[channel]; 536 531 537 - /* validate the port number (as configured and open) */ 538 - if( (channel < 0) || (NR_PORTS <= channel) ){ 539 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 540 - base_addr[CyTEOIR] = CyNOTRANS; 541 - return IRQ_HANDLED; 542 - } 543 - info->last_active = jiffies; 544 - if(info->tty == 0){ 545 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 546 - if (info->xmit_cnt < WAKEUP_CHARS) { 547 - cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 548 - } 549 - base_addr[CyTEOIR] = CyNOTRANS; 550 - return IRQ_HANDLED; 551 - } 552 - 553 - /* load the on-chip space available for outbound data */ 554 - saved_cnt = char_count = base_addr[CyTFTC]; 555 - 556 - if(info->x_char) { /* send special char */ 557 - outch = info->x_char; 558 - base_addr[CyTDR] = outch; 559 - char_count--; 560 - info->x_char = 0; 561 - } 562 - 563 - if (info->x_break){ 564 - /* The Cirrus chip requires the "Embedded Transmit 565 - Commands" of start break, delay, and end break 566 - sequences to be sent. The duration of the 567 - break is given in TICs, which runs at HZ 568 - (typically 100) and the PPR runs at 200 Hz, 569 - so the delay is duration * 200/HZ, and thus a 570 - break can run from 1/100 sec to about 5/4 sec. 571 - Need to check these values - RGH 141095. 572 - */ 573 - base_addr[CyTDR] = 0; /* start break */ 574 - base_addr[CyTDR] = 0x81; 575 - base_addr[CyTDR] = 0; /* delay a bit */ 576 - base_addr[CyTDR] = 0x82; 577 - base_addr[CyTDR] = info->x_break*200/HZ; 578 - base_addr[CyTDR] = 0; /* terminate break */ 579 - base_addr[CyTDR] = 0x83; 580 - char_count -= 7; 581 - info->x_break = 0; 582 - } 583 - 584 - while (char_count > 0){ 585 - if (!info->xmit_cnt){ 586 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 587 - break; 532 + /* validate the port number (as configured and open) */ 533 + if ((channel < 0) || (NR_PORTS <= channel)) { 534 + base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy); 535 + base_addr[CyTEOIR] = CyNOTRANS; 536 + return IRQ_HANDLED; 588 537 } 589 - if (info->xmit_buf == 0){ 590 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 591 - break; 538 + info->last_active = jiffies; 539 + if (info->tty == 0) { 540 + base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy); 541 + if (info->xmit_cnt < WAKEUP_CHARS) { 542 + cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 543 + } 544 + base_addr[CyTEOIR] = CyNOTRANS; 545 + return IRQ_HANDLED; 592 546 } 593 - if (info->tty->stopped || info->tty->hw_stopped){ 594 - base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 595 - break; 596 - } 597 - /* Because the Embedded Transmit Commands have been 598 - enabled, we must check to see if the escape 599 - character, NULL, is being sent. If it is, we 600 - must ensure that there is room for it to be 601 - doubled in the output stream. Therefore we 602 - no longer advance the pointer when the character 603 - is fetched, but rather wait until after the check 604 - for a NULL output character. (This is necessary 605 - because there may not be room for the two chars 606 - needed to send a NULL. 607 - */ 608 - outch = info->xmit_buf[info->xmit_tail]; 609 - if( outch ){ 610 - info->xmit_cnt--; 611 - info->xmit_tail = (info->xmit_tail + 1) 612 - & (PAGE_SIZE - 1); 613 - base_addr[CyTDR] = outch; 614 - char_count--; 615 - }else{ 616 - if(char_count > 1){ 617 - info->xmit_cnt--; 618 - info->xmit_tail = (info->xmit_tail + 1) 619 - & (PAGE_SIZE - 1); 547 + 548 + /* load the on-chip space available for outbound data */ 549 + saved_cnt = char_count = base_addr[CyTFTC]; 550 + 551 + if (info->x_char) { /* send special char */ 552 + outch = info->x_char; 620 553 base_addr[CyTDR] = outch; 621 - base_addr[CyTDR] = 0; 622 554 char_count--; 623 - char_count--; 624 - }else{ 625 - break; 626 - } 555 + info->x_char = 0; 627 556 } 628 - } 629 557 630 - if (info->xmit_cnt < WAKEUP_CHARS) { 631 - cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 632 - } 633 - base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS; 634 - return IRQ_HANDLED; 635 - } /* cy_tx_interrupt */ 558 + if (info->x_break) { 559 + /* The Cirrus chip requires the "Embedded Transmit 560 + Commands" of start break, delay, and end break 561 + sequences to be sent. The duration of the 562 + break is given in TICs, which runs at HZ 563 + (typically 100) and the PPR runs at 200 Hz, 564 + so the delay is duration * 200/HZ, and thus a 565 + break can run from 1/100 sec to about 5/4 sec. 566 + Need to check these values - RGH 141095. 567 + */ 568 + base_addr[CyTDR] = 0; /* start break */ 569 + base_addr[CyTDR] = 0x81; 570 + base_addr[CyTDR] = 0; /* delay a bit */ 571 + base_addr[CyTDR] = 0x82; 572 + base_addr[CyTDR] = info->x_break * 200 / HZ; 573 + base_addr[CyTDR] = 0; /* terminate break */ 574 + base_addr[CyTDR] = 0x83; 575 + char_count -= 7; 576 + info->x_break = 0; 577 + } 636 578 637 - static irqreturn_t 638 - cd2401_rx_interrupt(int irq, void *dev_id) 579 + while (char_count > 0) { 580 + if (!info->xmit_cnt) { 581 + base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy); 582 + break; 583 + } 584 + if (info->xmit_buf == 0) { 585 + base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy); 586 + break; 587 + } 588 + if (info->tty->stopped || info->tty->hw_stopped) { 589 + base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy); 590 + break; 591 + } 592 + /* Because the Embedded Transmit Commands have been 593 + enabled, we must check to see if the escape 594 + character, NULL, is being sent. If it is, we 595 + must ensure that there is room for it to be 596 + doubled in the output stream. Therefore we 597 + no longer advance the pointer when the character 598 + is fetched, but rather wait until after the check 599 + for a NULL output character. (This is necessary 600 + because there may not be room for the two chars 601 + needed to send a NULL. 602 + */ 603 + outch = info->xmit_buf[info->xmit_tail]; 604 + if (outch) { 605 + info->xmit_cnt--; 606 + info->xmit_tail = (info->xmit_tail + 1) 607 + & (PAGE_SIZE - 1); 608 + base_addr[CyTDR] = outch; 609 + char_count--; 610 + } else { 611 + if (char_count > 1) { 612 + info->xmit_cnt--; 613 + info->xmit_tail = (info->xmit_tail + 1) 614 + & (PAGE_SIZE - 1); 615 + base_addr[CyTDR] = outch; 616 + base_addr[CyTDR] = 0; 617 + char_count--; 618 + char_count--; 619 + } else { 620 + break; 621 + } 622 + } 623 + } 624 + 625 + if (info->xmit_cnt < WAKEUP_CHARS) { 626 + cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 627 + } 628 + base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS; 629 + return IRQ_HANDLED; 630 + } /* cy_tx_interrupt */ 631 + 632 + static irqreturn_t cd2401_rx_interrupt(int irq, void *dev_id) 639 633 { 640 - struct tty_struct *tty; 641 - struct cyclades_port *info; 642 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 643 - int channel; 644 - char data; 645 - int char_count; 646 - int save_cnt; 647 - int len; 634 + struct tty_struct *tty; 635 + struct cyclades_port *info; 636 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 637 + int channel; 638 + char data; 639 + int char_count; 640 + int save_cnt; 641 + int len; 648 642 649 - /* determine the channel and change to that context */ 650 - channel = (u_short ) (base_addr[CyLICR] >> 2); 651 - info = &cy_port[channel]; 652 - info->last_active = jiffies; 653 - save_cnt = char_count = base_addr[CyRFOC]; 643 + /* determine the channel and change to that context */ 644 + channel = (u_short) (base_addr[CyLICR] >> 2); 645 + info = &cy_port[channel]; 646 + info->last_active = jiffies; 647 + save_cnt = char_count = base_addr[CyRFOC]; 654 648 655 649 #ifdef CONFIG_REMOTE_DEBUG 656 - if (channel == DEBUG_PORT) { 657 - while (char_count--) { 658 - data = base_addr[CyRDR]; 659 - queueDebugChar(data); 660 - } 661 - } 662 - else 650 + if (channel == DEBUG_PORT) { 651 + while (char_count--) { 652 + data = base_addr[CyRDR]; 653 + queueDebugChar(data); 654 + } 655 + } else 663 656 #endif 664 - /* if there is nowhere to put the data, discard it */ 665 - if(info->tty == 0){ 666 - while(char_count--){ 667 - data = base_addr[CyRDR]; 668 - } 669 - }else{ /* there is an open port for this data */ 670 - tty = info->tty; 671 - /* load # characters available from the chip */ 657 + /* if there is nowhere to put the data, discard it */ 658 + if (info->tty == 0) { 659 + while (char_count--) { 660 + data = base_addr[CyRDR]; 661 + } 662 + } else { /* there is an open port for this data */ 663 + tty = info->tty; 664 + /* load # characters available from the chip */ 672 665 673 666 #ifdef CYCLOM_ENABLE_MONITORING 674 - ++info->mon.int_count; 675 - info->mon.char_count += char_count; 676 - if (char_count > info->mon.char_max) 677 - info->mon.char_max = char_count; 678 - info->mon.char_last = char_count; 667 + ++info->mon.int_count; 668 + info->mon.char_count += char_count; 669 + if (char_count > info->mon.char_max) 670 + info->mon.char_max = char_count; 671 + info->mon.char_last = char_count; 679 672 #endif 680 - len = tty_buffer_request_room(tty, char_count); 681 - while(len--){ 682 - data = base_addr[CyRDR]; 683 - tty_insert_flip_char(tty, data, TTY_NORMAL); 673 + len = tty_buffer_request_room(tty, char_count); 674 + while (len--) { 675 + data = base_addr[CyRDR]; 676 + tty_insert_flip_char(tty, data, TTY_NORMAL); 684 677 #ifdef CYCLOM_16Y_HACK 685 - udelay(10L); 678 + udelay(10L); 686 679 #endif 687 - } 688 - tty_schedule_flip(tty); 689 - } 690 - /* end of service */ 691 - base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS; 692 - return IRQ_HANDLED; 693 - } /* cy_rx_interrupt */ 680 + } 681 + tty_schedule_flip(tty); 682 + } 683 + /* end of service */ 684 + base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS; 685 + return IRQ_HANDLED; 686 + } /* cy_rx_interrupt */ 694 687 695 688 /* 696 689 * This routine is used to handle the "bottom half" processing for the ··· 712 705 * structure) to the bottom half of the driver. Previous kernels 713 706 * had to poll every port to see if that port needed servicing. 714 707 */ 715 - static void 716 - do_softint(struct work_struct *ugly_api) 708 + static void do_softint(struct work_struct *ugly_api) 717 709 { 718 - struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue); 719 - struct tty_struct *tty; 710 + struct cyclades_port *info = 711 + container_of(ugly_api, struct cyclades_port, tqueue); 712 + struct tty_struct *tty; 720 713 721 - tty = info->tty; 722 - if (!tty) 723 - return; 714 + tty = info->tty; 715 + if (!tty) 716 + return; 724 717 725 - if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) { 726 - tty_hangup(info->tty); 727 - wake_up_interruptible(&info->open_wait); 728 - info->flags &= ~ASYNC_NORMAL_ACTIVE; 729 - } 730 - if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) { 731 - wake_up_interruptible(&info->open_wait); 732 - } 733 - if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) { 734 - tty_wakeup(tty); 735 - } 736 - } /* do_softint */ 737 - 718 + if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) { 719 + tty_hangup(info->tty); 720 + wake_up_interruptible(&info->open_wait); 721 + info->flags &= ~ASYNC_NORMAL_ACTIVE; 722 + } 723 + if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) { 724 + wake_up_interruptible(&info->open_wait); 725 + } 726 + if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) { 727 + tty_wakeup(tty); 728 + } 729 + } /* do_softint */ 738 730 739 731 /* This is called whenever a port becomes active; 740 732 interrupts are enabled and DTR & RTS are turned on. 741 733 */ 742 - static int 743 - startup(struct cyclades_port * info) 734 + static int startup(struct cyclades_port *info) 744 735 { 745 - unsigned long flags; 746 - volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 747 - int channel; 736 + unsigned long flags; 737 + volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 738 + int channel; 748 739 749 - if (info->flags & ASYNC_INITIALIZED){ 750 - return 0; 751 - } 752 - 753 - if (!info->type){ 754 - if (info->tty){ 755 - set_bit(TTY_IO_ERROR, &info->tty->flags); 740 + if (info->flags & ASYNC_INITIALIZED) { 741 + return 0; 756 742 } 757 - return 0; 758 - } 759 - if (!info->xmit_buf){ 760 - info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL); 761 - if (!info->xmit_buf){ 762 - return -ENOMEM; 743 + 744 + if (!info->type) { 745 + if (info->tty) { 746 + set_bit(TTY_IO_ERROR, &info->tty->flags); 747 + } 748 + return 0; 763 749 } 764 - } 750 + if (!info->xmit_buf) { 751 + info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); 752 + if (!info->xmit_buf) { 753 + return -ENOMEM; 754 + } 755 + } 765 756 766 - config_setup(info); 757 + config_setup(info); 767 758 768 - channel = info->line; 759 + channel = info->line; 769 760 770 761 #ifdef SERIAL_DEBUG_OPEN 771 - printk("startup channel %d\n", channel); 762 + printk("startup channel %d\n", channel); 772 763 #endif 773 764 774 - local_irq_save(flags); 775 - base_addr[CyCAR] = (u_char)channel; 776 - write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR); 765 + local_irq_save(flags); 766 + base_addr[CyCAR] = (u_char) channel; 767 + write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR); 777 768 778 - base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */ 769 + base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */ 779 770 base_addr[CyMSVR1] = CyRTS; 780 771 /* CP('S');CP('1'); */ 781 772 base_addr[CyMSVR2] = CyDTR; 782 773 783 774 #ifdef SERIAL_DEBUG_DTR 784 - printk("cyc: %d: raising DTR\n", __LINE__); 785 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 775 + printk("cyc: %d: raising DTR\n", __LINE__); 776 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 777 + base_addr[CyMSVR2]); 786 778 #endif 787 779 788 780 base_addr[CyIER] |= CyRxData; 789 781 info->flags |= ASYNC_INITIALIZED; 790 782 791 - if (info->tty){ 792 - clear_bit(TTY_IO_ERROR, &info->tty->flags); 783 + if (info->tty) { 784 + clear_bit(TTY_IO_ERROR, &info->tty->flags); 793 785 } 794 786 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 795 787 796 - local_irq_restore(flags); 788 + local_irq_restore(flags); 797 789 798 790 #ifdef SERIAL_DEBUG_OPEN 799 - printk(" done\n"); 791 + printk(" done\n"); 800 792 #endif 801 - return 0; 802 - } /* startup */ 793 + return 0; 794 + } /* startup */ 803 795 804 - void 805 - start_xmit( struct cyclades_port *info ) 796 + void start_xmit(struct cyclades_port *info) 806 797 { 807 - unsigned long flags; 808 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 809 - int channel; 798 + unsigned long flags; 799 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 800 + int channel; 810 801 811 - channel = info->line; 812 - local_irq_save(flags); 802 + channel = info->line; 803 + local_irq_save(flags); 813 804 base_addr[CyCAR] = channel; 814 805 base_addr[CyIER] |= CyTxMpty; 815 - local_irq_restore(flags); 816 - } /* start_xmit */ 806 + local_irq_restore(flags); 807 + } /* start_xmit */ 817 808 818 809 /* 819 810 * This routine shuts down a serial port; interrupts are disabled, 820 811 * and DTR is dropped if the hangup on close termio flag is on. 821 812 */ 822 - static void 823 - shutdown(struct cyclades_port * info) 813 + static void shutdown(struct cyclades_port *info) 824 814 { 825 - unsigned long flags; 826 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 827 - int channel; 815 + unsigned long flags; 816 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 817 + int channel; 828 818 829 - if (!(info->flags & ASYNC_INITIALIZED)){ 819 + if (!(info->flags & ASYNC_INITIALIZED)) { 830 820 /* CP('$'); */ 831 - return; 832 - } 833 - 834 - channel = info->line; 835 - 836 - #ifdef SERIAL_DEBUG_OPEN 837 - printk("shutdown channel %d\n", channel); 838 - #endif 839 - 840 - /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE 841 - SENT BEFORE DROPPING THE LINE !!! (Perhaps 842 - set some flag that is read when XMTY happens.) 843 - Other choices are to delay some fixed interval 844 - or schedule some later processing. 845 - */ 846 - local_irq_save(flags); 847 - if (info->xmit_buf){ 848 - free_page((unsigned long) info->xmit_buf); 849 - info->xmit_buf = NULL; 821 + return; 850 822 } 851 823 852 - base_addr[CyCAR] = (u_char)channel; 853 - if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { 854 - base_addr[CyMSVR1] = 0; 855 - /* CP('C');CP('1'); */ 856 - base_addr[CyMSVR2] = 0; 857 - #ifdef SERIAL_DEBUG_DTR 858 - printk("cyc: %d: dropping DTR\n", __LINE__); 859 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 860 - #endif 861 - } 862 - write_cy_cmd(base_addr,CyDIS_RCVR); 863 - /* it may be appropriate to clear _XMIT at 864 - some later date (after testing)!!! */ 824 + channel = info->line; 865 825 866 - if (info->tty){ 867 - set_bit(TTY_IO_ERROR, &info->tty->flags); 826 + #ifdef SERIAL_DEBUG_OPEN 827 + printk("shutdown channel %d\n", channel); 828 + #endif 829 + 830 + /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE 831 + SENT BEFORE DROPPING THE LINE !!! (Perhaps 832 + set some flag that is read when XMTY happens.) 833 + Other choices are to delay some fixed interval 834 + or schedule some later processing. 835 + */ 836 + local_irq_save(flags); 837 + if (info->xmit_buf) { 838 + free_page((unsigned long)info->xmit_buf); 839 + info->xmit_buf = NULL; 840 + } 841 + 842 + base_addr[CyCAR] = (u_char) channel; 843 + if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { 844 + base_addr[CyMSVR1] = 0; 845 + /* CP('C');CP('1'); */ 846 + base_addr[CyMSVR2] = 0; 847 + #ifdef SERIAL_DEBUG_DTR 848 + printk("cyc: %d: dropping DTR\n", __LINE__); 849 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 850 + base_addr[CyMSVR2]); 851 + #endif 852 + } 853 + write_cy_cmd(base_addr, CyDIS_RCVR); 854 + /* it may be appropriate to clear _XMIT at 855 + some later date (after testing)!!! */ 856 + 857 + if (info->tty) { 858 + set_bit(TTY_IO_ERROR, &info->tty->flags); 868 859 } 869 860 info->flags &= ~ASYNC_INITIALIZED; 870 - local_irq_restore(flags); 861 + local_irq_restore(flags); 871 862 872 863 #ifdef SERIAL_DEBUG_OPEN 873 - printk(" done\n"); 864 + printk(" done\n"); 874 865 #endif 875 - return; 876 - } /* shutdown */ 866 + } /* shutdown */ 877 867 878 868 /* 879 869 * This routine finds or computes the various line characteristics. 880 870 */ 881 - static void 882 - config_setup(struct cyclades_port * info) 871 + static void config_setup(struct cyclades_port *info) 883 872 { 884 - unsigned long flags; 885 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 886 - int channel; 887 - unsigned cflag; 888 - int i; 889 - unsigned char ti, need_init_chan = 0; 873 + unsigned long flags; 874 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 875 + int channel; 876 + unsigned cflag; 877 + int i; 878 + unsigned char ti, need_init_chan = 0; 890 879 891 - if (!info->tty || !info->tty->termios){ 892 - return; 893 - } 894 - if (info->line == -1){ 895 - return; 896 - } 897 - cflag = info->tty->termios->c_cflag; 880 + if (!info->tty || !info->tty->termios) { 881 + return; 882 + } 883 + if (info->line == -1) { 884 + return; 885 + } 886 + cflag = info->tty->termios->c_cflag; 898 887 899 - /* baud rate */ 900 - i = cflag & CBAUD; 888 + /* baud rate */ 889 + i = cflag & CBAUD; 901 890 #ifdef CBAUDEX 902 891 /* Starting with kernel 1.1.65, there is direct support for 903 892 higher baud rates. The following code supports those ··· 903 900 is still the possibility of supporting 75 kbit/sec with 904 901 the Cyclades board.) 905 902 */ 906 - if (i & CBAUDEX) { 907 - if (i == B57600) 908 - i = 16; 909 - else if(i == B115200) 910 - i = 18; 903 + if (i & CBAUDEX) { 904 + if (i == B57600) 905 + i = 16; 906 + else if (i == B115200) 907 + i = 18; 911 908 #ifdef B78600 912 - else if(i == B78600) 913 - i = 17; 909 + else if (i == B78600) 910 + i = 17; 914 911 #endif 915 - else 916 - info->tty->termios->c_cflag &= ~CBAUDEX; 917 - } 918 - #endif 919 - if (i == 15) { 920 - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 921 - i += 1; 922 - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 923 - i += 3; 924 - } 925 - /* Don't ever change the speed of the console port. It will 926 - * run at the speed specified in bootinfo, or at 19.2K */ 927 - /* Actually, it should run at whatever speed 166Bug was using */ 928 - /* Note info->timeout isn't used at present */ 929 - if (info != serial_console_info) { 930 - info->tbpr = baud_bpr[i]; /* Tx BPR */ 931 - info->tco = baud_co[i]; /* Tx CO */ 932 - info->rbpr = baud_bpr[i]; /* Rx BPR */ 933 - info->rco = baud_co[i] >> 5; /* Rx CO */ 934 - if (baud_table[i] == 134) { 935 - info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; 936 - /* get it right for 134.5 baud */ 937 - } else if (baud_table[i]) { 938 - info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2; 939 - /* this needs to be propagated into the card info */ 940 - } else { 941 - info->timeout = 0; 912 + else 913 + info->tty->termios->c_cflag &= ~CBAUDEX; 942 914 } 943 - } 944 - /* By tradition (is it a standard?) a baud rate of zero 945 - implies the line should be/has been closed. A bit 946 - later in this routine such a test is performed. */ 947 - 948 - /* byte size and parity */ 949 - info->cor7 = 0; 950 - info->cor6 = 0; 951 - info->cor5 = 0; 952 - info->cor4 = (info->default_threshold 953 - ? info->default_threshold 954 - : baud_cor4[i]); /* receive threshold */ 955 - /* Following two lines added 101295, RGH. */ 956 - /* It is obviously wrong to access CyCORx, and not info->corx here, 957 - * try and remember to fix it later! */ 958 - channel = info->line; 959 - base_addr[CyCAR] = (u_char)channel; 960 - if (C_CLOCAL(info->tty)) { 961 - if (base_addr[CyIER] & CyMdmCh) 962 - base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */ 963 - /* ignore 1->0 modem transitions */ 964 - if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) 965 - base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD); 966 - /* ignore 0->1 modem transitions */ 967 - if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) 968 - base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD); 969 - } else { 970 - if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh) 971 - base_addr[CyIER] |= CyMdmCh; /* with modem intr */ 972 - /* act on 1->0 modem transitions */ 973 - if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD)) 974 - base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD; 975 - /* act on 0->1 modem transitions */ 976 - if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD)) 977 - base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD; 978 - } 979 - info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP; 980 - info->cor2 = CyETC; 981 - switch(cflag & CSIZE){ 982 - case CS5: 983 - info->cor1 = Cy_5_BITS; 984 - break; 985 - case CS6: 986 - info->cor1 = Cy_6_BITS; 987 - break; 988 - case CS7: 989 - info->cor1 = Cy_7_BITS; 990 - break; 991 - case CS8: 992 - info->cor1 = Cy_8_BITS; 993 - break; 994 - } 995 - if (cflag & PARENB){ 996 - if (cflag & PARODD){ 997 - info->cor1 |= CyPARITY_O; 998 - }else{ 999 - info->cor1 |= CyPARITY_E; 1000 - } 1001 - }else{ 1002 - info->cor1 |= CyPARITY_NONE; 1003 - } 1004 - 1005 - /* CTS flow control flag */ 1006 - #if 0 1007 - /* Don't complcate matters for now! RGH 141095 */ 1008 - if (cflag & CRTSCTS){ 1009 - info->flags |= ASYNC_CTS_FLOW; 1010 - info->cor2 |= CyCtsAE; 1011 - }else{ 1012 - info->flags &= ~ASYNC_CTS_FLOW; 1013 - info->cor2 &= ~CyCtsAE; 1014 - } 1015 915 #endif 1016 - if (cflag & CLOCAL) 1017 - info->flags &= ~ASYNC_CHECK_CD; 1018 - else 1019 - info->flags |= ASYNC_CHECK_CD; 916 + if (i == 15) { 917 + if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 918 + i += 1; 919 + if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 920 + i += 3; 921 + } 922 + /* Don't ever change the speed of the console port. It will 923 + * run at the speed specified in bootinfo, or at 19.2K */ 924 + /* Actually, it should run at whatever speed 166Bug was using */ 925 + /* Note info->timeout isn't used at present */ 926 + if (info != serial_console_info) { 927 + info->tbpr = baud_bpr[i]; /* Tx BPR */ 928 + info->tco = baud_co[i]; /* Tx CO */ 929 + info->rbpr = baud_bpr[i]; /* Rx BPR */ 930 + info->rco = baud_co[i] >> 5; /* Rx CO */ 931 + if (baud_table[i] == 134) { 932 + info->timeout = 933 + (info->xmit_fifo_size * HZ * 30 / 269) + 2; 934 + /* get it right for 134.5 baud */ 935 + } else if (baud_table[i]) { 936 + info->timeout = 937 + (info->xmit_fifo_size * HZ * 15 / baud_table[i]) + 938 + 2; 939 + /* this needs to be propagated into the card info */ 940 + } else { 941 + info->timeout = 0; 942 + } 943 + } 944 + /* By tradition (is it a standard?) a baud rate of zero 945 + implies the line should be/has been closed. A bit 946 + later in this routine such a test is performed. */ 947 + 948 + /* byte size and parity */ 949 + info->cor7 = 0; 950 + info->cor6 = 0; 951 + info->cor5 = 0; 952 + info->cor4 = (info->default_threshold ? info->default_threshold : baud_cor4[i]); /* receive threshold */ 953 + /* Following two lines added 101295, RGH. */ 954 + /* It is obviously wrong to access CyCORx, and not info->corx here, 955 + * try and remember to fix it later! */ 956 + channel = info->line; 957 + base_addr[CyCAR] = (u_char) channel; 958 + if (C_CLOCAL(info->tty)) { 959 + if (base_addr[CyIER] & CyMdmCh) 960 + base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */ 961 + /* ignore 1->0 modem transitions */ 962 + if (base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD)) 963 + base_addr[CyCOR4] &= ~(CyDSR | CyCTS | CyDCD); 964 + /* ignore 0->1 modem transitions */ 965 + if (base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD)) 966 + base_addr[CyCOR5] &= ~(CyDSR | CyCTS | CyDCD); 967 + } else { 968 + if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh) 969 + base_addr[CyIER] |= CyMdmCh; /* with modem intr */ 970 + /* act on 1->0 modem transitions */ 971 + if ((base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD)) != 972 + (CyDSR | CyCTS | CyDCD)) 973 + base_addr[CyCOR4] |= CyDSR | CyCTS | CyDCD; 974 + /* act on 0->1 modem transitions */ 975 + if ((base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD)) != 976 + (CyDSR | CyCTS | CyDCD)) 977 + base_addr[CyCOR5] |= CyDSR | CyCTS | CyDCD; 978 + } 979 + info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP; 980 + info->cor2 = CyETC; 981 + switch (cflag & CSIZE) { 982 + case CS5: 983 + info->cor1 = Cy_5_BITS; 984 + break; 985 + case CS6: 986 + info->cor1 = Cy_6_BITS; 987 + break; 988 + case CS7: 989 + info->cor1 = Cy_7_BITS; 990 + break; 991 + case CS8: 992 + info->cor1 = Cy_8_BITS; 993 + break; 994 + } 995 + if (cflag & PARENB) { 996 + if (cflag & PARODD) { 997 + info->cor1 |= CyPARITY_O; 998 + } else { 999 + info->cor1 |= CyPARITY_E; 1000 + } 1001 + } else { 1002 + info->cor1 |= CyPARITY_NONE; 1003 + } 1004 + 1005 + /* CTS flow control flag */ 1006 + #if 0 1007 + /* Don't complcate matters for now! RGH 141095 */ 1008 + if (cflag & CRTSCTS) { 1009 + info->flags |= ASYNC_CTS_FLOW; 1010 + info->cor2 |= CyCtsAE; 1011 + } else { 1012 + info->flags &= ~ASYNC_CTS_FLOW; 1013 + info->cor2 &= ~CyCtsAE; 1014 + } 1015 + #endif 1016 + if (cflag & CLOCAL) 1017 + info->flags &= ~ASYNC_CHECK_CD; 1018 + else 1019 + info->flags |= ASYNC_CHECK_CD; 1020 1020 1021 1021 /*********************************************** 1022 1022 The hardware option, CyRtsAO, presents RTS when ··· 1031 1025 cable. Contact Marcio Saito for details. 1032 1026 ***********************************************/ 1033 1027 1034 - channel = info->line; 1028 + channel = info->line; 1035 1029 1036 - local_irq_save(flags); 1037 - base_addr[CyCAR] = (u_char)channel; 1030 + local_irq_save(flags); 1031 + base_addr[CyCAR] = (u_char) channel; 1038 1032 1039 1033 /* CyCMR set once only in mvme167_init_serial() */ 1040 1034 if (base_addr[CyLICR] != channel << 2) 1041 - base_addr[CyLICR] = channel << 2; 1035 + base_addr[CyLICR] = channel << 2; 1042 1036 if (base_addr[CyLIVR] != 0x5c) 1043 - base_addr[CyLIVR] = 0x5c; 1037 + base_addr[CyLIVR] = 0x5c; 1044 1038 1045 - /* tx and rx baud rate */ 1039 + /* tx and rx baud rate */ 1046 1040 1047 1041 if (base_addr[CyCOR1] != info->cor1) 1048 - need_init_chan = 1; 1042 + need_init_chan = 1; 1049 1043 if (base_addr[CyTCOR] != info->tco) 1050 - base_addr[CyTCOR] = info->tco; 1044 + base_addr[CyTCOR] = info->tco; 1051 1045 if (base_addr[CyTBPR] != info->tbpr) 1052 - base_addr[CyTBPR] = info->tbpr; 1046 + base_addr[CyTBPR] = info->tbpr; 1053 1047 if (base_addr[CyRCOR] != info->rco) 1054 - base_addr[CyRCOR] = info->rco; 1048 + base_addr[CyRCOR] = info->rco; 1055 1049 if (base_addr[CyRBPR] != info->rbpr) 1056 - base_addr[CyRBPR] = info->rbpr; 1050 + base_addr[CyRBPR] = info->rbpr; 1057 1051 1058 1052 /* set line characteristics according configuration */ 1059 1053 1060 1054 if (base_addr[CySCHR1] != START_CHAR(info->tty)) 1061 - base_addr[CySCHR1] = START_CHAR(info->tty); 1055 + base_addr[CySCHR1] = START_CHAR(info->tty); 1062 1056 if (base_addr[CySCHR2] != STOP_CHAR(info->tty)) 1063 - base_addr[CySCHR2] = STOP_CHAR(info->tty); 1057 + base_addr[CySCHR2] = STOP_CHAR(info->tty); 1064 1058 if (base_addr[CySCRL] != START_CHAR(info->tty)) 1065 - base_addr[CySCRL] = START_CHAR(info->tty); 1059 + base_addr[CySCRL] = START_CHAR(info->tty); 1066 1060 if (base_addr[CySCRH] != START_CHAR(info->tty)) 1067 - base_addr[CySCRH] = START_CHAR(info->tty); 1061 + base_addr[CySCRH] = START_CHAR(info->tty); 1068 1062 if (base_addr[CyCOR1] != info->cor1) 1069 - base_addr[CyCOR1] = info->cor1; 1063 + base_addr[CyCOR1] = info->cor1; 1070 1064 if (base_addr[CyCOR2] != info->cor2) 1071 - base_addr[CyCOR2] = info->cor2; 1065 + base_addr[CyCOR2] = info->cor2; 1072 1066 if (base_addr[CyCOR3] != info->cor3) 1073 - base_addr[CyCOR3] = info->cor3; 1067 + base_addr[CyCOR3] = info->cor3; 1074 1068 if (base_addr[CyCOR4] != info->cor4) 1075 - base_addr[CyCOR4] = info->cor4; 1069 + base_addr[CyCOR4] = info->cor4; 1076 1070 if (base_addr[CyCOR5] != info->cor5) 1077 - base_addr[CyCOR5] = info->cor5; 1071 + base_addr[CyCOR5] = info->cor5; 1078 1072 if (base_addr[CyCOR6] != info->cor6) 1079 - base_addr[CyCOR6] = info->cor6; 1073 + base_addr[CyCOR6] = info->cor6; 1080 1074 if (base_addr[CyCOR7] != info->cor7) 1081 - base_addr[CyCOR7] = info->cor7; 1075 + base_addr[CyCOR7] = info->cor7; 1082 1076 1083 1077 if (need_init_chan) 1084 - write_cy_cmd(base_addr,CyINIT_CHAN); 1078 + write_cy_cmd(base_addr, CyINIT_CHAN); 1085 1079 1086 - base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */ 1080 + base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */ 1087 1081 1088 1082 /* 2ms default rx timeout */ 1089 1083 ti = info->default_timeout ? info->default_timeout : 0x02; 1090 1084 if (base_addr[CyRTPRL] != ti) 1091 - base_addr[CyRTPRL] = ti; 1085 + base_addr[CyRTPRL] = ti; 1092 1086 if (base_addr[CyRTPRH] != 0) 1093 - base_addr[CyRTPRH] = 0; 1087 + base_addr[CyRTPRH] = 0; 1094 1088 1095 1089 /* Set up RTS here also ????? RGH 141095 */ 1096 - if(i == 0){ /* baud rate is zero, turn off line */ 1097 - if ((base_addr[CyMSVR2] & CyDTR) == CyDTR) 1098 - base_addr[CyMSVR2] = 0; 1090 + if (i == 0) { /* baud rate is zero, turn off line */ 1091 + if ((base_addr[CyMSVR2] & CyDTR) == CyDTR) 1092 + base_addr[CyMSVR2] = 0; 1099 1093 #ifdef SERIAL_DEBUG_DTR 1100 - printk("cyc: %d: dropping DTR\n", __LINE__); 1101 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1094 + printk("cyc: %d: dropping DTR\n", __LINE__); 1095 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 1096 + base_addr[CyMSVR2]); 1102 1097 #endif 1103 - }else{ 1104 - if ((base_addr[CyMSVR2] & CyDTR) != CyDTR) 1105 - base_addr[CyMSVR2] = CyDTR; 1098 + } else { 1099 + if ((base_addr[CyMSVR2] & CyDTR) != CyDTR) 1100 + base_addr[CyMSVR2] = CyDTR; 1106 1101 #ifdef SERIAL_DEBUG_DTR 1107 - printk("cyc: %d: raising DTR\n", __LINE__); 1108 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1102 + printk("cyc: %d: raising DTR\n", __LINE__); 1103 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 1104 + base_addr[CyMSVR2]); 1109 1105 #endif 1110 1106 } 1111 1107 1112 - if (info->tty){ 1113 - clear_bit(TTY_IO_ERROR, &info->tty->flags); 1108 + if (info->tty) { 1109 + clear_bit(TTY_IO_ERROR, &info->tty->flags); 1114 1110 } 1115 1111 1116 - local_irq_restore(flags); 1112 + local_irq_restore(flags); 1117 1113 1118 - } /* config_setup */ 1114 + } /* config_setup */ 1119 1115 1120 - 1121 - static void 1122 - cy_put_char(struct tty_struct *tty, unsigned char ch) 1116 + static void cy_put_char(struct tty_struct *tty, unsigned char ch) 1123 1117 { 1124 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1125 - unsigned long flags; 1118 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1119 + unsigned long flags; 1126 1120 1127 1121 #ifdef SERIAL_DEBUG_IO 1128 - printk("cy_put_char %s(0x%02x)\n", tty->name, ch); 1122 + printk("cy_put_char %s(0x%02x)\n", tty->name, ch); 1129 1123 #endif 1130 1124 1131 - if (serial_paranoia_check(info, tty->name, "cy_put_char")) 1132 - return; 1125 + if (serial_paranoia_check(info, tty->name, "cy_put_char")) 1126 + return; 1133 1127 1134 - if (!info->xmit_buf) 1135 - return; 1128 + if (!info->xmit_buf) 1129 + return; 1136 1130 1137 - local_irq_save(flags); 1131 + local_irq_save(flags); 1138 1132 if (info->xmit_cnt >= PAGE_SIZE - 1) { 1139 - local_irq_restore(flags); 1140 - return; 1133 + local_irq_restore(flags); 1134 + return; 1141 1135 } 1142 1136 1143 1137 info->xmit_buf[info->xmit_head++] = ch; 1144 1138 info->xmit_head &= PAGE_SIZE - 1; 1145 1139 info->xmit_cnt++; 1146 - local_irq_restore(flags); 1147 - } /* cy_put_char */ 1140 + local_irq_restore(flags); 1141 + } /* cy_put_char */ 1148 1142 1149 - 1150 - static void 1151 - cy_flush_chars(struct tty_struct *tty) 1143 + static void cy_flush_chars(struct tty_struct *tty) 1152 1144 { 1153 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1154 - unsigned long flags; 1155 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1156 - int channel; 1157 - 1145 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1146 + unsigned long flags; 1147 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1148 + int channel; 1149 + 1158 1150 #ifdef SERIAL_DEBUG_IO 1159 - printk("cy_flush_chars %s\n", tty->name); /* */ 1151 + printk("cy_flush_chars %s\n", tty->name); /* */ 1160 1152 #endif 1161 1153 1162 - if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) 1163 - return; 1154 + if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) 1155 + return; 1164 1156 1165 - if (info->xmit_cnt <= 0 || tty->stopped 1166 - || tty->hw_stopped || !info->xmit_buf) 1167 - return; 1157 + if (info->xmit_cnt <= 0 || tty->stopped 1158 + || tty->hw_stopped || !info->xmit_buf) 1159 + return; 1168 1160 1169 - channel = info->line; 1161 + channel = info->line; 1170 1162 1171 - local_irq_save(flags); 1163 + local_irq_save(flags); 1172 1164 base_addr[CyCAR] = channel; 1173 1165 base_addr[CyIER] |= CyTxMpty; 1174 - local_irq_restore(flags); 1175 - } /* cy_flush_chars */ 1176 - 1166 + local_irq_restore(flags); 1167 + } /* cy_flush_chars */ 1177 1168 1178 1169 /* This routine gets called when tty_write has put something into 1179 1170 the write_queue. If the port is not already transmitting stuff, ··· 1178 1175 routine will then ensure that the characters are sent. If the 1179 1176 port is already active, there is no need to kick it. 1180 1177 */ 1181 - static int 1182 - cy_write(struct tty_struct * tty, 1183 - const unsigned char *buf, int count) 1178 + static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) 1184 1179 { 1185 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1186 - unsigned long flags; 1187 - int c, total = 0; 1180 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1181 + unsigned long flags; 1182 + int c, total = 0; 1188 1183 1189 1184 #ifdef SERIAL_DEBUG_IO 1190 - printk("cy_write %s\n", tty->name); /* */ 1185 + printk("cy_write %s\n", tty->name); /* */ 1191 1186 #endif 1192 1187 1193 - if (serial_paranoia_check(info, tty->name, "cy_write")){ 1194 - return 0; 1195 - } 1196 - 1197 - if (!info->xmit_buf){ 1198 - return 0; 1199 - } 1188 + if (serial_paranoia_check(info, tty->name, "cy_write")) { 1189 + return 0; 1190 + } 1200 1191 1201 - while (1) { 1202 - local_irq_save(flags); 1203 - c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, 1204 - SERIAL_XMIT_SIZE - info->xmit_head)); 1205 - if (c <= 0) { 1206 - local_irq_restore(flags); 1207 - break; 1208 - } 1192 + if (!info->xmit_buf) { 1193 + return 0; 1194 + } 1209 1195 1210 - memcpy(info->xmit_buf + info->xmit_head, buf, c); 1211 - info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); 1212 - info->xmit_cnt += c; 1213 - local_irq_restore(flags); 1196 + while (1) { 1197 + local_irq_save(flags); 1198 + c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, 1199 + SERIAL_XMIT_SIZE - info->xmit_head)); 1200 + if (c <= 0) { 1201 + local_irq_restore(flags); 1202 + break; 1203 + } 1214 1204 1215 - buf += c; 1216 - count -= c; 1217 - total += c; 1218 - } 1205 + memcpy(info->xmit_buf + info->xmit_head, buf, c); 1206 + info->xmit_head = 1207 + (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1); 1208 + info->xmit_cnt += c; 1209 + local_irq_restore(flags); 1219 1210 1220 - if (info->xmit_cnt 1221 - && !tty->stopped 1222 - && !tty->hw_stopped ) { 1223 - start_xmit(info); 1224 - } 1225 - return total; 1226 - } /* cy_write */ 1211 + buf += c; 1212 + count -= c; 1213 + total += c; 1214 + } 1227 1215 1216 + if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 1217 + start_xmit(info); 1218 + } 1219 + return total; 1220 + } /* cy_write */ 1228 1221 1229 - static int 1230 - cy_write_room(struct tty_struct *tty) 1222 + static int cy_write_room(struct tty_struct *tty) 1231 1223 { 1232 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1233 - int ret; 1234 - 1224 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1225 + int ret; 1226 + 1235 1227 #ifdef SERIAL_DEBUG_IO 1236 - printk("cy_write_room %s\n", tty->name); /* */ 1228 + printk("cy_write_room %s\n", tty->name); /* */ 1237 1229 #endif 1238 1230 1239 - if (serial_paranoia_check(info, tty->name, "cy_write_room")) 1240 - return 0; 1241 - ret = PAGE_SIZE - info->xmit_cnt - 1; 1242 - if (ret < 0) 1243 - ret = 0; 1244 - return ret; 1245 - } /* cy_write_room */ 1231 + if (serial_paranoia_check(info, tty->name, "cy_write_room")) 1232 + return 0; 1233 + ret = PAGE_SIZE - info->xmit_cnt - 1; 1234 + if (ret < 0) 1235 + ret = 0; 1236 + return ret; 1237 + } /* cy_write_room */ 1246 1238 1247 - 1248 - static int 1249 - cy_chars_in_buffer(struct tty_struct *tty) 1239 + static int cy_chars_in_buffer(struct tty_struct *tty) 1250 1240 { 1251 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1252 - 1241 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1242 + 1253 1243 #ifdef SERIAL_DEBUG_IO 1254 - printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */ 1244 + printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */ 1255 1245 #endif 1256 1246 1257 - if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) 1258 - return 0; 1247 + if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) 1248 + return 0; 1259 1249 1260 - return info->xmit_cnt; 1261 - } /* cy_chars_in_buffer */ 1250 + return info->xmit_cnt; 1251 + } /* cy_chars_in_buffer */ 1262 1252 1263 - 1264 - static void 1265 - cy_flush_buffer(struct tty_struct *tty) 1253 + static void cy_flush_buffer(struct tty_struct *tty) 1266 1254 { 1267 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1268 - unsigned long flags; 1269 - 1255 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1256 + unsigned long flags; 1257 + 1270 1258 #ifdef SERIAL_DEBUG_IO 1271 - printk("cy_flush_buffer %s\n", tty->name); /* */ 1259 + printk("cy_flush_buffer %s\n", tty->name); /* */ 1272 1260 #endif 1273 1261 1274 - if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) 1275 - return; 1276 - local_irq_save(flags); 1262 + if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) 1263 + return; 1264 + local_irq_save(flags); 1277 1265 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1278 - local_irq_restore(flags); 1279 - tty_wakeup(tty); 1280 - } /* cy_flush_buffer */ 1281 - 1266 + local_irq_restore(flags); 1267 + tty_wakeup(tty); 1268 + } /* cy_flush_buffer */ 1282 1269 1283 1270 /* This routine is called by the upper-layer tty layer to signal 1284 1271 that incoming characters should be throttled or that the 1285 1272 throttle should be released. 1286 1273 */ 1287 - static void 1288 - cy_throttle(struct tty_struct * tty) 1274 + static void cy_throttle(struct tty_struct *tty) 1289 1275 { 1290 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1291 - unsigned long flags; 1292 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1293 - int channel; 1276 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1277 + unsigned long flags; 1278 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1279 + int channel; 1294 1280 1295 1281 #ifdef SERIAL_DEBUG_THROTTLE 1296 - char buf[64]; 1297 - 1298 - printk("throttle %s: %d....\n", tty_name(tty, buf), 1299 - tty->ldisc.chars_in_buffer(tty)); 1300 - printk("cy_throttle %s\n", tty->name); 1282 + char buf[64]; 1283 + 1284 + printk("throttle %s: %d....\n", tty_name(tty, buf), 1285 + tty->ldisc.chars_in_buffer(tty)); 1286 + printk("cy_throttle %s\n", tty->name); 1301 1287 #endif 1302 1288 1303 - if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){ 1304 - return; 1305 - } 1289 + if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) { 1290 + return; 1291 + } 1306 1292 1307 - if (I_IXOFF(tty)) { 1308 - info->x_char = STOP_CHAR(tty); 1309 - /* Should use the "Send Special Character" feature!!! */ 1310 - } 1293 + if (I_IXOFF(tty)) { 1294 + info->x_char = STOP_CHAR(tty); 1295 + /* Should use the "Send Special Character" feature!!! */ 1296 + } 1311 1297 1312 - channel = info->line; 1298 + channel = info->line; 1313 1299 1314 - local_irq_save(flags); 1315 - base_addr[CyCAR] = (u_char)channel; 1300 + local_irq_save(flags); 1301 + base_addr[CyCAR] = (u_char) channel; 1316 1302 base_addr[CyMSVR1] = 0; 1317 - local_irq_restore(flags); 1303 + local_irq_restore(flags); 1304 + } /* cy_throttle */ 1318 1305 1319 - return; 1320 - } /* cy_throttle */ 1321 - 1322 - 1323 - static void 1324 - cy_unthrottle(struct tty_struct * tty) 1306 + static void cy_unthrottle(struct tty_struct *tty) 1325 1307 { 1326 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1327 - unsigned long flags; 1328 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1329 - int channel; 1308 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1309 + unsigned long flags; 1310 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1311 + int channel; 1330 1312 1331 1313 #ifdef SERIAL_DEBUG_THROTTLE 1332 - char buf[64]; 1333 - 1334 - printk("throttle %s: %d....\n", tty_name(tty, buf), 1335 - tty->ldisc.chars_in_buffer(tty)); 1336 - printk("cy_unthrottle %s\n", tty->name); 1314 + char buf[64]; 1315 + 1316 + printk("throttle %s: %d....\n", tty_name(tty, buf), 1317 + tty->ldisc.chars_in_buffer(tty)); 1318 + printk("cy_unthrottle %s\n", tty->name); 1337 1319 #endif 1338 1320 1339 - if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){ 1340 - return; 1341 - } 1321 + if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) { 1322 + return; 1323 + } 1342 1324 1343 - if (I_IXOFF(tty)) { 1344 - info->x_char = START_CHAR(tty); 1345 - /* Should use the "Send Special Character" feature!!! */ 1346 - } 1325 + if (I_IXOFF(tty)) { 1326 + info->x_char = START_CHAR(tty); 1327 + /* Should use the "Send Special Character" feature!!! */ 1328 + } 1347 1329 1348 - channel = info->line; 1330 + channel = info->line; 1349 1331 1350 - local_irq_save(flags); 1351 - base_addr[CyCAR] = (u_char)channel; 1332 + local_irq_save(flags); 1333 + base_addr[CyCAR] = (u_char) channel; 1352 1334 base_addr[CyMSVR1] = CyRTS; 1353 - local_irq_restore(flags); 1354 - 1355 - return; 1356 - } /* cy_unthrottle */ 1335 + local_irq_restore(flags); 1336 + } /* cy_unthrottle */ 1357 1337 1358 1338 static int 1359 - get_serial_info(struct cyclades_port * info, 1360 - struct serial_struct __user * retinfo) 1339 + get_serial_info(struct cyclades_port *info, 1340 + struct serial_struct __user * retinfo) 1361 1341 { 1362 - struct serial_struct tmp; 1342 + struct serial_struct tmp; 1363 1343 1364 1344 /* CP('g'); */ 1365 - if (!retinfo) 1366 - return -EFAULT; 1367 - memset(&tmp, 0, sizeof(tmp)); 1368 - tmp.type = info->type; 1369 - tmp.line = info->line; 1370 - tmp.port = info->line; 1371 - tmp.irq = 0; 1372 - tmp.flags = info->flags; 1373 - tmp.baud_base = 0; /*!!!*/ 1374 - tmp.close_delay = info->close_delay; 1375 - tmp.custom_divisor = 0; /*!!!*/ 1376 - tmp.hub6 = 0; /*!!!*/ 1377 - return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0; 1378 - } /* get_serial_info */ 1345 + if (!retinfo) 1346 + return -EFAULT; 1347 + memset(&tmp, 0, sizeof(tmp)); 1348 + tmp.type = info->type; 1349 + tmp.line = info->line; 1350 + tmp.port = info->line; 1351 + tmp.irq = 0; 1352 + tmp.flags = info->flags; 1353 + tmp.baud_base = 0; /*!!! */ 1354 + tmp.close_delay = info->close_delay; 1355 + tmp.custom_divisor = 0; /*!!! */ 1356 + tmp.hub6 = 0; /*!!! */ 1357 + return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 1358 + } /* get_serial_info */ 1379 1359 1380 1360 static int 1381 - set_serial_info(struct cyclades_port * info, 1382 - struct serial_struct __user * new_info) 1361 + set_serial_info(struct cyclades_port *info, 1362 + struct serial_struct __user * new_info) 1383 1363 { 1384 - struct serial_struct new_serial; 1385 - struct cyclades_port old_info; 1364 + struct serial_struct new_serial; 1365 + struct cyclades_port old_info; 1386 1366 1387 1367 /* CP('s'); */ 1388 - if (!new_info) 1389 - return -EFAULT; 1390 - if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1391 - return -EFAULT; 1392 - old_info = *info; 1368 + if (!new_info) 1369 + return -EFAULT; 1370 + if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 1371 + return -EFAULT; 1372 + old_info = *info; 1393 1373 1394 - if (!capable(CAP_SYS_ADMIN)) { 1395 - if ((new_serial.close_delay != info->close_delay) || 1396 - ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) != 1397 - (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))) 1398 - return -EPERM; 1399 - info->flags = ((info->flags & ~ASYNC_USR_MASK) | 1400 - (new_serial.flags & ASYNC_USR_MASK)); 1401 - goto check_and_exit; 1402 - } 1374 + if (!capable(CAP_SYS_ADMIN)) { 1375 + if ((new_serial.close_delay != info->close_delay) || 1376 + ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) != 1377 + (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))) 1378 + return -EPERM; 1379 + info->flags = ((info->flags & ~ASYNC_USR_MASK) | 1380 + (new_serial.flags & ASYNC_USR_MASK)); 1381 + goto check_and_exit; 1382 + } 1403 1383 1384 + /* 1385 + * OK, past this point, all the error checking has been done. 1386 + * At this point, we start making changes..... 1387 + */ 1404 1388 1405 - /* 1406 - * OK, past this point, all the error checking has been done. 1407 - * At this point, we start making changes..... 1408 - */ 1409 - 1410 - info->flags = ((info->flags & ~ASYNC_FLAGS) | 1411 - (new_serial.flags & ASYNC_FLAGS)); 1412 - info->close_delay = new_serial.close_delay; 1413 - 1389 + info->flags = ((info->flags & ~ASYNC_FLAGS) | 1390 + (new_serial.flags & ASYNC_FLAGS)); 1391 + info->close_delay = new_serial.close_delay; 1414 1392 1415 1393 check_and_exit: 1416 - if (info->flags & ASYNC_INITIALIZED){ 1417 - config_setup(info); 1418 - return 0; 1419 - }else{ 1420 - return startup(info); 1421 - } 1422 - } /* set_serial_info */ 1394 + if (info->flags & ASYNC_INITIALIZED) { 1395 + config_setup(info); 1396 + return 0; 1397 + } 1398 + return startup(info); 1399 + } /* set_serial_info */ 1423 1400 1424 - static int 1425 - cy_tiocmget(struct tty_struct *tty, struct file *file) 1401 + static int cy_tiocmget(struct tty_struct *tty, struct file *file) 1426 1402 { 1427 - struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1428 - int channel; 1429 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1430 - unsigned long flags; 1431 - unsigned char status; 1403 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1404 + int channel; 1405 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1406 + unsigned long flags; 1407 + unsigned char status; 1432 1408 1433 - channel = info->line; 1409 + channel = info->line; 1434 1410 1435 - local_irq_save(flags); 1436 - base_addr[CyCAR] = (u_char)channel; 1437 - status = base_addr[CyMSVR1] | base_addr[CyMSVR2]; 1438 - local_irq_restore(flags); 1411 + local_irq_save(flags); 1412 + base_addr[CyCAR] = (u_char) channel; 1413 + status = base_addr[CyMSVR1] | base_addr[CyMSVR2]; 1414 + local_irq_restore(flags); 1439 1415 1440 - return ((status & CyRTS) ? TIOCM_RTS : 0) 1441 - | ((status & CyDTR) ? TIOCM_DTR : 0) 1442 - | ((status & CyDCD) ? TIOCM_CAR : 0) 1443 - | ((status & CyDSR) ? TIOCM_DSR : 0) 1444 - | ((status & CyCTS) ? TIOCM_CTS : 0); 1445 - } /* cy_tiocmget */ 1416 + return ((status & CyRTS) ? TIOCM_RTS : 0) 1417 + | ((status & CyDTR) ? TIOCM_DTR : 0) 1418 + | ((status & CyDCD) ? TIOCM_CAR : 0) 1419 + | ((status & CyDSR) ? TIOCM_DSR : 0) 1420 + | ((status & CyCTS) ? TIOCM_CTS : 0); 1421 + } /* cy_tiocmget */ 1446 1422 1447 1423 static int 1448 1424 cy_tiocmset(struct tty_struct *tty, struct file *file, 1449 1425 unsigned int set, unsigned int clear) 1450 1426 { 1451 - struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1452 - int channel; 1453 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1454 - unsigned long flags; 1455 - 1456 - channel = info->line; 1427 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1428 + int channel; 1429 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1430 + unsigned long flags; 1457 1431 1458 - if (set & TIOCM_RTS){ 1459 - local_irq_save(flags); 1460 - base_addr[CyCAR] = (u_char)channel; 1432 + channel = info->line; 1433 + 1434 + if (set & TIOCM_RTS) { 1435 + local_irq_save(flags); 1436 + base_addr[CyCAR] = (u_char) channel; 1461 1437 base_addr[CyMSVR1] = CyRTS; 1462 - local_irq_restore(flags); 1438 + local_irq_restore(flags); 1463 1439 } 1464 - if (set & TIOCM_DTR){ 1465 - local_irq_save(flags); 1466 - base_addr[CyCAR] = (u_char)channel; 1440 + if (set & TIOCM_DTR) { 1441 + local_irq_save(flags); 1442 + base_addr[CyCAR] = (u_char) channel; 1467 1443 /* CP('S');CP('2'); */ 1468 - base_addr[CyMSVR2] = CyDTR; 1444 + base_addr[CyMSVR2] = CyDTR; 1469 1445 #ifdef SERIAL_DEBUG_DTR 1470 - printk("cyc: %d: raising DTR\n", __LINE__); 1471 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1446 + printk("cyc: %d: raising DTR\n", __LINE__); 1447 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 1448 + base_addr[CyMSVR2]); 1472 1449 #endif 1473 - local_irq_restore(flags); 1450 + local_irq_restore(flags); 1474 1451 } 1475 1452 1476 - if (clear & TIOCM_RTS){ 1477 - local_irq_save(flags); 1478 - base_addr[CyCAR] = (u_char)channel; 1453 + if (clear & TIOCM_RTS) { 1454 + local_irq_save(flags); 1455 + base_addr[CyCAR] = (u_char) channel; 1479 1456 base_addr[CyMSVR1] = 0; 1480 - local_irq_restore(flags); 1457 + local_irq_restore(flags); 1481 1458 } 1482 - if (clear & TIOCM_DTR){ 1483 - local_irq_save(flags); 1484 - base_addr[CyCAR] = (u_char)channel; 1459 + if (clear & TIOCM_DTR) { 1460 + local_irq_save(flags); 1461 + base_addr[CyCAR] = (u_char) channel; 1485 1462 /* CP('C');CP('2'); */ 1486 - base_addr[CyMSVR2] = 0; 1463 + base_addr[CyMSVR2] = 0; 1487 1464 #ifdef SERIAL_DEBUG_DTR 1488 - printk("cyc: %d: dropping DTR\n", __LINE__); 1489 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1465 + printk("cyc: %d: dropping DTR\n", __LINE__); 1466 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 1467 + base_addr[CyMSVR2]); 1490 1468 #endif 1491 - local_irq_restore(flags); 1469 + local_irq_restore(flags); 1492 1470 } 1493 1471 1494 - return 0; 1495 - } /* set_modem_info */ 1472 + return 0; 1473 + } /* set_modem_info */ 1496 1474 1497 - static void 1498 - send_break( struct cyclades_port * info, int duration) 1499 - { /* Let the transmit ISR take care of this (since it 1500 - requires stuffing characters into the output stream). 1501 - */ 1502 - info->x_break = duration; 1503 - if (!info->xmit_cnt ) { 1504 - start_xmit(info); 1505 - } 1506 - } /* send_break */ 1475 + static void send_break(struct cyclades_port *info, int duration) 1476 + { /* Let the transmit ISR take care of this (since it 1477 + requires stuffing characters into the output stream). 1478 + */ 1479 + info->x_break = duration; 1480 + if (!info->xmit_cnt) { 1481 + start_xmit(info); 1482 + } 1483 + } /* send_break */ 1507 1484 1508 1485 static int 1509 - get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon) 1486 + get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon) 1510 1487 { 1511 1488 1512 - if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 1513 - return -EFAULT; 1514 - info->mon.int_count = 0; 1515 - info->mon.char_count = 0; 1516 - info->mon.char_max = 0; 1517 - info->mon.char_last = 0; 1518 - return 0; 1489 + if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 1490 + return -EFAULT; 1491 + info->mon.int_count = 0; 1492 + info->mon.char_count = 0; 1493 + info->mon.char_max = 0; 1494 + info->mon.char_last = 0; 1495 + return 0; 1496 + } 1497 + 1498 + static int set_threshold(struct cyclades_port *info, unsigned long __user * arg) 1499 + { 1500 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1501 + unsigned long value; 1502 + int channel; 1503 + 1504 + if (get_user(value, arg)) 1505 + return -EFAULT; 1506 + 1507 + channel = info->line; 1508 + info->cor4 &= ~CyREC_FIFO; 1509 + info->cor4 |= value & CyREC_FIFO; 1510 + base_addr[CyCOR4] = info->cor4; 1511 + return 0; 1519 1512 } 1520 1513 1521 1514 static int 1522 - set_threshold(struct cyclades_port * info, unsigned long __user *arg) 1515 + get_threshold(struct cyclades_port *info, unsigned long __user * value) 1523 1516 { 1524 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1525 - unsigned long value; 1526 - int channel; 1527 - 1528 - if (get_user(value, arg)) 1529 - return -EFAULT; 1517 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1518 + int channel; 1519 + unsigned long tmp; 1530 1520 1531 - channel = info->line; 1532 - info->cor4 &= ~CyREC_FIFO; 1533 - info->cor4 |= value & CyREC_FIFO; 1534 - base_addr[CyCOR4] = info->cor4; 1535 - return 0; 1521 + channel = info->line; 1522 + 1523 + tmp = base_addr[CyCOR4] & CyREC_FIFO; 1524 + return put_user(tmp, value); 1536 1525 } 1537 1526 1538 1527 static int 1539 - get_threshold(struct cyclades_port * info, unsigned long __user *value) 1528 + set_default_threshold(struct cyclades_port *info, unsigned long __user * arg) 1540 1529 { 1541 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1542 - int channel; 1543 - unsigned long tmp; 1544 - 1545 - channel = info->line; 1530 + unsigned long value; 1546 1531 1547 - tmp = base_addr[CyCOR4] & CyREC_FIFO; 1548 - return put_user(tmp,value); 1532 + if (get_user(value, arg)) 1533 + return -EFAULT; 1534 + 1535 + info->default_threshold = value & 0x0f; 1536 + return 0; 1549 1537 } 1550 1538 1551 1539 static int 1552 - set_default_threshold(struct cyclades_port * info, unsigned long __user *arg) 1540 + get_default_threshold(struct cyclades_port *info, unsigned long __user * value) 1553 1541 { 1554 - unsigned long value; 1542 + return put_user(info->default_threshold, value); 1543 + } 1555 1544 1556 - if (get_user(value, arg)) 1557 - return -EFAULT; 1545 + static int set_timeout(struct cyclades_port *info, unsigned long __user * arg) 1546 + { 1547 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1548 + int channel; 1549 + unsigned long value; 1558 1550 1559 - info->default_threshold = value & 0x0f; 1560 - return 0; 1551 + if (get_user(value, arg)) 1552 + return -EFAULT; 1553 + 1554 + channel = info->line; 1555 + 1556 + base_addr[CyRTPRL] = value & 0xff; 1557 + base_addr[CyRTPRH] = (value >> 8) & 0xff; 1558 + return 0; 1559 + } 1560 + 1561 + static int get_timeout(struct cyclades_port *info, unsigned long __user * value) 1562 + { 1563 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 1564 + int channel; 1565 + unsigned long tmp; 1566 + 1567 + channel = info->line; 1568 + 1569 + tmp = base_addr[CyRTPRL]; 1570 + return put_user(tmp, value); 1571 + } 1572 + 1573 + static int set_default_timeout(struct cyclades_port *info, unsigned long value) 1574 + { 1575 + info->default_timeout = value & 0xff; 1576 + return 0; 1561 1577 } 1562 1578 1563 1579 static int 1564 - get_default_threshold(struct cyclades_port * info, unsigned long __user *value) 1580 + get_default_timeout(struct cyclades_port *info, unsigned long __user * value) 1565 1581 { 1566 - return put_user(info->default_threshold,value); 1582 + return put_user(info->default_timeout, value); 1567 1583 } 1568 1584 1569 1585 static int 1570 - set_timeout(struct cyclades_port * info, unsigned long __user *arg) 1586 + cy_ioctl(struct tty_struct *tty, struct file *file, 1587 + unsigned int cmd, unsigned long arg) 1571 1588 { 1572 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1573 - int channel; 1574 - unsigned long value; 1575 - 1576 - if (get_user(value, arg)) 1577 - return -EFAULT; 1578 - 1579 - channel = info->line; 1580 - 1581 - base_addr[CyRTPRL] = value & 0xff; 1582 - base_addr[CyRTPRH] = (value >> 8) & 0xff; 1583 - return 0; 1584 - } 1585 - 1586 - static int 1587 - get_timeout(struct cyclades_port * info, unsigned long __user *value) 1588 - { 1589 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1590 - int channel; 1591 - unsigned long tmp; 1592 - 1593 - channel = info->line; 1594 - 1595 - tmp = base_addr[CyRTPRL]; 1596 - return put_user(tmp,value); 1597 - } 1598 - 1599 - static int 1600 - set_default_timeout(struct cyclades_port * info, unsigned long value) 1601 - { 1602 - info->default_timeout = value & 0xff; 1603 - return 0; 1604 - } 1605 - 1606 - static int 1607 - get_default_timeout(struct cyclades_port * info, unsigned long __user *value) 1608 - { 1609 - return put_user(info->default_timeout,value); 1610 - } 1611 - 1612 - static int 1613 - cy_ioctl(struct tty_struct *tty, struct file * file, 1614 - unsigned int cmd, unsigned long arg) 1615 - { 1616 - unsigned long val; 1617 - struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1618 - int ret_val = 0; 1619 - void __user *argp = (void __user *)arg; 1589 + unsigned long val; 1590 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1591 + int ret_val = 0; 1592 + void __user *argp = (void __user *)arg; 1620 1593 1621 1594 #ifdef SERIAL_DEBUG_OTHER 1622 - printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */ 1595 + printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */ 1623 1596 #endif 1624 1597 1625 - switch (cmd) { 1626 - case CYGETMON: 1627 - ret_val = get_mon_info(info, argp); 1628 - break; 1629 - case CYGETTHRESH: 1630 - ret_val = get_threshold(info, argp); 1631 - break; 1632 - case CYSETTHRESH: 1633 - ret_val = set_threshold(info, argp); 1634 - break; 1635 - case CYGETDEFTHRESH: 1636 - ret_val = get_default_threshold(info, argp); 1637 - break; 1638 - case CYSETDEFTHRESH: 1639 - ret_val = set_default_threshold(info, argp); 1640 - break; 1641 - case CYGETTIMEOUT: 1642 - ret_val = get_timeout(info, argp); 1643 - break; 1644 - case CYSETTIMEOUT: 1645 - ret_val = set_timeout(info, argp); 1646 - break; 1647 - case CYGETDEFTIMEOUT: 1648 - ret_val = get_default_timeout(info, argp); 1649 - break; 1650 - case CYSETDEFTIMEOUT: 1651 - ret_val = set_default_timeout(info, (unsigned long)arg); 1652 - break; 1653 - case TCSBRK: /* SVID version: non-zero arg --> no break */ 1654 - ret_val = tty_check_change(tty); 1655 - if (ret_val) 1656 - break; 1657 - tty_wait_until_sent(tty,0); 1658 - if (!arg) 1659 - send_break(info, HZ/4); /* 1/4 second */ 1660 - break; 1661 - case TCSBRKP: /* support for POSIX tcsendbreak() */ 1662 - ret_val = tty_check_change(tty); 1663 - if (ret_val) 1598 + switch (cmd) { 1599 + case CYGETMON: 1600 + ret_val = get_mon_info(info, argp); 1664 1601 break; 1665 - tty_wait_until_sent(tty,0); 1666 - send_break(info, arg ? arg*(HZ/10) : HZ/4); 1667 - break; 1602 + case CYGETTHRESH: 1603 + ret_val = get_threshold(info, argp); 1604 + break; 1605 + case CYSETTHRESH: 1606 + ret_val = set_threshold(info, argp); 1607 + break; 1608 + case CYGETDEFTHRESH: 1609 + ret_val = get_default_threshold(info, argp); 1610 + break; 1611 + case CYSETDEFTHRESH: 1612 + ret_val = set_default_threshold(info, argp); 1613 + break; 1614 + case CYGETTIMEOUT: 1615 + ret_val = get_timeout(info, argp); 1616 + break; 1617 + case CYSETTIMEOUT: 1618 + ret_val = set_timeout(info, argp); 1619 + break; 1620 + case CYGETDEFTIMEOUT: 1621 + ret_val = get_default_timeout(info, argp); 1622 + break; 1623 + case CYSETDEFTIMEOUT: 1624 + ret_val = set_default_timeout(info, (unsigned long)arg); 1625 + break; 1626 + case TCSBRK: /* SVID version: non-zero arg --> no break */ 1627 + ret_val = tty_check_change(tty); 1628 + if (ret_val) 1629 + break; 1630 + tty_wait_until_sent(tty, 0); 1631 + if (!arg) 1632 + send_break(info, HZ / 4); /* 1/4 second */ 1633 + break; 1634 + case TCSBRKP: /* support for POSIX tcsendbreak() */ 1635 + ret_val = tty_check_change(tty); 1636 + if (ret_val) 1637 + break; 1638 + tty_wait_until_sent(tty, 0); 1639 + send_break(info, arg ? arg * (HZ / 10) : HZ / 4); 1640 + break; 1668 1641 1669 1642 /* The following commands are incompletely implemented!!! */ 1670 - case TIOCGSOFTCAR: 1671 - ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp); 1672 - break; 1673 - case TIOCSSOFTCAR: 1674 - ret_val = get_user(val, (unsigned long __user *) argp); 1675 - if (ret_val) 1676 - break; 1677 - tty->termios->c_cflag = 1678 - ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0)); 1679 - break; 1680 - case TIOCGSERIAL: 1681 - ret_val = get_serial_info(info, argp); 1682 - break; 1683 - case TIOCSSERIAL: 1684 - ret_val = set_serial_info(info, argp); 1685 - break; 1686 - default: 1687 - ret_val = -ENOIOCTLCMD; 1688 - } 1643 + case TIOCGSOFTCAR: 1644 + ret_val = 1645 + put_user(C_CLOCAL(tty) ? 1 : 0, 1646 + (unsigned long __user *)argp); 1647 + break; 1648 + case TIOCSSOFTCAR: 1649 + ret_val = get_user(val, (unsigned long __user *)argp); 1650 + if (ret_val) 1651 + break; 1652 + tty->termios->c_cflag = 1653 + ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0)); 1654 + break; 1655 + case TIOCGSERIAL: 1656 + ret_val = get_serial_info(info, argp); 1657 + break; 1658 + case TIOCSSERIAL: 1659 + ret_val = set_serial_info(info, argp); 1660 + break; 1661 + default: 1662 + ret_val = -ENOIOCTLCMD; 1663 + } 1689 1664 1690 1665 #ifdef SERIAL_DEBUG_OTHER 1691 - printk("cy_ioctl done\n"); 1666 + printk("cy_ioctl done\n"); 1692 1667 #endif 1693 1668 1694 - return ret_val; 1695 - } /* cy_ioctl */ 1669 + return ret_val; 1670 + } /* cy_ioctl */ 1696 1671 1697 - 1698 - 1699 - 1700 - static void 1701 - cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios) 1672 + static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1702 1673 { 1703 - struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1674 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1704 1675 1705 1676 #ifdef SERIAL_DEBUG_OTHER 1706 - printk("cy_set_termios %s\n", tty->name); 1677 + printk("cy_set_termios %s\n", tty->name); 1707 1678 #endif 1708 1679 1709 - if (tty->termios->c_cflag == old_termios->c_cflag) 1710 - return; 1711 - config_setup(info); 1680 + if (tty->termios->c_cflag == old_termios->c_cflag) 1681 + return; 1682 + config_setup(info); 1712 1683 1713 - if ((old_termios->c_cflag & CRTSCTS) && 1714 - !(tty->termios->c_cflag & CRTSCTS)) { 1715 - tty->stopped = 0; 1716 - cy_start(tty); 1717 - } 1684 + if ((old_termios->c_cflag & CRTSCTS) && 1685 + !(tty->termios->c_cflag & CRTSCTS)) { 1686 + tty->stopped = 0; 1687 + cy_start(tty); 1688 + } 1718 1689 #ifdef tytso_patch_94Nov25_1726 1719 - if (!(old_termios->c_cflag & CLOCAL) && 1720 - (tty->termios->c_cflag & CLOCAL)) 1721 - wake_up_interruptible(&info->open_wait); 1690 + if (!(old_termios->c_cflag & CLOCAL) && 1691 + (tty->termios->c_cflag & CLOCAL)) 1692 + wake_up_interruptible(&info->open_wait); 1722 1693 #endif 1694 + } /* cy_set_termios */ 1723 1695 1724 - return; 1725 - } /* cy_set_termios */ 1726 - 1727 - 1728 - static void 1729 - cy_close(struct tty_struct * tty, struct file * filp) 1696 + static void cy_close(struct tty_struct *tty, struct file *filp) 1730 1697 { 1731 - struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1698 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1732 1699 1733 1700 /* CP('C'); */ 1734 1701 #ifdef SERIAL_DEBUG_OTHER 1735 - printk("cy_close %s\n", tty->name); 1702 + printk("cy_close %s\n", tty->name); 1736 1703 #endif 1737 1704 1738 - if (!info 1739 - || serial_paranoia_check(info, tty->name, "cy_close")){ 1740 - return; 1741 - } 1742 - #ifdef SERIAL_DEBUG_OPEN 1743 - printk("cy_close %s, count = %d\n", tty->name, info->count); 1744 - #endif 1745 - 1746 - if ((tty->count == 1) && (info->count != 1)) { 1747 - /* 1748 - * Uh, oh. tty->count is 1, which means that the tty 1749 - * structure will be freed. Info->count should always 1750 - * be one in these conditions. If it's greater than 1751 - * one, we've got real problems, since it means the 1752 - * serial port won't be shutdown. 1753 - */ 1754 - printk("cy_close: bad serial port count; tty->count is 1, " 1755 - "info->count is %d\n", info->count); 1756 - info->count = 1; 1757 - } 1758 - #ifdef SERIAL_DEBUG_COUNT 1759 - printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1); 1760 - #endif 1761 - if (--info->count < 0) { 1762 - printk("cy_close: bad serial port count for ttys%d: %d\n", 1763 - info->line, info->count); 1764 - #ifdef SERIAL_DEBUG_COUNT 1765 - printk("cyc: %d: setting count to 0\n", __LINE__); 1766 - #endif 1767 - info->count = 0; 1768 - } 1769 - if (info->count) 1770 - return; 1771 - info->flags |= ASYNC_CLOSING; 1772 - if (info->flags & ASYNC_INITIALIZED) 1773 - tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 1774 - shutdown(info); 1775 - if (tty->driver->flush_buffer) 1776 - tty->driver->flush_buffer(tty); 1777 - tty_ldisc_flush(tty); 1778 - info->event = 0; 1779 - info->tty = NULL; 1780 - if (info->blocked_open) { 1781 - if (info->close_delay) { 1782 - msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1705 + if (!info || serial_paranoia_check(info, tty->name, "cy_close")) { 1706 + return; 1783 1707 } 1784 - wake_up_interruptible(&info->open_wait); 1785 - } 1786 - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1787 - wake_up_interruptible(&info->close_wait); 1708 + #ifdef SERIAL_DEBUG_OPEN 1709 + printk("cy_close %s, count = %d\n", tty->name, info->count); 1710 + #endif 1711 + 1712 + if ((tty->count == 1) && (info->count != 1)) { 1713 + /* 1714 + * Uh, oh. tty->count is 1, which means that the tty 1715 + * structure will be freed. Info->count should always 1716 + * be one in these conditions. If it's greater than 1717 + * one, we've got real problems, since it means the 1718 + * serial port won't be shutdown. 1719 + */ 1720 + printk("cy_close: bad serial port count; tty->count is 1, " 1721 + "info->count is %d\n", info->count); 1722 + info->count = 1; 1723 + } 1724 + #ifdef SERIAL_DEBUG_COUNT 1725 + printk("cyc: %d: decrementing count to %d\n", __LINE__, 1726 + info->count - 1); 1727 + #endif 1728 + if (--info->count < 0) { 1729 + printk("cy_close: bad serial port count for ttys%d: %d\n", 1730 + info->line, info->count); 1731 + #ifdef SERIAL_DEBUG_COUNT 1732 + printk("cyc: %d: setting count to 0\n", __LINE__); 1733 + #endif 1734 + info->count = 0; 1735 + } 1736 + if (info->count) 1737 + return; 1738 + info->flags |= ASYNC_CLOSING; 1739 + if (info->flags & ASYNC_INITIALIZED) 1740 + tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 1741 + shutdown(info); 1742 + if (tty->driver->flush_buffer) 1743 + tty->driver->flush_buffer(tty); 1744 + tty_ldisc_flush(tty); 1745 + info->event = 0; 1746 + info->tty = NULL; 1747 + if (info->blocked_open) { 1748 + if (info->close_delay) { 1749 + msleep_interruptible(jiffies_to_msecs 1750 + (info->close_delay)); 1751 + } 1752 + wake_up_interruptible(&info->open_wait); 1753 + } 1754 + info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 1755 + wake_up_interruptible(&info->close_wait); 1788 1756 1789 1757 #ifdef SERIAL_DEBUG_OTHER 1790 - printk("cy_close done\n"); 1758 + printk("cy_close done\n"); 1791 1759 #endif 1792 - 1793 - return; 1794 - } /* cy_close */ 1760 + } /* cy_close */ 1795 1761 1796 1762 /* 1797 1763 * cy_hangup() --- called by tty_hangup() when a hangup is signaled. 1798 1764 */ 1799 - void 1800 - cy_hangup(struct tty_struct *tty) 1765 + void cy_hangup(struct tty_struct *tty) 1801 1766 { 1802 - struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1803 - 1767 + struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1768 + 1804 1769 #ifdef SERIAL_DEBUG_OTHER 1805 - printk("cy_hangup %s\n", tty->name); /* */ 1770 + printk("cy_hangup %s\n", tty->name); /* */ 1806 1771 #endif 1807 1772 1808 - if (serial_paranoia_check(info, tty->name, "cy_hangup")) 1809 - return; 1810 - 1811 - shutdown(info); 1773 + if (serial_paranoia_check(info, tty->name, "cy_hangup")) 1774 + return; 1775 + 1776 + shutdown(info); 1812 1777 #if 0 1813 - info->event = 0; 1814 - info->count = 0; 1778 + info->event = 0; 1779 + info->count = 0; 1815 1780 #ifdef SERIAL_DEBUG_COUNT 1816 - printk("cyc: %d: setting count to 0\n", __LINE__); 1781 + printk("cyc: %d: setting count to 0\n", __LINE__); 1817 1782 #endif 1818 - info->tty = 0; 1783 + info->tty = 0; 1819 1784 #endif 1820 - info->flags &= ~ASYNC_NORMAL_ACTIVE; 1821 - wake_up_interruptible(&info->open_wait); 1822 - } /* cy_hangup */ 1823 - 1824 - 1785 + info->flags &= ~ASYNC_NORMAL_ACTIVE; 1786 + wake_up_interruptible(&info->open_wait); 1787 + } /* cy_hangup */ 1825 1788 1826 1789 /* 1827 1790 * ------------------------------------------------------------ ··· 1796 1827 */ 1797 1828 1798 1829 static int 1799 - block_til_ready(struct tty_struct *tty, struct file * filp, 1800 - struct cyclades_port *info) 1830 + block_til_ready(struct tty_struct *tty, struct file *filp, 1831 + struct cyclades_port *info) 1801 1832 { 1802 - DECLARE_WAITQUEUE(wait, current); 1803 - unsigned long flags; 1804 - int channel; 1805 - int retval; 1806 - volatile u_char *base_addr = (u_char *)BASE_ADDR; 1833 + DECLARE_WAITQUEUE(wait, current); 1834 + unsigned long flags; 1835 + int channel; 1836 + int retval; 1837 + volatile u_char *base_addr = (u_char *) BASE_ADDR; 1807 1838 1808 - /* 1809 - * If the device is in the middle of being closed, then block 1810 - * until it's done, and then try again. 1811 - */ 1812 - if (info->flags & ASYNC_CLOSING) { 1813 - interruptible_sleep_on(&info->close_wait); 1814 - if (info->flags & ASYNC_HUP_NOTIFY){ 1815 - return -EAGAIN; 1816 - }else{ 1817 - return -ERESTARTSYS; 1839 + /* 1840 + * If the device is in the middle of being closed, then block 1841 + * until it's done, and then try again. 1842 + */ 1843 + if (info->flags & ASYNC_CLOSING) { 1844 + interruptible_sleep_on(&info->close_wait); 1845 + if (info->flags & ASYNC_HUP_NOTIFY) { 1846 + return -EAGAIN; 1847 + } else { 1848 + return -ERESTARTSYS; 1849 + } 1818 1850 } 1819 - } 1820 1851 1821 - /* 1822 - * If non-blocking mode is set, then make the check up front 1823 - * and then exit. 1824 - */ 1825 - if (filp->f_flags & O_NONBLOCK) { 1852 + /* 1853 + * If non-blocking mode is set, then make the check up front 1854 + * and then exit. 1855 + */ 1856 + if (filp->f_flags & O_NONBLOCK) { 1857 + info->flags |= ASYNC_NORMAL_ACTIVE; 1858 + return 0; 1859 + } 1860 + 1861 + /* 1862 + * Block waiting for the carrier detect and the line to become 1863 + * free (i.e., not in use by the callout). While we are in 1864 + * this loop, info->count is dropped by one, so that 1865 + * cy_close() knows when to free things. We restore it upon 1866 + * exit, either normal or abnormal. 1867 + */ 1868 + retval = 0; 1869 + add_wait_queue(&info->open_wait, &wait); 1870 + #ifdef SERIAL_DEBUG_OPEN 1871 + printk("block_til_ready before block: %s, count = %d\n", 1872 + tty->name, info->count); 1873 + /**/ 1874 + #endif 1875 + info->count--; 1876 + #ifdef SERIAL_DEBUG_COUNT 1877 + printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count); 1878 + #endif 1879 + info->blocked_open++; 1880 + 1881 + channel = info->line; 1882 + 1883 + while (1) { 1884 + local_irq_save(flags); 1885 + base_addr[CyCAR] = (u_char) channel; 1886 + base_addr[CyMSVR1] = CyRTS; 1887 + /* CP('S');CP('4'); */ 1888 + base_addr[CyMSVR2] = CyDTR; 1889 + #ifdef SERIAL_DEBUG_DTR 1890 + printk("cyc: %d: raising DTR\n", __LINE__); 1891 + printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], 1892 + base_addr[CyMSVR2]); 1893 + #endif 1894 + local_irq_restore(flags); 1895 + set_current_state(TASK_INTERRUPTIBLE); 1896 + if (tty_hung_up_p(filp) 1897 + || !(info->flags & ASYNC_INITIALIZED)) { 1898 + if (info->flags & ASYNC_HUP_NOTIFY) { 1899 + retval = -EAGAIN; 1900 + } else { 1901 + retval = -ERESTARTSYS; 1902 + } 1903 + break; 1904 + } 1905 + local_irq_save(flags); 1906 + base_addr[CyCAR] = (u_char) channel; 1907 + /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */ 1908 + if (!(info->flags & ASYNC_CLOSING) 1909 + && (C_CLOCAL(tty) 1910 + || (base_addr[CyMSVR1] & CyDCD))) { 1911 + local_irq_restore(flags); 1912 + break; 1913 + } 1914 + local_irq_restore(flags); 1915 + if (signal_pending(current)) { 1916 + retval = -ERESTARTSYS; 1917 + break; 1918 + } 1919 + #ifdef SERIAL_DEBUG_OPEN 1920 + printk("block_til_ready blocking: %s, count = %d\n", 1921 + tty->name, info->count); 1922 + /**/ 1923 + #endif 1924 + schedule(); 1925 + } 1926 + current->state = TASK_RUNNING; 1927 + remove_wait_queue(&info->open_wait, &wait); 1928 + if (!tty_hung_up_p(filp)) { 1929 + info->count++; 1930 + #ifdef SERIAL_DEBUG_COUNT 1931 + printk("cyc: %d: incrementing count to %d\n", __LINE__, 1932 + info->count); 1933 + #endif 1934 + } 1935 + info->blocked_open--; 1936 + #ifdef SERIAL_DEBUG_OPEN 1937 + printk("block_til_ready after blocking: %s, count = %d\n", 1938 + tty->name, info->count); 1939 + /**/ 1940 + #endif 1941 + if (retval) 1942 + return retval; 1826 1943 info->flags |= ASYNC_NORMAL_ACTIVE; 1827 1944 return 0; 1828 - } 1829 - 1830 - /* 1831 - * Block waiting for the carrier detect and the line to become 1832 - * free (i.e., not in use by the callout). While we are in 1833 - * this loop, info->count is dropped by one, so that 1834 - * cy_close() knows when to free things. We restore it upon 1835 - * exit, either normal or abnormal. 1836 - */ 1837 - retval = 0; 1838 - add_wait_queue(&info->open_wait, &wait); 1839 - #ifdef SERIAL_DEBUG_OPEN 1840 - printk("block_til_ready before block: %s, count = %d\n", 1841 - tty->name, info->count);/**/ 1842 - #endif 1843 - info->count--; 1844 - #ifdef SERIAL_DEBUG_COUNT 1845 - printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count); 1846 - #endif 1847 - info->blocked_open++; 1848 - 1849 - channel = info->line; 1850 - 1851 - while (1) { 1852 - local_irq_save(flags); 1853 - base_addr[CyCAR] = (u_char)channel; 1854 - base_addr[CyMSVR1] = CyRTS; 1855 - /* CP('S');CP('4'); */ 1856 - base_addr[CyMSVR2] = CyDTR; 1857 - #ifdef SERIAL_DEBUG_DTR 1858 - printk("cyc: %d: raising DTR\n", __LINE__); 1859 - printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1860 - #endif 1861 - local_irq_restore(flags); 1862 - set_current_state(TASK_INTERRUPTIBLE); 1863 - if (tty_hung_up_p(filp) 1864 - || !(info->flags & ASYNC_INITIALIZED) ){ 1865 - if (info->flags & ASYNC_HUP_NOTIFY) { 1866 - retval = -EAGAIN; 1867 - }else{ 1868 - retval = -ERESTARTSYS; 1869 - } 1870 - break; 1871 - } 1872 - local_irq_save(flags); 1873 - base_addr[CyCAR] = (u_char)channel; 1874 - /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */ 1875 - if (!(info->flags & ASYNC_CLOSING) 1876 - && (C_CLOCAL(tty) 1877 - || (base_addr[CyMSVR1] & CyDCD))) { 1878 - local_irq_restore(flags); 1879 - break; 1880 - } 1881 - local_irq_restore(flags); 1882 - if (signal_pending(current)) { 1883 - retval = -ERESTARTSYS; 1884 - break; 1885 - } 1886 - #ifdef SERIAL_DEBUG_OPEN 1887 - printk("block_til_ready blocking: %s, count = %d\n", 1888 - tty->name, info->count);/**/ 1889 - #endif 1890 - schedule(); 1891 - } 1892 - current->state = TASK_RUNNING; 1893 - remove_wait_queue(&info->open_wait, &wait); 1894 - if (!tty_hung_up_p(filp)){ 1895 - info->count++; 1896 - #ifdef SERIAL_DEBUG_COUNT 1897 - printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count); 1898 - #endif 1899 - } 1900 - info->blocked_open--; 1901 - #ifdef SERIAL_DEBUG_OPEN 1902 - printk("block_til_ready after blocking: %s, count = %d\n", 1903 - tty->name, info->count);/**/ 1904 - #endif 1905 - if (retval) 1906 - return retval; 1907 - info->flags |= ASYNC_NORMAL_ACTIVE; 1908 - return 0; 1909 - } /* block_til_ready */ 1945 + } /* block_til_ready */ 1910 1946 1911 1947 /* 1912 1948 * This routine is called whenever a serial port is opened. It 1913 1949 * performs the serial-specific initialization for the tty structure. 1914 1950 */ 1915 - int 1916 - cy_open(struct tty_struct *tty, struct file * filp) 1951 + int cy_open(struct tty_struct *tty, struct file *filp) 1917 1952 { 1918 - struct cyclades_port *info; 1919 - int retval, line; 1953 + struct cyclades_port *info; 1954 + int retval, line; 1920 1955 1921 1956 /* CP('O'); */ 1922 - line = tty->index; 1923 - if ((line < 0) || (NR_PORTS <= line)){ 1924 - return -ENODEV; 1925 - } 1926 - info = &cy_port[line]; 1927 - if (info->line < 0){ 1928 - return -ENODEV; 1929 - } 1957 + line = tty->index; 1958 + if ((line < 0) || (NR_PORTS <= line)) { 1959 + return -ENODEV; 1960 + } 1961 + info = &cy_port[line]; 1962 + if (info->line < 0) { 1963 + return -ENODEV; 1964 + } 1930 1965 #ifdef SERIAL_DEBUG_OTHER 1931 - printk("cy_open %s\n", tty->name); /* */ 1966 + printk("cy_open %s\n", tty->name); /* */ 1932 1967 #endif 1933 - if (serial_paranoia_check(info, tty->name, "cy_open")){ 1934 - return -ENODEV; 1935 - } 1968 + if (serial_paranoia_check(info, tty->name, "cy_open")) { 1969 + return -ENODEV; 1970 + } 1936 1971 #ifdef SERIAL_DEBUG_OPEN 1937 - printk("cy_open %s, count = %d\n", tty->name, info->count);/**/ 1972 + printk("cy_open %s, count = %d\n", tty->name, info->count); 1973 + /**/ 1938 1974 #endif 1939 - info->count++; 1975 + info->count++; 1940 1976 #ifdef SERIAL_DEBUG_COUNT 1941 - printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count); 1977 + printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count); 1942 1978 #endif 1943 - tty->driver_data = info; 1944 - info->tty = tty; 1979 + tty->driver_data = info; 1980 + info->tty = tty; 1945 1981 1946 - /* 1947 - * Start up serial port 1948 - */ 1949 - retval = startup(info); 1950 - if (retval){ 1951 - return retval; 1952 - } 1982 + /* 1983 + * Start up serial port 1984 + */ 1985 + retval = startup(info); 1986 + if (retval) { 1987 + return retval; 1988 + } 1953 1989 1954 - retval = block_til_ready(tty, filp, info); 1955 - if (retval) { 1990 + retval = block_til_ready(tty, filp, info); 1991 + if (retval) { 1956 1992 #ifdef SERIAL_DEBUG_OPEN 1957 - printk("cy_open returning after block_til_ready with %d\n", 1958 - retval); 1993 + printk("cy_open returning after block_til_ready with %d\n", 1994 + retval); 1959 1995 #endif 1960 - return retval; 1961 - } 1962 - 1996 + return retval; 1997 + } 1963 1998 #ifdef SERIAL_DEBUG_OPEN 1964 - printk("cy_open done\n");/**/ 1999 + printk("cy_open done\n"); 2000 + /**/ 1965 2001 #endif 1966 - return 0; 1967 - } /* cy_open */ 1968 - 1969 - 2002 + return 0; 2003 + } /* cy_open */ 1970 2004 1971 2005 /* 1972 2006 * --------------------------------------------------------------------- ··· 1984 2012 * number, and identifies which options were configured into this 1985 2013 * driver. 1986 2014 */ 1987 - static void 1988 - show_version(void) 2015 + static void show_version(void) 1989 2016 { 1990 - printk("MVME166/167 cd2401 driver\n"); 1991 - } /* show_version */ 2017 + printk("MVME166/167 cd2401 driver\n"); 2018 + } /* show_version */ 1992 2019 1993 2020 /* initialize chips on card -- return number of valid 1994 2021 chips (which is number of ports/4) */ ··· 2001 2030 * ... I wonder what I should do if this fails ... 2002 2031 */ 2003 2032 2004 - void 2005 - mvme167_serial_console_setup(int cflag) 2033 + void mvme167_serial_console_setup(int cflag) 2006 2034 { 2007 - volatile unsigned char* base_addr = (u_char *)BASE_ADDR; 2035 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 2008 2036 int ch; 2009 2037 u_char spd; 2010 2038 u_char rcor, rbpr, badspeed = 0; ··· 2032 2062 2033 2063 /* OK, we have chosen a speed, now reset and reinitialise */ 2034 2064 2035 - my_udelay(20000L); /* Allow time for any active o/p to complete */ 2036 - if(base_addr[CyCCR] != 0x00){ 2037 - local_irq_restore(flags); 2038 - /* printk(" chip is never idle (CCR != 0)\n"); */ 2039 - return; 2040 - } 2065 + my_udelay(20000L); /* Allow time for any active o/p to complete */ 2066 + if (base_addr[CyCCR] != 0x00) { 2067 + local_irq_restore(flags); 2068 + /* printk(" chip is never idle (CCR != 0)\n"); */ 2069 + return; 2070 + } 2041 2071 2042 - base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */ 2043 - my_udelay(1000L); 2072 + base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */ 2073 + my_udelay(1000L); 2044 2074 2045 - if(base_addr[CyGFRCR] == 0x00){ 2046 - local_irq_restore(flags); 2047 - /* printk(" chip is not responding (GFRCR stayed 0)\n"); */ 2048 - return; 2049 - } 2075 + if (base_addr[CyGFRCR] == 0x00) { 2076 + local_irq_restore(flags); 2077 + /* printk(" chip is not responding (GFRCR stayed 0)\n"); */ 2078 + return; 2079 + } 2050 2080 2051 2081 /* 2052 2082 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms ··· 2055 2085 2056 2086 base_addr[CyTPR] = 10; 2057 2087 2058 - base_addr[CyPILR1] = 0x01; /* Interrupt level for modem change */ 2059 - base_addr[CyPILR2] = 0x02; /* Interrupt level for tx ints */ 2060 - base_addr[CyPILR3] = 0x03; /* Interrupt level for rx ints */ 2088 + base_addr[CyPILR1] = 0x01; /* Interrupt level for modem change */ 2089 + base_addr[CyPILR2] = 0x02; /* Interrupt level for tx ints */ 2090 + base_addr[CyPILR3] = 0x03; /* Interrupt level for rx ints */ 2061 2091 2062 2092 /* 2063 2093 * Attempt to set up all channels to something reasonable, and ··· 2065 2095 * the ammount of fiddling we have to do in normal running. 2066 2096 */ 2067 2097 2068 - for (ch = 3; ch >= 0 ; ch--) { 2069 - base_addr[CyCAR] = (u_char)ch; 2098 + for (ch = 3; ch >= 0; ch--) { 2099 + base_addr[CyCAR] = (u_char) ch; 2070 2100 base_addr[CyIER] = 0; 2071 2101 base_addr[CyCMR] = CyASYNC; 2072 - base_addr[CyLICR] = (u_char)ch << 2; 2102 + base_addr[CyLICR] = (u_char) ch << 2; 2073 2103 base_addr[CyLIVR] = 0x5c; 2074 2104 base_addr[CyTCOR] = baud_co[spd]; 2075 2105 base_addr[CyTBPR] = baud_bpr[spd]; ··· 2088 2118 base_addr[CyCOR7] = 0; 2089 2119 base_addr[CyRTPRL] = 2; 2090 2120 base_addr[CyRTPRH] = 0; 2091 - base_addr[CyMSVR1] = 0; 2092 - base_addr[CyMSVR2] = 0; 2093 - write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR); 2121 + base_addr[CyMSVR1] = 0; 2122 + base_addr[CyMSVR2] = 0; 2123 + write_cy_cmd(base_addr, CyINIT_CHAN | CyDIS_RCVR | CyDIS_XMTR); 2094 2124 } 2095 2125 2096 2126 /* 2097 2127 * Now do specials for channel zero.... 2098 2128 */ 2099 2129 2100 - base_addr[CyMSVR1] = CyRTS; 2101 - base_addr[CyMSVR2] = CyDTR; 2130 + base_addr[CyMSVR1] = CyRTS; 2131 + base_addr[CyMSVR2] = CyDTR; 2102 2132 base_addr[CyIER] = CyRxData; 2103 - write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR); 2133 + write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR); 2104 2134 2105 2135 local_irq_restore(flags); 2106 2136 2107 2137 my_udelay(20000L); /* Let it all settle down */ 2108 2138 2109 - printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]); 2139 + printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]); 2110 2140 if (badspeed) 2111 - printk(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n", 2112 - rcor >> 5, rbpr); 2113 - } /* serial_console_init */ 2141 + printk 2142 + (" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n", 2143 + rcor >> 5, rbpr); 2144 + } /* serial_console_init */ 2114 2145 2115 2146 static const struct tty_operations cy_ops = { 2116 2147 .open = cy_open, ··· 2132 2161 .tiocmget = cy_tiocmget, 2133 2162 .tiocmset = cy_tiocmset, 2134 2163 }; 2164 + 2135 2165 /* The serial driver boot-time initialization code! 2136 2166 Hardware I/O ports are mapped to character special devices on a 2137 2167 first found, first allocated manner. That is, this code searches ··· 2149 2177 If there are more cards with more ports than have been statically 2150 2178 allocated above, a warning is printed and the extra ports are ignored. 2151 2179 */ 2152 - static int __init 2153 - serial167_init(void) 2180 + static int __init serial167_init(void) 2154 2181 { 2155 - struct cyclades_port *info; 2156 - int ret = 0; 2157 - int good_ports = 0; 2158 - int port_num = 0; 2159 - int index; 2160 - int DefSpeed; 2182 + struct cyclades_port *info; 2183 + int ret = 0; 2184 + int good_ports = 0; 2185 + int port_num = 0; 2186 + int index; 2187 + int DefSpeed; 2161 2188 #ifdef notyet 2162 - struct sigaction sa; 2189 + struct sigaction sa; 2163 2190 #endif 2164 2191 2165 - if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401)) 2166 - return 0; 2192 + if (!(mvme16x_config & MVME16x_CONFIG_GOT_CD2401)) 2193 + return 0; 2167 2194 2168 - cy_serial_driver = alloc_tty_driver(NR_PORTS); 2169 - if (!cy_serial_driver) 2170 - return -ENOMEM; 2195 + cy_serial_driver = alloc_tty_driver(NR_PORTS); 2196 + if (!cy_serial_driver) 2197 + return -ENOMEM; 2171 2198 2172 2199 #if 0 2173 - scrn[1] = '\0'; 2200 + scrn[1] = '\0'; 2174 2201 #endif 2175 2202 2176 - show_version(); 2203 + show_version(); 2177 2204 2178 - /* Has "console=0,9600n8" been used in bootinfo to change speed? */ 2179 - if (serial_console_cflag) 2180 - DefSpeed = serial_console_cflag & 0017; 2181 - else { 2182 - DefSpeed = initial_console_speed; 2183 - serial_console_info = &cy_port[0]; 2184 - serial_console_cflag = DefSpeed | CS8; 2205 + /* Has "console=0,9600n8" been used in bootinfo to change speed? */ 2206 + if (serial_console_cflag) 2207 + DefSpeed = serial_console_cflag & 0017; 2208 + else { 2209 + DefSpeed = initial_console_speed; 2210 + serial_console_info = &cy_port[0]; 2211 + serial_console_cflag = DefSpeed | CS8; 2185 2212 #if 0 2186 - serial_console = 64; /*callout_driver.minor_start*/ 2213 + serial_console = 64; /*callout_driver.minor_start */ 2187 2214 #endif 2188 - } 2189 - 2190 - /* Initialize the tty_driver structure */ 2191 - 2192 - cy_serial_driver->owner = THIS_MODULE; 2193 - cy_serial_driver->name = "ttyS"; 2194 - cy_serial_driver->major = TTY_MAJOR; 2195 - cy_serial_driver->minor_start = 64; 2196 - cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 2197 - cy_serial_driver->subtype = SERIAL_TYPE_NORMAL; 2198 - cy_serial_driver->init_termios = tty_std_termios; 2199 - cy_serial_driver->init_termios.c_cflag = 2200 - B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2201 - cy_serial_driver->flags = TTY_DRIVER_REAL_RAW; 2202 - tty_set_operations(cy_serial_driver, &cy_ops); 2203 - 2204 - ret = tty_register_driver(cy_serial_driver); 2205 - if (ret) { 2206 - printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n"); 2207 - put_tty_driver(cy_serial_driver); 2208 - return ret; 2209 - } 2210 - 2211 - port_num = 0; 2212 - info = cy_port; 2213 - for (index = 0; index < 1; index++) { 2214 - 2215 - good_ports = 4; 2216 - 2217 - if(port_num < NR_PORTS){ 2218 - while( good_ports-- && port_num < NR_PORTS){ 2219 - /*** initialize port ***/ 2220 - info->magic = CYCLADES_MAGIC; 2221 - info->type = PORT_CIRRUS; 2222 - info->card = index; 2223 - info->line = port_num; 2224 - info->flags = STD_COM_FLAGS; 2225 - info->tty = NULL; 2226 - info->xmit_fifo_size = 12; 2227 - info->cor1 = CyPARITY_NONE|Cy_8_BITS; 2228 - info->cor2 = CyETC; 2229 - info->cor3 = Cy_1_STOP; 2230 - info->cor4 = 0x08; /* _very_ small receive threshold */ 2231 - info->cor5 = 0; 2232 - info->cor6 = 0; 2233 - info->cor7 = 0; 2234 - info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */ 2235 - info->tco = baud_co[DefSpeed]; /* Tx CO */ 2236 - info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */ 2237 - info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */ 2238 - info->close_delay = 0; 2239 - info->x_char = 0; 2240 - info->event = 0; 2241 - info->count = 0; 2242 - #ifdef SERIAL_DEBUG_COUNT 2243 - printk("cyc: %d: setting count to 0\n", __LINE__); 2244 - #endif 2245 - info->blocked_open = 0; 2246 - info->default_threshold = 0; 2247 - info->default_timeout = 0; 2248 - INIT_WORK(&info->tqueue, do_softint); 2249 - init_waitqueue_head(&info->open_wait); 2250 - init_waitqueue_head(&info->close_wait); 2251 - /* info->session */ 2252 - /* info->pgrp */ 2253 - /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/ 2254 - info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK 2255 - | CyPARITY| CyFRAME| CyOVERRUN; 2256 - /* info->timeout */ 2257 - 2258 - printk("ttyS%d ", info->line); 2259 - port_num++;info++; 2260 - if(!(port_num & 7)){ 2261 - printk("\n "); 2262 - } 2263 - } 2264 2215 } 2265 - printk("\n"); 2266 - } 2267 - while( port_num < NR_PORTS){ 2268 - info->line = -1; 2269 - port_num++;info++; 2270 - } 2271 - #ifdef CONFIG_REMOTE_DEBUG 2272 - debug_setup(); 2216 + 2217 + /* Initialize the tty_driver structure */ 2218 + 2219 + cy_serial_driver->owner = THIS_MODULE; 2220 + cy_serial_driver->name = "ttyS"; 2221 + cy_serial_driver->major = TTY_MAJOR; 2222 + cy_serial_driver->minor_start = 64; 2223 + cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 2224 + cy_serial_driver->subtype = SERIAL_TYPE_NORMAL; 2225 + cy_serial_driver->init_termios = tty_std_termios; 2226 + cy_serial_driver->init_termios.c_cflag = 2227 + B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2228 + cy_serial_driver->flags = TTY_DRIVER_REAL_RAW; 2229 + tty_set_operations(cy_serial_driver, &cy_ops); 2230 + 2231 + ret = tty_register_driver(cy_serial_driver); 2232 + if (ret) { 2233 + printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n"); 2234 + put_tty_driver(cy_serial_driver); 2235 + return ret; 2236 + } 2237 + 2238 + port_num = 0; 2239 + info = cy_port; 2240 + for (index = 0; index < 1; index++) { 2241 + 2242 + good_ports = 4; 2243 + 2244 + if (port_num < NR_PORTS) { 2245 + while (good_ports-- && port_num < NR_PORTS) { 2246 + /*** initialize port ***/ 2247 + info->magic = CYCLADES_MAGIC; 2248 + info->type = PORT_CIRRUS; 2249 + info->card = index; 2250 + info->line = port_num; 2251 + info->flags = STD_COM_FLAGS; 2252 + info->tty = NULL; 2253 + info->xmit_fifo_size = 12; 2254 + info->cor1 = CyPARITY_NONE | Cy_8_BITS; 2255 + info->cor2 = CyETC; 2256 + info->cor3 = Cy_1_STOP; 2257 + info->cor4 = 0x08; /* _very_ small receive threshold */ 2258 + info->cor5 = 0; 2259 + info->cor6 = 0; 2260 + info->cor7 = 0; 2261 + info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */ 2262 + info->tco = baud_co[DefSpeed]; /* Tx CO */ 2263 + info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */ 2264 + info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */ 2265 + info->close_delay = 0; 2266 + info->x_char = 0; 2267 + info->event = 0; 2268 + info->count = 0; 2269 + #ifdef SERIAL_DEBUG_COUNT 2270 + printk("cyc: %d: setting count to 0\n", 2271 + __LINE__); 2273 2272 #endif 2274 - ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0, 2275 - "cd2401_errors", cd2401_rxerr_interrupt); 2276 - if (ret) { 2277 - printk(KERN_ERR "Could't get cd2401_errors IRQ"); 2278 - goto cleanup_serial_driver; 2279 - } 2273 + info->blocked_open = 0; 2274 + info->default_threshold = 0; 2275 + info->default_timeout = 0; 2276 + INIT_WORK(&info->tqueue, do_softint); 2277 + init_waitqueue_head(&info->open_wait); 2278 + init_waitqueue_head(&info->close_wait); 2279 + /* info->session */ 2280 + /* info->pgrp */ 2281 + /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/ 2282 + info->read_status_mask = 2283 + CyTIMEOUT | CySPECHAR | CyBREAK | CyPARITY | 2284 + CyFRAME | CyOVERRUN; 2285 + /* info->timeout */ 2280 2286 2281 - ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0, 2282 - "cd2401_modem", cd2401_modem_interrupt); 2283 - if (ret) { 2284 - printk(KERN_ERR "Could't get cd2401_modem IRQ"); 2285 - goto cleanup_irq_cd2401_errors; 2286 - } 2287 + printk("ttyS%d ", info->line); 2288 + port_num++; 2289 + info++; 2290 + if (!(port_num & 7)) { 2291 + printk("\n "); 2292 + } 2293 + } 2294 + } 2295 + printk("\n"); 2296 + } 2297 + while (port_num < NR_PORTS) { 2298 + info->line = -1; 2299 + port_num++; 2300 + info++; 2301 + } 2302 + #ifdef CONFIG_REMOTE_DEBUG 2303 + debug_setup(); 2304 + #endif 2305 + ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0, 2306 + "cd2401_errors", cd2401_rxerr_interrupt); 2307 + if (ret) { 2308 + printk(KERN_ERR "Could't get cd2401_errors IRQ"); 2309 + goto cleanup_serial_driver; 2310 + } 2287 2311 2288 - ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0, 2289 - "cd2401_txints", cd2401_tx_interrupt); 2290 - if (ret) { 2291 - printk(KERN_ERR "Could't get cd2401_txints IRQ"); 2292 - goto cleanup_irq_cd2401_modem; 2293 - } 2312 + ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0, 2313 + "cd2401_modem", cd2401_modem_interrupt); 2314 + if (ret) { 2315 + printk(KERN_ERR "Could't get cd2401_modem IRQ"); 2316 + goto cleanup_irq_cd2401_errors; 2317 + } 2294 2318 2295 - ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0, 2296 - "cd2401_rxints", cd2401_rx_interrupt); 2297 - if (ret) { 2298 - printk(KERN_ERR "Could't get cd2401_rxints IRQ"); 2299 - goto cleanup_irq_cd2401_txints; 2300 - } 2319 + ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0, 2320 + "cd2401_txints", cd2401_tx_interrupt); 2321 + if (ret) { 2322 + printk(KERN_ERR "Could't get cd2401_txints IRQ"); 2323 + goto cleanup_irq_cd2401_modem; 2324 + } 2301 2325 2302 - /* Now we have registered the interrupt handlers, allow the interrupts */ 2326 + ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0, 2327 + "cd2401_rxints", cd2401_rx_interrupt); 2328 + if (ret) { 2329 + printk(KERN_ERR "Could't get cd2401_rxints IRQ"); 2330 + goto cleanup_irq_cd2401_txints; 2331 + } 2303 2332 2304 - pcc2chip[PccSCCMICR] = 0x15; /* Serial ints are level 5 */ 2305 - pcc2chip[PccSCCTICR] = 0x15; 2306 - pcc2chip[PccSCCRICR] = 0x15; 2333 + /* Now we have registered the interrupt handlers, allow the interrupts */ 2307 2334 2308 - pcc2chip[PccIMLR] = 3; /* Allow PCC2 ints above 3!? */ 2335 + pcc2chip[PccSCCMICR] = 0x15; /* Serial ints are level 5 */ 2336 + pcc2chip[PccSCCTICR] = 0x15; 2337 + pcc2chip[PccSCCRICR] = 0x15; 2309 2338 2310 - return 0; 2339 + pcc2chip[PccIMLR] = 3; /* Allow PCC2 ints above 3!? */ 2340 + 2341 + return 0; 2311 2342 cleanup_irq_cd2401_txints: 2312 - free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt); 2343 + free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt); 2313 2344 cleanup_irq_cd2401_modem: 2314 - free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt); 2345 + free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt); 2315 2346 cleanup_irq_cd2401_errors: 2316 - free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt); 2347 + free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt); 2317 2348 cleanup_serial_driver: 2318 - if (tty_unregister_driver(cy_serial_driver)) 2319 - printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n"); 2320 - put_tty_driver(cy_serial_driver); 2321 - return ret; 2322 - } /* serial167_init */ 2349 + if (tty_unregister_driver(cy_serial_driver)) 2350 + printk(KERN_ERR 2351 + "Couldn't unregister MVME166/7 serial driver\n"); 2352 + put_tty_driver(cy_serial_driver); 2353 + return ret; 2354 + } /* serial167_init */ 2323 2355 2324 2356 module_init(serial167_init); 2325 2357 2326 - 2327 2358 #ifdef CYCLOM_SHOW_STATUS 2328 - static void 2329 - show_status(int line_num) 2359 + static void show_status(int line_num) 2330 2360 { 2331 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2332 - int channel; 2333 - struct cyclades_port * info; 2334 - unsigned long flags; 2361 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 2362 + int channel; 2363 + struct cyclades_port *info; 2364 + unsigned long flags; 2335 2365 2336 - info = &cy_port[line_num]; 2337 - channel = info->line; 2338 - printk(" channel %d\n", channel);/**/ 2366 + info = &cy_port[line_num]; 2367 + channel = info->line; 2368 + printk(" channel %d\n", channel); 2369 + /**/ printk(" cy_port\n"); 2370 + printk(" card line flags = %d %d %x\n", 2371 + info->card, info->line, info->flags); 2372 + printk 2373 + (" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n", 2374 + (long)info->tty, info->read_status_mask, info->timeout, 2375 + info->xmit_fifo_size); 2376 + printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n", 2377 + info->cor1, info->cor2, info->cor3, info->cor4, info->cor5, 2378 + info->cor6, info->cor7); 2379 + printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", info->tbpr, info->tco, 2380 + info->rbpr, info->rco); 2381 + printk(" close_delay event count = %d %d %d\n", info->close_delay, 2382 + info->event, info->count); 2383 + printk(" x_char blocked_open = %x %x\n", info->x_char, 2384 + info->blocked_open); 2385 + printk(" open_wait = %lx %lx %lx\n", (long)info->open_wait); 2339 2386 2340 - printk(" cy_port\n"); 2341 - printk(" card line flags = %d %d %x\n", 2342 - info->card, info->line, info->flags); 2343 - printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n", 2344 - (long)info->tty, info->read_status_mask, 2345 - info->timeout, info->xmit_fifo_size); 2346 - printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n", 2347 - info->cor1, info->cor2, info->cor3, info->cor4, info->cor5, 2348 - info->cor6, info->cor7); 2349 - printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", 2350 - info->tbpr, info->tco, info->rbpr, info->rco); 2351 - printk(" close_delay event count = %d %d %d\n", 2352 - info->close_delay, info->event, info->count); 2353 - printk(" x_char blocked_open = %x %x\n", 2354 - info->x_char, info->blocked_open); 2355 - printk(" open_wait = %lx %lx %lx\n", 2356 - (long)info->open_wait); 2357 - 2358 - 2359 - local_irq_save(flags); 2387 + local_irq_save(flags); 2360 2388 2361 2389 /* Global Registers */ 2362 2390 ··· 2370 2398 printk(" CyMIR %x\n", base_addr[CyMIR]); 2371 2399 printk(" CyTPR %x\n", base_addr[CyTPR]); 2372 2400 2373 - base_addr[CyCAR] = (u_char)channel; 2401 + base_addr[CyCAR] = (u_char) channel; 2374 2402 2375 2403 /* Virtual Registers */ 2376 2404 ··· 2414 2442 printk(" CyTBPR %x\n", base_addr[CyTBPR]); 2415 2443 printk(" CyTCOR %x\n", base_addr[CyTCOR]); 2416 2444 2417 - local_irq_restore(flags); 2418 - } /* show_status */ 2445 + local_irq_restore(flags); 2446 + } /* show_status */ 2419 2447 #endif 2420 - 2421 2448 2422 2449 #if 0 2423 2450 /* Dummy routine in mvme16x/config.c for now */ ··· 2430 2459 int cflag = 0; 2431 2460 2432 2461 /* Sanity check. */ 2433 - if (ints[0] > 3 || ints[1] > 3) return; 2462 + if (ints[0] > 3 || ints[1] > 3) 2463 + return; 2434 2464 2435 2465 /* Get baud, bits and parity */ 2436 2466 baud = 2400; 2437 2467 bits = 8; 2438 2468 parity = 'n'; 2439 - if (ints[2]) baud = ints[2]; 2469 + if (ints[2]) 2470 + baud = ints[2]; 2440 2471 if ((s = strchr(str, ','))) { 2441 2472 do { 2442 2473 s++; 2443 - } while(*s >= '0' && *s <= '9'); 2444 - if (*s) parity = *s++; 2445 - if (*s) bits = *s - '0'; 2474 + } while (*s >= '0' && *s <= '9'); 2475 + if (*s) 2476 + parity = *s++; 2477 + if (*s) 2478 + bits = *s - '0'; 2446 2479 } 2447 2480 2448 2481 /* Now construct a cflag setting. */ 2449 - switch(baud) { 2450 - case 1200: 2451 - cflag |= B1200; 2452 - break; 2453 - case 9600: 2454 - cflag |= B9600; 2455 - break; 2456 - case 19200: 2457 - cflag |= B19200; 2458 - break; 2459 - case 38400: 2460 - cflag |= B38400; 2461 - break; 2462 - case 2400: 2463 - default: 2464 - cflag |= B2400; 2465 - break; 2482 + switch (baud) { 2483 + case 1200: 2484 + cflag |= B1200; 2485 + break; 2486 + case 9600: 2487 + cflag |= B9600; 2488 + break; 2489 + case 19200: 2490 + cflag |= B19200; 2491 + break; 2492 + case 38400: 2493 + cflag |= B38400; 2494 + break; 2495 + case 2400: 2496 + default: 2497 + cflag |= B2400; 2498 + break; 2466 2499 } 2467 - switch(bits) { 2468 - case 7: 2469 - cflag |= CS7; 2470 - break; 2471 - default: 2472 - case 8: 2473 - cflag |= CS8; 2474 - break; 2500 + switch (bits) { 2501 + case 7: 2502 + cflag |= CS7; 2503 + break; 2504 + default: 2505 + case 8: 2506 + cflag |= CS8; 2507 + break; 2475 2508 } 2476 - switch(parity) { 2477 - case 'o': case 'O': 2478 - cflag |= PARODD; 2479 - break; 2480 - case 'e': case 'E': 2481 - cflag |= PARENB; 2482 - break; 2509 + switch (parity) { 2510 + case 'o': 2511 + case 'O': 2512 + cflag |= PARODD; 2513 + break; 2514 + case 'e': 2515 + case 'E': 2516 + cflag |= PARENB; 2517 + break; 2483 2518 } 2484 2519 2485 2520 serial_console_info = &cy_port[ints[1]]; 2486 2521 serial_console_cflag = cflag; 2487 - serial_console = ints[1] + 64; /*callout_driver.minor_start*/ 2522 + serial_console = ints[1] + 64; /*callout_driver.minor_start */ 2488 2523 } 2489 2524 #endif 2490 2525 ··· 2509 2532 * The console must be locked when we get here. 2510 2533 */ 2511 2534 2512 - void serial167_console_write(struct console *co, const char *str, unsigned count) 2535 + void serial167_console_write(struct console *co, const char *str, 2536 + unsigned count) 2513 2537 { 2514 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2538 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 2515 2539 unsigned long flags; 2516 2540 volatile u_char sink; 2517 2541 u_char ier; ··· 2525 2547 /* Ensure transmitter is enabled! */ 2526 2548 2527 2549 port = 0; 2528 - base_addr[CyCAR] = (u_char)port; 2550 + base_addr[CyCAR] = (u_char) port; 2529 2551 while (base_addr[CyCCR]) 2530 2552 ; 2531 2553 base_addr[CyCCR] = CyENB_XMTR; ··· 2534 2556 base_addr[CyIER] = CyTxMpty; 2535 2557 2536 2558 while (1) { 2537 - if (pcc2chip[PccSCCTICR] & 0x20) 2538 - { 2559 + if (pcc2chip[PccSCCTICR] & 0x20) { 2539 2560 /* We have a Tx int. Acknowledge it */ 2540 2561 sink = pcc2chip[PccTPIACKR]; 2541 2562 if ((base_addr[CyLICR] >> 2) == port) { ··· 2548 2571 str++; 2549 2572 i++; 2550 2573 do_lf = 0; 2551 - } 2552 - else if (*str == '\n') { 2574 + } else if (*str == '\n') { 2553 2575 base_addr[CyTDR] = '\r'; 2554 2576 do_lf = 1; 2555 - } 2556 - else { 2577 + } else { 2557 2578 base_addr[CyTDR] = *str++; 2558 2579 i++; 2559 2580 } 2560 2581 base_addr[CyTEOIR] = 0; 2561 - } 2562 - else 2582 + } else 2563 2583 base_addr[CyTEOIR] = CyNOTRANS; 2564 2584 } 2565 2585 } ··· 2566 2592 local_irq_restore(flags); 2567 2593 } 2568 2594 2569 - static struct tty_driver *serial167_console_device(struct console *c, int *index) 2595 + static struct tty_driver *serial167_console_device(struct console *c, 2596 + int *index) 2570 2597 { 2571 2598 *index = c->index; 2572 2599 return cy_serial_driver; 2573 2600 } 2574 - 2575 2601 2576 2602 static int __init serial167_console_setup(struct console *co, char *options) 2577 2603 { 2578 2604 return 0; 2579 2605 } 2580 2606 2581 - 2582 2607 static struct console sercons = { 2583 - .name = "ttyS", 2584 - .write = serial167_console_write, 2585 - .device = serial167_console_device, 2586 - .setup = serial167_console_setup, 2587 - .flags = CON_PRINTBUFFER, 2588 - .index = -1, 2608 + .name = "ttyS", 2609 + .write = serial167_console_write, 2610 + .device = serial167_console_device, 2611 + .setup = serial167_console_setup, 2612 + .flags = CON_PRINTBUFFER, 2613 + .index = -1, 2589 2614 }; 2590 - 2591 2615 2592 2616 static int __init serial167_console_init(void) 2593 2617 { 2594 2618 if (vme_brdtype == VME_TYPE_MVME166 || 2595 - vme_brdtype == VME_TYPE_MVME167 || 2596 - vme_brdtype == VME_TYPE_MVME177) { 2619 + vme_brdtype == VME_TYPE_MVME167 || 2620 + vme_brdtype == VME_TYPE_MVME177) { 2597 2621 mvme167_serial_console_setup(0); 2598 2622 register_console(&sercons); 2599 2623 } 2600 2624 return 0; 2601 2625 } 2626 + 2602 2627 console_initcall(serial167_console_init); 2603 2628 2604 2629 #ifdef CONFIG_REMOTE_DEBUG 2605 - void putDebugChar (int c) 2630 + void putDebugChar(int c) 2606 2631 { 2607 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2632 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 2608 2633 unsigned long flags; 2609 2634 volatile u_char sink; 2610 2635 u_char ier; ··· 2614 2641 /* Ensure transmitter is enabled! */ 2615 2642 2616 2643 port = DEBUG_PORT; 2617 - base_addr[CyCAR] = (u_char)port; 2644 + base_addr[CyCAR] = (u_char) port; 2618 2645 while (base_addr[CyCCR]) 2619 2646 ; 2620 2647 base_addr[CyCCR] = CyENB_XMTR; ··· 2623 2650 base_addr[CyIER] = CyTxMpty; 2624 2651 2625 2652 while (1) { 2626 - if (pcc2chip[PccSCCTICR] & 0x20) 2627 - { 2653 + if (pcc2chip[PccSCCTICR] & 0x20) { 2628 2654 /* We have a Tx int. Acknowledge it */ 2629 2655 sink = pcc2chip[PccTPIACKR]; 2630 2656 if ((base_addr[CyLICR] >> 2) == port) { 2631 2657 base_addr[CyTDR] = c; 2632 2658 base_addr[CyTEOIR] = 0; 2633 2659 break; 2634 - } 2635 - else 2660 + } else 2636 2661 base_addr[CyTEOIR] = CyNOTRANS; 2637 2662 } 2638 2663 } ··· 2642 2671 2643 2672 int getDebugChar() 2644 2673 { 2645 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2674 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 2646 2675 unsigned long flags; 2647 2676 volatile u_char sink; 2648 2677 u_char ier; ··· 2664 2693 /* Ensure receiver is enabled! */ 2665 2694 2666 2695 port = DEBUG_PORT; 2667 - base_addr[CyCAR] = (u_char)port; 2696 + base_addr[CyCAR] = (u_char) port; 2668 2697 #if 0 2669 2698 while (base_addr[CyCCR]) 2670 2699 ; ··· 2674 2703 base_addr[CyIER] = CyRxData; 2675 2704 2676 2705 while (1) { 2677 - if (pcc2chip[PccSCCRICR] & 0x20) 2678 - { 2706 + if (pcc2chip[PccSCCRICR] & 0x20) { 2679 2707 /* We have a Rx int. Acknowledge it */ 2680 2708 sink = pcc2chip[PccRPIACKR]; 2681 2709 if ((base_addr[CyLICR] >> 2) == port) { 2682 2710 int cnt = base_addr[CyRFOC]; 2683 - while (cnt-- > 0) 2684 - { 2711 + while (cnt-- > 0) { 2685 2712 c = base_addr[CyRDR]; 2686 2713 if (c == 0) 2687 - printk ("!! debug char is null (cnt=%d) !!", cnt); 2714 + printk 2715 + ("!! debug char is null (cnt=%d) !!", 2716 + cnt); 2688 2717 else 2689 - queueDebugChar (c); 2718 + queueDebugChar(c); 2690 2719 } 2691 2720 base_addr[CyREOIR] = 0; 2692 2721 i = debugiq.out; 2693 2722 if (i == debugiq.in) 2694 - panic ("Debug input queue empty!"); 2723 + panic("Debug input queue empty!"); 2695 2724 c = debugiq.buf[i]; 2696 2725 if (++i == DEBUG_LEN) 2697 2726 i = 0; 2698 2727 debugiq.out = i; 2699 2728 break; 2700 - } 2701 - else 2729 + } else 2702 2730 base_addr[CyREOIR] = CyNOTRANS; 2703 2731 } 2704 2732 } ··· 2709 2739 return (c); 2710 2740 } 2711 2741 2712 - void queueDebugChar (int c) 2742 + void queueDebugChar(int c) 2713 2743 { 2714 2744 int i; 2715 2745 ··· 2721 2751 debugiq.in = i; 2722 2752 } 2723 2753 2724 - static void 2725 - debug_setup() 2754 + static void debug_setup() 2726 2755 { 2727 - unsigned long flags; 2728 - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2729 - int i, cflag; 2756 + unsigned long flags; 2757 + volatile unsigned char *base_addr = (u_char *) BASE_ADDR; 2758 + int i, cflag; 2730 2759 2731 - cflag = B19200; 2760 + cflag = B19200; 2732 2761 2733 - local_irq_save(flags); 2762 + local_irq_save(flags); 2734 2763 2735 - for (i = 0; i < 4; i++) 2736 - { 2737 - base_addr[CyCAR] = i; 2738 - base_addr[CyLICR] = i << 2; 2739 - } 2764 + for (i = 0; i < 4; i++) { 2765 + base_addr[CyCAR] = i; 2766 + base_addr[CyLICR] = i << 2; 2767 + } 2740 2768 2741 - debugiq.in = debugiq.out = 0; 2769 + debugiq.in = debugiq.out = 0; 2742 2770 2743 - base_addr[CyCAR] = DEBUG_PORT; 2771 + base_addr[CyCAR] = DEBUG_PORT; 2744 2772 2745 - /* baud rate */ 2746 - i = cflag & CBAUD; 2773 + /* baud rate */ 2774 + i = cflag & CBAUD; 2747 2775 2748 - base_addr[CyIER] = 0; 2776 + base_addr[CyIER] = 0; 2749 2777 2750 - base_addr[CyCMR] = CyASYNC; 2751 - base_addr[CyLICR] = DEBUG_PORT << 2; 2752 - base_addr[CyLIVR] = 0x5c; 2778 + base_addr[CyCMR] = CyASYNC; 2779 + base_addr[CyLICR] = DEBUG_PORT << 2; 2780 + base_addr[CyLIVR] = 0x5c; 2753 2781 2754 - /* tx and rx baud rate */ 2782 + /* tx and rx baud rate */ 2755 2783 2756 - base_addr[CyTCOR] = baud_co[i]; 2757 - base_addr[CyTBPR] = baud_bpr[i]; 2758 - base_addr[CyRCOR] = baud_co[i] >> 5; 2759 - base_addr[CyRBPR] = baud_bpr[i]; 2784 + base_addr[CyTCOR] = baud_co[i]; 2785 + base_addr[CyTBPR] = baud_bpr[i]; 2786 + base_addr[CyRCOR] = baud_co[i] >> 5; 2787 + base_addr[CyRBPR] = baud_bpr[i]; 2760 2788 2761 - /* set line characteristics according configuration */ 2789 + /* set line characteristics according configuration */ 2762 2790 2763 - base_addr[CySCHR1] = 0; 2764 - base_addr[CySCHR2] = 0; 2765 - base_addr[CySCRL] = 0; 2766 - base_addr[CySCRH] = 0; 2767 - base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE; 2768 - base_addr[CyCOR2] = 0; 2769 - base_addr[CyCOR3] = Cy_1_STOP; 2770 - base_addr[CyCOR4] = baud_cor4[i]; 2771 - base_addr[CyCOR5] = 0; 2772 - base_addr[CyCOR6] = 0; 2773 - base_addr[CyCOR7] = 0; 2791 + base_addr[CySCHR1] = 0; 2792 + base_addr[CySCHR2] = 0; 2793 + base_addr[CySCRL] = 0; 2794 + base_addr[CySCRH] = 0; 2795 + base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE; 2796 + base_addr[CyCOR2] = 0; 2797 + base_addr[CyCOR3] = Cy_1_STOP; 2798 + base_addr[CyCOR4] = baud_cor4[i]; 2799 + base_addr[CyCOR5] = 0; 2800 + base_addr[CyCOR6] = 0; 2801 + base_addr[CyCOR7] = 0; 2774 2802 2775 - write_cy_cmd(base_addr,CyINIT_CHAN); 2776 - write_cy_cmd(base_addr,CyENB_RCVR); 2803 + write_cy_cmd(base_addr, CyINIT_CHAN); 2804 + write_cy_cmd(base_addr, CyENB_RCVR); 2777 2805 2778 - base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */ 2806 + base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */ 2779 2807 2780 - base_addr[CyRTPRL] = 2; 2781 - base_addr[CyRTPRH] = 0; 2808 + base_addr[CyRTPRL] = 2; 2809 + base_addr[CyRTPRH] = 0; 2782 2810 2783 - base_addr[CyMSVR1] = CyRTS; 2784 - base_addr[CyMSVR2] = CyDTR; 2811 + base_addr[CyMSVR1] = CyRTS; 2812 + base_addr[CyMSVR2] = CyDTR; 2785 2813 2786 - base_addr[CyIER] = CyRxData; 2814 + base_addr[CyIER] = CyRxData; 2787 2815 2788 - local_irq_restore(flags); 2816 + local_irq_restore(flags); 2789 2817 2790 - } /* debug_setup */ 2818 + } /* debug_setup */ 2791 2819 2792 2820 #endif 2793 2821