Skip to content

Commit b57cd57

Browse files
walshbTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_lpc: Handle zero length read/write
cros_ec_lpc_mec_read_bytes and cros_ec_lpc_mec_write_bytes call cros_ec_lpc_mec_in_range, which checks if addresses are in the MEC address range, and returns -EINVAL if the range given is not sensible. However cros_ec_lpc_mec_in_range was also returning -EINVAL for a zero length range. A zero length range should not be an error condition. cros_ec_lpc_mec_in_range now returns 1 in this case. cros_ec_lpc_io_bytes_mec checks for zero length, and returns immediately without beginning a transfer. Fixes: 68dbac0 ("platform/chrome: cros_ec_lpc: MEC access can return error code") Fixes: 77a7143 ("platform/chrome: cros_ec_lpc: Fix error code in cros_ec_lpc_mec_read_bytes()") Signed-off-by: Ben Walsh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent 77a7143 commit b57cd57

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/platform/chrome/cros_ec_lpc_mec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ static void cros_ec_lpc_mec_emi_write_address(u16 addr,
9393
*/
9494
int cros_ec_lpc_mec_in_range(unsigned int offset, unsigned int length)
9595
{
96-
if (length == 0)
97-
return -EINVAL;
98-
9996
if (WARN_ON(mec_emi_base == 0 || mec_emi_end == 0))
10097
return -EINVAL;
10198

@@ -132,6 +129,9 @@ int cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type io_type,
132129
enum cros_ec_lpc_mec_emi_access_mode access, new_access;
133130
int ret;
134131

132+
if (length == 0)
133+
return 0;
134+
135135
/* Return checksum of 0 if window is not initialized */
136136
WARN_ON(mec_emi_base == 0 || mec_emi_end == 0);
137137
if (mec_emi_base == 0 || mec_emi_end == 0)

0 commit comments

Comments
 (0)