From nobody Sun Nov 24 06:48:18 2024 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C46F2EAE0 for ; Wed, 6 Nov 2024 15:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730907971; cv=none; b=QZlzJG9OmlUd+sYjFqxrUyFar+SD3/i24zQWwm1LfSaOPaLDaVULVFi0lnQ34HOdMUkZUVYBegAd8q8WGHAViW84Tegv3NkeN5f0CFsJKwVYhv3C3rJYu6UPdB5A/YCkLgA/3MzsskTHezCuVmAUExx4OwDPZVmyaaBdECk2G8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730907971; c=relaxed/simple; bh=7N2RygYMW4TJF9hiZlrbcmdrvhQWopVDKDZZavZfja8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QEJzoHp7H28YC/mZXzaGtZSXJskosSE3REPs8wB36Df9mBkkIJoPsG7AvNqpBnWf7m06n/hZyzBrlXHDfxkRYH2IC0+GXnE/3Yp1dkkp6Z5AofU7Uf+oNy4j18MobIw86SnHt3gHXCSHEsXt4zW3/5tfgLHReop2Z029KaGWel4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Wb0XH1Im; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Wb0XH1Im" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-539fe02c386so950248e87.0 for ; Wed, 06 Nov 2024 07:46:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730907967; x=1731512767; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5YXju+0Q6i1brMsiu/0qAiWLrwUOJs+9ByckwSi6A14=; b=Wb0XH1ImshigU7F5wNjwaO/L0tXb7cZ6lJ9LGNjyyEmiaoErqn9BTVPL5GjWH1al6n BZt5y59SEo++aNw3kgprXG2IcKCYMEE+9lnj/E4lLMDeuCdDZC+NxbpKSM8knHW7BgA4 PM5QKaPuT+yAamB01FaUgHhZwZMV38AXbXiBJ1CZLsH8acLxSKpN1M95q7cklHf4UkFx EHyi+366LX4sDmAZjgXhoq1sQLUA8W9Itjw1AWx7tO4zI2O2fsDa/mDAcQhQBG9HdzdO vlMJVOpbWAyRbgZxpeOEuWOlhHYWwFHDSZwnZL6tgNGuizQsEUk8be/CZEBh3eWUYJxV U+yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730907967; x=1731512767; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5YXju+0Q6i1brMsiu/0qAiWLrwUOJs+9ByckwSi6A14=; b=D5atVvxZxQoYEu06TBQU5VthRrEA6reIIkG+EYViedSazZZjWDiV8f7r4d8jpd7tPG ueWTtHSp6kWnsXgG9kiWRwslbWYWQz2qLlRBR8KIoSAHk3CHBkKrCjzrImSDwHXHIkwo L0HwYdZwKmjDs+7I5lBT0JtWCqP/z+wzQcVkoi3mvZJm+feq3hr50nMGzXRU6kjkgybh YyQToG+FCK5tx3UmrTC8iHLxp5kGhxeqj1X/rnGQzQovsp0URvXwHUISJRl0lwPXE/d9 xyou22L6PgCJHLZykHwkn4YCFZXP9mBgu/2NU69GfAMLxNR/Rhj9JU7JcUcj+Hm0f3u5 rXtg== X-Forwarded-Encrypted: i=1; AJvYcCV3S89NmHwnzwRRz4ri8IzqK6oC3qWVNdQaB7VVutqXdQulanmKuR+h8PIRKiGINvWkY7GI5GCCvut0ljE=@vger.kernel.org X-Gm-Message-State: AOJu0YypCs24Y/7h5f2BEGWCcGOrgERe9S8cdBevoVZ1bIdvNeELEi6R MOmo38jRuJ32YgBXlw65FiUqYWqyTKZbc6xbLMlID2HqFXFH0MGjXYkF0Sxrf3TufeWL2KAH6pV ZnoU= X-Google-Smtp-Source: AGHT+IFG18kkxYOS6GvDQf5y4iYLbTKJAlu7llPe7M19xR33bK9+tOVzg92mBlKjzurOS+rl0SZ2AQ== X-Received: by 2002:a05:6512:2248:b0:53b:1684:c1df with SMTP id 2adb3069b0e04-53d7cfd8097mr1259613e87.1.1730907967260; Wed, 06 Nov 2024 07:46:07 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53c7bc9598dsm2536626e87.22.2024.11.06.07.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 07:46:06 -0800 (PST) From: Dmitry Baryshkov Date: Wed, 06 Nov 2024 17:45:54 +0200 Subject: [PATCH 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241106-ucsi-glue-fixes-v1-1-d0183d78c522@linaro.org> References: <20241106-ucsi-glue-fixes-v1-0-d0183d78c522@linaro.org> In-Reply-To: <20241106-ucsi-glue-fixes-v1-0-d0183d78c522@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Abel Vesa , Johan Hovold X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1137; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=7N2RygYMW4TJF9hiZlrbcmdrvhQWopVDKDZZavZfja8=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnK487m+/b4peGCADrFBKYSdE7vl/qEmknV19z0 SHJSXrVEWqJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZyuPOwAKCRCLPIo+Aiko 1ThxB/46S8vBcyyTbFk7tKRn/OZAUkoQF8N7VUn/ZqPBkDme2oQSDh/iTT6H1P8r/czH3PQhfgG B4gCGPByL8BIPWChWByskmQDDB4xINgPlJBhifwRwUmNCL2CQhmBHSRqJTDnlVCB62aI8he5pgq 93CzTzwSQw9Lp6CcnsXgDSj/hRkDTn/Mdy4BdHXv/Xxngv/MIdo6Ak4YuFDI/o+bOFrPlapXvlu CySq5ydGxppM6BGkHaAEcphbib7zI30ynsQ0/5/kA0loSWkW9XRh7VKn3rORAiYfVa1/eE18hXZ 5ULvZyQFdU/NxLrRnwNEbrKUW9vKQaLl1m28A9XmAHPGAXF/ X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A UCSI connector's indices start from 1 up to 3, PMIC_GLINK_MAX_PORTS. Correct the condition in the pmic_glink_ucsi_connector_status() callback, fixing Type-C orientation reporting for the third USB-C connector. Fixes: 76716fd5bf09 ("usb: typec: ucsi: glink: move GPIO reading into conne= ctor_status callback") Reported-by: Abel Vesa Signed-off-by: Dmitry Baryshkov Reviewed-by: Johan Hovold Reviewed-by: Neil Armstrong Tested-by: Johan Hovold --- drivers/usb/typec/ucsi/ucsi_glink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/u= csi_glink.c index 3e4d88ab338e50d4265df15fc960907c36675282..2e12758000a7d2d62f6e0b273cb= 29eafa631122c 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -185,7 +185,7 @@ static void pmic_glink_ucsi_connector_status(struct ucs= i_connector *con) struct pmic_glink_ucsi *ucsi =3D ucsi_get_drvdata(con->ucsi); int orientation; =20 - if (con->num >=3D PMIC_GLINK_MAX_PORTS || + if (con->num > PMIC_GLINK_MAX_PORTS || !ucsi->port_orientation[con->num - 1]) return; =20 --=20 2.39.5 From nobody Sun Nov 24 06:48:18 2024 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B23F204F72 for ; Wed, 6 Nov 2024 15:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730907972; cv=none; b=E/0KQlatKcgrYa1ZhJUVw00ReAIUzrxBiGg3QxNtdKj4qsdn/5RqlCziIa9l09fp0BnmUoTbDfOeoFXylf5NL/w+T5/Ubg583cmWmsScGuBNGRsOWUe47oxrUCMCJ5ZOWIcCCyRgb76b0/fgZ9Zx0pHsg3/NIntga7+k95MCxgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730907972; c=relaxed/simple; bh=M8HPZh1+/AbA2gNG9MKXsspTiP4s86OPzcBOT20Yh4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CiL2+v4uEuyWOByN6PnAQzSuLyltZ6RX/0VJzTOI1+FbIc2mB/5WdP2LWsfCeg8Qg0yXY/E4KeLO8hT4QIJWdRy/X5Y3OLCS2GlM5o0RwBATuLThUGBbK0emkPj/cwfAuud/3JymM4UL0X+4tsPy69tbO68TTYeqpiHcDM/hOOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mCGNRA2z; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mCGNRA2z" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-539f4d8ef84so8753934e87.0 for ; Wed, 06 Nov 2024 07:46:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730907969; x=1731512769; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1NZe3BHus0cCe7ERcHLwvghPFG3p54ztVsTlGG+rY9g=; b=mCGNRA2zET9WdbC5yjoY0YzgFRaYWsOjsRo4fFz0Kg0lKS+CJK+EMYORvT97R46hY6 VolWSeNxXPT/8CdNZQmwWx5QaPCSahgk1FwUejFvyh869SW1O+UKOcx84yR2Iuh422X4 eoUihzoMkR7QLarilPiqYQoGyuLgmEDUtlqHVJCUK6CHo9n8vK1EHcq6aIY3cj4wOusC msM9Q3qXnJqsYFeiHoKVtB+Z1dxI94AsXeAI7SpS4zBajIFNSbadHReXElonUMujKiEB GAlfx4hGTlwkP67WqHCQ4aYnwi5tg59CvzcKh1qGmtEKruzkaeN8DpJ+RgY/7RzPySP6 gDgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730907969; x=1731512769; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1NZe3BHus0cCe7ERcHLwvghPFG3p54ztVsTlGG+rY9g=; b=bv+TGN7EeZ/MgvD7X6sGTv74+IymXL18SZt1BGzUv4MifL2Bq3PovejVa5+pe8WRt+ dJaHvCZnDKjKx1ANEo5+gn3z6EjB/LDsAd8SU5JhZ/DNi6FB/7uqteA8k6SXuWuoJBGM kSOghmQ15wEjvObcQbASNIX/fUvWGVHM7SHhi4yo9Q+h5+5oDsnM7EGMfX3GczDJkUih cgDwJBCQzf7oH19BNZykIbFqT7aH4IWfg+Ze9eEsqzIqSDRzNrR6pM5AZRATC1Otd8Rw qvMWx1QIL8cZ1w/fi9kAZIKBZWSY4kDwF511UqE0ZkoL0e0ISH7X7uCpEmGawK+ONpFw Yiow== X-Forwarded-Encrypted: i=1; AJvYcCVyXCMXQ2eavud9ZsVKax0UYBU4om1k8FosAr6UsL5br52UDWlvJuXZFPVNjdcKXiv+jY2B7ibTuRSfOGs=@vger.kernel.org X-Gm-Message-State: AOJu0YyPgK1DMVSMrA2HgnQbOe+oQzNkCprIkfScUfTvDaV8aBo8Iovf rg+wFPOzwYW/kVNKn359MC+rOrbhCoWKPZpj8Mqco2h543SJbnxxuhHynXFv5VQ= X-Google-Smtp-Source: AGHT+IE/ZB8rXBTy5Tnq85t9AV9uUbYdWY3aKtN/NNUgIGMzLSYfsl9Ge+5uZeb3gK8oFYzvOuDRKA== X-Received: by 2002:a05:6512:b94:b0:539:f7ab:e161 with SMTP id 2adb3069b0e04-53c79e8ec22mr13131356e87.45.1730907968784; Wed, 06 Nov 2024 07:46:08 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53c7bc9598dsm2536626e87.22.2024.11.06.07.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 07:46:07 -0800 (PST) From: Dmitry Baryshkov Date: Wed, 06 Nov 2024 17:45:55 +0200 Subject: [PATCH 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241106-ucsi-glue-fixes-v1-2-d0183d78c522@linaro.org> References: <20241106-ucsi-glue-fixes-v1-0-d0183d78c522@linaro.org> In-Reply-To: <20241106-ucsi-glue-fixes-v1-0-d0183d78c522@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Abel Vesa , Johan Hovold X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1230; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=M8HPZh1+/AbA2gNG9MKXsspTiP4s86OPzcBOT20Yh4g=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ7p2v03nsbQr4ZviVwXbSvWsYLguVH9CcYsAh7j+THuXg 9NY2CZ2MhqzMDByMciKKbL4FLRMjdmUHPZhx9R6mEGsTCBTGLg4BWAiQRs4GPobs85q/eI+9Mz9 nvPjTy5pr9zlYyWd59/ZFHn9Ob/p+latViFhcdMrYmpVfnrnDr2WqgjYeO61kEul5N69JnufzY9 KObx73b/VRt9c+WbfebxfS1vkqJIum+hZJ+u1Lv6HLif/zrjQbsP8Q09It+C27fMXBhdqeSWt57 RnsplOjeQ5z5xZrhNkeK950fwgU79TlTM5yxwW2V/gX5f/MnLl/lfyYh/6FfmEH8xxmbWSkYvlv crheQt1Fju53Kr1Zmi88P6Xa1KNX5N5NB+L35NttS73pOMz2ZvfhW2TvJq24Bn3cxPu/pqlG94I 2jBXKu1dOjUwaqFPyWnGyxLX2DYkPzfidmZf5hHze9Z9AA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Instead of checking if any of the USB-C ports have orientation GPIO and thus is orientation-aware, check for the GPIO for the port being registered. Signed-off-by: Dmitry Baryshkov Reviewed-by: Abel Vesa Reviewed-by: Johan Hovold Reviewed-by: Neil Armstrong Tested-by: Johan Hovold --- drivers/usb/typec/ucsi/ucsi_glink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/u= csi_glink.c index 2e12758000a7d2d62f6e0b273cb29eafa631122c..90948cd6d2972402465a2adaba3= e1ed055cf0cfa 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -172,12 +172,12 @@ static int pmic_glink_ucsi_async_control(struct ucsi = *__ucsi, u64 command) static void pmic_glink_ucsi_update_connector(struct ucsi_connector *con) { struct pmic_glink_ucsi *ucsi =3D ucsi_get_drvdata(con->ucsi); - int i; =20 - for (i =3D 0; i < PMIC_GLINK_MAX_PORTS; i++) { - if (ucsi->port_orientation[i]) - con->typec_cap.orientation_aware =3D true; - } + if (con->num > PMIC_GLINK_MAX_PORTS || + !ucsi->port_orientation[con->num - 1]) + return; + + con->typec_cap.orientation_aware =3D true; } =20 static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con) --=20 2.39.5