summaryrefslogtreecommitdiff
path: root/drivers/platform/chrome
diff options
context:
space:
mode:
authorPrashant Malani <pmalani@chromium.org>2023-01-13 21:26:26 +0300
committerPrashant Malani <pmalani@chromium.org>2023-01-24 22:02:38 +0300
commit478f32ab4daae8a9bae3723d1040c6e4e3a09bc5 (patch)
tree75759d76e8d1a781a5731b11129899b8f463b18e /drivers/platform/chrome
parent13aba1e532f047459a683f76439ad90fb29eab05 (diff)
downloadlinux-478f32ab4daae8a9bae3723d1040c6e4e3a09bc5.tar.xz
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: 40a9b13a09ef ("platform/chrome: cros_typec_vdm: Add VDM send support") Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Link: https://lore.kernel.org/r/20230113182626.1149539-1-pmalani@chromium.org Signed-off-by: Prashant Malani <pmalani@chromium.org>
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r--drivers/platform/chrome/cros_typec_vdm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
index aca9d337118e..06f4a55999c5 100644
--- a/drivers/platform/chrome/cros_typec_vdm.c
+++ b/drivers/platform/chrome/cros_typec_vdm.c
@@ -86,10 +86,12 @@ static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr,
.command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
};
struct typec_vdm_req vdm_req = {};
+ int i;
vdm_req.vdm_data[0] = hdr;
vdm_req.vdm_data_objects = cnt;
- memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1);
+ for (i = 1; i < cnt; i++)
+ vdm_req.vdm_data[i] = vdo[i-1];
vdm_req.partner_type = TYPEC_PARTNER_SOP;
req.vdm_req_params = vdm_req;