Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp904372lqt; Fri, 19 Apr 2024 14:18:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEdgWZbFTwuGu6Lr+9RVNgg3PzW/m4J89a3x9rm1jR1sGKWaTlhnfc0smUrOzkW/mA3VpXofTDjkv5YFkg+Ynqww6jJq1L20H5+IRHmQ== X-Google-Smtp-Source: AGHT+IFC8J2XZlLjTyQhuVksEf+tQ09axgv+BqX/J2qaTbFiOXgtWnJje38A7WGKvhYwEvbSsCAR X-Received: by 2002:a17:902:f689:b0:1e3:d242:418a with SMTP id l9-20020a170902f68900b001e3d242418amr4906287plg.9.1713561508113; Fri, 19 Apr 2024 14:18:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713561508; cv=pass; d=google.com; s=arc-20160816; b=BDY4ZGg4vR5iZ028ddEmx5lxdoxxA670VNcUWg2aR2JZ4/VodB1uEV6BSxWPHtfjyB I0+g5LwxBHzZV6UBo8ojp0dry855+HLQGz0xumym/Qut8zTD3tWGoH+/IEsqDB1Ii2EQ UJ+cjEUXRxMgfGuymAAnsAnEp3NQ4CPNX21GKCTuaaKit9lSYj5XfAnFWW/HA41U3XQV 8Afzlgwor24jJ3KI5PBbTJ5S8u/btqHUQxDAzmgU6d/+OR78/ndhZU/fJtdn7LLCgaK+ ydUolw46J0/7uSHVHN5N07czIVanciNPXELdfueqrtU2Ae6g72EDz0JiwFwhYsvkMIIk DbuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=S0xPvMdWQfhMydIZIXU8mYIUBlrWjYZf7B5Lw0rva50=; fh=V96HBBzqs85TIpms4BzNU1XrHmRHuqKIH2S9nxHX8Ow=; b=FF2csZfqbMg1D6AblpjJUDi9Oo1/fgOgA6uPhxV7sRkGZLKGN8LvFVT324MHcn6Cuk QjNSkYt2KsNF7itX0Z3wjiOk7M4rvKhBZic61th2IAc6cwYbtXISSxN9+eo4L4B7gCZO 3UfphJNU3x1PmZLj5OY4/j5WRAQwqczjKMtrDbJq9T0UYYMIiOquuFJFY7wJJLqZC9jC Tpvh+9OYDtb9244uyq9rPv+zVg+wlTB9gyKG7vPZqp2lzueS3ipfQR5TRciIXi8fX+4v rCvdYo6WXyE4rqV/XsF2C5fJOsdJxtbs42dFTxMpakJ82z0nto4BfyCYD6LfO2G0JDwl A02Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DUNdSrUp; arc=pass (i=1 spf=pass spfdomain=flex--jthies.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-151970-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151970-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u17-20020a170903125100b001e7d3d37eeasi3800861plh.507.2024.04.19.14.18.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 14:18:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151970-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DUNdSrUp; arc=pass (i=1 spf=pass spfdomain=flex--jthies.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-151970-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151970-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7A332281306 for ; Fri, 19 Apr 2024 21:18:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DC7513D29F; Fri, 19 Apr 2024 21:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DUNdSrUp" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 26FA313C91F for ; Fri, 19 Apr 2024 21:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713561461; cv=none; b=pzEcfKI7DpFTlVc/AF9yB8Dp6j/XZKsSoubk9agjqbPZSdHT0E0spx8ayF1gJ9dD6PoBAHFQlKtKt3QM6wIz9s5Z335ZTk/tAiEcPho/YbgspFrwPTXwJedXQI7DuI+sDP14daZLz/pOGdMyeVeqXJOTZT5Dd4bdRr8uUP+i3Gk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713561461; c=relaxed/simple; bh=fKUL0oJVWhyKPyuWrBggFRR7WK6liB65Z5EkXKyHftw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=o77xe1RKTXjFQ4CTS/uLgKMwAi+TRqACgHH0TPhxQESr5Wl2phJVJQC5WnumFrv+rQaVowYv25giBlC1oJ6qxMyXENTTW8YZ9y3nYeIVMNgfSkqQCXmCHITf8RqYbmYciMwWMUuOjKv7LJ+X2X9lu1b9mcgsMEwlECMWLrHNw70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DUNdSrUp; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-ddaf2f115f2so4113966276.3 for ; Fri, 19 Apr 2024 14:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713561459; x=1714166259; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=S0xPvMdWQfhMydIZIXU8mYIUBlrWjYZf7B5Lw0rva50=; b=DUNdSrUpu+CxyiD3iIHfZ7mgXpFDpyJGvXy0bSwXyYLAnXZ79FWKVji+Tzdf+J/zLl a61PjEqt1HLuNQKr0Eo/0kFlcHEL73I+JcF7f6LxA1fPZbD1T5H5K0BTOzTSwHf/KcNw I9XmgMSAgxkinyiAJzRyFZtpBAL95xVciWvEBe7VBU20HBWkLkKikDjhXqFyG7gyc5bb 0ggZX0Y4fPsJZWHHYzqOajT58iccyTZl0UEts5kT0BRjNX29dIo6zLKq3djBrzpD2AKs 8b7vEvbm5qYpW28p43l6q8xzXYPIBJPCnO82gHxohLJoe0sZjdlldv8a0c8hFPrGokEY 54zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713561459; x=1714166259; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S0xPvMdWQfhMydIZIXU8mYIUBlrWjYZf7B5Lw0rva50=; b=sW58ho+QMY9dfrOMdJkstZS3PrKftaj39KXrkn5wINFMlUgzp28erGezZSdU4a3j7y 3cZeo/fjFlqM0irgSifm7C4j7LLYR/7jHQN8EkWRq1ayz3UZy98xMGRLV3jubcXqjEsf +lT1ZL1Nn+4wpgj5xcUK6lkgRwlB4U6WCkM0iG4LCs9MvrkG7IqeM3FtZ14wIgmd571o CkU+0svJTUqPlwAT5a28/aAzyg3Xg+jiXugjVdGGF1AmZ2rNMhs1AYhrgoefD2fk0HIz RSiQBmVkhXzK4JYr48aC0j3GmN/ehY8WSH3tU1g42lEEBScU18imc7rpMAhGyPdrcPe6 17OA== X-Forwarded-Encrypted: i=1; AJvYcCXffwwKDnlv6fcs11DEvCgl3jejwwqoo1Xa0I7uwayDeyQCmpj3P4wo5iRfETLg+BC5GlvaT18GWMC7+RgDI98ew0kOicccnc9FmS6S X-Gm-Message-State: AOJu0Yx0saD+ktfen/SZ+HOxeASAeDT1KDaHEIYwYAwZhurs8wzfmoeN Oxx0SRlz0G1jzN7GYHVVu2NZ5xNkj8CbG2HOw+fp/oDr8dLDPImXNZS+G9D+KXOgAMtwZLI0vWm WNA== X-Received: from jthies.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:23db]) (user=jthies job=sendgmr) by 2002:a05:6902:120b:b0:de4:c681:ca96 with SMTP id s11-20020a056902120b00b00de4c681ca96mr249811ybu.2.1713561459255; Fri, 19 Apr 2024 14:17:39 -0700 (PDT) Date: Fri, 19 Apr 2024 21:16:50 +0000 In-Reply-To: <20240419211650.2657096-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240419211650.2657096-1-jthies@google.com> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240419211650.2657096-5-jthies@google.com> Subject: [PATCH v1 4/4] usb: typec: ucsi: Always set number of alternate modes From: Jameson Thies To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org Cc: jthies@google.com, pmalani@chromium.org, bleung@google.com, abhishekpandit@chromium.org, andersson@kernel.org, dmitry.baryshkov@linaro.org, fabrice.gasnier@foss.st.com, gregkh@linuxfoundation.org, hdegoede@redhat.com, neil.armstrong@linaro.org, rajaram.regupathy@intel.com, saranya.gopal@intel.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Providing the number of known alternate modes allows user space to determine when device registration has completed. Always register a number of known alternate modes for the partner and cable plug, even when the number of supported alternate modes is 0. Signed-off-by: Jameson Thies --- drivers/usb/typec/ucsi/ucsi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index cd4c3b7a5d989..ea76d42fd1504 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -812,10 +812,11 @@ static int ucsi_check_altmodes(struct ucsi_connector *con) /* Ignoring the errors in this case. */ if (con->partner_altmode[0]) { num_partner_am = ucsi_get_num_altmode(con->partner_altmode); - if (num_partner_am > 0) - typec_partner_set_num_altmodes(con->partner, num_partner_am); + typec_partner_set_num_altmodes(con->partner, num_partner_am); ucsi_altmode_update_active(con); return 0; + } else { + typec_partner_set_num_altmodes(con->partner, 0); } return ret; @@ -1138,7 +1139,7 @@ static int ucsi_check_connection(struct ucsi_connector *con) static int ucsi_check_cable(struct ucsi_connector *con) { u64 command; - int ret; + int ret, num_plug_am; if (con->cable) return 0; @@ -1172,6 +1173,13 @@ static int ucsi_check_cable(struct ucsi_connector *con) return ret; } + if (con->plug_altmode[0]) { + num_plug_am = ucsi_get_num_altmode(con->plug_altmode); + typec_plug_set_num_altmodes(con->plug, num_plug_am); + } else { + typec_plug_set_num_altmodes(con->plug, 0); + } + return 0; } -- 2.44.0.769.g3c40516874-goog