Skip to content

Commit

Permalink
usb: typec: ucsi: inline ucsi_read_message_in
Browse files Browse the repository at this point in the history
There is no need to have a separate wrapper for reading MESSAGE_IN data,
inline it to ucsi_run_command().

Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240627-ucsi-rework-interface-v4-5-289ddc6874c7@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
lumag authored and gregkh committed Jul 3, 2024
1 parent 5e9c166 commit e1870c1
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions drivers/usb/typec/ucsi/ucsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@
*/
#define UCSI_SWAP_TIMEOUT_MS 5000

static int ucsi_read_message_in(struct ucsi *ucsi, void *buf,
size_t buf_size)
{
/*
* Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the
* reads here.
*/
if (ucsi->version <= UCSI_VERSION_1_2)
buf_size = clamp(buf_size, 0, 16);

return ucsi->ops->read_message_in(ucsi, buf, buf_size);
}

static int ucsi_acknowledge(struct ucsi *ucsi, bool conn_ack)
{
u64 ctrl;
Expand All @@ -70,6 +57,13 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci,

*cci = 0;

/*
* Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the
* reads here.
*/
if (ucsi->version <= UCSI_VERSION_1_2)
size = clamp(size, 0, 16);

ret = ucsi->ops->sync_control(ucsi, command);
if (ret)
return ret;
Expand Down Expand Up @@ -98,7 +92,7 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci,
}

if (data) {
ret = ucsi_read_message_in(ucsi, data, size);
ret = ucsi->ops->read_message_in(ucsi, data, size);
if (ret)
return ret;
}
Expand Down

0 comments on commit e1870c1

Please sign in to comment.