Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2193932iof; Tue, 7 Jun 2022 22:48:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyncj6bxEa8bNeq3PTX8T/gWquGX6nSTjLgpaVMga8ie5ZaIUlL/mYS33pt2tr6tYb4eSqN X-Received: by 2002:a17:90b:4d12:b0:1e8:895c:e542 with SMTP id mw18-20020a17090b4d1200b001e8895ce542mr13887679pjb.128.1654667292179; Tue, 07 Jun 2022 22:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667292; cv=none; d=google.com; s=arc-20160816; b=pG4rUpprvDzyrJORrXtKndVG8sS06X4rLAQqHC0CaHi6gPVmp+bUckcPrP3oUULCgL UHrgTOxwCqaEdXvGADzx4G8GT2PxgYZV5DWYvJILqsr/iK4F4nJdoxb5rsReEUqDqza6 PwI44vMr7hINQzyQKqKFSRBxHZOWWoHx88fcxFqrzl40geD2BmlkPjcqm6udvJlEqQ1E sipOp+F39qaFjNb+qFkmI3MvTTQ2VmW26aDyXmK+DCokCc90WDOb/eKwQ9HPBtaqpgZH CdEjPcMd3yrpBQ+u13SMEQYCSlr2J1xe3dAyX3JhQ1AIXKFK36OdmFzv9lLZTdA3yTSq A9mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hV3xEmz3VLxIR9I3qG4yWszU0CvP4zSv4bB50jhgWQY=; b=lZhs40dhQ4xH1aNguOsKdO1xgFtmdwsYBriVLvJB1GX85RUrmWb2yKy2hJDtl6bA64 X/5a5IwgmBCatFzYeZ7TtQ8QNS45ZO9zQanIxhNQFXod2N7YQ60OWAm9o0f0RMg4vith nJI5MI0F+XbFyIaH0gX4u4cEJj0MysMI2B4Qin9ztHrhT3eKTcXwC/BsMiWo/5IkC+C0 vpQTStA4RrgwePbR2O+bRBghKjnI6ocQ2xOL+K/lQZ+kxIzUM/2R1+vN0I1v68omH307 6e0rgXGU8R05ZCOC5wgsUauJ0YBu/GB6Q1A0y8/604sdpU87gbAFFmxIiSRY7uZFqGF4 o0xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FsOTpaCN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bv6-20020a17090af18600b001df47daf815si28943758pjb.141.2022.06.07.22.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:48:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FsOTpaCN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E5914A3618; Tue, 7 Jun 2022 22:14:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388476AbiFHAcT (ORCPT + 99 others); Tue, 7 Jun 2022 20:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383388AbiFGVxJ (ORCPT ); Tue, 7 Jun 2022 17:53:09 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BDAB289B8 for ; Tue, 7 Jun 2022 12:11:38 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id c2so24206205edf.5 for ; Tue, 07 Jun 2022 12:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hV3xEmz3VLxIR9I3qG4yWszU0CvP4zSv4bB50jhgWQY=; b=FsOTpaCNvMmctTnP+zSEnTxCEQrRXWsITIdWtaHz5VCwaCh5RKGXylUsssMJ85p6wQ sb2Hjkscx9prhO++TxwhhysL4Z5n3qHt1c4c92Wc4qWs7HHu1pu6Z9V0Q2qU579iu5Lm PlBvFDeoEfE/D6RQ4VyRR+Jrn5X+GjXT9PVR7o+1N0E/cyeosjHoDIb8TGiZ7kXDMY0r aweTDpAuGXVX4QypEnIq90r0MYBiFO329pOeu5R73LKQj7eW4nw6x3UteyRo+UP3p7ux WeYoL9A+hCUhumITWwg4yBG0VI5zmlgmk8nmXpe56osIMet5WGsOMQ5oTIeSbrsLGlUc NLtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hV3xEmz3VLxIR9I3qG4yWszU0CvP4zSv4bB50jhgWQY=; b=U8hAefEOwaqD8x9fm1U51LxAPJH3gmpL4BqTp/5CgPwkppcgFEQNON5BAn8nYbn7Gd jHV0tHfr8jTNBUX4L49jidcJaM0biXvA+5e8xDiFlEdt3JqdloSX9gfP87Z30a5xyN1T hHGeQS3zSj56RoKZfWi/VKo9auFsRU+yLP/4Xyos2L0lpNMXhA8LVuqqm3wEeOyC1LB3 UJAQwb9GauMHRxc3lVaIlwRyu2rhNL/QdSYiO+wadxSXACYNd0QHKJLyuIVj3wDyI4mt lGGV5laKZPrD49ggH7l+nHp7wBtM3M0UX19/S63n9pAfdSQ/FU1dAhrR6gQ2W47X1CYO Tz5g== X-Gm-Message-State: AOAM532bNLmGpROUBbvvZFm81umPeU2GqbpfvASmFN6mWy+sO49fakvr KZUTfY4o5S4SOwfjbtXgCcAhvKYI9rbrmzrqfcg8nA== X-Received: by 2002:a05:6402:2405:b0:431:6ef1:e2a with SMTP id t5-20020a056402240500b004316ef10e2amr11282812eda.26.1654629095871; Tue, 07 Jun 2022 12:11:35 -0700 (PDT) MIME-Version: 1.0 References: <20220607145639.2362750-1-tzungbi@kernel.org> <20220607145639.2362750-15-tzungbi@kernel.org> In-Reply-To: <20220607145639.2362750-15-tzungbi@kernel.org> From: Guenter Roeck Date: Tue, 7 Jun 2022 12:11:23 -0700 Message-ID: Subject: Re: [PATCH v2 14/15] platform/chrome: cros_ec_proto: return 0 on getting version mask success To: Tzung-Bi Shih Cc: bleung@chromium.org, groeck@chromium.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 7, 2022 at 7:57 AM Tzung-Bi Shih wrote: > > cros_ec_get_host_command_version_mask() used to return value from > send_command() which is number of bytes for input payload on success > (i.e. sizeof(struct ec_response_get_cmd_versions)). > > However, the callers don't need to know how many bytes are available. > > - Fix cros_ec_get_host_command_version_mask() to return 0 on success; > negative integers on error. > > - Remove the unneeded `ver_mask` initialization as the callers should > take it only if cros_ec_get_host_command_version_mask() returns 0. > > - Add a Kunit test: `ver_mask` has some garbage bytes from previous > EC_CMD_GET_NEXT_EVENT but there is no host sleep to make sure the > caller checks the return values correctly. > This should be separate patches. Thanks, Guenter > Signed-off-by: Tzung-Bi Shih > --- > Changes from v1: > - Return 0 on success; otherwise, negative intergers. > > drivers/platform/chrome/cros_ec_proto.c | 37 ++- > drivers/platform/chrome/cros_ec_proto_test.c | 286 +++++++++++++++++++ > 2 files changed, 308 insertions(+), 15 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > index ee15a73eee38..9d96ed16244f 100644 > --- a/drivers/platform/chrome/cros_ec_proto.c > +++ b/drivers/platform/chrome/cros_ec_proto.c > @@ -428,13 +428,12 @@ static int cros_ec_get_proto_info_legacy(struct cros_ec_device *ec_dev) > * the caller has ec_dev->lock mutex or the caller knows there is > * no other command in progress. > */ > -static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, > - u16 cmd, u32 *mask) > +static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, u16 cmd, u32 *mask) > { > struct ec_params_get_cmd_versions *pver; > struct ec_response_get_cmd_versions *rver; > struct cros_ec_command *msg; > - int ret; > + int ret, mapped; > > msg = kmalloc(sizeof(*msg) + max(sizeof(*rver), sizeof(*pver)), > GFP_KERNEL); > @@ -450,13 +449,25 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, > pver->cmd = cmd; > > ret = send_command(ec_dev, msg); > - if (ret > 0) { > - rver = (struct ec_response_get_cmd_versions *)msg->data; > - *mask = rver->version_mask; > + if (ret < 0) > + goto exit; > + > + mapped = cros_ec_map_error(msg->result); > + if (mapped) { > + ret = mapped; > + goto exit; > } > > - kfree(msg); > + if (ret == 0) { > + ret = -EPROTO; > + goto exit; > + } > > + rver = (struct ec_response_get_cmd_versions *)msg->data; > + *mask = rver->version_mask; > + ret = 0; > +exit: > + kfree(msg); > return ret; > } > > @@ -469,7 +480,7 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, > */ > int cros_ec_query_all(struct cros_ec_device *ec_dev) > { > - u32 ver_mask = 0; > + u32 ver_mask; > int ret; > u8 *din, *dout; > > @@ -503,9 +514,7 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) > ec_dev->dout = dout; > > /* Probe if MKBP event is supported */ > - ret = cros_ec_get_host_command_version_mask(ec_dev, > - EC_CMD_GET_NEXT_EVENT, > - &ver_mask); > + ret = cros_ec_get_host_command_version_mask(ec_dev, EC_CMD_GET_NEXT_EVENT, &ver_mask); > if (ret < 0 || ver_mask == 0) { > ec_dev->mkbp_event_supported = 0; > } else { > @@ -515,10 +524,8 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) > } > > /* Probe if host sleep v1 is supported for S0ix failure detection. */ > - ret = cros_ec_get_host_command_version_mask(ec_dev, > - EC_CMD_HOST_SLEEP_EVENT, > - &ver_mask); > - ec_dev->host_sleep_v1 = (ret >= 0 && (ver_mask & EC_VER_MASK(1))); > + ret = cros_ec_get_host_command_version_mask(ec_dev, EC_CMD_HOST_SLEEP_EVENT, &ver_mask); > + ec_dev->host_sleep_v1 = (ret == 0 && (ver_mask & EC_VER_MASK(1))); > > /* Get host event wake mask. */ > ret = cros_ec_get_host_event_wake_mask(ec_dev, &ec_dev->host_event_wake_mask); > diff --git a/drivers/platform/chrome/cros_ec_proto_test.c b/drivers/platform/chrome/cros_ec_proto_test.c > index 27b81a5a9880..af69410f2978 100644 > --- a/drivers/platform/chrome/cros_ec_proto_test.c > +++ b/drivers/platform/chrome/cros_ec_proto_test.c > @@ -890,6 +890,182 @@ static void cros_ec_proto_test_query_all_no_mkbp(struct kunit *test) > } > } > > +static void cros_ec_proto_test_query_all_no_mkbp_return_error(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + struct ec_xfer_mock *mock; > + int ret; > + > + /* Set some garbage bytes. */ > + ec_dev->mkbp_event_supported = 0xbf; > + > + /* For cros_ec_get_proto_info() without passthru. */ > + { > + struct ec_response_get_protocol_info *data; > + > + mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + > + /* > + * Although it doesn't check the value, provides valid sizes so that > + * cros_ec_query_all() allocates din and dout correctly. > + */ > + data = (struct ec_response_get_protocol_info *)mock->o_data; > + data->max_request_packet_size = 0xbe; > + data->max_response_packet_size = 0xef; > + } > + > + /* For cros_ec_get_proto_info() with passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + } > + > + /* For cros_ec_get_host_command_version_mask() for MKBP. */ > + { > + mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + } > + > + cros_ec_proto_test_query_all_pretest(test); > + ret = cros_ec_query_all(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, 0); > + > + /* For cros_ec_get_proto_info() without passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_protocol_info)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > + } > + > + /* For cros_ec_get_proto_info() with passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > + EC_CMD_GET_PROTOCOL_INFO); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_protocol_info)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > + } > + > + /* For cros_ec_get_host_command_version_mask() for MKBP. */ > + { > + struct ec_params_get_cmd_versions *data; > + > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_cmd_versions)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); > + > + data = (struct ec_params_get_cmd_versions *)mock->i_data; > + KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); > + > + KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); > + } > +} > + > +static void cros_ec_proto_test_query_all_no_mkbp_return0(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + struct ec_xfer_mock *mock; > + int ret; > + > + /* Set some garbage bytes. */ > + ec_dev->mkbp_event_supported = 0xbf; > + > + /* For cros_ec_get_proto_info() without passthru. */ > + { > + struct ec_response_get_protocol_info *data; > + > + mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + > + /* > + * Although it doesn't check the value, provides valid sizes so that > + * cros_ec_query_all() allocates din and dout correctly. > + */ > + data = (struct ec_response_get_protocol_info *)mock->o_data; > + data->max_request_packet_size = 0xbe; > + data->max_response_packet_size = 0xef; > + } > + > + /* For cros_ec_get_proto_info() with passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + } > + > + /* For cros_ec_get_host_command_version_mask() for MKBP. */ > + { > + mock = cros_kunit_ec_xfer_mock_add(test, 0); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + } > + > + cros_ec_proto_test_query_all_pretest(test); > + ret = cros_ec_query_all(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, 0); > + > + /* For cros_ec_get_proto_info() without passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_protocol_info)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > + } > + > + /* For cros_ec_get_proto_info() with passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > + EC_CMD_GET_PROTOCOL_INFO); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_protocol_info)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > + } > + > + /* For cros_ec_get_host_command_version_mask() for MKBP. */ > + { > + struct ec_params_get_cmd_versions *data; > + > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_cmd_versions)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); > + > + data = (struct ec_params_get_cmd_versions *)mock->i_data; > + KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); > + > + KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); > + } > +} > + > static void cros_ec_proto_test_query_all_no_host_sleep(struct kunit *test) > { > struct cros_ec_proto_test_priv *priv = test->priv; > @@ -996,6 +1172,113 @@ static void cros_ec_proto_test_query_all_no_host_sleep(struct kunit *test) > } > } > > +static void cros_ec_proto_test_query_all_no_host_sleep_return0(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + struct ec_xfer_mock *mock; > + int ret; > + > + /* Set some garbage bytes. */ > + ec_dev->host_sleep_v1 = true; > + > + /* For cros_ec_get_proto_info() without passthru. */ > + { > + struct ec_response_get_protocol_info *data; > + > + mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + > + /* > + * Although it doesn't check the value, provides valid sizes so that > + * cros_ec_query_all() allocates din and dout correctly. > + */ > + data = (struct ec_response_get_protocol_info *)mock->o_data; > + data->max_request_packet_size = 0xbe; > + data->max_response_packet_size = 0xef; > + } > + > + /* For cros_ec_get_proto_info() with passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + } > + > + /* For cros_ec_get_host_command_version_mask() for MKBP. */ > + { > + struct ec_response_get_cmd_versions *data; > + > + mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + > + /* In order to pollute next cros_ec_get_host_command_version_mask(). */ > + data = (struct ec_response_get_cmd_versions *)mock->o_data; > + data->version_mask = 0xbeef; > + } > + > + /* For cros_ec_get_host_command_version_mask() for host sleep v1. */ > + { > + mock = cros_kunit_ec_xfer_mock_add(test, 0); > + KUNIT_ASSERT_PTR_NE(test, mock, NULL); > + } > + > + cros_ec_proto_test_query_all_pretest(test); > + ret = cros_ec_query_all(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, 0); > + > + /* For cros_ec_get_proto_info() without passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_protocol_info)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > + } > + > + /* For cros_ec_get_proto_info() with passthru. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > + EC_CMD_GET_PROTOCOL_INFO); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_protocol_info)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > + } > + > + /* For cros_ec_get_host_command_version_mask() for MKBP. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_cmd_versions)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); > + } > + > + /* For cros_ec_get_host_command_version_mask() for host sleep v1. */ > + { > + mock = cros_kunit_ec_xfer_mock_next(); > + KUNIT_EXPECT_PTR_NE(test, mock, NULL); > + > + KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > + KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); > + KUNIT_EXPECT_EQ(test, mock->msg.insize, > + sizeof(struct ec_response_get_cmd_versions)); > + KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); > + > + KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1); > + } > +} > + > static void cros_ec_proto_test_query_all_default_wake_mask_return_error(struct kunit *test) > { > struct cros_ec_proto_test_priv *priv = test->priv; > @@ -1183,7 +1466,10 @@ static struct kunit_case cros_ec_proto_test_cases[] = { > KUNIT_CASE(cros_ec_proto_test_query_all_legacy_data_error), > KUNIT_CASE(cros_ec_proto_test_query_all_legacy_return0), > KUNIT_CASE(cros_ec_proto_test_query_all_no_mkbp), > + KUNIT_CASE(cros_ec_proto_test_query_all_no_mkbp_return_error), > + KUNIT_CASE(cros_ec_proto_test_query_all_no_mkbp_return0), > KUNIT_CASE(cros_ec_proto_test_query_all_no_host_sleep), > + KUNIT_CASE(cros_ec_proto_test_query_all_no_host_sleep_return0), > KUNIT_CASE(cros_ec_proto_test_query_all_default_wake_mask_return_error), > {} > }; > -- > 2.36.1.255.ge46751e96f-goog >