Skip to content

Commit e1870c1

Browse files
lumaggregkh
authored andcommitted
usb: typec: ucsi: inline ucsi_read_message_in
There is no need to have a separate wrapper for reading MESSAGE_IN data, inline it to ucsi_run_command(). Tested-by: Heikki Krogerus <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5e9c166 commit e1870c1

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@
3636
*/
3737
#define UCSI_SWAP_TIMEOUT_MS 5000
3838

39-
static int ucsi_read_message_in(struct ucsi *ucsi, void *buf,
40-
size_t buf_size)
41-
{
42-
/*
43-
* Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the
44-
* reads here.
45-
*/
46-
if (ucsi->version <= UCSI_VERSION_1_2)
47-
buf_size = clamp(buf_size, 0, 16);
48-
49-
return ucsi->ops->read_message_in(ucsi, buf, buf_size);
50-
}
51-
5239
static int ucsi_acknowledge(struct ucsi *ucsi, bool conn_ack)
5340
{
5441
u64 ctrl;
@@ -70,6 +57,13 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci,
7057

7158
*cci = 0;
7259

60+
/*
61+
* Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the
62+
* reads here.
63+
*/
64+
if (ucsi->version <= UCSI_VERSION_1_2)
65+
size = clamp(size, 0, 16);
66+
7367
ret = ucsi->ops->sync_control(ucsi, command);
7468
if (ret)
7569
return ret;
@@ -98,7 +92,7 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci,
9892
}
9993

10094
if (data) {
101-
ret = ucsi_read_message_in(ucsi, data, size);
95+
ret = ucsi->ops->read_message_in(ucsi, data, size);
10296
if (ret)
10397
return ret;
10498
}

0 commit comments

Comments
 (0)