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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 990C9C4361B for ; Thu, 10 Dec 2020 06:12:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EA70239FD for ; Thu, 10 Dec 2020 06:12:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733109AbgLJGLm (ORCPT ); Thu, 10 Dec 2020 01:11:42 -0500 Received: from mga05.intel.com ([192.55.52.43]:21004 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733093AbgLJGLW (ORCPT ); Thu, 10 Dec 2020 01:11:22 -0500 IronPort-SDR: blkyVcqrfBd9+8/KfSnTYRNpndBla5KtIPBB9f3TDnjcMbU4eFLnqywEWsm9xEsPxFCkAq+B9l tMwl6d9qejhA== X-IronPort-AV: E=McAfee;i="6000,8403,9830"; a="258920617" X-IronPort-AV: E=Sophos;i="5.78,407,1599548400"; d="scan'208";a="258920617" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2020 22:10:30 -0800 IronPort-SDR: 1+V+b/Xa14Ktqley73euezP8KCLL6auZXFlOCL770BeV4cHEFg+PT16kfMjzcRbwsaVXNyFIx8 LiZE/7H/lUvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,407,1599548400"; d="scan'208";a="368644872" Received: from uhpatel-desk4.jf.intel.com ([10.23.15.15]) by fmsmga004.fm.intel.com with ESMTP; 09 Dec 2020 22:10:30 -0800 From: Utkarsh Patel To: linux-kernel@vger.kernel.org, enric.balletbo@collabora.com, pmalani@chromium.org, bleung@chromium.org Cc: heikki.krogerus@linux.intel.com, rajmohan.mani@intel.com, Utkarsh Patel Subject: [PATCH 1/2] platform/chrome: cros_ec_typec: Parameterize cros_typec_cmds_supported() Date: Wed, 9 Dec 2020 22:09:02 -0800 Message-Id: <20201210060903.2205-2-utkarsh.h.patel@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201210060903.2205-1-utkarsh.h.patel@intel.com> References: <20201210060903.2205-1-utkarsh.h.patel@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cros_typec_cmds_supported() is currently being used to check only one feature flag. Add a new feature parameter to it so that it can be used to check multiple feature flags supported in cros_ec. Rename cros_typec_cmds_supported() to cros_typec_feature_supported(). Signed-off-by: Utkarsh Patel --- drivers/platform/chrome/cros_ec_typec.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index ce031a10eb1b..650aa5332055 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -829,8 +829,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) return 0; } -/* Check the EC feature flags to see if TYPEC_* commands are supported. */ -static int cros_typec_cmds_supported(struct cros_typec_data *typec) +/* Check the EC feature flags to see if TYPEC_* features are supported. */ +static int cros_typec_feature_supported(struct cros_typec_data *typec, enum ec_feature_code feature) { struct ec_response_get_features resp = {}; int ret; @@ -839,11 +839,12 @@ static int cros_typec_cmds_supported(struct cros_typec_data *typec) &resp, sizeof(resp)); if (ret < 0) { dev_warn(typec->dev, - "Failed to get features, assuming typec commands unsupported.\n"); + "Failed to get features, assuming typec feature=%d unsupported.\n", + feature); return 0; } - return resp.flags[EC_FEATURE_TYPEC_CMD / 32] & EC_FEATURE_MASK_1(EC_FEATURE_TYPEC_CMD); + return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature); } static void cros_typec_port_work(struct work_struct *work) @@ -905,7 +906,8 @@ static int cros_typec_probe(struct platform_device *pdev) return ret; } - typec->typec_cmd_supported = !!cros_typec_cmds_supported(typec); + typec->typec_cmd_supported = !!cros_typec_feature_supported(typec, + EC_FEATURE_TYPEC_CMD); ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0, &resp, sizeof(resp)); -- 2.25.1