History

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).

Prashant Malani committed 3 years ago

Commit 478f32a1 parent 13aba1e1 file · +3 −1Browse files

Unified · Split

drivers/platform/chrome/cros_typec_vdm.c+3−1
@@ -86,10 +86,12 @@ static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr, · 85 unmodified lines
86 .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,86 .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
87 };87 };
88 struct typec_vdm_req vdm_req = {};88 struct typec_vdm_req vdm_req = {};
89 int i;
89 90
90 vdm_req.vdm_data[0] = hdr;91 vdm_req.vdm_data[0] = hdr;
91 vdm_req.vdm_data_objects = cnt;92 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];
93 vdm_req.partner_type = TYPEC_PARTNER_SOP;95 vdm_req.partner_type = TYPEC_PARTNER_SOP;
94 req.vdm_req_params = vdm_req;96 req.vdm_req_params = vdm_req;
95 97

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t