Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2286900ybg; Thu, 30 Jul 2020 15:56:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0jK08KktUW0s6fOrN67GNgXQ1dGTG7DKzPIaKjdT6t+bq1NEYv/bWj58ApUvhtWYgK8Hj X-Received: by 2002:a17:906:d8f:: with SMTP id m15mr1314715eji.494.1596149815068; Thu, 30 Jul 2020 15:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596149815; cv=none; d=google.com; s=arc-20160816; b=H4zjusyPCYoXp0CcHWIsuBtRbW4qMLcQUEcdL8CS/J6cDPKiZNnlcrb48uNHWB4iez mOm96612zUC8S3jH86jMBKJ8B4JJoy+b3o4ts6bqbIrDvXhmxPpA33WNEhbs0aGyWaN4 8y08p3mVpzWz3LgMLQxwZnpoIVpvJj2r4i3FCO+seekmXA5aKaMPGrATZFPJnQnbliHg kcVZ48772LZPW/L1LMv9pLTv1QoJsuXLec/H0/mRZDD9U/TRaM6NpAO3GkXQyQitM865 b2gILXjVsJy4P+AlvyiYqx3OfYwAZ9hF8h/YOcogKVjn/9bD7P/CWWtczEEeExXbv5iV hWPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=1m83rtkfb25YUw43CUB060lNWQIYOupS+Rbr1uGxdec=; b=tPZXWtuPT3HnSckAdE7lfsNIVDvBLjgYunFWoduhMWXaz+UrQI5Gwq91z+TWxNY3kd Y5xyV0ZcrP+4fI+Yaly1V2NUz7AbqNT7IulmlLzZiNbKu2KstR4LamkifHgtzd2z+VxP kE3OkHS7hGm71GVDjTh4hK3nO/LPA5YwDGI6HfstP83mBUNCaiDedxjD4fu+DLJXm/IJ 4QyHV92U9UQf862i3I5SiNEE/DZsOPd9Z+ayZqna/TUQAJO2Yv+HirFFlj3+2DxHn2GR UxTdKi7e2IGuKjGlEBYo2dvxoTxeWoRvBl3akxSJ6qOZ6wztyWfSvOwDPFHzdNr/UCqt RDDg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si3933721eju.192.2020.07.30.15.56.33; Thu, 30 Jul 2020 15:56:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730564AbgG3Wzt (ORCPT + 99 others); Thu, 30 Jul 2020 18:55:49 -0400 Received: from mga14.intel.com ([192.55.52.115]:45564 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729995AbgG3Wzm (ORCPT ); Thu, 30 Jul 2020 18:55:42 -0400 IronPort-SDR: uAJkNBziQkcgufPec5JC2DybvGwYBcGVAhi8XKuOsxsQR9ES0xq+UmdMMoHc5uPqsdi3kX/fOC Eg36bcmcdPwg== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="150902159" X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="150902159" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 15:55:41 -0700 IronPort-SDR: nQTTPm5nWtMCFgfj9n++aLnBNQV58b/0mlVTTCbzvPA3MC3WUoQcbmEfcMbfim4mcxDGfVCUdS pxbKNKV2kWyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,415,1589266800"; d="scan'208";a="273056534" Received: from otc-chromeosbuild-1.jf.intel.com ([10.54.30.83]) by fmsmga007.fm.intel.com with ESMTP; 30 Jul 2020 15:55:41 -0700 From: Azhar Shaikh To: bleung@chromium.org, enric.balletbo@collabora.com, groeck@chromium.org, pmalani@chromium.org, linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, azhar.shaikh@intel.com, utkarsh.h.patel@intel.com, casey.g.bowman@intel.com, rajmohan.mani@intel.com Subject: [PATCH v2 2/2] platform/chrome: cros_ec_typec: Avoid setting usb role during disconnect Date: Thu, 30 Jul 2020 15:56:09 -0700 Message-Id: <20200730225609.7395-3-azhar.shaikh@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200730225609.7395-1-azhar.shaikh@intel.com> References: <20200730225609.7395-1-azhar.shaikh@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On disconnect port partner is removed and usb role is set to NONE. But then in cros_typec_port_update() the role is set again. Avoid this by moving usb_role_switch_set_role() to cros_typec_configure_mux(). Signed-off-by: Azhar Shaikh Suggested-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index eb4713b7ae14..df97431b2275 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -515,6 +515,12 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, if (ret) return ret; + ret = usb_role_switch_set_role(typec->ports[port_num]->role_sw, + pd_ctrl->role & PD_CTRL_RESP_ROLE_DATA + ? USB_ROLE_HOST : USB_ROLE_DEVICE); + if (ret) + return ret; + if (mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) { ret = cros_typec_enable_tbt(typec, port_num, pd_ctrl); } else if (mux_flags & USB_PD_MUX_DP_ENABLED) { @@ -589,9 +595,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) if (ret) dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret); - return usb_role_switch_set_role(typec->ports[port_num]->role_sw, - resp.role & PD_CTRL_RESP_ROLE_DATA - ? USB_ROLE_HOST : USB_ROLE_DEVICE); + return ret; } static int cros_typec_get_cmd_version(struct cros_typec_data *typec) -- 2.17.1