From patchwork Fri Jan 24 19:40:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 859750 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 6AE2035976 for ; Fri, 24 Jan 2025 19:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737747630; cv=none; b=IdE/w0uL9wWjxrkZLR19K6Y863W4542cJCFEbSSNj8dts8xw76xL0GiWeY2HPEp2ISFpEsWKFlcmCBpSbQ1ZWibCVFi564tfNCloOai8d0J7hZQKDf/aBUWmHrjGzS9a60v/3hz3m1uotnkrBJZZoDtLaNBitXP0OJqS36kDAdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737747630; c=relaxed/simple; bh=7u/oXjBRZp/xICilidPMGfoO3yKFUNQrNcrjM+JLEOQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=A67Hb2ZAAXu4EfeknT42Jx5JqyQV3I7szD7DT4B/QvKSA8cVeP9QOLQ0QEwut7aJ6Kbi5EIpDiEGPQWlFr965oSYudIRNNthuwWguSD6/OQbPHODEGbjgG2bp7k0ufjIOynFa7N8pGkkCZQ2rVEh0+AMNcKyAkpeyzgEh8D0m10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tGCEBmVB; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tGCEBmVB" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21a7ed0155cso43558625ad.3 for ; Fri, 24 Jan 2025 11:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737747628; x=1738352428; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=XeTFUke24YztL2UFTa1EA42MEpaJFIIZjeHmRdx9I0M=; b=tGCEBmVBW03gAbx7+KQlmgYSZMvK8u8SmYISov6WgHorPoEbbBNHZ0xaWmGm+HVjeX GccmBZtA0oPkLdoSFdZPjqfcbVRcuAlOb42D0CqqK0HMCpAPMUPz8sjSfJP2U6Ee2i1/ PnvNHtUZl9zyPsJTeqarTq09Sc37B5nDW4y3DfwuxawW1c9NOtgLH7n/H3bomQyVts6j E7R2uEDqR71HSrwtrg4TPUT1fGq9r44nEJ5WG+D65tWlN3k8V/gUJ9dqj5M/7ZX9M1Ty VY5Z6jS/+5B/Ql+PELxs63tkuL+nlfxISRNRyTdvSsyAhKGN7G74c7fifH024aDuZSvq 3a4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737747628; x=1738352428; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XeTFUke24YztL2UFTa1EA42MEpaJFIIZjeHmRdx9I0M=; b=KopK/c/7wZoMxl96msNeXvmydYhjm9Qot8Yt1XMgGIEgDZSEbWWP+Ec8vI4i/ggq+d oGwBwZJ/PKmDyqbtRfqW1NPveGiM1xVsSv3L+b4KuC+PhIlrYRwyZoDC+ckBW825hw5J AxegdeiHwIXKzHnmf3wktRlKTiGCZPUDFur6wbvY+H6jx3PMw3j5KcBrsBSglYdKrSxM dZiZtk2HqxtbzYTZ7XFGeUMkfhflCaH7n6Cn779T/0IYDxzcqNj4UV0mrNHjBE957gNP debWt391Oe+nt1d6TH3NftvZbKczT16DDs6OIXQybNGdKGOSo3oXeOT/QvAZx6M4y8BL E/PA== X-Forwarded-Encrypted: i=1; AJvYcCV5uX7IOtbPv0QyCXlWXsjzIUxD/ADFWCvvVMCljj6mOscIFeTvTvhjK6kxGCXoRRzkkYu0RRZ387Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzOaRU0//b9RX6W2jhPnbEQNm38Hqx1ErnXW9yfM7byK9QTJrFw Za1uN+5+EfuGkbFrYnWnE0GjP0L+b9ApTfB94cOGP/LVWDYI7MNxrKgDnir0Bw== X-Gm-Gg: ASbGncuz9dyUzAXc5EiE5gjGC2xBRohGYCEx6LMyxBakYE9BgKN7h3LZS4KVxEC5Llx KcglFDvcsN6k2tHMTIwCYQcPMcb7xw4DNoT1R8hDwYawWEuYXn70ff4+S0Se10Rnq89GUvLrEyI pWfJlVr58p+ncdAbDH2JS/BhGaipY9dC/zVIOhFGFfrke3uf37QjC/5DA9DZ75KcCtDOuve8P0m 5TsAFuGU2IGa2PHyWKmvTRDuzmcldOnlXYd5aA3POrOVovw+YKCBhThE49hTB98y4WH7rBcEhyq WEAzlq4YN0Ats1n27iWDitZewW7+QC8vGTKTzVu4ufvwre+TWDs= X-Google-Smtp-Source: AGHT+IED3i4wnCoiLFROaAx+kXZsYkw8NBVlPE2QiqDLo+oCmVgIvJn05HRKiZA5a7lTiHsXuu3C/w== X-Received: by 2002:a17:902:ce8a:b0:216:32c4:f7f5 with SMTP id d9443c01a7336-21c3540c7a1mr484270375ad.19.1737747628323; Fri, 24 Jan 2025 11:40:28 -0800 (PST) Received: from google.com (28.67.125.34.bc.googleusercontent.com. [34.125.67.28]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da414db35sm20118915ad.195.2025.01.24.11.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 11:40:26 -0800 (PST) Sender: Benson Leung Date: Fri, 24 Jan 2025 19:40:23 +0000 From: Benson Leung To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, abhishekpandit@chromium.org, dan.carpenter@linaro.org Cc: bleung@chromium.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, akuchynski@google.com, ukaszb@chromium.org Subject: [PATCH 1/2] usb: typec: thunderbolt: Fix loops that iterate TYPEC_PLUG_SOP_P and TYPEC_PLUG_SOP_PP Message-ID: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Fixes these Smatch static checker warnings: drivers/usb/typec/altmodes/thunderbolt.c:116 tbt_altmode_work() warn: why is zero skipped 'i' drivers/usb/typec/altmodes/thunderbolt.c:147 tbt_enter_modes_ordered() warn: why is zero skipped 'i' drivers/usb/typec/altmodes/thunderbolt.c:328 tbt_altmode_remove() warn: why is zero skipped 'i' Fixes: 100e25738659 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mode") Signed-off-by: Benson Leung Reported-by: Dan Carpenter --- drivers/usb/typec/altmodes/thunderbolt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/altmodes/thunderbolt.c index 1b475b1d98e7..94e47d30e598 100644 --- a/drivers/usb/typec/altmodes/thunderbolt.c +++ b/drivers/usb/typec/altmodes/thunderbolt.c @@ -112,7 +112,7 @@ static void tbt_altmode_work(struct work_struct *work) return; disable_plugs: - for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) { + for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) { if (tbt->plug[i]) typec_altmode_put_plug(tbt->plug[i]); @@ -143,7 +143,7 @@ static int tbt_enter_modes_ordered(struct typec_altmode *alt) if (tbt->plug[TYPEC_PLUG_SOP_P]) { ret = typec_cable_altmode_enter(alt, TYPEC_PLUG_SOP_P, NULL); if (ret < 0) { - for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) { + for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) { if (tbt->plug[i]) typec_altmode_put_plug(tbt->plug[i]); @@ -324,7 +324,7 @@ static void tbt_altmode_remove(struct typec_altmode *alt) { struct tbt_altmode *tbt = typec_altmode_get_drvdata(alt); - for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) { + for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) { if (tbt->plug[i]) typec_altmode_put_plug(tbt->plug[i]); } From patchwork Fri Jan 24 19:40:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 860004 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 72ED9202C27 for ; Fri, 24 Jan 2025 19:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737747647; cv=none; b=dhj8UX7pqSeo8S2R/yj1x+zE3xKeTnA6IgBfYaC1DE1jrvf0z85q8zvaI+4suDbSN8y4ue6lXJZfK7Nh3nzmLt7d/4xi7fjHa7gCq7WTuyJfKWni9WzY0jIBuhFlnQCP+tQqVPXwRKccezc08LdKndJvcN+vEvd8TvG4XjHMuNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737747647; c=relaxed/simple; bh=QwYO9PZxCThzcCpITbcXVs1XiBBnSgAirneVfxCQzwQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=t+m0AqopEPNGgY3x64q1qbqjYS7AyBt2ww93uI9GuAjZKZiEGCbF81iZKgdCKKMVVHJTq0b+LsZnp+cbrYxCfLbPXvfZrl1mhJFRpdAauOoKGAxYETfMd/Toq1o6DIN+bsKFFWoIGFbvOOmjis3AIqg29/V/h/NmccimdqNN530= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=r8iGu4Sr; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="r8iGu4Sr" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2162c0f6a39so68008615ad.0 for ; Fri, 24 Jan 2025 11:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737747643; x=1738352443; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=RsA2Td0GmZhvsNv3upCcErafZhW9TcZYUo0FDnBPQBg=; b=r8iGu4Sr/GQUJmhf6uELTcKf7ZHAwBRsKre/QpKLe/GD0HXoS734flNQpnWs+mPWij P40DE+OfMjTAryITZUPjQpMO3DH2S55rjTQMjT/TATItjNtMuNufQJqEA1jDjQ3BGBk4 3OKC2GKbcc+Ep6GoYE8n/V4EuI5TJMAk/aG5wcCiGtSS0MOgtGDme+Sr9Ic2oC8CnsUI AygUPE/ROlUzzvzVhg5iUXO7uJjHDUi8RNUQWfGk7p+G4Aq9kOCQLjVFXBsd24ZPg8fU HrR+H0j5/01kWltSBeQ9/zVR9dGJSRXpf1JXldFyzNxAHMnXFjfnW5GhXe2mPua2sIo6 5K5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737747643; x=1738352443; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RsA2Td0GmZhvsNv3upCcErafZhW9TcZYUo0FDnBPQBg=; b=sjcyyo8BJKvB6akGrEdNPb8B9O5M+99rsW85h1nDybg9QLBl3XiuTz3IsqRXtpC2z1 QgPH90bhnsguWcEZiKfagBstak7b2VMs9Bi+F9X+VsyoXXSdLeTuucH6N6Xp1PaLtH/K NG308nGpcHbdlLCt84hvWcM7oQeIwlXyelH4luai5arHMgIv/foO+e4TgdFDXrhEGSAF nNCOtt0vrGPkev6nz1BDEuF3SapCyco0v9beiQobMq18mfBHcOOKX7UhzbHyKxM7NtrJ o9pAvt9td4fzXjlJ7Snoc7xs4AQY1MBdZIEIuGl0Pk1Sv/Bn+IsUFrXPezTF/UgmJbW+ ho8w== X-Forwarded-Encrypted: i=1; AJvYcCUCLLv/5NEfUj70r6Um/Nlv1cty1nXYk4ygCtE96SwV6ECKdjkjuFvobihRAoTVanY4S9hNErBHoNo=@vger.kernel.org X-Gm-Message-State: AOJu0YyEwg0G5OvMwm+q0RPVI1iuEIk/l1lRN9sGE1EKoTHtncLkBG7V JnJw+VYtLPQk+3QE4orNwT+FyfbCjtOwwGJtqQohf6AssKO9z6CKS5AkurEVlw== X-Gm-Gg: ASbGnctNtl5OtJsi64ehobDItlosRCkms69J9S7z4KqMu5HEQJGbOhOX92mLStii8fz ChWiUDSo4K1ZsY1Y74OT2Qc+K8e9ytt6Q1hCTYDKVCvL6+eiIemCxibh1uSpb7JNC6x/94JOFab hw0tLKm9txAwRT1RFc9caLf4fpMKIdg30wYtuEKZr0UGJKEREW/DVE2Wgt3g6hS+t8SDAkswhg0 2+QYAif2p7kVgPvyPak5BFuWnjY3o3ekssBM9fUuT/PbaDzODGgn8WuccNsyFn1YJT1ts7RnmKv f6/6GaXSJaTyM1J/hdHrtU68Ton2C9W5BtwPSSPr X-Google-Smtp-Source: AGHT+IHi8ugXNTLktZ75i6e/hZMghmmljaGGFz8gyT88jOcuSFXoV3Q30l2pcd5HlYB7doPvxH4tkQ== X-Received: by 2002:a05:6a21:6b17:b0:1e4:745c:4965 with SMTP id adf61e73a8af0-1eb696de77bmr13239928637.8.1737747643397; Fri, 24 Jan 2025 11:40:43 -0800 (PST) Received: from google.com (28.67.125.34.bc.googleusercontent.com. [34.125.67.28]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a78e351sm2298237b3a.180.2025.01.24.11.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 11:40:42 -0800 (PST) Sender: Benson Leung Date: Fri, 24 Jan 2025 19:40:38 +0000 From: Benson Leung To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, abhishekpandit@chromium.org, dan.carpenter@linaro.org Cc: bleung@chromium.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, akuchynski@google.com, ukaszb@chromium.org Subject: [PATCH 2/2] usb: typec: thunderbolt: Remove IS_ERR check for plug Message-ID: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Fixes these Smatch static checker warnings: drivers/usb/typec/altmodes/thunderbolt.c:354 tbt_ready() warn: 'plug' is not an error pointer Fixes: 100e25738659 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mode") Signed-off-by: Benson Leung Reported-by: Dan Carpenter --- drivers/usb/typec/altmodes/thunderbolt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/altmodes/thunderbolt.c index 94e47d30e598..6eadf7835f8f 100644 --- a/drivers/usb/typec/altmodes/thunderbolt.c +++ b/drivers/usb/typec/altmodes/thunderbolt.c @@ -351,10 +351,10 @@ static bool tbt_ready(struct typec_altmode *alt) */ for (int i = 0; i < TYPEC_PLUG_SOP_PP + 1; i++) { plug = typec_altmode_get_plug(tbt->alt, i); - if (IS_ERR(plug)) + if (!plug) continue; - if (!plug || plug->svid != USB_TYPEC_TBT_SID) + if (plug->svid != USB_TYPEC_TBT_SID) break; plug->desc = "Thunderbolt3";