Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1691493pxb; Wed, 9 Feb 2022 02:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+m6bX9zyvsAXCYsRAAoLbXHf+iHju2rkSIj1DItYI3G0lFmYCA1hZcBDry8DgIXO/tnxr X-Received: by 2002:a05:6a00:234a:: with SMTP id j10mr1531040pfj.7.1644401926491; Wed, 09 Feb 2022 02:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644401926; cv=none; d=google.com; s=arc-20160816; b=bUVGPcD01McDez34xhpZKu9zxZeeZ4JB+6+MfyqYGex9z3Cg0EVvARJV/HkPmR4xcz k0MYxPB9VvA0TMedAMhi76stqynP2a+AbR6WjvDAptNmXJLzKk8eLoIYrhhJQLZGhuUZ X+qZ0PpuGaTLzarylGXGEodmVVsDEkufA5qWpMJs1+knQVw6kviQqz4wg2U/nWgzxAG7 ZCwx0o6/7AH0T1LGBfuBds+EWbg9exq3XJmlBtvmC96cCkBGaKcfV61bayc0j5Gi19Jx YVnOavtj4qznQeJtqqbICwsCmskpyhkybtwsLR/QLhKYnJXNL/t97R/6iAqQrtnw4SWp ndgQ== 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=w3J0QKkr84VrudaJ3bhOXmAFtwa7Bv5tWoh+lneUqWM=; b=YXc6Hmk4yeOLZ/HAJRp9V5p+kO3t4mEe1d1uPosxV5juSXzg3kdcCVHHP+toibfMSJ lZ+5VfJjirb63sRb1h/zStMOS1V5X1OskNSpMZ92lzLQkz4MlS4R23vcQa9DtZ1KR4jO 2GkzXCWrdZf7OPZFOMtABLKdzqtHwCxj8wr2UyM1/ljKoLYcJyMK8JB1fFvDnabcbGh6 ZMhoHtdnt0fkQhCqyXyamANgLnugfIwkxJW6SYIYK31FssFt4Ef8WEObX6YzCQr9Rvgh Pw0KSDU05fPk545aLBB4Ila5hlqIIwXyCZZjtqdaAdgvQLqtdPm112BR1sUwbm8zZYzu Y/aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CXeTCXrz; 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 v185si2489681pgd.170.2022.02.09.02.18.34; Wed, 09 Feb 2022 02:18:46 -0800 (PST) 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=CXeTCXrz; 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 S1385409AbiBHSrq (ORCPT + 99 others); Tue, 8 Feb 2022 13:47:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353557AbiBHSrk (ORCPT ); Tue, 8 Feb 2022 13:47:40 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B4D4C06157B for ; Tue, 8 Feb 2022 10:47:40 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id x65so5919876pfx.12 for ; Tue, 08 Feb 2022 10:47:40 -0800 (PST) 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=w3J0QKkr84VrudaJ3bhOXmAFtwa7Bv5tWoh+lneUqWM=; b=CXeTCXrzzT3Ml1fOtNTfQXwkPNlG/WSDsQlqTW/zEywRyF7j0hBThR0OpQtEw29wF5 THBzVhkjvzf2l/H5yqCg5ADcVm+vos7y8H4hYAEs2XS8GQg3Jz030Sp3iqyWbuQ1YXP8 mt/25TAsI7zRzLsWfDb8xb5cSyI2oeNpM6NyM= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=w3J0QKkr84VrudaJ3bhOXmAFtwa7Bv5tWoh+lneUqWM=; b=EBbMhcP8elnhHwIysO7Cks+kTxoqVjo7GOu8MdOJtYkua9pGvyt7zsH5NLI/0vVaBl 3/Rq6CNXVfEmHq2AAbSEH5QhAGydmJr4V376I4yjnFQ1u/2iibdYItl5SKYkz7q082+4 /7GCtWOKJqwf4GahU0mSlhZ8tZJFMDbHlVJEFgeqaNLX7wZG1fywDIhNIhtwn2+daPH4 jYnAcNq68PqO/GVFR9oNvvkH951uYfEi0KYF5qolj2u8VSWrnVZ/9DRGjN4r7VgesPyV bVSn9PvUs659Ugp58Mh4uTFh2MVGd5+Es7fjjGJQa+IOu2DD7KR5mzCeuIyTHdEOzzKd BpGw== X-Gm-Message-State: AOAM5319l5ox5fY+xTs+2FSxVSlQ/UDEiKAVo0pHRMwpGOLq8b+k7n+2 Ix1kYye/pM6iUXQIjhJkxOhJ/20GDBx61g== X-Received: by 2002:a63:61d3:: with SMTP id v202mr4607974pgb.193.1644346058707; Tue, 08 Feb 2022 10:47:38 -0800 (PST) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id gk15sm3594453pjb.3.2022.02.08.10.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:47:38 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , chrome-platform@lists.linux.dev (open list:CHROMEOS EC USB TYPE-C DRIVER), Guenter Roeck Subject: [PATCH v2 1/4] platform/chrome: cros_ec_typec: Move mux flag checks Date: Tue, 8 Feb 2022 18:47:18 +0000 Message-Id: <20220208184721.1697194-2-pmalani@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184721.1697194-1-pmalani@chromium.org> References: <20220208184721.1697194-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Move mux and role flag checks inside of cros_typec_configure_mux(), which is a more logical location for them. Signed-off-by: Prashant Malani --- Changes in v2: - Removed unrelated "ret" variable initialization. drivers/platform/chrome/cros_ec_typec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index c6f17e3ef72d..58d08dd02f65 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -521,6 +521,13 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, enum typec_orientation orientation; int ret; + /* No change needs to be made, let's exit early. */ + if (port->mux_flags == mux_flags && port->role == pd_ctrl->role) + return 0; + + port->mux_flags = mux_flags; + port->role = pd_ctrl->role; + if (mux_flags == USB_PD_MUX_NONE) { ret = cros_typec_usb_disconnect_state(port); goto mux_ack; @@ -983,13 +990,6 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) return 0; } - /* No change needs to be made, let's exit early. */ - if (typec->ports[port_num]->mux_flags == mux_resp.flags && - typec->ports[port_num]->role == resp.role) - return 0; - - typec->ports[port_num]->mux_flags = mux_resp.flags; - typec->ports[port_num]->role = resp.role; ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp); if (ret) dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret); -- 2.35.0.263.gb82422642f-goog