Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2643131pxy; Tue, 3 Aug 2021 11:15:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9uuZuw0gFTUorUIwL7bXVJbA5FO01CJFCkHrh68SgMgmgm72nJTt6hp/zT5g5XJu8NJD6 X-Received: by 2002:a17:906:3b53:: with SMTP id h19mr21651337ejf.211.1628014540994; Tue, 03 Aug 2021 11:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628014540; cv=none; d=google.com; s=arc-20160816; b=KepC4ZqGmGEMamLE4FJzm1StMwCkop1iYHFU9ydMnESaNTtyC8MC8GzkV9ERcSSW88 MXfTsZv1efPRTt+vjspd9y7G+Y/lXMT7OFEZE262Bgd823+jK45/MZSwHUaFZqro427P HhTLebTKYTU4YLxKP1rcl798SHw6G5TaQgdVOeUQE9blKKgLtRyDLkxK2h5v+7XQ2lPR gCkYkRkiNT5RD5mgGI5Fi3c86E+Izrs+xuh5tmwUHRcgbrwXiBPbC2yzl/HmO53yNfOC fsO4slH15YL+DnVA14edJS951O/GdcTV43gMzsdaRL61GmEo/Pa46pn8cFgRFlL7ZFH/ LZDQ== 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=kVHFkbYxov8P54Gvz7uidbv1qRggx9Wu8jBqilyaQew=; b=W12to4+rToUj4WIt2I4iV3wfCO+sgNuTOBHaFMZ1V266XDmNT9oAZlvuI52kG3uOaq KJaiQkM4XjW5oVHeGJiDIxveSAlZGduyk//ngfBlFOOlC75MZQvl3Sf7KKF2lSUBlLbo cPpRvdx1Chcj27N+NBXjBoH02jrvBZK9HNORayH2XykRu9MPSolvOqMzoAD7HDQXzeRq MU8UEDbg03Y1vDLVMH1VeEsr6OZrk/wJUHzcVW+nc+9vbtYblX+9xCes2KE0tZDQhxMb k57c6Ju9u6UYDZ50iQyd3TZnOQA+p923/1D0Mi7rz+CqNsDACGnTk+w8W9VelUMu1XGo LmpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gLHsqVrr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u11si14733677edr.202.2021.08.03.11.15.17; Tue, 03 Aug 2021 11:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gLHsqVrr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238307AbhHCRhF (ORCPT + 99 others); Tue, 3 Aug 2021 13:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238204AbhHCRhF (ORCPT ); Tue, 3 Aug 2021 13:37:05 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FFF7C061757 for ; Tue, 3 Aug 2021 10:36:54 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id q2so24579108plr.11 for ; Tue, 03 Aug 2021 10:36:54 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=kVHFkbYxov8P54Gvz7uidbv1qRggx9Wu8jBqilyaQew=; b=gLHsqVrry/WfOnFBPp7woMWg9Y+G4sSHtKMhAfeO17rEYG/GbjE08YXyhbNqqWCTdu AVA1F++imAM9WBrMmulU7wIRwMiGhviaW6aJtCo6zqPoOxAzr6ukIC8gcIu+v9roFXK8 SwhBmf2eATOpwGClE5CkXASGlEyEsVTAUvg9U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kVHFkbYxov8P54Gvz7uidbv1qRggx9Wu8jBqilyaQew=; b=Kt9pL9Uy/e7VfJCQTGBAegy+vIwPdaBm3aPU6AdNE1+XwqFuICBgE4w7VX/odTuqGN G4NCJMofu264Fojg52Vy3sJyyALWUouQKTW2Ac8tZMqND2PRrRlyBEussJn/lRph38O8 HKXkIJ9AeiNQD+s+VoWv67xdb8jLgrK/0w9svT4B4okucgdL9ttlByQThoGV6HU/RjRv H1524hkX58DG2mIhEBplBwm1R+MRVBAwcMf811lVLLGsLcCXBaXdJ/FKt1IsWNb7OehX BQ+P6DnUtbfZn0SGrt/5y4pFJpSiPZ2RiouketmfwrznRglclSAfWmrfEkXm92TgCVd3 3IlQ== X-Gm-Message-State: AOAM530S8bvrrSO8F37pKp8+Kuf4aUywTkHfxXhfB8KIXBBmVtVPXLPH Hz71Bv+xJ/eHHKGmwWetkAEk/oiX3mz/Ew== X-Received: by 2002:a62:dd42:0:b029:330:6bf8:b02c with SMTP id w63-20020a62dd420000b02903306bf8b02cmr22992582pff.67.1628012213807; Tue, 03 Aug 2021 10:36:53 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:8875:fb28:686e:1c31]) by smtp.gmail.com with ESMTPSA id g202sm2026748pfb.125.2021.08.03.10.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 10:36:53 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v2 2/2] platform/chrome: cros_ec_typec: Use existing feature check Date: Tue, 3 Aug 2021 10:36:21 -0700 Message-Id: <20210803173619.91539-2-pmalani@chromium.org> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210803173619.91539-1-pmalani@chromium.org> References: <20210803173619.91539-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace the cros_typec_feature_supported() function with the pre-existing cros_ec_check_features() function which does the same thing. Signed-off-by: Prashant Malani --- Changes in v2: - Dropped unnecessary NULL checks, per review comments. drivers/platform/chrome/cros_ec_typec.c | 27 +++++-------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 27c068c4c38d..262a891eded3 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -1054,24 +1054,6 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) return 0; } -/* 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; - - ret = cros_typec_ec_command(typec, 0, EC_CMD_GET_FEATURES, NULL, 0, - &resp, sizeof(resp)); - if (ret < 0) { - dev_warn(typec->dev, - "Failed to get features, assuming typec feature=%d unsupported.\n", - feature); - return 0; - } - - return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature); -} - static void cros_typec_port_work(struct work_struct *work) { struct cros_typec_data *typec = container_of(work, struct cros_typec_data, port_work); @@ -1113,6 +1095,7 @@ MODULE_DEVICE_TABLE(of, cros_typec_of_match); static int cros_typec_probe(struct platform_device *pdev) { + struct cros_ec_dev *ec_dev = NULL; struct device *dev = &pdev->dev; struct cros_typec_data *typec; struct ec_response_usb_pd_ports resp; @@ -1132,10 +1115,10 @@ static int cros_typec_probe(struct platform_device *pdev) return ret; } - typec->typec_cmd_supported = !!cros_typec_feature_supported(typec, - EC_FEATURE_TYPEC_CMD); - typec->needs_mux_ack = !!cros_typec_feature_supported(typec, - EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK); + ec_dev = dev_get_drvdata(&typec->ec->ec->dev); + typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD); + typec->needs_mux_ack = !!cros_ec_check_features(ec_dev, + EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK); ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0, &resp, sizeof(resp)); -- 2.32.0.554.ge1b32706d8-goog