tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing head: b8badbf3b592d3f8b70efc66be2c2c4d9698de51 commit: baa864d1ac1f2901499f52e6a7e67b4dfe42ccff [31/36] serial: st-asc: don't get/put GPIOs in atomic context config: arm-defconfig (https://download.01.org/0day-ci/archive/20240218/202402180801.2LNKohCO-lkp@xxxxxxxxx/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240218/202402180801.2LNKohCO-lkp@xxxxxxxxx/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@xxxxxxxxx> | Closes: https://lore.kernel.org/oe-kbuild-all/202402180801.2LNKohCO-lkp@xxxxxxxxx/ All warnings (new ones prefixed by >>): >> drivers/tty/serial/st-asc.c:525:7: warning: variable 'manual_rts' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/st-asc.c:586:6: note: uninitialized use occurs here if (manual_rts) { ^~~~~~~~~~ drivers/tty/serial/st-asc.c:525:3: note: remove the 'if' if its condition is always true if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/tty/serial/st-asc.c:525:7: warning: variable 'manual_rts' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) ^~~~~~~~~~~~~ drivers/tty/serial/st-asc.c:586:6: note: uninitialized use occurs here if (manual_rts) { ^~~~~~~~~~ drivers/tty/serial/st-asc.c:525:7: note: remove the '&&' if its condition is always true if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) ^~~~~~~~~~~~~~~~ drivers/tty/serial/st-asc.c:521:7: warning: variable 'manual_rts' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (ascport->rts) ^~~~~~~~~~~~ drivers/tty/serial/st-asc.c:586:6: note: uninitialized use occurs here if (manual_rts) { ^~~~~~~~~~ drivers/tty/serial/st-asc.c:521:3: note: remove the 'if' if its condition is always true if (ascport->rts) ^~~~~~~~~~~~~~~~~ drivers/tty/serial/st-asc.c:470:17: note: initialize the variable 'manual_rts' to silence this warning bool manual_rts; ^ = 0 3 warnings generated. vim +525 drivers/tty/serial/st-asc.c 463 464 static void asc_set_termios(struct uart_port *port, struct ktermios *termios, 465 const struct ktermios *old) 466 { 467 struct asc_port *ascport = to_asc_port(port); 468 struct gpio_desc *gpiod; 469 unsigned int baud; 470 bool manual_rts; 471 u32 ctrl_val; 472 tcflag_t cflag; 473 unsigned long flags; 474 475 /* Update termios to reflect hardware capabilities */ 476 termios->c_cflag &= ~(CMSPAR | 477 (ascport->hw_flow_control ? 0 : CRTSCTS)); 478 479 port->uartclk = clk_get_rate(ascport->clk); 480 481 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 482 cflag = termios->c_cflag; 483 484 uart_port_lock_irqsave(port, &flags); 485 486 /* read control register */ 487 ctrl_val = asc_in(port, ASC_CTL); 488 489 /* stop serial port and reset value */ 490 asc_out(port, ASC_CTL, (ctrl_val & ~ASC_CTL_RUN)); 491 ctrl_val = ASC_CTL_RXENABLE | ASC_CTL_FIFOENABLE; 492 493 /* reset fifo rx & tx */ 494 asc_out(port, ASC_TXRESET, 1); 495 asc_out(port, ASC_RXRESET, 1); 496 497 /* set character length */ 498 if ((cflag & CSIZE) == CS7) { 499 ctrl_val |= ASC_CTL_MODE_7BIT_PAR; 500 cflag |= PARENB; 501 } else { 502 ctrl_val |= (cflag & PARENB) ? ASC_CTL_MODE_8BIT_PAR : 503 ASC_CTL_MODE_8BIT; 504 cflag &= ~CSIZE; 505 cflag |= CS8; 506 } 507 termios->c_cflag = cflag; 508 509 /* set stop bit */ 510 ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT; 511 512 /* odd parity */ 513 if (cflag & PARODD) 514 ctrl_val |= ASC_CTL_PARITYODD; 515 516 /* hardware flow control */ 517 if ((cflag & CRTSCTS)) { 518 ctrl_val |= ASC_CTL_CTSENABLE; 519 520 /* If flow-control selected, stop handling RTS manually */ 521 if (ascport->rts) 522 manual_rts = false; 523 } else { 524 /* If flow-control disabled, it's safe to handle RTS manually */ > 525 if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) 526 manual_rts = true; 527 } 528 529 if ((baud < 19200) && !ascport->force_m1) { 530 asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); 531 } else { 532 /* 533 * MODE 1: recommended for high bit rates (above 19.2K) 534 * 535 * baudrate * 16 * 2^16 536 * ASCBaudRate = ------------------------ 537 * inputclock 538 * 539 * To keep maths inside 64bits, we divide inputclock by 16. 540 */ 541 u64 dividend = (u64)baud * (1 << 16); 542 543 do_div(dividend, port->uartclk / 16); 544 asc_out(port, ASC_BAUDRATE, dividend); 545 ctrl_val |= ASC_CTL_BAUDMODE; 546 } 547 548 uart_update_timeout(port, cflag, baud); 549 550 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE; 551 if (termios->c_iflag & INPCK) 552 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; 553 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) 554 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE; 555 556 /* 557 * Characters to ignore 558 */ 559 ascport->port.ignore_status_mask = 0; 560 if (termios->c_iflag & IGNPAR) 561 ascport->port.ignore_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; 562 if (termios->c_iflag & IGNBRK) { 563 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_BE; 564 /* 565 * If we're ignoring parity and break indicators, 566 * ignore overruns too (for real raw support). 567 */ 568 if (termios->c_iflag & IGNPAR) 569 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_OE; 570 } 571 572 /* 573 * Ignore all characters if CREAD is not set. 574 */ 575 if (!(termios->c_cflag & CREAD)) 576 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_RX; 577 578 /* Set the timeout */ 579 asc_out(port, ASC_TIMEOUT, 20); 580 581 /* write final value and enable port */ 582 asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN)); 583 584 uart_port_unlock_irqrestore(port, flags); 585 586 if (manual_rts) { 587 pinctrl_select_state(ascport->pinctrl, 588 ascport->states[NO_HW_FLOWCTRL]); 589 590 gpiod = devm_gpiod_get(port->dev, "rts", GPIOD_OUT_LOW); 591 if (!IS_ERR(gpiod)) { 592 gpiod_set_consumer_name(gpiod, 593 port->dev->of_node->name); 594 ascport->rts = gpiod; 595 } else { 596 devm_gpiod_put(port->dev, ascport->rts); 597 ascport->rts = NULL; 598 pinctrl_select_state(ascport->pinctrl, 599 ascport->states[DEFAULT]); 600 } 601 } 602 } 603 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki