Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp218603iol; Thu, 9 Jun 2022 02:25:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI3Ds9wJXvXVMxUis9UeV7E+xxDBuMV1ClNpeBv88bc2IJD5BbeAdP5+8WBjEnjJmiRPpU X-Received: by 2002:a17:907:9813:b0:711:d5ac:b9ef with SMTP id ji19-20020a170907981300b00711d5acb9efmr16276586ejc.95.1654766745142; Thu, 09 Jun 2022 02:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654766745; cv=none; d=google.com; s=arc-20160816; b=hfjz+XvwAcUm++rIRTF9srmKEZBltqWs+QARn7+eYk/bI7mzmFHLyPdGxhtbPmcFuJ QK9FqYPX4ALK0WASDdqrlXh76F++lJBa+YgU9AkP/pBz0ONcjhoSBpt5/wO2AWg5V/hx Wg5/+glOh+UMd4uY93ef1IJpMSSNJqZgAdNoBjs4dK2ctEPWUzCmCvaTcnMNHVfuMJyL 4b1Gg3ZGG6Kx1TBJ/26ZmQBE2JY40SJkEfNq2e2q7EtdDl/ANTX4yQTGrg5SNypol84O LjNWBx1Ej3a+h7kB32Kp/aadVI0BkMg7LYpfzI77gh4Woez2lHtGyrMmF/XgdjK8HmCk OYYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UA8YQ5U66hILVQ8Wy2hSoFrYrb+e82Wl3tUDakPuIVI=; b=TssYst/kT9Wnt9Gqua/dAsHvs04sAUL0DXRyYRu9TQtTV0FXakDnwHGVlw8T7z+PGf n2bxqAA8vR/Qt5JjtGakBkjsFl6/Y1jMGFKMj9PZU22sqjn8MeN3x6/0nbOwTs5JYBjB UdmaY/bu4d6g/Nxon7NZW5vwyErrrLDJniAbAY8GREN8xhmOTqn5feO/+6litU/OHycf eR5iJmwhqjFH3+4h7wJ0+dIANXbfIi19AvK6qfPGAWzHWr5KZN+ki3tahU+WK8KK9Trv zcUhpggppDNYyrtVZIj+gQVHWiH4/fsQEGnce3/bXfaOi85Gyrqg3EAD/sBW8McFojq5 390A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j2v1Ll+9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i16-20020a1709064fd000b006f38a65b1c2si23087315ejw.848.2022.06.09.02.25.18; Thu, 09 Jun 2022 02:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j2v1Ll+9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233109AbiFIIv0 (ORCPT + 99 others); Thu, 9 Jun 2022 04:51:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242476AbiFIIuq (ORCPT ); Thu, 9 Jun 2022 04:50:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE18152BBE for ; Thu, 9 Jun 2022 01:50:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 52ADCB82C8A for ; Thu, 9 Jun 2022 08:50:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C45CC34114; Thu, 9 Jun 2022 08:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654764614; bh=OosFH16273fdadkKbi7aHx2sr6aFfpoVmI5r3sGa0PA=; h=From:To:Cc:Subject:Date:From; b=j2v1Ll+98oxBHtKDOFMsBfK7Xi0EqzAJmSAXHVN9FKDtRNDpgdLnXmr0ZS4KP2BIb K9FMsNMiTHpudNbWen0lI1ZjVCdkHP6KNOH2PVxmg7Brpi3DwYvO1QRRjMSoG0l0SO yF2/BFDFn5P/maQBVc17iiTf6CrveWHjPYdEMRMU4k5R8DXpdqI2kgIwiOdAihAQQi wd0tHGDAHqHSm9BCnC+jQ0hx8ldTyvJFS+TY0z4OB2eysE3UFOHfomuGqMPlcTnHVg gxF4z5zJWG+/BMFcYmtKFsiLCU9Zq3pj7cbejIFJsPf00LXbLa8pTsIHgYascpD4nv /j/F7g73uddrg== From: Tzung-Bi Shih To: bleung@chromium.org, groeck@chromium.org Cc: chrome-platform@lists.linux.dev, tzungbi@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 00/21] platform/chrome: Kunit tests and refactor for cros_ec_query_all() Date: Thu, 9 Jun 2022 08:49:36 +0000 Message-Id: <20220609084957.3684698-1-tzungbi@kernel.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 The series adds Kunit tests, refactors, and clean-ups for cros_ec_query_all(). Tzung-Bi Shih (21): platform/chrome: cros_ec_commands: fix compile errors -> Fixes compile errors when including cros_ec_commands.h. platform/chrome: cros_ec_proto: add Kunit tests for cros_ec_query_all() -> Adds Kunit tests for cros_ec_query_all(). They are baseline tests for the following refactor patches. They are designed to pass current code. platform/chrome: use macros for passthru indexes platform/chrome: cros_ec_proto: assign buffer size from protocol info -> Refactors. platform/chrome: cros_ec_proto: remove redundant NULL check -> Clean up. platform/chrome: cros_ec_proto: use cros_ec_map_error() -> Changes the internal return code. platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info() -> Move refactor. platform/chrome: cros_ec_proto: add Kunit tests for getting proto info platform/chrome: cros_ec_proto: handle empty payload in getting proto info -> Test and handle if send_command() returns 0 in cros_ec_get_proto_info(). platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info_legacy() -> Move refactor. platform/chrome: cros_ec_proto: add Kunit test for getting legacy info platform/chrome: cros_ec_proto: handle empty payload in getting info legacy -> Test and handle if send_command() returns 0 in cros_ec_get_proto_info_legacy(). platform/chrome: cros_ec_proto: don't show MKBP version if unsupported -> Minor fix up. platform/chrome: cros_ec_proto: return 0 on getting cmd mask success -> Conform to kernel convention: return 0 on success; otherwise, negative integers. platform/chrome: cros_ec_proto: add Kunit test for getting cmd mask error platform/chrome: cros_ec_proto: check `msg->result` in getting cmd mask -> Test and handle if `msg->result` isn't EC_RES_SUCCESS in cros_ec_get_host_command_version_mask(). platform/chrome: cros_ec_proto: add Kunit tests for getting cmd mask platform/chrome: cros_ec_proto: handle empty payload in getting cmd mask -> Test and handle if send_command() returns 0 in cros_ec_get_host_command_version_mask(). platform/chrome: cros_ec_proto: return 0 on getting wake mask success -> Conform to kernel convention: return 0 on success; otherwise, negative integers. platform/chrome: cros_ec_proto: add Kunit test for getting wake mask platform/chrome: cros_ec_proto: handle empty payload in getting wake mask -> Test and handle if send_command() returns 0 in cros_ec_get_host_event_wake_mask(). drivers/platform/chrome/Kconfig | 6 + drivers/platform/chrome/Makefile | 1 + drivers/platform/chrome/cros_ec.c | 3 - drivers/platform/chrome/cros_ec_proto.c | 291 ++-- drivers/platform/chrome/cros_ec_proto_test.c | 1402 +++++++++++++++++ drivers/platform/chrome/cros_ec_trace.h | 8 +- drivers/platform/chrome/cros_kunit_util.c | 98 ++ drivers/platform/chrome/cros_kunit_util.h | 36 + .../linux/platform_data/cros_ec_commands.h | 4 +- include/linux/platform_data/cros_ec_proto.h | 3 + 10 files changed, 1700 insertions(+), 152 deletions(-) create mode 100644 drivers/platform/chrome/cros_kunit_util.c create mode 100644 drivers/platform/chrome/cros_kunit_util.h Changes from v3: (https://patchwork.kernel.org/project/chrome-platform/cover/20220608110734.2928245-1-tzungbi@kernel.org/) - Drop 2 patches regarding `din` and `dout`. One of them crashes kernel. - Fix typo in commit message. Changes from v2: (https://patchwork.kernel.org/project/chrome-platform/cover/20220607145639.2362750-1-tzungbi@kernel.org/) - Split patches into smaller pieces. Changes from v1: (https://patchwork.kernel.org/project/chrome-platform/cover/20220606141051.285823-1-tzungbi@kernel.org/) - Fix review comments. - Split and reorder patches. -- 2.36.1.255.ge46751e96f-goog