Re: [PATCH v5] usb-serial:cp210x: add support to software flow control
From: kernel test robot
Date: Thu Oct 15 2020 - 06:10:14 EST
Hi Sheng,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on usb-serial/usb-next]
[also build test WARNING on v5.9 next-20201015]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Sheng-Long-Wang/usb-serial-cp210x-add-support-to-software-flow-control/20201015-150459
base: https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git usb-next
config: x86_64-randconfig-a004-20201014 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project e7b4feea8e1bf520b34ad8c116abab6677344b74)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/87886eacf097dd70bd9f9391eb329fa40706038a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sheng-Long-Wang/usb-serial-cp210x-add-support-to-software-flow-control/20201015-150459
git checkout 87886eacf097dd70bd9f9391eb329fa40706038a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All warnings (new ones prefixed by >>):
>> drivers/usb/serial/cp210x.c:1553:6: warning: variable 'result' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (((iflag & IXOFF) != (old_iflag & IXOFF)) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/serial/cp210x.c:1592:6: note: uninitialized use occurs here
if (result < 0)
^~~~~~
drivers/usb/serial/cp210x.c:1553:2: note: remove the 'if' if its condition is always true
if (((iflag & IXOFF) != (old_iflag & IXOFF)) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/serial/cp210x.c:1436:12: note: initialize the variable 'result' to silence this warning
int result;
^
= 0
1 warning generated.
vim +1553 drivers/usb/serial/cp210x.c
1427
1428 static void cp210x_set_termios(struct tty_struct *tty,
1429 struct usb_serial_port *port, struct ktermios *old_termios)
1430 {
1431 struct device *dev = &port->dev;
1432 unsigned int cflag, old_cflag, iflag, old_iflag;
1433 struct cp210x_special_chars special_chars;
1434 struct cp210x_flow_ctl flow_ctl;
1435 u16 bits;
1436 int result;
1437 u32 ctl_hs;
1438 u32 flow_repl;
1439
1440 cflag = tty->termios.c_cflag;
1441 iflag = tty->termios.c_iflag;
1442 old_cflag = old_termios->c_cflag;
1443 old_iflag = old_termios->c_iflag;
1444
1445 if (tty->termios.c_ospeed != old_termios->c_ospeed)
1446 cp210x_change_speed(tty, port, old_termios);
1447
1448 /* If the number of data bits is to be updated */
1449 if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
1450 cp210x_get_line_ctl(port, &bits);
1451 bits &= ~BITS_DATA_MASK;
1452 switch (cflag & CSIZE) {
1453 case CS5:
1454 bits |= BITS_DATA_5;
1455 dev_dbg(dev, "%s - data bits = 5\n", __func__);
1456 break;
1457 case CS6:
1458 bits |= BITS_DATA_6;
1459 dev_dbg(dev, "%s - data bits = 6\n", __func__);
1460 break;
1461 case CS7:
1462 bits |= BITS_DATA_7;
1463 dev_dbg(dev, "%s - data bits = 7\n", __func__);
1464 break;
1465 case CS8:
1466 default:
1467 bits |= BITS_DATA_8;
1468 dev_dbg(dev, "%s - data bits = 8\n", __func__);
1469 break;
1470 }
1471 if (cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits))
1472 dev_dbg(dev, "Number of data bits requested not supported by device\n");
1473 }
1474
1475 if ((cflag & (PARENB|PARODD|CMSPAR)) !=
1476 (old_cflag & (PARENB|PARODD|CMSPAR))) {
1477 cp210x_get_line_ctl(port, &bits);
1478 bits &= ~BITS_PARITY_MASK;
1479 if (cflag & PARENB) {
1480 if (cflag & CMSPAR) {
1481 if (cflag & PARODD) {
1482 bits |= BITS_PARITY_MARK;
1483 dev_dbg(dev, "%s - parity = MARK\n", __func__);
1484 } else {
1485 bits |= BITS_PARITY_SPACE;
1486 dev_dbg(dev, "%s - parity = SPACE\n", __func__);
1487 }
1488 } else {
1489 if (cflag & PARODD) {
1490 bits |= BITS_PARITY_ODD;
1491 dev_dbg(dev, "%s - parity = ODD\n", __func__);
1492 } else {
1493 bits |= BITS_PARITY_EVEN;
1494 dev_dbg(dev, "%s - parity = EVEN\n", __func__);
1495 }
1496 }
1497 }
1498 if (cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits))
1499 dev_dbg(dev, "Parity mode not supported by device\n");
1500 }
1501
1502 if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) {
1503 cp210x_get_line_ctl(port, &bits);
1504 bits &= ~BITS_STOP_MASK;
1505 if (cflag & CSTOPB) {
1506 bits |= BITS_STOP_2;
1507 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
1508 } else {
1509 bits |= BITS_STOP_1;
1510 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
1511 }
1512 if (cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits))
1513 dev_dbg(dev, "Number of stop bits requested not supported by device\n");
1514 }
1515
1516 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
1517 cp210x_read_reg_block(port, CP210X_GET_FLOW, &flow_ctl,
1518 sizeof(flow_ctl));
1519 ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake);
1520 flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace);
1521 dev_dbg(dev, "%s - read ulControlHandshake=0x%08x, ulFlowReplace=0x%08x\n",
1522 __func__, ctl_hs, flow_repl);
1523
1524 ctl_hs &= ~CP210X_SERIAL_DSR_HANDSHAKE;
1525 ctl_hs &= ~CP210X_SERIAL_DCD_HANDSHAKE;
1526 ctl_hs &= ~CP210X_SERIAL_DSR_SENSITIVITY;
1527 ctl_hs &= ~CP210X_SERIAL_DTR_MASK;
1528 ctl_hs |= CP210X_SERIAL_DTR_SHIFT(CP210X_SERIAL_DTR_ACTIVE);
1529 if (cflag & CRTSCTS) {
1530 ctl_hs |= CP210X_SERIAL_CTS_HANDSHAKE;
1531
1532 flow_repl &= ~CP210X_SERIAL_RTS_MASK;
1533 flow_repl |= CP210X_SERIAL_RTS_SHIFT(
1534 CP210X_SERIAL_RTS_FLOW_CTL);
1535 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
1536 } else {
1537 ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE;
1538
1539 flow_repl &= ~CP210X_SERIAL_RTS_MASK;
1540 flow_repl |= CP210X_SERIAL_RTS_SHIFT(
1541 CP210X_SERIAL_RTS_ACTIVE);
1542 dev_dbg(dev, "%s - flow control = NONE\n", __func__);
1543 }
1544
1545 dev_dbg(dev, "%s - write ulControlHandshake=0x%08x, ulFlowReplace=0x%08x\n",
1546 __func__, ctl_hs, flow_repl);
1547 flow_ctl.ulControlHandshake = cpu_to_le32(ctl_hs);
1548 flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
1549 cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl,
1550 sizeof(flow_ctl));
1551 }
1552
> 1553 if (((iflag & IXOFF) != (old_iflag & IXOFF)) ||
1554 ((iflag & IXON) != (old_iflag & IXON))) {
1555 result = cp210x_get_chars(port, &special_chars);
1556 if (result < 0)
1557 goto out;
1558
1559 special_chars.bXonChar = START_CHAR(tty);
1560 special_chars.bXoffChar = STOP_CHAR(tty);
1561
1562 result = cp210x_set_chars(port, &special_chars);
1563 if (result < 0)
1564 goto out;
1565
1566 result = cp210x_read_reg_block(port,
1567 CP210X_GET_FLOW,
1568 &flow_ctl,
1569 sizeof(flow_ctl));
1570 if (result < 0)
1571 goto out;
1572
1573 flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace);
1574
1575 if (iflag & IXOFF)
1576 flow_repl |= CP210X_SERIAL_AUTO_RECEIVE;
1577 else
1578 flow_repl &= ~CP210X_SERIAL_AUTO_RECEIVE;
1579
1580 if (iflag & IXON)
1581 flow_repl |= CP210X_SERIAL_AUTO_TRANSMIT;
1582 else
1583 flow_repl &= ~CP210X_SERIAL_AUTO_TRANSMIT;
1584
1585 flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
1586 result = cp210x_write_reg_block(port,
1587 CP210X_SET_FLOW,
1588 &flow_ctl,
1589 sizeof(flow_ctl));
1590 }
1591 out:
1592 if (result < 0)
1593 dev_err(dev, "failed to set software flow control: %d\n", result);
1594
1595 /*
1596 * Enable event-insertion mode only if input parity checking is
1597 * enabled for now.
1598 */
1599 if (I_INPCK(tty))
1600 cp210x_enable_event_mode(port);
1601 else
1602 cp210x_disable_event_mode(port);
1603 }
1604
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip