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

usb: typec: ucsi: acpi: move LG Gram quirk to ucsi_gram_sync_control()

It is easier to keep all command-specific quirks in a single place. Move
them to ucsi_gram_sync_control() as the code now allows us to return
modified messages data.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250120-ucsi-merge-commands-v2-3-462a1ec22ecc@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dmitry Baryshkov and committed by
Greg Kroah-Hartman
f9cf5401 7f826354

+9 -21
+9 -21
drivers/usb/typec/ucsi/ucsi_acpi.c
··· 99 99 .async_control = ucsi_acpi_async_control 100 100 }; 101 101 102 - static int ucsi_gram_read_message_in(struct ucsi *ucsi, void *val, size_t val_len) 102 + static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci, 103 + void *val, size_t len) 103 104 { 104 105 u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE | 105 106 UCSI_CONSTAT_PDOS_CHANGE; 106 107 struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 107 108 int ret; 108 109 109 - ret = ucsi_acpi_read_message_in(ucsi, val, val_len); 110 + ret = ucsi_sync_control_common(ucsi, command, cci, val, len); 110 111 if (ret < 0) 111 112 return ret; 113 + 114 + if (UCSI_COMMAND(ua->cmd) == UCSI_GET_PDOS && 115 + ua->cmd & UCSI_GET_PDOS_PARTNER_PDO(1) && 116 + ua->cmd & UCSI_GET_PDOS_SRC_PDOS) 117 + ua->check_bogus_event = true; 112 118 113 119 if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS && 114 120 ua->check_bogus_event) { ··· 128 122 return ret; 129 123 } 130 124 131 - static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci, 132 - void *data, size_t size) 133 - { 134 - struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 135 - int ret; 136 - 137 - ret = ucsi_sync_control_common(ucsi, command, cci, data, size); 138 - if (ret < 0) 139 - return ret; 140 - 141 - if (UCSI_COMMAND(ua->cmd) == UCSI_GET_PDOS && 142 - ua->cmd & UCSI_GET_PDOS_PARTNER_PDO(1) && 143 - ua->cmd & UCSI_GET_PDOS_SRC_PDOS) 144 - ua->check_bogus_event = true; 145 - 146 - return ret; 147 - } 148 - 149 125 static const struct ucsi_operations ucsi_gram_ops = { 150 126 .read_version = ucsi_acpi_read_version, 151 127 .read_cci = ucsi_acpi_read_cci, 152 - .read_message_in = ucsi_gram_read_message_in, 128 + .read_message_in = ucsi_acpi_read_message_in, 153 129 .sync_control = ucsi_gram_sync_control, 154 130 .async_control = ucsi_acpi_async_control 155 131 };