Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: ucsi: Update UCSI structure to have message in and message out fields

Update UCSI structure by adding fields for incoming and outgoing
messages. Update .sync_control function and other related functions
to use these new fields within the UCSI structure, instead of handling
them as separate parameters.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Pooja Katiyar <pooja.katiyar@intel.com>
Link: https://patch.msgid.link/214b0a90c3220db33084ab714f4f33a004f70a41.1761773881.git.pooja.katiyar@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Pooja Katiyar and committed by
Greg Kroah-Hartman
3e082978 a67df6d1

+112 -71
+2 -3
drivers/usb/typec/ucsi/cros_ec_ucsi.c
··· 105 105 return 0; 106 106 } 107 107 108 - static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci, 109 - void *data, size_t size) 108 + static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci) 110 109 { 111 110 struct cros_ucsi_data *udata = ucsi_get_drvdata(ucsi); 112 111 int ret; 113 112 114 - ret = ucsi_sync_control_common(ucsi, cmd, cci, data, size); 113 + ret = ucsi_sync_control_common(ucsi, cmd, cci); 115 114 switch (ret) { 116 115 case -EBUSY: 117 116 /* EC may return -EBUSY if CCI.busy is set.
+5 -4
drivers/usb/typec/ucsi/debugfs.c
··· 37 37 case UCSI_SET_USB: 38 38 case UCSI_SET_POWER_LEVEL: 39 39 case UCSI_READ_POWER_LEVEL: 40 - ret = ucsi_send_command(ucsi, val, NULL, 0); 40 + ucsi->message_in_size = 0; 41 + ret = ucsi_send_command(ucsi, val); 41 42 break; 42 43 case UCSI_GET_CAPABILITY: 43 44 case UCSI_GET_CONNECTOR_CAPABILITY: ··· 53 52 case UCSI_GET_ATTENTION_VDO: 54 53 case UCSI_GET_CAM_CS: 55 54 case UCSI_GET_LPM_PPM_INFO: 56 - ret = ucsi_send_command(ucsi, val, 57 - &ucsi->debugfs->response, 58 - sizeof(ucsi->debugfs->response)); 55 + ucsi->message_in_size = sizeof(ucsi->debugfs->response); 56 + ret = ucsi_send_command(ucsi, val); 57 + memcpy(&ucsi->debugfs->response, ucsi->message_in, sizeof(ucsi->debugfs->response)); 59 58 break; 60 59 default: 61 60 ret = -EOPNOTSUPP;
+8 -3
drivers/usb/typec/ucsi/displayport.c
··· 67 67 } 68 68 69 69 command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(dp->con->num); 70 - ret = ucsi_send_command(ucsi, command, &cur, sizeof(cur)); 70 + ucsi->message_in_size = sizeof(cur); 71 + ret = ucsi_send_command(ucsi, command); 71 72 if (ret < 0) { 72 73 if (ucsi->version > 0x0100) 73 74 goto err_unlock; 74 75 cur = 0xff; 76 + } else { 77 + memcpy(&cur, ucsi->message_in, ucsi->message_in_size); 75 78 } 76 79 77 80 if (cur != 0xff) { ··· 129 126 } 130 127 131 128 command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 0, dp->offset, 0); 132 - ret = ucsi_send_command(dp->con->ucsi, command, NULL, 0); 129 + dp->con->ucsi->message_in_size = 0; 130 + ret = ucsi_send_command(dp->con->ucsi, command); 133 131 if (ret < 0) 134 132 goto out_unlock; 135 133 ··· 197 193 198 194 command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 1, dp->offset, pins); 199 195 200 - return ucsi_send_command(dp->con->ucsi, command, NULL, 0); 196 + dp->con->ucsi->message_in_size = 0; 197 + return ucsi_send_command(dp->con->ucsi, command); 201 198 } 202 199 203 200 static int ucsi_displayport_vdm(struct typec_altmode *alt,
+68 -36
drivers/usb/typec/ucsi/ucsi.c
··· 55 55 } 56 56 EXPORT_SYMBOL_GPL(ucsi_notify_common); 57 57 58 - int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci, 59 - void *data, size_t size) 58 + int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci) 60 59 { 61 60 bool ack = UCSI_COMMAND(command) == UCSI_ACK_CC_CI; 62 61 int ret; ··· 83 84 if (!ret && cci) 84 85 ret = ucsi->ops->read_cci(ucsi, cci); 85 86 86 - if (!ret && data && 87 + if (!ret && ucsi->message_in_size > 0 && 87 88 (*cci & UCSI_CCI_COMMAND_COMPLETE)) 88 - ret = ucsi->ops->read_message_in(ucsi, data, size); 89 + ret = ucsi->ops->read_message_in(ucsi, ucsi->message_in, 90 + ucsi->message_in_size); 89 91 90 92 return ret; 91 93 } ··· 103 103 ctrl |= UCSI_ACK_CONNECTOR_CHANGE; 104 104 } 105 105 106 - return ucsi->ops->sync_control(ucsi, ctrl, NULL, NULL, 0); 106 + ucsi->message_in_size = 0; 107 + return ucsi->ops->sync_control(ucsi, ctrl, NULL); 107 108 } 108 109 109 - static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci, 110 - void *data, size_t size, bool conn_ack) 110 + static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci, bool conn_ack) 111 111 { 112 112 int ret, err; 113 113 114 114 *cci = 0; 115 115 116 - if (size > UCSI_MAX_DATA_LENGTH(ucsi)) 116 + if (ucsi->message_in_size > UCSI_MAX_DATA_LENGTH(ucsi)) 117 117 return -EINVAL; 118 118 119 - ret = ucsi->ops->sync_control(ucsi, command, cci, data, size); 119 + ret = ucsi->ops->sync_control(ucsi, command, cci); 120 120 121 - if (*cci & UCSI_CCI_BUSY) 122 - return ucsi_run_command(ucsi, UCSI_CANCEL, cci, NULL, 0, false) ?: -EBUSY; 121 + if (*cci & UCSI_CCI_BUSY) { 122 + ucsi->message_in_size = 0; 123 + return ucsi_run_command(ucsi, UCSI_CANCEL, cci, false) ?: -EBUSY; 124 + } 123 125 if (ret) 124 126 return ret; 125 127 ··· 153 151 int ret; 154 152 155 153 command = UCSI_GET_ERROR_STATUS | UCSI_CONNECTOR_NUMBER(connector_num); 156 - ret = ucsi_run_command(ucsi, command, &cci, &error, sizeof(error), false); 154 + ucsi->message_in_size = sizeof(error); 155 + ret = ucsi_run_command(ucsi, command, &cci, false); 157 156 if (ret < 0) 158 157 return ret; 158 + 159 + memcpy(&error, ucsi->message_in, sizeof(error)); 159 160 160 161 switch (error) { 161 162 case UCSI_ERROR_INCOMPATIBLE_PARTNER: ··· 205 200 return -EIO; 206 201 } 207 202 208 - static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd, 209 - void *data, size_t size, bool conn_ack) 203 + static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd, bool conn_ack) 210 204 { 211 205 u8 connector_num; 212 206 u32 cci; ··· 233 229 234 230 mutex_lock(&ucsi->ppm_lock); 235 231 236 - ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack); 232 + ret = ucsi_run_command(ucsi, cmd, &cci, conn_ack); 237 233 238 234 if (cci & UCSI_CCI_ERROR) 239 235 ret = ucsi_read_error(ucsi, connector_num); ··· 242 238 return ret; 243 239 } 244 240 245 - int ucsi_send_command(struct ucsi *ucsi, u64 command, 246 - void *data, size_t size) 241 + int ucsi_send_command(struct ucsi *ucsi, u64 command) 247 242 { 248 - return ucsi_send_command_common(ucsi, command, data, size, false); 243 + return ucsi_send_command_common(ucsi, command, false); 249 244 } 250 245 EXPORT_SYMBOL_GPL(ucsi_send_command); 251 246 ··· 322 319 int i; 323 320 324 321 command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num); 325 - ret = ucsi_send_command(con->ucsi, command, &cur, sizeof(cur)); 322 + con->ucsi->message_in_size = sizeof(cur); 323 + ret = ucsi_send_command(con->ucsi, command); 326 324 if (ret < 0) { 327 325 if (con->ucsi->version > 0x0100) { 328 326 dev_err(con->ucsi->dev, ··· 331 327 return; 332 328 } 333 329 cur = 0xff; 330 + } else { 331 + memcpy(&cur, con->ucsi->message_in, sizeof(cur)); 334 332 } 335 333 336 334 if (cur < UCSI_MAX_ALTMODES) ··· 516 510 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient); 517 511 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num); 518 512 command |= UCSI_GET_ALTMODE_OFFSET(i); 519 - len = ucsi_send_command(con->ucsi, command, &alt, sizeof(alt)); 513 + ucsi->message_in_size = sizeof(alt); 514 + len = ucsi_send_command(con->ucsi, command); 520 515 /* 521 516 * We are collecting all altmodes first and then registering. 522 517 * Some type-C device will return zero length data beyond last ··· 525 518 */ 526 519 if (len < 0) 527 520 return len; 521 + 522 + memcpy(&alt, ucsi->message_in, sizeof(alt)); 528 523 529 524 /* We got all altmodes, now break out and register them */ 530 525 if (!len || !alt.svid) ··· 595 586 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient); 596 587 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num); 597 588 command |= UCSI_GET_ALTMODE_OFFSET(i); 598 - len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt)); 589 + con->ucsi->message_in_size = sizeof(alt); 590 + len = ucsi_send_command(con->ucsi, command); 599 591 if (len == -EBUSY) 600 592 continue; 601 593 if (len <= 0) 602 594 return len; 595 + 596 + memcpy(&alt, con->ucsi->message_in, sizeof(alt)); 603 597 604 598 /* 605 599 * This code is requesting one alt mode at a time, but some PPMs ··· 671 659 UCSI_MAX_DATA_LENGTH(con->ucsi)); 672 660 int ret; 673 661 674 - ret = ucsi_send_command_common(con->ucsi, command, &con->status, size, conn_ack); 662 + con->ucsi->message_in_size = size; 663 + ret = ucsi_send_command_common(con->ucsi, command, conn_ack); 664 + memcpy(&con->status, con->ucsi->message_in, size); 675 665 676 666 return ret < 0 ? ret : 0; 677 667 } ··· 696 682 command |= UCSI_GET_PDOS_PDO_OFFSET(offset); 697 683 command |= UCSI_GET_PDOS_NUM_PDOS(num_pdos - 1); 698 684 command |= is_source(role) ? UCSI_GET_PDOS_SRC_PDOS : 0; 699 - ret = ucsi_send_command(ucsi, command, pdos + offset, 700 - num_pdos * sizeof(u32)); 685 + ucsi->message_in_size = num_pdos * sizeof(u32); 686 + ret = ucsi_send_command(ucsi, command); 687 + memcpy(pdos + offset, ucsi->message_in, num_pdos * sizeof(u32)); 701 688 if (ret < 0 && ret != -ETIMEDOUT) 702 689 dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret); 703 690 ··· 785 770 command |= UCSI_GET_PD_MESSAGE_BYTES(len); 786 771 command |= UCSI_GET_PD_MESSAGE_TYPE(type); 787 772 788 - ret = ucsi_send_command(con->ucsi, command, data + offset, len); 773 + con->ucsi->message_in_size = len; 774 + ret = ucsi_send_command(con->ucsi, command); 775 + memcpy(data + offset, con->ucsi->message_in, len); 789 776 if (ret < 0) 790 777 return ret; 791 778 } ··· 952 935 int ret; 953 936 954 937 command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num); 955 - ret = ucsi_send_command(con->ucsi, command, &cable_prop, sizeof(cable_prop)); 938 + con->ucsi->message_in_size = sizeof(cable_prop); 939 + ret = ucsi_send_command(con->ucsi, command); 940 + memcpy(&cable_prop, con->ucsi->message_in, sizeof(cable_prop)); 956 941 if (ret < 0) { 957 942 dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n", ret); 958 943 return ret; ··· 1015 996 return 0; 1016 997 1017 998 command = UCSI_GET_CONNECTOR_CAPABILITY | UCSI_CONNECTOR_NUMBER(con->num); 1018 - ret = ucsi_send_command(con->ucsi, command, &con->cap, sizeof(con->cap)); 999 + con->ucsi->message_in_size = sizeof(con->cap); 1000 + ret = ucsi_send_command(con->ucsi, command); 1001 + memcpy(&con->cap, con->ucsi->message_in, sizeof(con->cap)); 1019 1002 if (ret < 0) { 1020 1003 dev_err(con->ucsi->dev, "GET_CONNECTOR_CAPABILITY failed (%d)\n", ret); 1021 1004 return ret; ··· 1401 1380 else if (con->ucsi->version >= UCSI_VERSION_2_0) 1402 1381 command |= hard ? 0 : UCSI_CONNECTOR_RESET_DATA_VER_2_0; 1403 1382 1404 - return ucsi_send_command(con->ucsi, command, NULL, 0); 1383 + con->ucsi->message_in_size = 0; 1384 + return ucsi_send_command(con->ucsi, command); 1405 1385 } 1406 1386 1407 1387 static int ucsi_reset_ppm(struct ucsi *ucsi) ··· 1483 1461 { 1484 1462 int ret; 1485 1463 1486 - ret = ucsi_send_command(con->ucsi, command, NULL, 0); 1464 + con->ucsi->message_in_size = 0; 1465 + ret = ucsi_send_command(con->ucsi, command); 1487 1466 if (ret == -ETIMEDOUT) { 1488 1467 u64 c; 1489 1468 ··· 1492 1469 ucsi_reset_ppm(con->ucsi); 1493 1470 1494 1471 c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy; 1495 - ucsi_send_command(con->ucsi, c, NULL, 0); 1472 + con->ucsi->message_in_size = 0; 1473 + ucsi_send_command(con->ucsi, c); 1496 1474 1497 1475 ucsi_reset_connector(con, true); 1498 1476 } ··· 1646 1622 /* Get connector capability */ 1647 1623 command = UCSI_GET_CONNECTOR_CAPABILITY; 1648 1624 command |= UCSI_CONNECTOR_NUMBER(con->num); 1649 - ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap)); 1625 + ucsi->message_in_size = sizeof(con->cap); 1626 + ret = ucsi_send_command(ucsi, command); 1650 1627 if (ret < 0) 1651 1628 goto out_unlock; 1629 + 1630 + memcpy(&con->cap, ucsi->message_in, sizeof(con->cap)); 1652 1631 1653 1632 if (UCSI_CONCAP(con, OPMODE_DRP)) 1654 1633 cap->data = TYPEC_PORT_DRD; ··· 1849 1822 /* Enable basic notifications */ 1850 1823 ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR; 1851 1824 command = UCSI_SET_NOTIFICATION_ENABLE | ntfy; 1852 - ret = ucsi_send_command(ucsi, command, NULL, 0); 1825 + ucsi->message_in_size = 0; 1826 + ret = ucsi_send_command(ucsi, command); 1853 1827 if (ret < 0) 1854 1828 goto err_reset; 1855 1829 1856 1830 /* Get PPM capabilities */ 1857 1831 command = UCSI_GET_CAPABILITY; 1858 - ret = ucsi_send_command(ucsi, command, &ucsi->cap, 1859 - BITS_TO_BYTES(UCSI_GET_CAPABILITY_SIZE)); 1832 + ucsi->message_in_size = BITS_TO_BYTES(UCSI_GET_CAPABILITY_SIZE); 1833 + ret = ucsi_send_command(ucsi, command); 1860 1834 if (ret < 0) 1861 1835 goto err_reset; 1836 + 1837 + memcpy(&ucsi->cap, ucsi->message_in, BITS_TO_BYTES(UCSI_GET_CAPABILITY_SIZE)); 1862 1838 1863 1839 if (!ucsi->cap.num_connectors) { 1864 1840 ret = -ENODEV; ··· 1892 1862 /* Enable all supported notifications */ 1893 1863 ntfy = ucsi_get_supported_notifications(ucsi); 1894 1864 command = UCSI_SET_NOTIFICATION_ENABLE | ntfy; 1895 - ret = ucsi_send_command(ucsi, command, NULL, 0); 1865 + ucsi->message_in_size = 0; 1866 + ret = ucsi_send_command(ucsi, command); 1896 1867 if (ret < 0) 1897 1868 goto err_unregister; 1898 1869 ··· 1944 1913 1945 1914 /* Restore UCSI notification enable mask after system resume */ 1946 1915 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy; 1947 - ret = ucsi_send_command(ucsi, command, NULL, 0); 1916 + ucsi->message_in_size = 0; 1917 + ret = ucsi_send_command(ucsi, command); 1948 1918 if (ret < 0) { 1949 1919 dev_err(ucsi->dev, "failed to re-enable notifications (%d)\n", ret); 1950 1920 return;
+13 -6
drivers/usb/typec/ucsi/ucsi.h
··· 29 29 #define UCSI_MESSAGE_OUT 32 30 30 #define UCSIv2_MESSAGE_OUT 272 31 31 32 + /* Define maximum lengths for message buffers */ 33 + #define UCSI_MAX_MESSAGE_IN_LENGTH 256 34 + #define UCSI_MAX_MESSAGE_OUT_LENGTH 256 35 + 32 36 /* UCSI versions */ 33 37 #define UCSI_VERSION_1_0 0x0100 34 38 #define UCSI_VERSION_1_1 0x0110 ··· 84 80 int (*read_cci)(struct ucsi *ucsi, u32 *cci); 85 81 int (*poll_cci)(struct ucsi *ucsi, u32 *cci); 86 82 int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len); 87 - int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci, 88 - void *data, size_t size); 83 + int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci); 89 84 int (*async_control)(struct ucsi *ucsi, u64 command); 90 85 bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient, 91 86 struct ucsi_altmode *orig, ··· 496 493 unsigned long quirks; 497 494 #define UCSI_NO_PARTNER_PDOS BIT(0) /* Don't read partner's PDOs */ 498 495 #define UCSI_DELAY_DEVICE_PDOS BIT(1) /* Reading PDOs fails until the parter is in PD mode */ 496 + 497 + /* Fixed-size buffers for incoming and outgoing messages */ 498 + u8 message_in[UCSI_MAX_MESSAGE_IN_LENGTH]; 499 + size_t message_in_size; 500 + u8 message_out[UCSI_MAX_MESSAGE_OUT_LENGTH]; 501 + size_t message_out_size; 499 502 }; 500 503 501 504 #define UCSI_MAX_DATA_LENGTH(u) (((u)->version < UCSI_VERSION_2_0) ? 0x10 : 0xff) ··· 564 555 struct usb_pd_identity cable_identity; 565 556 }; 566 557 567 - int ucsi_send_command(struct ucsi *ucsi, u64 command, 568 - void *retval, size_t size); 558 + int ucsi_send_command(struct ucsi *ucsi, u64 command); 569 559 570 560 void ucsi_altmode_update_active(struct ucsi_connector *con); 571 561 int ucsi_resume(struct ucsi *ucsi); 572 562 573 563 void ucsi_notify_common(struct ucsi *ucsi, u32 cci); 574 - int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci, 575 - void *data, size_t size); 564 + int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci); 576 565 577 566 #if IS_ENABLED(CONFIG_POWER_SUPPLY) 578 567 int ucsi_register_port_psy(struct ucsi_connector *con);
+4 -5
drivers/usb/typec/ucsi/ucsi_acpi.c
··· 105 105 .async_control = ucsi_acpi_async_control 106 106 }; 107 107 108 - static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci, 109 - void *val, size_t len) 108 + static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci) 110 109 { 111 110 u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE | 112 111 UCSI_CONSTAT_PDOS_CHANGE; 113 112 struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 114 113 int ret; 115 114 116 - ret = ucsi_sync_control_common(ucsi, command, cci, val, len); 115 + ret = ucsi_sync_control_common(ucsi, command, cci); 117 116 if (ret < 0) 118 117 return ret; 119 118 ··· 124 125 if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS && 125 126 ua->check_bogus_event) { 126 127 /* Clear the bogus change */ 127 - if (*(u16 *)val == bogus_change) 128 - *(u16 *)val = 0; 128 + if (*(u16 *)ucsi->message_in == bogus_change) 129 + *(u16 *)ucsi->message_in = 0; 129 130 130 131 ua->check_bogus_event = false; 131 132 }
+5 -6
drivers/usb/typec/ucsi/ucsi_ccg.c
··· 606 606 return ccg_write(uc, reg, (u8 *)&command, sizeof(command)); 607 607 } 608 608 609 - static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci, 610 - void *data, size_t size) 609 + static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci) 611 610 { 612 611 struct ucsi_ccg *uc = ucsi_get_drvdata(ucsi); 613 612 struct ucsi_connector *con; ··· 628 629 ucsi_ccg_update_set_new_cam_cmd(uc, con, &command); 629 630 } 630 631 631 - ret = ucsi_sync_control_common(ucsi, command, cci, data, size); 632 + ret = ucsi_sync_control_common(ucsi, command, cci); 632 633 633 634 switch (UCSI_COMMAND(command)) { 634 635 case UCSI_GET_CURRENT_CAM: 635 636 if (uc->has_multiple_dp) 636 - ucsi_ccg_update_get_current_cam_cmd(uc, (u8 *)data); 637 + ucsi_ccg_update_get_current_cam_cmd(uc, (u8 *)ucsi->message_in); 637 638 break; 638 639 case UCSI_GET_ALTERNATE_MODES: 639 640 if (UCSI_ALTMODE_RECIPIENT(command) == UCSI_RECIPIENT_SOP) { 640 - struct ucsi_altmode *alt = data; 641 + struct ucsi_altmode *alt = (struct ucsi_altmode *)ucsi->message_in; 641 642 642 643 if (alt[0].svid == USB_TYPEC_NVIDIA_VLINK_SID) 643 644 ucsi_ccg_nvidia_altmode(uc, alt, command); ··· 645 646 break; 646 647 case UCSI_GET_CAPABILITY: 647 648 if (uc->fw_build == CCG_FW_BUILD_NVIDIA_TEGRA) { 648 - struct ucsi_capability *cap = data; 649 + struct ucsi_capability *cap = (struct ucsi_capability *)ucsi->message_in; 649 650 650 651 cap->features &= ~UCSI_CAP_ALT_MODE_DETAILS; 651 652 }
+7 -8
drivers/usb/typec/ucsi/ucsi_yoga_c630.c
··· 88 88 89 89 static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi, 90 90 u64 command, 91 - u32 *cci, 92 - void *data, size_t size) 91 + u32 *cci) 93 92 { 94 93 int ret; 95 94 ··· 106 107 }; 107 108 108 109 dev_dbg(ucsi->dev, "faking DP altmode for con1\n"); 109 - memset(data, 0, size); 110 - memcpy(data, &alt, min(sizeof(alt), size)); 110 + memset(ucsi->message_in, 0, ucsi->message_in_size); 111 + memcpy(ucsi->message_in, &alt, min(sizeof(alt), ucsi->message_in_size)); 111 112 *cci = UCSI_CCI_COMMAND_COMPLETE | UCSI_SET_CCI_LENGTH(sizeof(alt)); 112 113 return 0; 113 114 } ··· 120 121 if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES && 121 122 UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 2) { 122 123 dev_dbg(ucsi->dev, "ignoring altmodes for con2\n"); 123 - memset(data, 0, size); 124 + memset(ucsi->message_in, 0, ucsi->message_in_size); 124 125 *cci = UCSI_CCI_COMMAND_COMPLETE; 125 126 return 0; 126 127 } 127 128 128 - ret = ucsi_sync_control_common(ucsi, command, cci, data, size); 129 + ret = ucsi_sync_control_common(ucsi, command, cci); 129 130 if (ret < 0) 130 131 return ret; 131 132 132 133 /* UCSI_GET_CURRENT_CAM is off-by-one on all ports */ 133 - if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && data) 134 - ((u8 *)data)[0]--; 134 + if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && ucsi->message_in_size > 0) 135 + ucsi->message_in[0]--; 135 136 136 137 return ret; 137 138 }