Skip to content

Commit 478f32a

Browse files
author
Prashant Malani
committed
platform/chrome: cros_typec_vdm: Fix VDO copy
The usage of memcpy() affects the representation of the VDOs as they are copied to the EC Host Command buffer. Specifically, all higher order bits get dropped (for example: a VDO of 0x406 just gets copied as 0x6). Avoid this by explicitly copying each VDO in the array. The number of VDOs generated by alternate mode drivers in their VDMs is almost always just 1 (apart from the header) so this doesn't affect performance in a meaningful way). Fixes: 40a9b13 ("platform/chrome: cros_typec_vdm: Add VDM send support") Signed-off-by: Prashant Malani <[email protected]> Reviewed-by: Benson Leung <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Prashant Malani <[email protected]>
1 parent 13aba1e commit 478f32a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/platform/chrome/cros_typec_vdm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr,
8686
.command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
8787
};
8888
struct typec_vdm_req vdm_req = {};
89+
int i;
8990

9091
vdm_req.vdm_data[0] = hdr;
9192
vdm_req.vdm_data_objects = cnt;
92-
memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1);
93+
for (i = 1; i < cnt; i++)
94+
vdm_req.vdm_data[i] = vdo[i-1];
9395
vdm_req.partner_type = TYPEC_PARTNER_SOP;
9496
req.vdm_req_params = vdm_req;
9597

0 commit comments

Comments
 (0)