summaryrefslogtreecommitdiffstats
path: root/drivers/platform/chrome
diff options
context:
space:
mode:
authorBen Walsh <ben@jubnut.com>2024-06-13 23:25:42 +0200
committerTzung-Bi Shih <tzungbi@kernel.org>2024-06-14 04:47:25 +0200
commitb57cd5703a1618e87772094ac12c5ee7d6c35e2f (patch)
tree1aae33d4e738d7f97630e4703e381d3319957d4c /drivers/platform/chrome
parentplatform/chrome: cros_ec_lpc: Fix error code in cros_ec_lpc_mec_read_bytes() (diff)
downloadlinux-b57cd5703a1618e87772094ac12c5ee7d6c35e2f.tar.xz
linux-b57cd5703a1618e87772094ac12c5ee7d6c35e2f.zip
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: 68dbac0a58ef ("platform/chrome: cros_ec_lpc: MEC access can return error code") Fixes: 77a714325d09 ("platform/chrome: cros_ec_lpc: Fix error code in cros_ec_lpc_mec_read_bytes()") Signed-off-by: Ben Walsh <ben@jubnut.com> Link: https://lore.kernel.org/r/20240613212542.403-1-ben@jubnut.com Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r--drivers/platform/chrome/cros_ec_lpc_mec.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/platform/chrome/cros_ec_lpc_mec.c b/drivers/platform/chrome/cros_ec_lpc_mec.c
index dfad934e65ca..a56584171168 100644
--- a/drivers/platform/chrome/cros_ec_lpc_mec.c
+++ b/drivers/platform/chrome/cros_ec_lpc_mec.c
@@ -93,9 +93,6 @@ static void cros_ec_lpc_mec_emi_write_address(u16 addr,
*/
int cros_ec_lpc_mec_in_range(unsigned int offset, unsigned int length)
{
- if (length == 0)
- return -EINVAL;
-
if (WARN_ON(mec_emi_base == 0 || mec_emi_end == 0))
return -EINVAL;
@@ -132,6 +129,9 @@ int cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type io_type,
enum cros_ec_lpc_mec_emi_access_mode access, new_access;
int ret;
+ if (length == 0)
+ return 0;
+
/* Return checksum of 0 if window is not initialized */
WARN_ON(mec_emi_base == 0 || mec_emi_end == 0);
if (mec_emi_base == 0 || mec_emi_end == 0)