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

serial: sa1100: use container_of to resolve sa1100_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Fabian Frederick and committed by
Greg Kroah-Hartman
c9db776b b6b30d67

+30 -15
+30 -15
drivers/tty/serial/sa1100.c
··· 142 142 */ 143 143 static void sa1100_stop_tx(struct uart_port *port) 144 144 { 145 - struct sa1100_port *sport = (struct sa1100_port *)port; 145 + struct sa1100_port *sport = 146 + container_of(port, struct sa1100_port, port); 146 147 u32 utcr3; 147 148 148 149 utcr3 = UART_GET_UTCR3(sport); ··· 156 155 */ 157 156 static void sa1100_start_tx(struct uart_port *port) 158 157 { 159 - struct sa1100_port *sport = (struct sa1100_port *)port; 158 + struct sa1100_port *sport = 159 + container_of(port, struct sa1100_port, port); 160 160 u32 utcr3; 161 161 162 162 utcr3 = UART_GET_UTCR3(sport); ··· 170 168 */ 171 169 static void sa1100_stop_rx(struct uart_port *port) 172 170 { 173 - struct sa1100_port *sport = (struct sa1100_port *)port; 171 + struct sa1100_port *sport = 172 + container_of(port, struct sa1100_port, port); 174 173 u32 utcr3; 175 174 176 175 utcr3 = UART_GET_UTCR3(sport); ··· 183 180 */ 184 181 static void sa1100_enable_ms(struct uart_port *port) 185 182 { 186 - struct sa1100_port *sport = (struct sa1100_port *)port; 183 + struct sa1100_port *sport = 184 + container_of(port, struct sa1100_port, port); 187 185 188 186 mod_timer(&sport->timer, jiffies); 189 187 } ··· 327 323 */ 328 324 static unsigned int sa1100_tx_empty(struct uart_port *port) 329 325 { 330 - struct sa1100_port *sport = (struct sa1100_port *)port; 326 + struct sa1100_port *sport = 327 + container_of(port, struct sa1100_port, port); 331 328 332 329 return UART_GET_UTSR1(sport) & UTSR1_TBY ? 0 : TIOCSER_TEMT; 333 330 } ··· 347 342 */ 348 343 static void sa1100_break_ctl(struct uart_port *port, int break_state) 349 344 { 350 - struct sa1100_port *sport = (struct sa1100_port *)port; 345 + struct sa1100_port *sport = 346 + container_of(port, struct sa1100_port, port); 351 347 unsigned long flags; 352 348 unsigned int utcr3; 353 349 ··· 364 358 365 359 static int sa1100_startup(struct uart_port *port) 366 360 { 367 - struct sa1100_port *sport = (struct sa1100_port *)port; 361 + struct sa1100_port *sport = 362 + container_of(port, struct sa1100_port, port); 368 363 int retval; 369 364 370 365 /* ··· 394 387 395 388 static void sa1100_shutdown(struct uart_port *port) 396 389 { 397 - struct sa1100_port *sport = (struct sa1100_port *)port; 390 + struct sa1100_port *sport = 391 + container_of(port, struct sa1100_port, port); 398 392 399 393 /* 400 394 * Stop our timer. ··· 417 409 sa1100_set_termios(struct uart_port *port, struct ktermios *termios, 418 410 struct ktermios *old) 419 411 { 420 - struct sa1100_port *sport = (struct sa1100_port *)port; 412 + struct sa1100_port *sport = 413 + container_of(port, struct sa1100_port, port); 421 414 unsigned long flags; 422 415 unsigned int utcr0, old_utcr3, baud, quot; 423 416 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; ··· 521 512 522 513 static const char *sa1100_type(struct uart_port *port) 523 514 { 524 - struct sa1100_port *sport = (struct sa1100_port *)port; 515 + struct sa1100_port *sport = 516 + container_of(port, struct sa1100_port, port); 525 517 526 518 return sport->port.type == PORT_SA1100 ? "SA1100" : NULL; 527 519 } ··· 532 522 */ 533 523 static void sa1100_release_port(struct uart_port *port) 534 524 { 535 - struct sa1100_port *sport = (struct sa1100_port *)port; 525 + struct sa1100_port *sport = 526 + container_of(port, struct sa1100_port, port); 536 527 537 528 release_mem_region(sport->port.mapbase, UART_PORT_SIZE); 538 529 } ··· 543 532 */ 544 533 static int sa1100_request_port(struct uart_port *port) 545 534 { 546 - struct sa1100_port *sport = (struct sa1100_port *)port; 535 + struct sa1100_port *sport = 536 + container_of(port, struct sa1100_port, port); 547 537 548 538 return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, 549 539 "sa11x0-uart") != NULL ? 0 : -EBUSY; ··· 555 543 */ 556 544 static void sa1100_config_port(struct uart_port *port, int flags) 557 545 { 558 - struct sa1100_port *sport = (struct sa1100_port *)port; 546 + struct sa1100_port *sport = 547 + container_of(port, struct sa1100_port, port); 559 548 560 549 if (flags & UART_CONFIG_TYPE && 561 550 sa1100_request_port(&sport->port) == 0) ··· 571 558 static int 572 559 sa1100_verify_port(struct uart_port *port, struct serial_struct *ser) 573 560 { 574 - struct sa1100_port *sport = (struct sa1100_port *)port; 561 + struct sa1100_port *sport = 562 + container_of(port, struct sa1100_port, port); 575 563 int ret = 0; 576 564 577 565 if (ser->type != PORT_UNKNOWN && ser->type != PORT_SA1100) ··· 705 691 #ifdef CONFIG_SERIAL_SA1100_CONSOLE 706 692 static void sa1100_console_putchar(struct uart_port *port, int ch) 707 693 { 708 - struct sa1100_port *sport = (struct sa1100_port *)port; 694 + struct sa1100_port *sport = 695 + container_of(port, struct sa1100_port, port); 709 696 710 697 while (!(UART_GET_UTSR1(sport) & UTSR1_TNF)) 711 698 barrier();