Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2684421rdb; Mon, 5 Feb 2024 14:30:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IENl4CihhttrbvtbggPhZuLjrFylXDurvCLPDKvWWv1fZfSEdrQTknUix1ErQnyCVK2tRtc X-Received: by 2002:a92:c7d1:0:b0:363:cc27:714 with SMTP id g17-20020a92c7d1000000b00363cc270714mr1132528ilk.28.1707172200964; Mon, 05 Feb 2024 14:30:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707172200; cv=pass; d=google.com; s=arc-20160816; b=BnQp/jxXb9D/FHsmuGJsHZfLE9YEKBiOKlsVk3N21okxsyx2aEJg38ZqLmvZUe9789 CykSicaR1RLEs5R4D4qqJVIKHWek3hhlsUFT69KZ58WifsCz415UnPkmBaKnmhS5Si40 EGZ3VW2Z1VpTMWeHq53VYRXxm6BlIa8gov6M40rNFFA2OnjXmJ8LMjWh4XaUza9dcJVS WEzCt9udfDZhK+hFKX/UGYCnOMB32fw/szJLA52J0JWmGLQ194vj1kl3voXWGH7DpcEK ews34VJAddC9NF6u7odPfwr8PY6l+EqNP37VIFNlhndE8l0cvyFq8vqx4j+sWlOeAdnP JT3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=+uyM7Qy9ebYgtc0T1FfcjgiWLInu4H67aNLCBp8izTI=; fh=fb/O+RMNjF1dnlNrWDB+7zQUPEO5ze1mSZnxZH8KV3E=; b=gFs6SA7y7LASFBAbUApkQhJ1hkmX39UZ1YlGPNiBg4l60gtGiiDyFHEgtyPEIdf7mq CgqsRv2gAePhHVUX8J6ZpD7WJdanTJhzjizzgLKrRxWVMU2OhhkXtFxmFTy3ywa+UeOZ wb9JEhCAMci1J9uN5l8ZdEOpLE2vdTjxwG3DTyo1ecAivW9avR69i+UF0rG/d5hSMtFN M+mqxMcUzSkA1wXQRP5VxCRwEdzuNA02o8gpeBYNtSBrIoedDtUnVZOYhoL3ilo76eCE jdEygTlG6jnRum9NQYmNBOJYJMXa9ySzpKkJpfeCa9FMHF8lNUepbZguQPov/xDvONBn 4WGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Qf8DHVmu; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-53999-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=1; AJvYcCVAF/fytIiU1gkUlIHzZ8BcNn6EAb57BRMXf38lQgCUtGlolKIPw/tryw6Te+rxpYH+bSx93aKf00vQ721CJx9tVQyQTpBZY3yLEZbHEw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c35-20020a634e23000000b005cf88b065b1si553842pgb.121.2024.02.05.14.30.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 14:30:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53999-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=@chromium.org header.s=google header.b=Qf8DHVmu; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-53999-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 340DC285370 for ; Mon, 5 Feb 2024 22:17:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D09C48793; Mon, 5 Feb 2024 22:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Qf8DHVmu" Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.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 DD42A2C1B9 for ; Mon, 5 Feb 2024 22:05:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707170752; cv=none; b=f0oFcFZPTp0qtQSPrIkHdCQfYpy9vmKMWGWu2DHkRrtS4k6yyrvjEp2/v1EzjHRAUAoApZg1NI51P8CMGeAuhreN4u8sORzETKtPeYSyEknb/G6hFOTOsTwohgn3GGbfAf8PRq83BbcecBXO5/IsXBIb6JiWApR727rWLnMkySU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707170752; c=relaxed/simple; bh=/yC6ukCR6M9OWDOAQofhpPWkpb0+7yFSlv5kx0Xd2yY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=EdtJO+7V29ZEXZqxkduGpuE90jgudJovXq+HH1OWTbeKszMOEH9Sg4GbEU1I4sSm68VCivYJ0ndNRhyV3NctM53fdGlYJw2VS4fUXCctuV+KlDkQP5vWbbpcYix/dZO2zFHrbrAwfY8ODiP27Itkcw0W4ZdoiYMul01xwjL/Yus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Qf8DHVmu; arc=none smtp.client-ip=209.85.219.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-dc6db13f1abso4215800276.2 for ; Mon, 05 Feb 2024 14:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707170750; x=1707775550; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+uyM7Qy9ebYgtc0T1FfcjgiWLInu4H67aNLCBp8izTI=; b=Qf8DHVmufNeX4fR9YPGoVxlpcuXXutYOFLjXGtJze/yMGBmlAhiNw1fPPtwioEp1Ib msJPhNHGIzoVfcXNtI43JyTVOfkLRTXZsby/qN1C5Rh84evuFOpa/OzBKe4brYB90wxZ CJX8DSbRxVc1iWzjyw+0GrZN+OEBtq1nWRBoI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707170750; x=1707775550; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+uyM7Qy9ebYgtc0T1FfcjgiWLInu4H67aNLCBp8izTI=; b=cnkrhu2IuxBJz+dmJwuD7qgEewFAqmweMpfiOWxGLuT0DgqNGV8zqvNJioeCbTRH8W hs/2FFBrTOp2fysSBeNuCdT5DTH+csOniQ2o74BSZEib3deHEgvhch8Y8enldut81IEi dW3OiwdeimNF44BwV8Xb8je5ZYgZz5dzFsBwQugEJv8/V0rmtpnIPspyCVUJ69aGNbO2 Qn2nnKHsdABHua2han39qsUKXrA9W6HLsfx7/e9Ca0K+5fV0wlGWYANlloPxG3mmt3D6 F7yQ/Y28KMO0Ys4b9lQJauDUq6WeuA1BhNkMa/au+apzj7tU15NbsiC33GI0/M+v+aCr fo8Q== X-Gm-Message-State: AOJu0YywRrBIl0V0KY975NGDPD7V6gJGsj6ckrfFo23K2DQ0bHyYMIJM 5hH14AZFi/06N1MnX6vwYDJxjTH0AuVqB918Ap2gbNkdmSwUpPcnabJq5cO49JOkyfx4oc7+8aD GeJ698KoctwQAqGLJzdw8gm7Nw1wpo5QhEvXI X-Received: by 2002:a25:ace1:0:b0:dc2:28b1:2e8b with SMTP id x33-20020a25ace1000000b00dc228b12e8bmr713829ybd.15.1707170749681; Mon, 05 Feb 2024 14:05:49 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240126183930.1170845-1-abhishekpandit@chromium.org> <20240126103859.v3.3.Idf7d373c3cbb54058403cb951d644f1f09973d15@changeid> In-Reply-To: From: Abhishek Pandit-Subedi Date: Mon, 5 Feb 2024 14:05:38 -0800 Message-ID: Subject: Re: [PATCH v3 3/3] usb: typec: ucsi: Get PD revision for partner To: Prashant Malani Cc: Heikki Krogerus , linux-usb@vger.kernel.org, jthies@google.com, Andy Shevchenko , Bjorn Andersson , Dmitry Baryshkov , Fabrice Gasnier , Greg Kroah-Hartman , Hans de Goede , Neil Armstrong , Rajaram Regupathy , Saranya Gopal , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Heikki, Friendly ping to review this patch (I see you added Reviewed-by to the other two in this series). Thanks, Abhishek On Fri, Jan 26, 2024 at 12:25=E2=80=AFPM Prashant Malani wrote: > > Hi Abhishek, > > On Fri, Jan 26, 2024 at 10:39=E2=80=AFAM Abhishek Pandit-Subedi > wrote: > > > > PD major revision for the port partner is described in > > GET_CONNECTOR_CAPABILITY and is only valid on UCSI 2.0 and newer. Updat= e > > the pd_revision on the partner if the UCSI version is 2.0 or newer. > > > > Signed-off-by: Abhishek Pandit-Subedi > > --- > > $ cat /sys/class/typec/port2-partner/usb_power_delivery_revision > > 3.0 > > > > (no changes since v2) > > > > Changes in v2: > > - Formatting changes and update macro to use brackets. > > - Fix incorrect guard condition when checking connector capability. > > > > drivers/usb/typec/ucsi/ucsi.c | 23 +++++++++++++++++++++++ > > drivers/usb/typec/ucsi/ucsi.h | 3 +++ > > 2 files changed, 26 insertions(+) > > > > diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucs= i.c > > index a35056ee3e96..2b7983d2fdae 100644 > > --- a/drivers/usb/typec/ucsi/ucsi.c > > +++ b/drivers/usb/typec/ucsi/ucsi.c > > @@ -782,6 +782,7 @@ static int ucsi_register_partner(struct ucsi_connec= tor *con) > > } > > > > desc.usb_pd =3D pwr_opmode =3D=3D UCSI_CONSTAT_PWR_OPMODE_PD; > > + desc.pd_revision =3D UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_B= CD(con->cap.flags); > > > > partner =3D typec_register_partner(con->port, &desc); > > if (IS_ERR(partner)) { > > @@ -856,6 +857,27 @@ static void ucsi_partner_change(struct ucsi_connec= tor *con) > > con->num, u_role); > > } > > > > +static int ucsi_check_connector_capability(struct ucsi_connector *con) > > +{ > > + u64 command; > > + int ret; > > + > > + if (!con->partner || !IS_MIN_VERSION_2_0(con->ucsi)) > > I'll reiterate my comment from a previous version, since this series > has been revv-ed a few > times since and it may have gotten lost; no need to respond to it if > you don't want to, > since I believe we left it to the maintainer(s) to decide [1]: > > This macro is unnecessary. Since the version is in BCD format and we > already have the > macros for versions, just a simple comparison is enough: > if (!con-partner || con->ucsi->version < UCSI_VERSION_2_0) > return 0; > > I'll add that Patch 1 of this series [2] is also using the same style > for comparing version numbers. > > > + return 0; > > + > > + command =3D UCSI_GET_CONNECTOR_CAPABILITY | UCSI_CONNECTOR_NUMB= ER(con->num); > > + ret =3D ucsi_send_command(con->ucsi, command, &con->cap, sizeof= (con->cap)); > > + if (ret < 0) { > > + dev_err(con->ucsi->dev, "GET_CONNECTOR_CAPABILITY faile= d (%d)\n", ret); > > nit: I know this is being done elsewhere in this file, but we should > avoid putting error > numbers in parentheses [3]. Perhaps something for a separate cleanup patc= h. > > [1] https://lore.kernel.org/linux-usb/CANFp7mXP=3DaN8bQi4akKKcoMZE8RaCBuF= nwTa5hbp0MZvZe0hYQ@mail.gmail.com/ > [2] https://lore.kernel.org/linux-usb/20240126103859.v3.1.Iacf5570a66b82b= 73ef03daa6557e2fc0db10266a@changeid/ > [3] https://www.kernel.org/doc/html/latest/process/coding-style.html#prin= ting-kernel-messages