From nobody Sun Jun 28 10:37:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C036C433EF for ; Tue, 8 Feb 2022 18:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385396AbiBHSrr (ORCPT ); Tue, 8 Feb 2022 13:47:47 -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-Google-Smtp-Source: ABdhPJytsqdO5d2kpVqJ9mIDwNDjF08hSxlxJZgO7iZIJNRCJ4lHvtHfAQZ7XFMm+yJ82HUdKUUH5Q== 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Tzung-Bi Shih --- 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/chr= ome/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; =20 + /* No change needs to be made, let's exit early. */ + if (port->mux_flags =3D=3D mux_flags && port->role =3D=3D pd_ctrl->role) + return 0; + + port->mux_flags =3D mux_flags; + port->role =3D pd_ctrl->role; + if (mux_flags =3D=3D USB_PD_MUX_NONE) { ret =3D cros_typec_usb_disconnect_state(port); goto mux_ack; @@ -983,13 +990,6 @@ static int cros_typec_port_update(struct cros_typec_da= ta *typec, int port_num) return 0; } =20 - /* No change needs to be made, let's exit early. */ - if (typec->ports[port_num]->mux_flags =3D=3D mux_resp.flags && - typec->ports[port_num]->role =3D=3D resp.role) - return 0; - - typec->ports[port_num]->mux_flags =3D mux_resp.flags; - typec->ports[port_num]->role =3D resp.role; ret =3D cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp); if (ret) dev_warn(typec->dev, "Configure muxes failed, err =3D %d\n", ret); --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:37:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D48BC433F5 for ; Tue, 8 Feb 2022 18:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385430AbiBHSry (ORCPT ); Tue, 8 Feb 2022 13:47:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385420AbiBHSrv (ORCPT ); Tue, 8 Feb 2022 13:47:51 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF5FFC0613CB for ; Tue, 8 Feb 2022 10:47:48 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id z35so65239pfw.2 for ; Tue, 08 Feb 2022 10:47:48 -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=/3NuIwovuNz7GFfgDQq4eFqfd72S+Kgga4jDeLgjulM=; b=SzH2BGmudD3cz76o4hl70v9hFx3qos+SW+CF2fSdozabjfuEYin1BxdO3i1Sh3bz1k f0QnRL2Hg/FR+wrTeG2j/LIoVU+XsLkzJu1R0kwKk83N2TRU0H00ewQBTObfFOT07DKp b28EoLTtSO7N5TuA0VEV9OQpT/Dq7zIM1LSUE= 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=/3NuIwovuNz7GFfgDQq4eFqfd72S+Kgga4jDeLgjulM=; b=GddWLimVzu76zlf6MmLjcoU2TnDuoxbBFpsqZx+/F8G6nWLsVSolV6XBUoezHhJVpt drhE3FEHfoPBZkRdgyjNXFmePQB+QnxUWtVMSE7qi4Sr6lQoICDd/989wn8XudrWZ3NB jaIbdLDiZGOQ+CisUnuOm15G5OlI+xx/8MAehOtoU4Th0rqid3j3bp4bwQ+N3e5b02WU HsKw08iC/22LFJBOzCPUmXZbP7BBEystbnXPze/5iWHG0uFy19tzVAQ/zM7uuKthoFmb mKnD+FE2ZOhUxdNBQze7cGksr6j5KD//jEcJce+c2Ne4sY5JP+ScRsANCNZ3Q9R/B9od RjgA== X-Gm-Message-State: AOAM532FFfcodN3pdjaF1j1IRA72Qu901Kfqf7Ouh1Ycumd6wRlFMaBF KUqbvpldF7ipb2+UtAbLVEFy12MO+RrIBQ== X-Google-Smtp-Source: ABdhPJyo4hczEo4QVG0QQbOtNVE621++a+UKKID1yceuZbTeFSoguE2vzqnQAoU7XAW46pwWfXOsPw== X-Received: by 2002:a63:8343:: with SMTP id h64mr4581287pge.566.1644346068314; Tue, 08 Feb 2022 10:47:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:47:48 -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 2/4] platform/chrome: cros_ec_typec: Get mux state inside configure_mux Date: Tue, 8 Feb 2022 18:47:20 +0000 Message-Id: <20220208184721.1697194-3-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move the function which gets current mux state inside the cros_typec_configure_mux() function. It is better to group those bits of functionality together, and it makes it easier to move around cros_typec_configure_mux() later. While we are doing this, also inline the cros_typec_get_mux_info() inside of cros_typec_configure_mux(). Signed-off-by: Prashant Malani Reviewed-by: Tzung-Bi Shih --- Changes in v2: - Changed "mux_resp" variable to "resp". drivers/platform/chrome/cros_ec_typec.c | 55 +++++++++++-------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chr= ome/cros_ec_typec.c index 58d08dd02f65..3d34ece7f790 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -513,27 +513,38 @@ static int cros_typec_enable_usb4(struct cros_typec_d= ata *typec, } =20 static int cros_typec_configure_mux(struct cros_typec_data *typec, int por= t_num, - uint8_t mux_flags, struct ec_response_usb_pd_control_v2 *pd_ctrl) { struct cros_typec_port *port =3D typec->ports[port_num]; + struct ec_response_usb_pd_mux_info resp; + struct ec_params_usb_pd_mux_info req =3D { + .port =3D port_num, + }; struct ec_params_usb_pd_mux_ack mux_ack; enum typec_orientation orientation; int ret; =20 + ret =3D cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO, + &req, sizeof(req), &resp, sizeof(resp)); + if (ret < 0) { + dev_warn(typec->dev, "Failed to get mux info for port: %d, err =3D %d\n", + port_num, ret); + return ret; + } + /* No change needs to be made, let's exit early. */ - if (port->mux_flags =3D=3D mux_flags && port->role =3D=3D pd_ctrl->role) + if (port->mux_flags =3D=3D resp.flags && port->role =3D=3D pd_ctrl->role) return 0; =20 - port->mux_flags =3D mux_flags; + port->mux_flags =3D resp.flags; port->role =3D pd_ctrl->role; =20 - if (mux_flags =3D=3D USB_PD_MUX_NONE) { + if (port->mux_flags =3D=3D USB_PD_MUX_NONE) { ret =3D cros_typec_usb_disconnect_state(port); goto mux_ack; } =20 - if (mux_flags & USB_PD_MUX_POLARITY_INVERTED) + if (port->mux_flags & USB_PD_MUX_POLARITY_INVERTED) orientation =3D TYPEC_ORIENTATION_REVERSE; else orientation =3D TYPEC_ORIENTATION_NORMAL; @@ -548,22 +559,22 @@ static int cros_typec_configure_mux(struct cros_typec= _data *typec, int port_num, if (ret) return ret; =20 - if (mux_flags & USB_PD_MUX_USB4_ENABLED) { + if (port->mux_flags & USB_PD_MUX_USB4_ENABLED) { ret =3D cros_typec_enable_usb4(typec, port_num, pd_ctrl); - } else if (mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) { + } else if (port->mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) { ret =3D cros_typec_enable_tbt(typec, port_num, pd_ctrl); - } else if (mux_flags & USB_PD_MUX_DP_ENABLED) { + } else if (port->mux_flags & USB_PD_MUX_DP_ENABLED) { ret =3D cros_typec_enable_dp(typec, port_num, pd_ctrl); - } else if (mux_flags & USB_PD_MUX_SAFE_MODE) { + } else if (port->mux_flags & USB_PD_MUX_SAFE_MODE) { ret =3D cros_typec_usb_safe_state(port); - } else if (mux_flags & USB_PD_MUX_USB_ENABLED) { + } else if (port->mux_flags & USB_PD_MUX_USB_ENABLED) { port->state.alt =3D NULL; port->state.mode =3D TYPEC_STATE_USB; ret =3D typec_mux_set(port->mux, &port->state); } else { dev_dbg(typec->dev, "Unrecognized mode requested, mux flags: %x\n", - mux_flags); + port->mux_flags); } =20 mux_ack: @@ -638,17 +649,6 @@ static void cros_typec_set_port_params_v1(struct cros_= typec_data *typec, } } =20 -static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port= _num, - struct ec_response_usb_pd_mux_info *resp) -{ - struct ec_params_usb_pd_mux_info req =3D { - .port =3D port_num, - }; - - return cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO, &req, - sizeof(req), resp, sizeof(*resp)); -} - /* * Helper function to register partner/plug altmodes. */ @@ -946,7 +946,6 @@ static int cros_typec_port_update(struct cros_typec_dat= a *typec, int port_num) { struct ec_params_usb_pd_control req; struct ec_response_usb_pd_control_v2 resp; - struct ec_response_usb_pd_mux_info mux_resp; int ret; =20 if (port_num < 0 || port_num >=3D typec->num_ports) { @@ -982,15 +981,7 @@ static int cros_typec_port_update(struct cros_typec_da= ta *typec, int port_num) cros_typec_handle_status(typec, port_num); =20 /* Update the switches if they exist, according to requested state */ - ret =3D cros_typec_get_mux_info(typec, port_num, &mux_resp); - if (ret < 0) { - dev_warn(typec->dev, - "Failed to get mux info for port: %d, err =3D %d\n", - port_num, ret); - return 0; - } - - ret =3D cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp); + ret =3D cros_typec_configure_mux(typec, port_num, &resp); if (ret) dev_warn(typec->dev, "Configure muxes failed, err =3D %d\n", ret); =20 --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:37:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 413CBC433EF for ; Tue, 8 Feb 2022 18:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385442AbiBHSsF (ORCPT ); Tue, 8 Feb 2022 13:48:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238272AbiBHSsC (ORCPT ); Tue, 8 Feb 2022 13:48:02 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C8EC0613CC for ; Tue, 8 Feb 2022 10:47:59 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id on2so12077pjb.4 for ; Tue, 08 Feb 2022 10:47:59 -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=jLio1a1l75mHbmNEuBlAUNzao55kTSeKszQYcAQRX+I=; b=MsjVta7IYbQNKqHe58RtLXBHcrrrukRhSUHG22zWAasQ99i8xGDjf6fjdG686TlnIa nybAKSUI943yDMYt1V4L4HPXRb7QQjwNcAdgkBEA7mkKq7rvOzgkYGUwhNrja80IyCzj TubUKDuwMDz9gZ1PzfVVVhqUkOhBd0PGbly6A= 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=jLio1a1l75mHbmNEuBlAUNzao55kTSeKszQYcAQRX+I=; b=yR8OfIgywEkpHzTanDV1iAzmnN33WOiQdcEKwXUFdfZpWuxsNUJurdwbXp1UnuGG3m irEOkIClwrfC4OoRZKHjMuLIDdvk5x90eQkfxcvr9eSVqkobsaXB9+UlLXWgF0314YK/ DsCBoejthoRKtt+W+QX/oC3WOeLcVq0b5klvqnoBsh+WzgflnCkyuNJDU/xIJygHytOf K3DZiBwlNcUxeqUVG91wOZLRKZmijhiGYRFuj9PwBVguei0PANI02ca+GQ4zfmpxUUqi gXnmq+2qCD63lRDxjv0yPKtVnKXPUEsm0a8ewKHocUflhkzEGyeqFLOUBHOFINrL76yQ mPrA== X-Gm-Message-State: AOAM5335vHQOYU9qPwERHn4bO0ws6huXBtF3bt6mwND16IRd3d1Oh0c5 QBKlXujBtooxk+7trnpWmrxNueRviGfLlA== X-Google-Smtp-Source: ABdhPJzA8ECq/26nKv0NhBy5xwK2bu7d8aQaB1wRho9op9ZuMhWeJ0H4ktflQM6NMxY0ajIdDbI8/g== X-Received: by 2002:a17:902:da88:: with SMTP id j8mr5904035plx.105.1644346078477; Tue, 08 Feb 2022 10:47:58 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:47:58 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev (open list:CHROMEOS EC USB TYPE-C DRIVER) Subject: [PATCH v2 3/4] platform/chrome: cros_ec_typec: Configure muxes at start of port update Date: Tue, 8 Feb 2022 18:47:22 +0000 Message-Id: <20220208184721.1697194-4-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There are situations where the mux state reported by the Embedded Controller (EC), might lag the partner "connected" state. So, the mux state might still suggest that a partner is connected, while the PD "connected" state, being in Try.SNK (for example) suggests that the partner is disconnected. In such a scenario, we will end up sending a disconnect command to the mux driver, followed by a connect command, since the mux is configured later. Avoid this by configuring the mux before registering/disconnecting a partner. Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- Changes in v2: - Change return at end of port_update() to just return 0. drivers/platform/chrome/cros_ec_typec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chr= ome/cros_ec_typec.c index 3d34ece7f790..3019e29f200d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -965,6 +965,11 @@ static int cros_typec_port_update(struct cros_typec_da= ta *typec, int port_num) if (ret < 0) return ret; =20 + /* Update the switches if they exist, according to requested state */ + ret =3D cros_typec_configure_mux(typec, port_num, &resp); + if (ret) + dev_warn(typec->dev, "Configure muxes failed, err =3D %d\n", ret); + dev_dbg(typec->dev, "Enabled %d: 0x%hhx\n", port_num, resp.enabled); dev_dbg(typec->dev, "Role %d: 0x%hhx\n", port_num, resp.role); dev_dbg(typec->dev, "Polarity %d: 0x%hhx\n", port_num, resp.polarity); @@ -980,12 +985,7 @@ static int cros_typec_port_update(struct cros_typec_da= ta *typec, int port_num) if (typec->typec_cmd_supported) cros_typec_handle_status(typec, port_num); =20 - /* Update the switches if they exist, according to requested state */ - ret =3D cros_typec_configure_mux(typec, port_num, &resp); - if (ret) - dev_warn(typec->dev, "Configure muxes failed, err =3D %d\n", ret); - - return ret; + return 0; } =20 static int cros_typec_get_cmd_version(struct cros_typec_data *typec) --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:37:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ED93C433EF for ; Tue, 8 Feb 2022 18:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385480AbiBHSsc (ORCPT ); Tue, 8 Feb 2022 13:48:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385472AbiBHSs3 (ORCPT ); Tue, 8 Feb 2022 13:48:29 -0500 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 7F95DC0612C2 for ; Tue, 8 Feb 2022 10:48:28 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id y17so121347plg.7 for ; Tue, 08 Feb 2022 10:48:28 -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=3nJw75yUn0Ak2LbjP8FDSUKGk9cBjMNSHZr8K3rv/n8=; b=Kcc50LqTHuQIYf273mHplhXaUKkVZo5PUBRoSWfRcf58iiGQ2BqdIdG45EwyPs1uXs CAAbXNkEd2gr6pK4HN7DiQh4qUIHHNlorxb+wH1BXIOdeK6oQxUKyLl5QTwejhLKNtmR CteLOdhUCS5CWbC0mzNmxIdXJAHtmnBxfT90k= 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=3nJw75yUn0Ak2LbjP8FDSUKGk9cBjMNSHZr8K3rv/n8=; b=vo8E//jxoAnG+SOHjuTzR/ka2ICwpmXEmvCTE5P9GXxlSV4e8ldlbDhF9qa5M3Nzg1 F5WrVxeId0TbupCKC38E0xv6WKZnUw9XImPiOJx7w+Xh136kq4JpA8AXDDWE/BKVglPg 2Kuo1KgUZq8u374Q7jEStxbr5ybTjtpni+etGqn/fdAh4nn7qx+GDEv2CKuREiGSBK23 WgyalZI2ZeD/FsJtZvZFZ8FZwCdlsZ7cQ7hyxrIAltJwJ4eUWPM7+LcLjM4jwy+4n5Du 89sXVIYA2VHLXvpiDDqYk2VYvR4GE+BRfZUrJdFAlEj7XL2ydc7gbVZWUjMYciXZxKNV b2QA== X-Gm-Message-State: AOAM532ngBi9hOgsUbedftC8B28vNt8JoxNihjJxRl3oqZOggVHam5jR WML7zhcUINRnVhPSZ0vB23h/0LgDMfqG4Q== X-Google-Smtp-Source: ABdhPJzUwlOAtGq+Y2cBB0fnuRDAYTc8P/abuAm1YmIdSlVd7T3zol+qZiMELS+dYrh3y9do6LWUBA== X-Received: by 2002:a17:90b:4c91:: with SMTP id my17mr2870441pjb.121.1644346107948; Tue, 08 Feb 2022 10:48:27 -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.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:48:27 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev (open list:CHROMEOS EC USB TYPE-C DRIVER) Subject: [PATCH v2 4/4] platform/chrome: cros_ec_typec: Update mux flags during partner removal Date: Tue, 8 Feb 2022 18:47:24 +0000 Message-Id: <20220208184721.1697194-5-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In cros_typec_remove_partner(), we call cros_typec_usb_disconnect_state() which sets the switches/muxes to be in a disconnected state. This also happens in cros_typec_configure_mux(). However, unlike there, here the mux_flags variable hasn't been updated to reflect that a disconnection has occurred. Update the flag here accordingly. Signed-off-by: Prashant Malani --- Changes in v2: - No changes. drivers/platform/chrome/cros_ec_typec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chr= ome/cros_ec_typec.c index 3019e29f200d..4bd2752c0823 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -228,6 +228,7 @@ static void cros_typec_remove_partner(struct cros_typec= _data *typec, cros_typec_unregister_altmodes(typec, port_num, true); =20 cros_typec_usb_disconnect_state(port); + port->mux_flags =3D USB_PD_MUX_NONE; =20 typec_unregister_partner(port->partner); port->partner =3D NULL; --=20 2.35.0.263.gb82422642f-goog