Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2418456iof; Wed, 8 Jun 2022 04:42:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9WfAbEmJ0R7+kH5Fh8TUaejO8OWpxlUgS5AYGh+DiaVVIu3KvZuIDCfizMLNAVE5p45hW X-Received: by 2002:a17:902:e750:b0:166:3058:d0ed with SMTP id p16-20020a170902e75000b001663058d0edmr33981248plf.0.1654688547387; Wed, 08 Jun 2022 04:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654688547; cv=none; d=google.com; s=arc-20160816; b=tnnsn8eZpmqtoLeCht0BgO20svfCV9n4m5UDz26ZOd7/0xv/9ubt2HRl/cvg9f+isg 7rf9OzLvPwPY3QnDWWn9egv00hsVg3E0ZUe9PoBxV1iNEXKK1I9d8FYtvDIXyIqnwuIz eS7l1BYh8LZ2mHTe13fzSOKEMGuktx17AZbm6Ns6+qD5ULWDRLGt7NshfoqEGni++QhK tJw6LktEZZuul6iXfouvxsgUqUezbVnrPQW03z7pIrBy1j09cxQ4g/7dMGkYQNl/gnMN s8yOjJ5sWW/grHDUBdnU9iPCeXCdpTkUOI9DAwvETDyO5G5GRMBdgjMYUm8JD9QZ+baj 3m/g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EgrF5k2Z4jZgde/BlaiqOKrLs+Tf0WjPMT5299qz3T0=; b=tFmLoL2WPRGgPPIC7L82wrHi26MHIPgwn4liOQ2MlP/mfovUtjqPg3cK3XOZIc3u2S GwtTB2Enb8Gbq0kRq6xo/iHfcDGGMrA7kYIhAlHLnzNoz5KRr88RUJ1zKQuJr9o/xb5t EiA9mE90kMpix6yaQIM2NYEWkoBhgO7L7Qghu252Xa+8rjJot+CGn35AIspHf7bU0lHo Evf1uRclC7sGXJ2yzOGAqEltNc5lTvhmhDrxLTCUiLoiodWLHsGQ4YvwW2D8pvxxcMDw k2NqbXkewADiqfGiF/BhcFN56RkSsbLUKQVjLNf+IDA7FSnf0EWogN/HSQHIgxu3bDck aEmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S1LtJO6k; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ip4-20020a17090b314400b001e82bdf4718si23080951pjb.3.2022.06.08.04.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 04:42:27 -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=@kernel.org header.s=k20201202 header.b=S1LtJO6k; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9022524705B; Wed, 8 Jun 2022 04:11:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237831AbiFHLJL (ORCPT + 99 others); Wed, 8 Jun 2022 07:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237874AbiFHLIQ (ORCPT ); Wed, 8 Jun 2022 07:08:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5AF42010E3 for ; Wed, 8 Jun 2022 04:08:09 -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 4FCCFB826F0 for ; Wed, 8 Jun 2022 11:08:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21190C341C4; Wed, 8 Jun 2022 11:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654686488; bh=AK1qFo6Tmuz0zcWaXZ/wuGjHC69Ezlky7hqTBqz+/Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S1LtJO6kwxR0jCVB5t6V0puFmQiY/eMpEhRwJG8qzpfPUdAb/6M/e3T/kG7GVMrLm s1t6qT6dmdufndU9EMbDQXEIXv3TGN6qI+UvuttZetxZRvBfwluyHeHFt5P/8LFkiE e0XZR4KyN+3kI025N01wagAAq1vS8mqy986X11UJ7cBn7RCAjKsn70j8TiK5jTQn9X vfED2qXPCq+y+gFyT9O8+I+IAYpG8CWzx794Rh5MVQ8vKAUuQ/O39d+uOjdocj+1Yl SsE3obJ2pK4zVyb2BjAdz9xHnYhvzvfzDwDcxYxiTlk3DiCDkshTgk3SpyLWGJitxh QOYCe4DSrBQWw== 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 v3 16/23] platform/chrome: cros_ec_proto: return 0 on getting cmd mask success Date: Wed, 8 Jun 2022 11:07:27 +0000 Message-Id: <20220608110734.2928245-17-tzungbi@kernel.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608110734.2928245-1-tzungbi@kernel.org> References: <20220608110734.2928245-1-tzungbi@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 cros_ec_get_host_command_version_mask() used to return value from send_command() which is number of available 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. Don't return number of available bytes. Instead, return 0 on success; otherwise, negative integers on error. Also remove the unneeded `ver_mask` initialization as the callers should take it only if cros_ec_get_host_command_version_mask() returns 0. Signed-off-by: Tzung-Bi Shih --- Changes from v2: - Separate Kunit test to another patch. - Rephrase the commit message. Changes from v1: - Return 0 on success; otherwise, negative intergers. drivers/platform/chrome/cros_ec_proto.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index efbabdcb31ae..06bc7db1213e 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -453,6 +453,7 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, if (ret > 0) { rver = (struct ec_response_get_cmd_versions *)msg->data; *mask = rver->version_mask; + ret = 0; } kfree(msg); @@ -469,7 +470,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; /* First try sending with proto v3. */ @@ -505,9 +506,7 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) return -ENOMEM; /* 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 { @@ -517,10 +516,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); -- 2.36.1.255.ge46751e96f-goog