From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0ED0C433EF for ; Thu, 16 Sep 2021 01:47:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7625611C4 for ; Thu, 16 Sep 2021 01:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233795AbhIPBsV (ORCPT ); Wed, 15 Sep 2021 21:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233569AbhIPBsS (ORCPT ); Wed, 15 Sep 2021 21:48:18 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14DB2C061574 for ; Wed, 15 Sep 2021 18:46:59 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id n2so203697plk.12 for ; Wed, 15 Sep 2021 18:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B5bHui6kRHhxVzD9UTLyVFqHuGAj8kifzoni+rjsgcA=; b=Bb8RuoUIcGF+PmzvKzsWqah2eoHj2JCFr5u8jqUQb62Q/8q5jwAijFuItshKfTtp3z sJXBpLg7Zer4K5SJ0egvH6gKEZndhJt+E+2UV4r/2z2piJWqo8aS5PH/rbqSv+Cq/Q/v +T1rm0Ah1IsN4uwjRuKo48p1PLqgjPrHfj4zc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B5bHui6kRHhxVzD9UTLyVFqHuGAj8kifzoni+rjsgcA=; b=oJx2Nj89E2vZ0m7R9keNahHzkV3kOUyuINEoVRw1nC3z5qCDYqFoTzGSNPIQOXjrCa HW/4EpMa+wpkQUuQGvN/9Gg6Hyp8F7d7slcfNvEQsYC8+8LQZjeNSRStuAMQlZYD6BJK gPJI3EyG0J2HLcpVVt9NQ8i0Npv+m6FRcmyuZjeSWgg4NLkyConarB6E236LTcNZD7JP rmfIxdtfAXARL8P6VATXWW5XPg2WLNzxSI6Q2nqjWVl2deJ42mWRIFgauzU5yM59+tzg 41p4jQ30TPXxzcocc+nMrWFxByVqRIX82o04uS9N88cnkXxr7b3pAT0iz1Xu9Kvl2wIh T5Hg== X-Gm-Message-State: AOAM532OkUQuON9UtbGpVIO/AyXDiw5uP2roGfCmVdFDDuHjmO3mXSMx MxyiM3g45H+l7PTahu1kaa19i680iAGBBg== X-Google-Smtp-Source: ABdhPJyTqq/sLzhH8+TUbLZyHOYCOstANkB68AIE9vuBjIi2m0iqHAKXRnOg+4wTnTg210bstLE2JQ== X-Received: by 2002:a17:90b:384a:: with SMTP id nl10mr11814258pjb.65.1631756818310; Wed, 15 Sep 2021 18:46:58 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:6b70:cd1e:def4:efaa]) by smtp.gmail.com with ESMTPSA id x16sm1091766pgc.49.2021.09.15.18.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 18:46:57 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , "Gustavo A. R. Silva" Subject: [PATCH] platform/chrome: cros_ec_proto: Fix check_features ret val Date: Wed, 15 Sep 2021 18:46:27 -0700 Message-Id: <20210916014632.2662612-1-pmalani@chromium.org> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kerneldoc for cros_ec_check_features() states that it returns 1 or 0 depedending on whether a feature is supported or not, but it instead returns a negative error number in one case, and a non-1 bitmask in other cases. Since all call-sites only check for a 1 or 0 return value, update the function to return boolean values. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_proto.c | 12 +++++++----- include/linux/platform_data/cros_ec_proto.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index a7404d69b2d3..a34cf58c5ef7 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -808,9 +808,9 @@ EXPORT_SYMBOL(cros_ec_get_host_event); * * Call this function to test whether the ChromeOS EC supports a feature. * - * Return: 1 if supported, 0 if not + * Return: true if supported, false if not (or if an error was encountered). */ -int cros_ec_check_features(struct cros_ec_dev *ec, int feature) +bool cros_ec_check_features(struct cros_ec_dev *ec, int feature) { struct cros_ec_command *msg; int ret; @@ -818,8 +818,10 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature) if (ec->features[0] == -1U && ec->features[1] == -1U) { /* features bitmap not read yet */ msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL); - if (!msg) - return -ENOMEM; + if (!msg) { + dev_err(ec->dev, "failed to allocate memory to get EC features\n"); + return false; + } msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; msg->insize = sizeof(ec->features); @@ -839,7 +841,7 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature) kfree(msg); } - return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature); + return !!(ec->features[feature / 32] & EC_FEATURE_MASK_0(feature)); } EXPORT_SYMBOL_GPL(cros_ec_check_features); diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h index 02599687770c..55844ece0b32 100644 --- a/include/linux/platform_data/cros_ec_proto.h +++ b/include/linux/platform_data/cros_ec_proto.h @@ -227,7 +227,7 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev, u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); -int cros_ec_check_features(struct cros_ec_dev *ec, int feature); +bool cros_ec_check_features(struct cros_ec_dev *ec, int feature); int cros_ec_get_sensor_count(struct cros_ec_dev *ec); -- 2.33.0.309.g3052b89438-goog