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

serial: sunsab: use container_of to resolve uart_sunsu_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Fabian Frederick and committed by
Greg Kroah-Hartman
72665765 9a6962c5

+24 -12
+24 -12
drivers/tty/serial/sunsab.c
··· 345 345 /* port->lock is not held. */ 346 346 static unsigned int sunsab_tx_empty(struct uart_port *port) 347 347 { 348 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 348 + struct uart_sunsab_port *up = 349 + container_of(port, struct uart_sunsab_port, port); 349 350 int ret; 350 351 351 352 /* Do not need a lock for a state test like this. */ ··· 361 360 /* port->lock held by caller. */ 362 361 static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl) 363 362 { 364 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 363 + struct uart_sunsab_port *up = 364 + container_of(port, struct uart_sunsab_port, port); 365 365 366 366 if (mctrl & TIOCM_RTS) { 367 367 up->cached_mode &= ~SAB82532_MODE_FRTS; ··· 385 383 /* port->lock is held by caller and interrupts are disabled. */ 386 384 static unsigned int sunsab_get_mctrl(struct uart_port *port) 387 385 { 388 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 386 + struct uart_sunsab_port *up = 387 + container_of(port, struct uart_sunsab_port, port); 389 388 unsigned char val; 390 389 unsigned int result; 391 390 ··· 407 404 /* port->lock held by caller. */ 408 405 static void sunsab_stop_tx(struct uart_port *port) 409 406 { 410 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 407 + struct uart_sunsab_port *up = 408 + container_of(port, struct uart_sunsab_port, port); 411 409 412 410 up->interrupt_mask1 |= SAB82532_IMR1_XPR; 413 411 writeb(up->interrupt_mask1, &up->regs->w.imr1); ··· 436 432 /* port->lock held by caller. */ 437 433 static void sunsab_start_tx(struct uart_port *port) 438 434 { 439 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 435 + struct uart_sunsab_port *up = 436 + container_of(port, struct uart_sunsab_port, port); 440 437 struct circ_buf *xmit = &up->port.state->xmit; 441 438 int i; 442 439 ··· 470 465 /* port->lock is not held. */ 471 466 static void sunsab_send_xchar(struct uart_port *port, char ch) 472 467 { 473 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 468 + struct uart_sunsab_port *up = 469 + container_of(port, struct uart_sunsab_port, port); 474 470 unsigned long flags; 475 471 476 472 if (ch == __DISABLED_CHAR) ··· 488 482 /* port->lock held by caller. */ 489 483 static void sunsab_stop_rx(struct uart_port *port) 490 484 { 491 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 485 + struct uart_sunsab_port *up = 486 + container_of(port, struct uart_sunsab_port, port); 492 487 493 488 up->interrupt_mask0 |= SAB82532_IMR0_TCD; 494 489 writeb(up->interrupt_mask1, &up->regs->w.imr0); ··· 498 491 /* port->lock is not held. */ 499 492 static void sunsab_break_ctl(struct uart_port *port, int break_state) 500 493 { 501 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 494 + struct uart_sunsab_port *up = 495 + container_of(port, struct uart_sunsab_port, port); 502 496 unsigned long flags; 503 497 unsigned char val; 504 498 ··· 522 514 /* port->lock is not held. */ 523 515 static int sunsab_startup(struct uart_port *port) 524 516 { 525 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 517 + struct uart_sunsab_port *up = 518 + container_of(port, struct uart_sunsab_port, port); 526 519 unsigned long flags; 527 520 unsigned char tmp; 528 521 int err = request_irq(up->port.irq, sunsab_interrupt, ··· 594 585 /* port->lock is not held. */ 595 586 static void sunsab_shutdown(struct uart_port *port) 596 587 { 597 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 588 + struct uart_sunsab_port *up = 589 + container_of(port, struct uart_sunsab_port, port); 598 590 unsigned long flags; 599 591 600 592 spin_lock_irqsave(&up->port.lock, flags); ··· 781 771 static void sunsab_set_termios(struct uart_port *port, struct ktermios *termios, 782 772 struct ktermios *old) 783 773 { 784 - struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 774 + struct uart_sunsab_port *up = 775 + container_of(port, struct uart_sunsab_port, port); 785 776 unsigned long flags; 786 777 unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); 787 778 unsigned int quot = uart_get_divisor(port, baud); ··· 851 840 852 841 static void sunsab_console_putchar(struct uart_port *port, int c) 853 842 { 854 - struct uart_sunsab_port *up = (struct uart_sunsab_port *)port; 843 + struct uart_sunsab_port *up = 844 + container_of(port, struct uart_sunsab_port, port); 855 845 856 846 sunsab_tec_wait(up); 857 847 writeb(c, &up->regs->w.tic);