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

tty: serial: serial_txx9: remove struct uart_txx9_port

It's only a wrapper to struct uart_port, so unwrap the whole code.

No change in functionality is intended.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220307054348.31748-1-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
4f6f194f ab818c7a

+167 -197
+167 -197
drivers/tty/serial/serial_txx9.c
··· 54 54 */ 55 55 #define UART_NR CONFIG_SERIAL_TXX9_NR_UARTS 56 56 57 - struct uart_txx9_port { 58 - struct uart_port port; 59 - /* No additional info for now */ 60 - }; 61 - 62 57 #define TXX9_REGION_SIZE 0x24 63 58 64 59 /* TXX9 Serial Registers */ ··· 155 160 #define TXX9_SIBGR_BCLK_T6 0x00000300 156 161 #define TXX9_SIBGR_BRD_MASK 0x000000ff 157 162 158 - static inline unsigned int sio_in(struct uart_txx9_port *up, int offset) 163 + static inline unsigned int sio_in(struct uart_port *up, int offset) 159 164 { 160 - switch (up->port.iotype) { 165 + switch (up->iotype) { 161 166 default: 162 - return __raw_readl(up->port.membase + offset); 167 + return __raw_readl(up->membase + offset); 163 168 case UPIO_PORT: 164 - return inl(up->port.iobase + offset); 169 + return inl(up->iobase + offset); 165 170 } 166 171 } 167 172 168 173 static inline void 169 - sio_out(struct uart_txx9_port *up, int offset, int value) 174 + sio_out(struct uart_port *up, int offset, int value) 170 175 { 171 - switch (up->port.iotype) { 176 + switch (up->iotype) { 172 177 default: 173 - __raw_writel(value, up->port.membase + offset); 178 + __raw_writel(value, up->membase + offset); 174 179 break; 175 180 case UPIO_PORT: 176 - outl(value, up->port.iobase + offset); 181 + outl(value, up->iobase + offset); 177 182 break; 178 183 } 179 184 } 180 185 181 186 static inline void 182 - sio_mask(struct uart_txx9_port *up, int offset, unsigned int value) 187 + sio_mask(struct uart_port *up, int offset, unsigned int value) 183 188 { 184 189 sio_out(up, offset, sio_in(up, offset) & ~value); 185 190 } 186 191 static inline void 187 - sio_set(struct uart_txx9_port *up, int offset, unsigned int value) 192 + sio_set(struct uart_port *up, int offset, unsigned int value) 188 193 { 189 194 sio_out(up, offset, sio_in(up, offset) | value); 190 195 } 191 196 192 197 static inline void 193 - sio_quot_set(struct uart_txx9_port *up, int quot) 198 + sio_quot_set(struct uart_port *up, int quot) 194 199 { 195 200 quot >>= 1; 196 201 if (quot < 256) ··· 205 210 sio_out(up, TXX9_SIBGR, 0xff | TXX9_SIBGR_BCLK_T6); 206 211 } 207 212 208 - static struct uart_txx9_port *to_uart_txx9_port(struct uart_port *port) 213 + static void serial_txx9_stop_tx(struct uart_port *up) 209 214 { 210 - return container_of(port, struct uart_txx9_port, port); 211 - } 212 - 213 - static void serial_txx9_stop_tx(struct uart_port *port) 214 - { 215 - struct uart_txx9_port *up = to_uart_txx9_port(port); 216 215 sio_mask(up, TXX9_SIDICR, TXX9_SIDICR_TIE); 217 216 } 218 217 219 - static void serial_txx9_start_tx(struct uart_port *port) 218 + static void serial_txx9_start_tx(struct uart_port *up) 220 219 { 221 - struct uart_txx9_port *up = to_uart_txx9_port(port); 222 220 sio_set(up, TXX9_SIDICR, TXX9_SIDICR_TIE); 223 221 } 224 222 225 - static void serial_txx9_stop_rx(struct uart_port *port) 223 + static void serial_txx9_stop_rx(struct uart_port *up) 226 224 { 227 - struct uart_txx9_port *up = to_uart_txx9_port(port); 228 - up->port.read_status_mask &= ~TXX9_SIDISR_RDIS; 225 + up->read_status_mask &= ~TXX9_SIDISR_RDIS; 229 226 } 230 227 231 - static void serial_txx9_initialize(struct uart_port *port) 228 + static void serial_txx9_initialize(struct uart_port *up) 232 229 { 233 - struct uart_txx9_port *up = to_uart_txx9_port(port); 234 230 unsigned int tmout = 10000; 235 231 236 232 sio_out(up, TXX9_SIFCR, TXX9_SIFCR_SWRST); ··· 236 250 /* initial settings */ 237 251 sio_out(up, TXX9_SILCR, 238 252 TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT | 239 - ((up->port.flags & UPF_TXX9_USE_SCLK) ? 253 + ((up->flags & UPF_TXX9_USE_SCLK) ? 240 254 TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG)); 241 - sio_quot_set(up, uart_get_divisor(port, 9600)); 255 + sio_quot_set(up, uart_get_divisor(up, 9600)); 242 256 sio_out(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSTL_MAX /* 15 */); 243 257 sio_out(up, TXX9_SIDICR, 0); 244 258 } 245 259 246 260 static inline void 247 - receive_chars(struct uart_txx9_port *up, unsigned int *status) 261 + receive_chars(struct uart_port *up, unsigned int *status) 248 262 { 249 263 unsigned char ch; 250 264 unsigned int disr = *status; ··· 255 269 do { 256 270 ch = sio_in(up, TXX9_SIRFIFO); 257 271 flag = TTY_NORMAL; 258 - up->port.icount.rx++; 272 + up->icount.rx++; 259 273 260 274 /* mask out RFDN_MASK bit added by previous overrun */ 261 275 next_ignore_status_mask = 262 - up->port.ignore_status_mask & ~TXX9_SIDISR_RFDN_MASK; 276 + up->ignore_status_mask & ~TXX9_SIDISR_RFDN_MASK; 263 277 if (unlikely(disr & (TXX9_SIDISR_UBRK | TXX9_SIDISR_UPER | 264 278 TXX9_SIDISR_UFER | TXX9_SIDISR_UOER))) { 265 279 /* ··· 267 281 */ 268 282 if (disr & TXX9_SIDISR_UBRK) { 269 283 disr &= ~(TXX9_SIDISR_UFER | TXX9_SIDISR_UPER); 270 - up->port.icount.brk++; 284 + up->icount.brk++; 271 285 /* 272 286 * We do the SysRQ and SAK checking 273 287 * here because otherwise the break 274 288 * may get masked by ignore_status_mask 275 289 * or read_status_mask. 276 290 */ 277 - if (uart_handle_break(&up->port)) 291 + if (uart_handle_break(up)) 278 292 goto ignore_char; 279 293 } else if (disr & TXX9_SIDISR_UPER) 280 - up->port.icount.parity++; 294 + up->icount.parity++; 281 295 else if (disr & TXX9_SIDISR_UFER) 282 - up->port.icount.frame++; 296 + up->icount.frame++; 283 297 if (disr & TXX9_SIDISR_UOER) { 284 - up->port.icount.overrun++; 298 + up->icount.overrun++; 285 299 /* 286 300 * The receiver read buffer still hold 287 301 * a char which caused overrun. ··· 295 309 /* 296 310 * Mask off conditions which should be ingored. 297 311 */ 298 - disr &= up->port.read_status_mask; 312 + disr &= up->read_status_mask; 299 313 300 314 if (disr & TXX9_SIDISR_UBRK) { 301 315 flag = TTY_BREAK; ··· 304 318 else if (disr & TXX9_SIDISR_UFER) 305 319 flag = TTY_FRAME; 306 320 } 307 - if (uart_handle_sysrq_char(&up->port, ch)) 321 + if (uart_handle_sysrq_char(up, ch)) 308 322 goto ignore_char; 309 323 310 - uart_insert_char(&up->port, disr, TXX9_SIDISR_UOER, ch, flag); 324 + uart_insert_char(up, disr, TXX9_SIDISR_UOER, ch, flag); 311 325 312 326 ignore_char: 313 - up->port.ignore_status_mask = next_ignore_status_mask; 327 + up->ignore_status_mask = next_ignore_status_mask; 314 328 disr = sio_in(up, TXX9_SIDISR); 315 329 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); 316 330 317 - tty_flip_buffer_push(&up->port.state->port); 331 + tty_flip_buffer_push(&up->state->port); 318 332 319 333 *status = disr; 320 334 } 321 335 322 - static inline void transmit_chars(struct uart_txx9_port *up) 336 + static inline void transmit_chars(struct uart_port *up) 323 337 { 324 - struct circ_buf *xmit = &up->port.state->xmit; 338 + struct circ_buf *xmit = &up->state->xmit; 325 339 int count; 326 340 327 - if (up->port.x_char) { 328 - sio_out(up, TXX9_SITFIFO, up->port.x_char); 329 - up->port.icount.tx++; 330 - up->port.x_char = 0; 341 + if (up->x_char) { 342 + sio_out(up, TXX9_SITFIFO, up->x_char); 343 + up->icount.tx++; 344 + up->x_char = 0; 331 345 return; 332 346 } 333 - if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) { 334 - serial_txx9_stop_tx(&up->port); 347 + if (uart_circ_empty(xmit) || uart_tx_stopped(up)) { 348 + serial_txx9_stop_tx(up); 335 349 return; 336 350 } 337 351 ··· 339 353 do { 340 354 sio_out(up, TXX9_SITFIFO, xmit->buf[xmit->tail]); 341 355 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 342 - up->port.icount.tx++; 356 + up->icount.tx++; 343 357 if (uart_circ_empty(xmit)) 344 358 break; 345 359 } while (--count > 0); 346 360 347 361 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 348 - uart_write_wakeup(&up->port); 362 + uart_write_wakeup(up); 349 363 350 364 if (uart_circ_empty(xmit)) 351 - serial_txx9_stop_tx(&up->port); 365 + serial_txx9_stop_tx(up); 352 366 } 353 367 354 368 static irqreturn_t serial_txx9_interrupt(int irq, void *dev_id) 355 369 { 356 370 int pass_counter = 0; 357 - struct uart_txx9_port *up = dev_id; 371 + struct uart_port *up = dev_id; 358 372 unsigned int status; 359 373 360 374 while (1) { 361 - spin_lock(&up->port.lock); 375 + spin_lock(&up->lock); 362 376 status = sio_in(up, TXX9_SIDISR); 363 377 if (!(sio_in(up, TXX9_SIDICR) & TXX9_SIDICR_TIE)) 364 378 status &= ~TXX9_SIDISR_TDIS; 365 379 if (!(status & (TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS | 366 380 TXX9_SIDISR_TOUT))) { 367 - spin_unlock(&up->port.lock); 381 + spin_unlock(&up->lock); 368 382 break; 369 383 } 370 384 ··· 376 390 sio_mask(up, TXX9_SIDISR, 377 391 TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS | 378 392 TXX9_SIDISR_TOUT); 379 - spin_unlock(&up->port.lock); 393 + spin_unlock(&up->lock); 380 394 381 395 if (pass_counter++ > PASS_LIMIT) 382 396 break; ··· 385 399 return pass_counter ? IRQ_HANDLED : IRQ_NONE; 386 400 } 387 401 388 - static unsigned int serial_txx9_tx_empty(struct uart_port *port) 402 + static unsigned int serial_txx9_tx_empty(struct uart_port *up) 389 403 { 390 - struct uart_txx9_port *up = to_uart_txx9_port(port); 391 404 unsigned long flags; 392 405 unsigned int ret; 393 406 394 - spin_lock_irqsave(&up->port.lock, flags); 407 + spin_lock_irqsave(&up->lock, flags); 395 408 ret = (sio_in(up, TXX9_SICISR) & TXX9_SICISR_TXALS) ? TIOCSER_TEMT : 0; 396 - spin_unlock_irqrestore(&up->port.lock, flags); 409 + spin_unlock_irqrestore(&up->lock, flags); 397 410 398 411 return ret; 399 412 } 400 413 401 - static unsigned int serial_txx9_get_mctrl(struct uart_port *port) 414 + static unsigned int serial_txx9_get_mctrl(struct uart_port *up) 402 415 { 403 - struct uart_txx9_port *up = to_uart_txx9_port(port); 404 416 unsigned int ret; 405 417 406 418 /* no modem control lines */ ··· 409 425 return ret; 410 426 } 411 427 412 - static void serial_txx9_set_mctrl(struct uart_port *port, unsigned int mctrl) 428 + static void serial_txx9_set_mctrl(struct uart_port *up, unsigned int mctrl) 413 429 { 414 - struct uart_txx9_port *up = to_uart_txx9_port(port); 415 430 416 431 if (mctrl & TIOCM_RTS) 417 432 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSSC); ··· 418 435 sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSSC); 419 436 } 420 437 421 - static void serial_txx9_break_ctl(struct uart_port *port, int break_state) 438 + static void serial_txx9_break_ctl(struct uart_port *up, int break_state) 422 439 { 423 - struct uart_txx9_port *up = to_uart_txx9_port(port); 424 440 unsigned long flags; 425 441 426 - spin_lock_irqsave(&up->port.lock, flags); 442 + spin_lock_irqsave(&up->lock, flags); 427 443 if (break_state == -1) 428 444 sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK); 429 445 else 430 446 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK); 431 - spin_unlock_irqrestore(&up->port.lock, flags); 447 + spin_unlock_irqrestore(&up->lock, flags); 432 448 } 433 449 434 450 #if defined(CONFIG_SERIAL_TXX9_CONSOLE) || defined(CONFIG_CONSOLE_POLL) 435 451 /* 436 452 * Wait for transmitter & holding register to empty 437 453 */ 438 - static void wait_for_xmitr(struct uart_txx9_port *up) 454 + static void wait_for_xmitr(struct uart_port *up) 439 455 { 440 456 unsigned int tmout = 10000; 441 457 ··· 444 462 udelay(1); 445 463 446 464 /* Wait up to 1s for flow control if necessary */ 447 - if (up->port.flags & UPF_CONS_FLOW) { 465 + if (up->flags & UPF_CONS_FLOW) { 448 466 tmout = 1000000; 449 467 while (--tmout && 450 468 (sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS)) ··· 459 477 * in an interrupt or debug context. 460 478 */ 461 479 462 - static int serial_txx9_get_poll_char(struct uart_port *port) 480 + static int serial_txx9_get_poll_char(struct uart_port *up) 463 481 { 464 482 unsigned int ier; 465 483 unsigned char c; 466 - struct uart_txx9_port *up = to_uart_txx9_port(port); 467 484 468 485 /* 469 486 * First save the IER then disable the interrupts ··· 485 504 } 486 505 487 506 488 - static void serial_txx9_put_poll_char(struct uart_port *port, unsigned char c) 507 + static void serial_txx9_put_poll_char(struct uart_port *up, unsigned char c) 489 508 { 490 509 unsigned int ier; 491 - struct uart_txx9_port *up = to_uart_txx9_port(port); 492 510 493 511 /* 494 512 * First save the IER then disable the interrupts ··· 511 531 512 532 #endif /* CONFIG_CONSOLE_POLL */ 513 533 514 - static int serial_txx9_startup(struct uart_port *port) 534 + static int serial_txx9_startup(struct uart_port *up) 515 535 { 516 - struct uart_txx9_port *up = to_uart_txx9_port(port); 517 536 unsigned long flags; 518 537 int retval; 519 538 ··· 532 553 */ 533 554 sio_out(up, TXX9_SIDISR, 0); 534 555 535 - retval = request_irq(up->port.irq, serial_txx9_interrupt, 556 + retval = request_irq(up->irq, serial_txx9_interrupt, 536 557 IRQF_SHARED, "serial_txx9", up); 537 558 if (retval) 538 559 return retval; ··· 540 561 /* 541 562 * Now, initialize the UART 542 563 */ 543 - spin_lock_irqsave(&up->port.lock, flags); 544 - serial_txx9_set_mctrl(&up->port, up->port.mctrl); 545 - spin_unlock_irqrestore(&up->port.lock, flags); 564 + spin_lock_irqsave(&up->lock, flags); 565 + serial_txx9_set_mctrl(up, up->mctrl); 566 + spin_unlock_irqrestore(&up->lock, flags); 546 567 547 568 /* Enable RX/TX */ 548 569 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_RSDE | TXX9_SIFLCR_TSDE); ··· 555 576 return 0; 556 577 } 557 578 558 - static void serial_txx9_shutdown(struct uart_port *port) 579 + static void serial_txx9_shutdown(struct uart_port *up) 559 580 { 560 - struct uart_txx9_port *up = to_uart_txx9_port(port); 561 581 unsigned long flags; 562 582 563 583 /* ··· 564 586 */ 565 587 sio_out(up, TXX9_SIDICR, 0); /* disable all intrs */ 566 588 567 - spin_lock_irqsave(&up->port.lock, flags); 568 - serial_txx9_set_mctrl(&up->port, up->port.mctrl); 569 - spin_unlock_irqrestore(&up->port.lock, flags); 589 + spin_lock_irqsave(&up->lock, flags); 590 + serial_txx9_set_mctrl(up, up->mctrl); 591 + spin_unlock_irqrestore(&up->lock, flags); 570 592 571 593 /* 572 594 * Disable break condition ··· 574 596 sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK); 575 597 576 598 #ifdef CONFIG_SERIAL_TXX9_CONSOLE 577 - if (up->port.cons && up->port.line == up->port.cons->index) { 578 - free_irq(up->port.irq, up); 599 + if (up->cons && up->line == up->cons->index) { 600 + free_irq(up->irq, up); 579 601 return; 580 602 } 581 603 #endif ··· 589 611 /* Disable RX/TX */ 590 612 sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_RSDE | TXX9_SIFLCR_TSDE); 591 613 592 - free_irq(up->port.irq, up); 614 + free_irq(up->irq, up); 593 615 } 594 616 595 617 static void 596 - serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios, 618 + serial_txx9_set_termios(struct uart_port *up, struct ktermios *termios, 597 619 struct ktermios *old) 598 620 { 599 - struct uart_txx9_port *up = to_uart_txx9_port(port); 600 621 unsigned int cval, fcr = 0; 601 622 unsigned long flags; 602 623 unsigned int baud, quot; ··· 635 658 /* 636 659 * Ask the core to calculate the divisor for us. 637 660 */ 638 - baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16/2); 639 - quot = uart_get_divisor(port, baud); 661 + baud = uart_get_baud_rate(up, termios, old, 0, up->uartclk/16/2); 662 + quot = uart_get_divisor(up, baud); 640 663 641 664 /* Set up FIFOs */ 642 665 /* TX Int by FIFO Empty, RX Int by Receiving 1 char. */ ··· 646 669 * Ok, we're now changing the port state. Do it with 647 670 * interrupts disabled. 648 671 */ 649 - spin_lock_irqsave(&up->port.lock, flags); 672 + spin_lock_irqsave(&up->lock, flags); 650 673 651 674 /* 652 675 * Update the per-port timeout. 653 676 */ 654 - uart_update_timeout(port, termios->c_cflag, baud); 677 + uart_update_timeout(up, termios->c_cflag, baud); 655 678 656 - up->port.read_status_mask = TXX9_SIDISR_UOER | 679 + up->read_status_mask = TXX9_SIDISR_UOER | 657 680 TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS; 658 681 if (termios->c_iflag & INPCK) 659 - up->port.read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER; 682 + up->read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER; 660 683 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) 661 - up->port.read_status_mask |= TXX9_SIDISR_UBRK; 684 + up->read_status_mask |= TXX9_SIDISR_UBRK; 662 685 663 686 /* 664 687 * Characteres to ignore 665 688 */ 666 - up->port.ignore_status_mask = 0; 689 + up->ignore_status_mask = 0; 667 690 if (termios->c_iflag & IGNPAR) 668 - up->port.ignore_status_mask |= TXX9_SIDISR_UPER | TXX9_SIDISR_UFER; 691 + up->ignore_status_mask |= TXX9_SIDISR_UPER | TXX9_SIDISR_UFER; 669 692 if (termios->c_iflag & IGNBRK) { 670 - up->port.ignore_status_mask |= TXX9_SIDISR_UBRK; 693 + up->ignore_status_mask |= TXX9_SIDISR_UBRK; 671 694 /* 672 695 * If we're ignoring parity and break indicators, 673 696 * ignore overruns too (for real raw support). 674 697 */ 675 698 if (termios->c_iflag & IGNPAR) 676 - up->port.ignore_status_mask |= TXX9_SIDISR_UOER; 699 + up->ignore_status_mask |= TXX9_SIDISR_UOER; 677 700 } 678 701 679 702 /* 680 703 * ignore all characters if CREAD is not set 681 704 */ 682 705 if ((termios->c_cflag & CREAD) == 0) 683 - up->port.ignore_status_mask |= TXX9_SIDISR_RDIS; 706 + up->ignore_status_mask |= TXX9_SIDISR_RDIS; 684 707 685 708 /* CTS flow control flag */ 686 709 if ((termios->c_cflag & CRTSCTS) && 687 - (up->port.flags & UPF_TXX9_HAVE_CTS_LINE)) { 710 + (up->flags & UPF_TXX9_HAVE_CTS_LINE)) { 688 711 sio_set(up, TXX9_SIFLCR, 689 712 TXX9_SIFLCR_RCS | TXX9_SIFLCR_TES); 690 713 } else { ··· 696 719 sio_quot_set(up, quot); 697 720 sio_out(up, TXX9_SIFCR, fcr); 698 721 699 - serial_txx9_set_mctrl(&up->port, up->port.mctrl); 700 - spin_unlock_irqrestore(&up->port.lock, flags); 722 + serial_txx9_set_mctrl(up, up->mctrl); 723 + spin_unlock_irqrestore(&up->lock, flags); 701 724 } 702 725 703 726 static void ··· 716 739 serial_txx9_initialize(port); 717 740 } 718 741 719 - static int serial_txx9_request_resource(struct uart_txx9_port *up) 742 + static int serial_txx9_request_resource(struct uart_port *up) 720 743 { 721 744 unsigned int size = TXX9_REGION_SIZE; 722 745 int ret = 0; 723 746 724 - switch (up->port.iotype) { 747 + switch (up->iotype) { 725 748 default: 726 - if (!up->port.mapbase) 749 + if (!up->mapbase) 727 750 break; 728 751 729 - if (!request_mem_region(up->port.mapbase, size, "serial_txx9")) { 752 + if (!request_mem_region(up->mapbase, size, "serial_txx9")) { 730 753 ret = -EBUSY; 731 754 break; 732 755 } 733 756 734 - if (up->port.flags & UPF_IOREMAP) { 735 - up->port.membase = ioremap(up->port.mapbase, size); 736 - if (!up->port.membase) { 737 - release_mem_region(up->port.mapbase, size); 757 + if (up->flags & UPF_IOREMAP) { 758 + up->membase = ioremap(up->mapbase, size); 759 + if (!up->membase) { 760 + release_mem_region(up->mapbase, size); 738 761 ret = -ENOMEM; 739 762 } 740 763 } 741 764 break; 742 765 743 766 case UPIO_PORT: 744 - if (!request_region(up->port.iobase, size, "serial_txx9")) 767 + if (!request_region(up->iobase, size, "serial_txx9")) 745 768 ret = -EBUSY; 746 769 break; 747 770 } 748 771 return ret; 749 772 } 750 773 751 - static void serial_txx9_release_resource(struct uart_txx9_port *up) 774 + static void serial_txx9_release_resource(struct uart_port *up) 752 775 { 753 776 unsigned int size = TXX9_REGION_SIZE; 754 777 755 - switch (up->port.iotype) { 778 + switch (up->iotype) { 756 779 default: 757 - if (!up->port.mapbase) 780 + if (!up->mapbase) 758 781 break; 759 782 760 - if (up->port.flags & UPF_IOREMAP) { 761 - iounmap(up->port.membase); 762 - up->port.membase = NULL; 783 + if (up->flags & UPF_IOREMAP) { 784 + iounmap(up->membase); 785 + up->membase = NULL; 763 786 } 764 787 765 - release_mem_region(up->port.mapbase, size); 788 + release_mem_region(up->mapbase, size); 766 789 break; 767 790 768 791 case UPIO_PORT: 769 - release_region(up->port.iobase, size); 792 + release_region(up->iobase, size); 770 793 break; 771 794 } 772 795 } 773 796 774 - static void serial_txx9_release_port(struct uart_port *port) 797 + static void serial_txx9_release_port(struct uart_port *up) 775 798 { 776 - struct uart_txx9_port *up = to_uart_txx9_port(port); 777 799 serial_txx9_release_resource(up); 778 800 } 779 801 780 - static int serial_txx9_request_port(struct uart_port *port) 802 + static int serial_txx9_request_port(struct uart_port *up) 781 803 { 782 - struct uart_txx9_port *up = to_uart_txx9_port(port); 783 804 return serial_txx9_request_resource(up); 784 805 } 785 806 786 - static void serial_txx9_config_port(struct uart_port *port, int uflags) 807 + static void serial_txx9_config_port(struct uart_port *up, int uflags) 787 808 { 788 - struct uart_txx9_port *up = to_uart_txx9_port(port); 789 809 int ret; 790 810 791 811 /* ··· 792 818 ret = serial_txx9_request_resource(up); 793 819 if (ret < 0) 794 820 return; 795 - port->type = PORT_TXX9; 796 - up->port.fifosize = TXX9_SIO_TX_FIFO; 821 + up->type = PORT_TXX9; 822 + up->fifosize = TXX9_SIO_TX_FIFO; 797 823 798 824 #ifdef CONFIG_SERIAL_TXX9_CONSOLE 799 - if (up->port.line == up->port.cons->index) 825 + if (up->line == up->cons->index) 800 826 return; 801 827 #endif 802 - serial_txx9_initialize(port); 828 + serial_txx9_initialize(up); 803 829 } 804 830 805 831 static const char * ··· 830 856 #endif 831 857 }; 832 858 833 - static struct uart_txx9_port serial_txx9_ports[UART_NR]; 859 + static struct uart_port serial_txx9_ports[UART_NR]; 834 860 835 861 static void __init serial_txx9_register_ports(struct uart_driver *drv, 836 862 struct device *dev) ··· 838 864 int i; 839 865 840 866 for (i = 0; i < UART_NR; i++) { 841 - struct uart_txx9_port *up = &serial_txx9_ports[i]; 867 + struct uart_port *up = &serial_txx9_ports[i]; 842 868 843 - up->port.line = i; 844 - up->port.ops = &serial_txx9_pops; 845 - up->port.dev = dev; 846 - if (up->port.iobase || up->port.mapbase) 847 - uart_add_one_port(drv, &up->port); 869 + up->line = i; 870 + up->ops = &serial_txx9_pops; 871 + up->dev = dev; 872 + if (up->iobase || up->mapbase) 873 + uart_add_one_port(drv, up); 848 874 } 849 875 } 850 876 851 877 #ifdef CONFIG_SERIAL_TXX9_CONSOLE 852 878 853 - static void serial_txx9_console_putchar(struct uart_port *port, unsigned char ch) 879 + static void serial_txx9_console_putchar(struct uart_port *up, unsigned char ch) 854 880 { 855 - struct uart_txx9_port *up = to_uart_txx9_port(port); 856 - 857 881 wait_for_xmitr(up); 858 882 sio_out(up, TXX9_SITFIFO, ch); 859 883 } ··· 865 893 static void 866 894 serial_txx9_console_write(struct console *co, const char *s, unsigned int count) 867 895 { 868 - struct uart_txx9_port *up = &serial_txx9_ports[co->index]; 896 + struct uart_port *up = &serial_txx9_ports[co->index]; 869 897 unsigned int ier, flcr; 870 898 871 899 /* ··· 877 905 * Disable flow-control if enabled (and unnecessary) 878 906 */ 879 907 flcr = sio_in(up, TXX9_SIFLCR); 880 - if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES)) 908 + if (!(up->flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES)) 881 909 sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES); 882 910 883 - uart_console_write(&up->port, s, count, serial_txx9_console_putchar); 911 + uart_console_write(up, s, count, serial_txx9_console_putchar); 884 912 885 913 /* 886 914 * Finally, wait for transmitter to become empty ··· 893 921 894 922 static int __init serial_txx9_console_setup(struct console *co, char *options) 895 923 { 896 - struct uart_port *port; 897 - struct uart_txx9_port *up; 924 + struct uart_port *up; 898 925 int baud = 9600; 899 926 int bits = 8; 900 927 int parity = 'n'; ··· 907 936 if (co->index >= UART_NR) 908 937 co->index = 0; 909 938 up = &serial_txx9_ports[co->index]; 910 - port = &up->port; 911 - if (!port->ops) 939 + if (!up->ops) 912 940 return -ENODEV; 913 941 914 - serial_txx9_initialize(&up->port); 942 + serial_txx9_initialize(up); 915 943 916 944 if (options) 917 945 uart_parse_options(options, &baud, &parity, &bits, &flow); 918 946 919 - return uart_set_options(port, co, baud, parity, bits, flow); 947 + return uart_set_options(up, co, baud, parity, bits, flow); 920 948 } 921 949 922 950 static struct uart_driver serial_txx9_reg; ··· 956 986 if (port->line >= ARRAY_SIZE(serial_txx9_ports)) 957 987 return -ENODEV; 958 988 959 - serial_txx9_ports[port->line].port = *port; 960 - serial_txx9_ports[port->line].port.ops = &serial_txx9_pops; 961 - serial_txx9_ports[port->line].port.flags |= 989 + serial_txx9_ports[port->line] = *port; 990 + serial_txx9_ports[port->line].ops = &serial_txx9_pops; 991 + serial_txx9_ports[port->line].flags |= 962 992 UPF_BOOT_AUTOCONF | UPF_FIXED_PORT; 963 993 return 0; 964 994 } ··· 979 1009 static int serial_txx9_register_port(struct uart_port *port) 980 1010 { 981 1011 int i; 982 - struct uart_txx9_port *uart; 1012 + struct uart_port *uart; 983 1013 int ret = -ENOSPC; 984 1014 985 1015 mutex_lock(&serial_txx9_mutex); 986 1016 for (i = 0; i < UART_NR; i++) { 987 1017 uart = &serial_txx9_ports[i]; 988 - if (uart_match_port(&uart->port, port)) { 989 - uart_remove_one_port(&serial_txx9_reg, &uart->port); 1018 + if (uart_match_port(uart, port)) { 1019 + uart_remove_one_port(&serial_txx9_reg, uart); 990 1020 break; 991 1021 } 992 1022 } ··· 994 1024 /* Find unused port */ 995 1025 for (i = 0; i < UART_NR; i++) { 996 1026 uart = &serial_txx9_ports[i]; 997 - if (!(uart->port.iobase || uart->port.mapbase)) 1027 + if (!(uart->iobase || uart->mapbase)) 998 1028 break; 999 1029 } 1000 1030 } 1001 1031 if (i < UART_NR) { 1002 - uart->port.iobase = port->iobase; 1003 - uart->port.membase = port->membase; 1004 - uart->port.irq = port->irq; 1005 - uart->port.uartclk = port->uartclk; 1006 - uart->port.iotype = port->iotype; 1007 - uart->port.flags = port->flags 1032 + uart->iobase = port->iobase; 1033 + uart->membase = port->membase; 1034 + uart->irq = port->irq; 1035 + uart->uartclk = port->uartclk; 1036 + uart->iotype = port->iotype; 1037 + uart->flags = port->flags 1008 1038 | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT; 1009 - uart->port.mapbase = port->mapbase; 1039 + uart->mapbase = port->mapbase; 1010 1040 if (port->dev) 1011 - uart->port.dev = port->dev; 1012 - ret = uart_add_one_port(&serial_txx9_reg, &uart->port); 1041 + uart->dev = port->dev; 1042 + ret = uart_add_one_port(&serial_txx9_reg, uart); 1013 1043 if (ret == 0) 1014 - ret = uart->port.line; 1044 + ret = uart->line; 1015 1045 } 1016 1046 mutex_unlock(&serial_txx9_mutex); 1017 1047 return ret; ··· 1026 1056 */ 1027 1057 static void serial_txx9_unregister_port(int line) 1028 1058 { 1029 - struct uart_txx9_port *uart = &serial_txx9_ports[line]; 1059 + struct uart_port *uart = &serial_txx9_ports[line]; 1030 1060 1031 1061 mutex_lock(&serial_txx9_mutex); 1032 - uart_remove_one_port(&serial_txx9_reg, &uart->port); 1033 - uart->port.flags = 0; 1034 - uart->port.type = PORT_UNKNOWN; 1035 - uart->port.iobase = 0; 1036 - uart->port.mapbase = 0; 1037 - uart->port.membase = NULL; 1038 - uart->port.dev = NULL; 1062 + uart_remove_one_port(&serial_txx9_reg, uart); 1063 + uart->flags = 0; 1064 + uart->type = PORT_UNKNOWN; 1065 + uart->iobase = 0; 1066 + uart->mapbase = 0; 1067 + uart->membase = NULL; 1068 + uart->dev = NULL; 1039 1069 mutex_unlock(&serial_txx9_mutex); 1040 1070 } 1041 1071 ··· 1078 1108 int i; 1079 1109 1080 1110 for (i = 0; i < UART_NR; i++) { 1081 - struct uart_txx9_port *up = &serial_txx9_ports[i]; 1111 + struct uart_port *up = &serial_txx9_ports[i]; 1082 1112 1083 - if (up->port.dev == &dev->dev) 1113 + if (up->dev == &dev->dev) 1084 1114 serial_txx9_unregister_port(i); 1085 1115 } 1086 1116 return 0; ··· 1092 1122 int i; 1093 1123 1094 1124 for (i = 0; i < UART_NR; i++) { 1095 - struct uart_txx9_port *up = &serial_txx9_ports[i]; 1125 + struct uart_port *up = &serial_txx9_ports[i]; 1096 1126 1097 - if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 1098 - uart_suspend_port(&serial_txx9_reg, &up->port); 1127 + if (up->type != PORT_UNKNOWN && up->dev == &dev->dev) 1128 + uart_suspend_port(&serial_txx9_reg, up); 1099 1129 } 1100 1130 1101 1131 return 0; ··· 1106 1136 int i; 1107 1137 1108 1138 for (i = 0; i < UART_NR; i++) { 1109 - struct uart_txx9_port *up = &serial_txx9_ports[i]; 1139 + struct uart_port *up = &serial_txx9_ports[i]; 1110 1140 1111 - if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 1112 - uart_resume_port(&serial_txx9_reg, &up->port); 1141 + if (up->type != PORT_UNKNOWN && up->dev == &dev->dev) 1142 + uart_resume_port(&serial_txx9_reg, up); 1113 1143 } 1114 1144 1115 1145 return 0; ··· 1165 1195 1166 1196 static void pciserial_txx9_remove_one(struct pci_dev *dev) 1167 1197 { 1168 - struct uart_txx9_port *up = pci_get_drvdata(dev); 1198 + struct uart_port *up = pci_get_drvdata(dev); 1169 1199 1170 1200 if (up) { 1171 - serial_txx9_unregister_port(up->port.line); 1201 + serial_txx9_unregister_port(up->line); 1172 1202 pci_disable_device(dev); 1173 1203 } 1174 1204 } ··· 1176 1206 #ifdef CONFIG_PM 1177 1207 static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) 1178 1208 { 1179 - struct uart_txx9_port *up = pci_get_drvdata(dev); 1209 + struct uart_port *up = pci_get_drvdata(dev); 1180 1210 1181 1211 if (up) 1182 - uart_suspend_port(&serial_txx9_reg, &up->port); 1212 + uart_suspend_port(&serial_txx9_reg, up); 1183 1213 pci_save_state(dev); 1184 1214 pci_set_power_state(dev, pci_choose_state(dev, state)); 1185 1215 return 0; ··· 1187 1217 1188 1218 static int pciserial_txx9_resume_one(struct pci_dev *dev) 1189 1219 { 1190 - struct uart_txx9_port *up = pci_get_drvdata(dev); 1220 + struct uart_port *up = pci_get_drvdata(dev); 1191 1221 1192 1222 pci_set_power_state(dev, PCI_D0); 1193 1223 pci_restore_state(dev); 1194 1224 if (up) 1195 - uart_resume_port(&serial_txx9_reg, &up->port); 1225 + uart_resume_port(&serial_txx9_reg, up); 1196 1226 return 0; 1197 1227 } 1198 1228 #endif ··· 1272 1302 platform_driver_unregister(&serial_txx9_plat_driver); 1273 1303 platform_device_unregister(serial_txx9_plat_devs); 1274 1304 for (i = 0; i < UART_NR; i++) { 1275 - struct uart_txx9_port *up = &serial_txx9_ports[i]; 1276 - if (up->port.iobase || up->port.mapbase) 1277 - uart_remove_one_port(&serial_txx9_reg, &up->port); 1305 + struct uart_port *up = &serial_txx9_ports[i]; 1306 + if (up->iobase || up->mapbase) 1307 + uart_remove_one_port(&serial_txx9_reg, up); 1278 1308 } 1279 1309 1280 1310 uart_unregister_driver(&serial_txx9_reg);