[android-common:android17-6.18 0/2] drivers/usb/typec/tcpm/tcpm.c:1685:18: sparse: sparse: incorrect type in assignment (different base types)

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://android.googlesource.com/kernel/common android17-6.18
head:   108028936ad167fb2d330e9151ce744f363fb538
commit: 19fa58626d0aaa0440aa17f36ca216e23293b383 [0/2] FROMGIT: usb: typec: tcpm: Add support for Battery Cap response message
config: i386-randconfig-063-20260825 (https://download.01.org/0day-ci/archive/20260825/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)
>> drivers/usb/typec/tcpm/tcpm.c:1685:18: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le16 [usertype] vid @@     got int @@
   drivers/usb/typec/tcpm/tcpm.c:1685:18: sparse:     expected restricted __le16 [usertype] vid
   drivers/usb/typec/tcpm/tcpm.c:1685:18: sparse:     got int

vim +1685 drivers/usb/typec/tcpm/tcpm.c

  1638	
  1639	static int tcpm_pd_send_batt_cap(struct tcpm_port *port)
  1640	{
  1641		u16 design_cap = BATTERY_PROPERTY_UNKNOWN;
  1642		u16 charge_cap = BATTERY_PROPERTY_UNKNOWN;
  1643		u32 batt_id = port->batt_request_id;
  1644		union power_supply_propval val;
  1645		struct batt_cap_ext_msg bcdb;
  1646		struct power_supply *batt;
  1647		bool invalid_ref = true;
  1648		struct pd_message msg;
  1649		u8 data_obj_cnt;
  1650		int ret, vol;
  1651	
  1652		tcpm_get_fixed_batt(port);
  1653		memset(&msg, 0, sizeof(msg));
  1654	
  1655		if (batt_id >= port->fixed_batt_cnt || batt_id >= MAX_NUM_FIXED_BATT)
  1656			goto send_cap;
  1657	
  1658		invalid_ref = false;
  1659		batt = port->fixed_batt[batt_id];
  1660		ret = power_supply_get_property(batt, POWER_SUPPLY_PROP_VOLTAGE_AVG,
  1661						&val);
  1662		if (!ret) {
  1663			vol = val.intval;
  1664			ret = power_supply_get_property(batt,
  1665							POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
  1666							&val);
  1667			if (!ret)
  1668				design_cap = tcpm_charge_to_energy(val.intval, vol);
  1669	
  1670			ret = power_supply_get_property(batt,
  1671							POWER_SUPPLY_PROP_CHARGE_FULL,
  1672							&val);
  1673			if (!ret)
  1674				charge_cap = tcpm_charge_to_energy(val.intval, vol);
  1675		}
  1676	
  1677	send_cap:
  1678	
  1679		/*
  1680		 * As per the USB PD Rev3.1 v1.8 spec, if a battery VID (assigned by the
  1681		 * USB-IF) does not exist or an invalid battery reference is made by the
  1682		 * requestor, then set the VID field to 0xffff. If the VID field is
  1683		 * 0xffff, set the PID field to 0.
  1684		 */
> 1685		bcdb.vid = BATTERY_PROPERTY_UNKNOWN;
  1686		bcdb.pid = 0;
  1687		bcdb.batt_design_cap = cpu_to_le16(design_cap);
  1688		bcdb.batt_last_chg_cap = cpu_to_le16(charge_cap);
  1689		bcdb.batt_type = invalid_ref ? BATT_CAP_BATT_TYPE_INVALID_REF : 0;
  1690		memcpy(msg.ext_msg.data, &bcdb, sizeof(bcdb));
  1691		msg.ext_msg.header = PD_EXT_HDR_LE(sizeof(bcdb),
  1692						   0, /* Denotes if request chunk */
  1693						   0, /* Chunk number */
  1694						   1  /* Chunked */);
  1695	
  1696		data_obj_cnt = count_chunked_data_objs(sizeof(bcdb));
  1697		msg.header = PD_HEADER_EXT_LE(PD_EXT_BATT_CAP, port->pwr_role,
  1698					      port->data_role, port->negotiated_rev,
  1699					      port->message_id, data_obj_cnt);
  1700	
  1701		return tcpm_pd_transmit(port, TCPC_TX_SOP, &msg);
  1702	}
  1703	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.