Re: [PATCH v8] USB: serial: cp210x: Add support for GPIOs on CP2108

From: kernel test robot
Date: Tue Apr 06 2021 - 09:11:31 EST


Hi Pho,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on usb-serial/usb-next]
[also build test WARNING on usb/usb-testing tty/tty-testing v5.12-rc6 next-20210401]
[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/Pho-Tran/USB-serial-cp210x-Add-support-for-GPIOs-on-CP2108/20210406-182022
base: https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git usb-next
config: i386-randconfig-s001-20210406 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-279-g6d5d9b42-dirty
# https://github.com/0day-ci/linux/commit/850a69bacbd236b7bbdadfa4007e7f13b3c79471
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Pho-Tran/USB-serial-cp210x-Add-support-for-GPIOs-on-CP2108/20210406-182022
git checkout 850a69bacbd236b7bbdadfa4007e7f13b3c79471
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)
>> drivers/usb/serial/cp210x.c:1540:15: sparse: sparse: cast to restricted __le16

vim +1540 drivers/usb/serial/cp210x.c

1496
1497 static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
1498 {
1499 struct usb_serial *serial = gpiochip_get_data(gc);
1500 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
1501 u8 req_type = REQTYPE_DEVICE_TO_HOST;
1502 int result;
1503 u16 buf;
1504
1505 result = usb_autopm_get_interface(serial->interface);
1506 if (result)
1507 return result;
1508 /*
1509 * This function will be read latch value of gpio and storage to buf(16bit)
1510 * where bit 0 is GPIO0, bit 1 is GPIO1, etc. Up to GPIOn where n is
1511 * total number of GPIO pins the interface supports.
1512 * Interfaces on CP2102N supports 7 GPIOs
1513 * Interfaces on CP2103 amd CP2104 supports 4 GPIOs
1514 * Enhanced interfaces on CP2105 support 3 GPIOs
1515 * Standard interfaces on CP2105 support 4 GPIOs
1516 * Interfaces on CP2108 supports 16 GPIOs
1517 */
1518 switch (priv->partnum) {
1519 /*
1520 * Request type to Read_Latch of CP2105 and Cp2108
1521 * is 0xc1 <REQTYPE_INTERFACE_TO_HOST>
1522 */
1523 case CP210X_PARTNUM_CP2108:
1524 req_type = REQTYPE_INTERFACE_TO_HOST;
1525 result = cp210x_read_vendor_block(serial, req_type,
1526 CP210X_READ_LATCH, &buf, sizeof(__le16));
1527 break;
1528 case CP210X_PARTNUM_CP2105:
1529 req_type = REQTYPE_INTERFACE_TO_HOST;
1530 result = cp210x_read_vendor_block(serial, req_type,
1531 CP210X_READ_LATCH, &buf, sizeof(u8));
1532 break;
1533 default:
1534 result = cp210x_read_vendor_block(serial, req_type,
1535 CP210X_READ_LATCH, &buf, sizeof(u8));
1536 break;
1537 }
1538 if (result < 0)
1539 return result;
> 1540 buf = le16_to_cpu(buf);
1541 usb_autopm_put_interface(serial->interface);
1542 return !!(buf & BIT(gpio));
1543 }
1544

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip