From patchwork Sat Nov 9 00:04:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13869075 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 C58E52581 for ; Sat, 9 Nov 2024 00:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731110664; cv=none; b=kspXVoXOWoGc/SJkBDJQUHDdbxN4SWr1Zw1MBp19pODeiVzonD7M/ky6zflCMCdZSl1H1A9eJsGoG+B7JYFv81tRHaPK7/jEGsApWIJtHIok6F5vvsXSjlfhphlVLWOv2DvERsIKjRo/pxJ3+7/96T0FqeGwjH6YmWVHo0PGdGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731110664; c=relaxed/simple; bh=3V2nbDJYpptGWjzVHtq/pkL46D3rJH/ZxerBXx7L1ek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G6J+qTdXOoktEPcbQJFXL2tI4nOKy6Eqg1kQg2qWnC+ti5ijQHsSOhxYa0SEaouxsgBPVb04lhB37jem4H7S5X1TFHjOZcliTIsU4DsJbEOtnf89Ngo+S5mtNv0HIKfSYkm58pqj8ooyAii8BaFoLglIaOOVYpfaQ7SpLmWJzac= 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=nwSuc63W; arc=none smtp.client-ip=209.85.208.169 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="nwSuc63W" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2fb5014e2daso21691321fa.0 for ; Fri, 08 Nov 2024 16:04:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731110661; x=1731715461; 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=3s5+t9Fz8C3WI9SbcTcnEleY6fD4F078kSD55sW9Rqo=; b=nwSuc63WXXMCd+uvf1DztDco+fJZ5r30CNpzKrwPUwSzGyK5tEcJDcGNt69YgMBWg5 UpK9UxIMsXwc0Ntdcz+Z/mDpqXAH+PAry7k+napx2U3mdgy865xR5yhZqa35bGprat3E xlXfZxJiOqaWDwdqaffX1ze6egKnJp4/DFxeAUD5ZULJsDLYUsWA7nukrEM/0IfifI3y SGBVjglJ/10XNXm7YmEriBbFIPrBs9YCgyjJJ5G4cv280vFsm98c/gE8Jh+Uz9cl80fC vg2kZ7N6+NKI9ILB+mytmMx4Oc4bfsTVLF7OKl5B8W/xMT7tD2Y2akqxJ++wg0HcJy7q I7Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731110661; x=1731715461; 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=3s5+t9Fz8C3WI9SbcTcnEleY6fD4F078kSD55sW9Rqo=; b=fENrWp4DxMk87biIFQMhl+e6Cs5mFyEwINQ7IfWtRlM74D9DGD6TUKiL9pSUpQt/o5 tPiFbxuJtesr6ch/GhGGix2EsoWrDTHCOQw7+6UyQgGRUDqNtqjJFELCJVOYAAMFUo+t Vp2zXem5JfQimEjC7Z7LNBhlHiDzCChrsVWgpjSAc/pAt7yeZnt/+kOb3YRleM48e/Oo a677q4pVkawd0CmSPNitxCuWMyR5aOtJX7eqr0psi8E8F2jka3mB+tmH3DlppbrF/NUz m0U+BVoPLGZ4gO2Qg12h71w9DuZrHpzhf1R5P+OxVsLXR5OQEwOx1N96ZN7ucDwwr3Tu CDhg== X-Forwarded-Encrypted: i=1; AJvYcCV/whaFkEruRzwTslMhq1/YDDhszv71A2TWpFjwloQVQ5k1UbjkYFCfBD3hXNp+kUMJ3pV7EBjOOCxkA74s@vger.kernel.org X-Gm-Message-State: AOJu0Yx1QZo5efBLY2J6CCxOiW85SQEMmVAKrnctokBxofg53ElOh0Gq qgF7u3cGeEtECRZqA4yFkzV3dsBLpf540kQU/wKt6Lki6VflnC5U3EyFGXzq8dc= X-Google-Smtp-Source: AGHT+IGSMmGdQuupUVqY9d2iFzKEZntKmWoUY0L+QAr8gmtjlKLNeXFZizvFw9XedM2SCOaMM9LMnQ== X-Received: by 2002:a2e:be20:0:b0:2fa:cac0:2a14 with SMTP id 38308e7fff4ca-2ff20185b17mr28584861fa.11.1731110660983; Fri, 08 Nov 2024 16:04:20 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ff17902152sm8221431fa.57.2024.11.08.16.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:04:19 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Nov 2024 02:04:14 +0200 Subject: [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241109-ucsi-glue-fixes-v2-1-8b21ff4f9fbe@linaro.org> References: <20241109-ucsi-glue-fixes-v2-0-8b21ff4f9fbe@linaro.org> In-Reply-To: <20241109-ucsi-glue-fixes-v2-0-8b21ff4f9fbe@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 , stable@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1326; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=3V2nbDJYpptGWjzVHtq/pkL46D3rJH/ZxerBXx7L1ek=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnLqb/RrUpLWMzqz3Z50ZKx/wbVyesK9kxjZEAY RQM0ENGhVeJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZy6m/wAKCRCLPIo+Aiko 1S5sB/9SKnz2iqzGhPdnAXBwJ6/U0QudJSc9xvuqb78wO25ZQ7KYAjSI6hvHXzp9ls2+5S8SBeL WDMGlFiew5Oja0bwxBt/MAjdWkSTGYRTQw2Y2svetrKXKlK4+m1OQpnj8VuQqiLUainPpArGLOb eqOIsSgkffIYS2gYP54NtWvH4Ub0EY8D/plW4vAMAdEAYIsHUOJ74LIVcyHUUV+2Axs3DKHNDFN XDjWLiMMX7JbTfgYCHdqKRhYe/xWDsGK5VYQU3xW10vkVm04wGyXH6ukNpSsmYa/ZzdQGWmLCF7 Mk56gvQwu2JwBan6mB1G4zXLobHEnX4D7VcWBWZ7tL/Z/rVK 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 connector_status callback") Cc: stable@vger.kernel.org Reported-by: Abel Vesa Reviewed-by: Neil Armstrong Reviewed-by: Johan Hovold Tested-by: Johan Hovold Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- 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/ucsi_glink.c index 3e4d88ab338e50d4265df15fc960907c36675282..2e12758000a7d2d62f6e0b273cb29eafa631122c 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 ucsi_connector *con) struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi); int orientation; - if (con->num >= PMIC_GLINK_MAX_PORTS || + if (con->num > PMIC_GLINK_MAX_PORTS || !ucsi->port_orientation[con->num - 1]) return; From patchwork Sat Nov 9 00:04:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13869076 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 52D708C0B for ; Sat, 9 Nov 2024 00:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731110666; cv=none; b=UusMbIbcKaFVs5ApTqJ3tLJVF7/BkPy6tjI86mZ6Vdr7o4MhC0uoeTUvX2+JarbRDXcMZx/aK3npGOqiIvjS0H86PctnXh36trhVNr2wCvSJoew50Hlq/Wn/3NU+TWvxbX5oohJ2BBACzM4Wym3dYBAygZA/8eiTIDjcXrlOehY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731110666; c=relaxed/simple; bh=vNc9pzUAAlpSLHdwupXEtJEBYi/DEYLSea6HQqWBRGU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Fi4L9A6C3Yrr+LJl8uD0MLqZsnrbajh0DAv7CdUYTd4GmYureEvAl3FkgFZkYTZyUruPE6yud/Gy9q5/30UM5WBDo2toeSlOs3CCPYWmfUkh/oMOc6batw8+xGP5nvZg8DE+XZ307cKTgWpe/RNg05MTLbuZMyJccywnoC6AEF4= 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=iXU2w6Mn; arc=none smtp.client-ip=209.85.167.47 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="iXU2w6Mn" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-539fbe22ac0so3097287e87.2 for ; Fri, 08 Nov 2024 16:04:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731110663; x=1731715463; 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=BiTEPthPqo3/ebkD0qqxoaM8WpYM9XGm0Z4Ybp7u6u4=; b=iXU2w6MnMSLnBqQJgwiz0M0I8uCA4JzbXZqRn2xf5ntWsGWDpqL2ofCxiFb40/9xxg Ir6D2HYSPkINexUDcic3Umls0iVtYsqw2GGrBEMEW41cYSAwSz8mIZ5eYAHFtywmGGMH tcYAdySxaoP2diycBe6msySgr0yCNV2aWp7FiUU8fWodpqnSCk1+ZHq+AOHSr7Twqw7+ XTRBlyuJX8I5yOIK0DCAmoSJ6O96rAUVvqfeaoHHaEYnBoOt+Zntb5HqE8APFEeqDxfK Xta0Qs234FFJhfCg+ECePYnwVtr0QavtNapKNOLeoFn1Mh2uXTa9UKmsRLtAC+tHdGhh 0k5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731110663; x=1731715463; 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=BiTEPthPqo3/ebkD0qqxoaM8WpYM9XGm0Z4Ybp7u6u4=; b=E64lPWwhfYjIXqGWJ7vwJGWkpgeJA+b3m7a1gho2iRsidhVM5tDwPMSDPH9xCNi2SL J1QuaJzlxK7BjDjX+4XNtLUZdpaUdGJetzyqO8UEFwDPR+HMmnIx9C+oXCc2N9OaaBcz kYVlIIiGhAHa3wxMs3gplnFQYjDd3Z0z81jJtep4rDFkU9JOfcW241TQygvnV+3T0yyb 6HBtNaGIld06wOE991d5lmicvTC34noTKVhdSSKa1sm+d6WHkUxxMnBBmPDKSSmtBrK9 17Mfcaatx0NlnpKmdvUg7122CvrxIPOCqlujmnlp+1RRmpYds5DeNuz1Ul52A1h3024i OU4w== X-Forwarded-Encrypted: i=1; AJvYcCVlURFhaCft3VVHQ9+5riF/O/Ae80/cTtJjAoLmyevOH+dL+hWBEareO7bolETPacHBF8DvHtmDykW6fix6@vger.kernel.org X-Gm-Message-State: AOJu0Yx1uVSr3SkaAoBDmWeMWQXp7ZndZM/KOwLi2Fn/BWN1454CtDnq h91kNMdJjkJdx16KVowDZ1FlHT1H+GwA1pPfMhVHhuynls4+e1R6cNiIHEYufn0= X-Google-Smtp-Source: AGHT+IHWEG5PGsyY3GLZoDdm2ZbEVdV9W9AgH9pPqyg0jHr5gvSoOytLziAHUCiZwZEroy6C1g3BvQ== X-Received: by 2002:a05:651c:1506:b0:2fb:7e65:cb27 with SMTP id 38308e7fff4ca-2ff201e73a4mr27560931fa.6.1731110663495; Fri, 08 Nov 2024 16:04:23 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ff17902152sm8221431fa.57.2024.11.08.16.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:04:22 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Nov 2024 02:04:15 +0200 Subject: [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241109-ucsi-glue-fixes-v2-2-8b21ff4f9fbe@linaro.org> References: <20241109-ucsi-glue-fixes-v2-0-8b21ff4f9fbe@linaro.org> In-Reply-To: <20241109-ucsi-glue-fixes-v2-0-8b21ff4f9fbe@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 , Neil Armstrong X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1590; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=vNc9pzUAAlpSLHdwupXEtJEBYi/DEYLSea6HQqWBRGU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnLqcAO15Qotft0szsjqbSNzcaxCYWgZEOzS82i 56/L/hrM5aJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZy6nAAAKCRCLPIo+Aiko 1YhQB/4phgE/zYsTgO/BKGTEhgTp6cOPDbL9814ZC0n+yzunQFXi9vj539T1t0vrCGzzJFLW1RY 6e77MQreozkWv5vPZpfbpxRaIbsMYgwQVtBu/0KzkUZaZEH64BzwxLmcCBB7TYmqjh2SOoYxxok 3sD2ASy3QI4a0NNYbDQhGW+b04jpqmRNqIDpkCqkJT1q1aZUnbY3yhLHhMU8qcdGFBVaS5tUaeQ Ff6DxtpKS9kaTIlLKU7A+L0FB2AKb89Y8AQ03mj+rhO1ItkqE0FTh8QVPnAospp41hfaFGVcD2A tjBkvRav7YAEOjSvxgC1YyWYeSywZoUiNGwK9aJET29833Xh 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. There are no boards that are affected by this change at this moment, so the patch is not marked as a fix, but it might affect other boards in future. Reviewed-by: Abel Vesa Reviewed-by: Neil Armstrong Reviewed-by: Johan Hovold Tested-by: Johan Hovold Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- 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/ucsi_glink.c index 2e12758000a7d2d62f6e0b273cb29eafa631122c..90948cd6d2972402465a2adaba3e1ed055cf0cfa 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 = ucsi_get_drvdata(con->ucsi); - int i; - for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) { - if (ucsi->port_orientation[i]) - con->typec_cap.orientation_aware = true; - } + if (con->num > PMIC_GLINK_MAX_PORTS || + !ucsi->port_orientation[con->num - 1]) + return; + + con->typec_cap.orientation_aware = true; } static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)