From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 53A703B9D83 for ; Mon, 13 Jul 2026 08:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783932218; cv=none; b=qCze0oe2NZa+8CGdEppXlARlI3viZ0TMddAkKbFfDuh3GZTjc5J9jR3TAPKjdP2ZEflc/at0TowrgbL2xnTuwwQBwpbRsyzM28wzHe5D4zwFS56K8+YSva6fa8mZ+2EkGk5T+RsEsMuxSubBK8pSXAZGyiJ9uf/9OhWI8Dp4Cws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783932218; c=relaxed/simple; bh=ICOZsyEGwZCTA9L3q7C65uuVPVLW9hoxigfXr5Zj32A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mPEFgHIbhs9L6OHPLGUB10neJqoARNwIRPBMbu07sIeiPogw3x7OdRxZ5VC3MVKPYvvht7IC5IevhHErdD61as92pAKG/0mFE43OuO8Ba2ahEm1z61/hApvmnaclZ7RbKEJ+YtAqT13y1e9cvIW1LdyteNyrAzXIkSpU2ovcq/k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aZRykKSo; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aZRykKSo" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-8484f229529so1379754b3a.2 for ; Mon, 13 Jul 2026 01:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783932217; x=1784537017; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HLvdDGRQf151GznkrG1JNojgtuMjVxHxehUwm2F90DY=; b=aZRykKSoFhQOpKvNt5pp/2h58mNKvHyixkZRfnIGamVpmW0t0WCio6S/ULyJZ6N0V0 q5eQGPNyQw7XHde4wKVVkuunzH3B2E/PqLRpcZH95Q4OPax997QntVykw4AARELXoWCo 2Tj5UeupR/5ErCuFISq/4V+xgy1Ffov1LAEWPNfxl9CBBG4iFfnsD713+XxRSGYCtqrJ 1TPwoYRs+ygENkV/aBAMMFPO7+UFXNqlZbTEEfbMxSma5CLJ07m9i/95F7QbhhybC8EW SzezeLgonbMHwdCQ85DS+H1zz3N/1UXcw8++kwQzLMnSToCteMaQR+mZXgefBItWVrzM xtWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783932217; x=1784537017; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HLvdDGRQf151GznkrG1JNojgtuMjVxHxehUwm2F90DY=; b=pF6daduB0YCorW5M0DWILvUj0h6uEqIV/ff3Wzvw4BPoCMaPQ/NiCkMU/YofpA97NX /KYIcaF69QDuXLWmYc87J0tO9IQicguPfIRefnr/lFXzQWcZqW1VxmDg9ndPZX5qr8xG NXo9N518qhmgZHJML/g/V3y7jz32HUuMm5F2FelsP0HyoluhNm2Wxtmp7Z+XX898ZoGR Rps+sZTR6qu4DWSZpepCP0GZdhDbdIkI7nTNvlSMCbvvTMhqQ/0OgJcuXwY3nyqtdsaF hEpAA/kOA00zrH2soctSmRwu9jtHS0ylrhZD1LoteHtu03+spu424qhij0s7jH0lQL/V x2pA== X-Forwarded-Encrypted: i=1; AHgh+Rr9wcmLqpsw+rcUyoWXNgmy9CJem70AdsyVM+WaMUKAXEktkPNRtDJLUB5pSTPca/C9Dsn1JZYeeJQhkQI=@vger.kernel.org X-Gm-Message-State: AOJu0YwOA00bHVTXPwoFPqClqVLpCBuiULAm2oKKRlRAcjZuVnAukPJr 7ZPWM/vctnsGdRdVKSy1xr5CU9u9PpBcipCMvEr7uRQRPP/VCQKQIiRX X-Gm-Gg: AfdE7cmWhfmKGo4fx7aJm7tJfrBw8tazNxGbqytQmMD8WTSrEImjdmh2d0dTcNzlsGa MIlz8AsEfFEZHmqby0Bl0juBt+AC24j5p37pBK9rf25BhBG4rA0b5AXD14QEkqooF9qssqASSwv 6whqA5g/ZA/h031UMI0inSJuz5mO3E1C9kPHJbbNeNBn1mUukBLnZpy6cqdwegESwKLDFdYJCqg E6vi1xXMYxaaD8jZYrb0RspuigLc2KfYwPLnlzTsUeOPI1+nSVmnbrYLNg16SBAmdo+t2hi5gNu 6fhoOyuQUseutMm4oUqyCBi3eS2vVTm50wh2Q1tRE3eOP96LsdKFwJT+CUzfSb8VT01eTB4Fsr0 7UbUw7G6BXbRpUH6+kwCFj1G3iJ2M1k9BxPTXkKDe5sFKKb/YBQWc2f0kWIyQic+C3MscKPHHek MghettZdSutJ+5y/nu+y4nY6W3DC/Brwdt6JkbH8koLEFkMqVG9Wep X-Received: by 2002:a05:6a00:23c9:b0:848:8829:8585 with SMTP id d2e1a72fcca58-848896c548emr7302716b3a.8.1783932216650; Mon, 13 Jul 2026 01:43:36 -0700 (PDT) Received: from localhost (211-75-139-220.hinet-ip.hinet.net. [211.75.139.220]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84909673e32sm2837537b3a.56.2026.07.13.01.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 01:43:36 -0700 (PDT) Sender: AceLan Kao From: "Chia-Lin Kao (AceLan)" To: Heikki Krogerus , Greg Kroah-Hartman , Andrei Kuchynski , Johan Hovold , Jameson Thies , Pooja Katiyar , Hsin-Te Yuan , Dmitry Baryshkov Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 3/3] usb: typec: ucsi: yoga_c630: Remove redundant duplicate altmode handling Date: Mon, 13 Jul 2026 16:43:23 +0800 Message-ID: <20260713084323.287516-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260713084323.287516-1-acelan.kao@canonical.com> References: <20260713084323.287516-1-acelan.kao@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This reverts commit e0c48e42d818 ("usb: typec: ucsi: yoga-c630: remove duplicate AltModes"). The yoga_c630 driver previously implemented its own duplicate altmode detection in yoga_c630_ucsi_update_altmodes() to work around buggy EC firmware that returns duplicate AltModes instead of empty ones. With the introduction of the common ucsi_altmode_is_duplicate() helper in both the standard and nvidia registration paths, duplicate detection is now handled automatically in the core UCSI code. This makes the yoga_c630-specific implementation added in commit e0c48e42d818 ("usb: typec: ucsi: yoga-c630: remove duplicate AltModes") redundant. Remove yoga_c630_ucsi_update_altmodes() and its callback to eliminate code duplication and simplify the driver. Note that this causes the driver to switch back from the nvidia registration path to the standard path, which is the original behavior before commit e0c48e42d818 ("usb: typec: ucsi: yoga-c630: remove duplicate AltModes"). Both paths now include duplicate detection, ensuring the firmware bug is still properly handled. Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c index 1be18d101842..bb7b09bc7c1c 100644 --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c @@ -139,28 +139,6 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi, return ret; } -static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi, - u8 recipient, - struct ucsi_altmode *orig, - struct ucsi_altmode *updated) -{ - int i; - - if (orig[0].svid == 0 || recipient != UCSI_RECIPIENT_SOP) - return false; - - /* EC is nice and repeats altmodes again and again. Ignore copies. */ - for (i = 1; i < UCSI_MAX_ALTMODES; i++) { - if (orig[i].svid == orig[0].svid) { - dev_dbg(ucsi->dev, "Found duplicate altmodes, starting from %d\n", i); - memset(&orig[i], 0, (UCSI_MAX_ALTMODES - i) * sizeof(*orig)); - break; - } - } - - return false; -} - static void yoga_c630_ucsi_update_connector(struct ucsi_connector *con) { if (con->num == 1) @@ -174,7 +152,6 @@ static const struct ucsi_operations yoga_c630_ucsi_ops = { .read_message_in = yoga_c630_ucsi_read_message_in, .sync_control = yoga_c630_ucsi_sync_control, .async_control = yoga_c630_ucsi_async_control, - .update_altmodes = yoga_c630_ucsi_update_altmodes, .update_connector = yoga_c630_ucsi_update_connector, }; -- 2.53.0