Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1330876rdb; Wed, 24 Jan 2024 11:34:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDjlkTENdhKGSZoApOm42HtRoK5IyEzBBNwkrG6XGIcRy4mhAOzE6ONLUqZ1FNe5qdO0xg X-Received: by 2002:a17:902:ecc9:b0:1d7:163:54be with SMTP id a9-20020a170902ecc900b001d7016354bemr1406986plh.59.1706124889559; Wed, 24 Jan 2024 11:34:49 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j8-20020a170903024800b001d51f6f87e6si12348385plh.342.2024.01.24.11.34.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 11:34:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37598-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=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=cKXLWlWN; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-37598-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 2ED4A2864C9 for ; Wed, 24 Jan 2024 19:34:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FC7A132C3B; Wed, 24 Jan 2024 19:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="cKXLWlWN" Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 33E8A132C0D for ; Wed, 24 Jan 2024 19:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706124879; cv=none; b=JllWRGp0wwmMCAOBHoxJGT6DTR3V6yHEW4OTHfRUEahXruMeINE+rRa8MOfwmNP7bC2XYvdaBUl3zaxDyrlHoYIvMNeBxS9XELlFF9/hvLpjQ6j5io+4fJIQH9dncJRYMfcC7wU9joIThFkCvTGJIYDHrx824MEaCQ68fy/K6QU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706124879; c=relaxed/simple; bh=WgifWUz3Gr+kTQxM0rtP5N6Jm9nsIzie+HFNuWed/bE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aGq3qP6fi0v1QM0fPzd7PhhzExFQY73vowzsIgAnn5lEVnkQWCbeQIIlE20/OHqFp2UXSckdL6shTy/HQIcBa8IHiTdjzYHxrae4zH40qEMD9HRkaHci/TEQQT4AWjrWixjeXM7Kl5QJ8uLgDw5tj8bsZ5nbjhic9yEDQLBxukk= 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=cKXLWlWN; arc=none smtp.client-ip=209.85.219.46 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-qv1-f46.google.com with SMTP id 6a1803df08f44-68196a09e2eso34602136d6.3 for ; Wed, 24 Jan 2024 11:34:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1706124868; x=1706729668; 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=ZUvX5R1ypOP3ZoaGMkONSc/GtN51J4XYq4lgSnIUNL0=; b=cKXLWlWNYJ6CaVfwjFa5sfCsmyvcxocg7dpyhaOv2kbAcp1UjHzUKsifZQblG4usN1 hSrQ1rWOY0IDK8RhTpeaYrGSvG9uy5W/B95Twu2PkqZQuQEhN82dHuhAYjwsX5hGVvDa /kew3MzFfk2UzLFNIY2Gjl+JFn/WF451rM9hg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706124868; x=1706729668; 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=ZUvX5R1ypOP3ZoaGMkONSc/GtN51J4XYq4lgSnIUNL0=; b=c4YHnX7ncVsjgEwpcMKPl4mlZtmHW6k1VG6FzHLrZoopt8IvWVZgCG53f6QOIlOtMg hBFfGAEiNXzCqLSd/n/YdRTqSa8WyOHLfR1haxAR+swbY8BzrWxDI4j74bJbNm5z+VT0 F2/xKcab7ZELa+dZC0Ffd4UL8GPOCUWHORVGuCDKzm7iYX8J9uHnqW4ULYPwc1/OBqxN 68o2LJY94zF4BtJjbZ2ZZ609Zmmsafl7FMd9k46dhh8TQfZrgGvZWcvNXG5nb0Qk7vVK K8jZsAg2zCoXdPGpMLPCCwXmGMze9y3/09PCceiC9+YYJZNRnmdL1KfPg4U2WAJnUCZs mCqQ== X-Gm-Message-State: AOJu0YyMzWbAqNr9YfI4Bq6z0G/jCYS19Om//qRVfYK3pd8rfEAKD9Lf FA1J9W8nxruXD4JsdzEn+wZ0gD3WD2dr/Pkf1LBdxMnmuiBxWq0/0KuQk25/VOJ3ILNkYOW0Saw LVE5lJxjPraNHvJeg2/NrfNVa9OIoKctDUHhY X-Received: by 2002:a05:6214:622:b0:680:8373:4932 with SMTP id a2-20020a056214062200b0068083734932mr3380504qvx.69.1706124868109; Wed, 24 Jan 2024 11:34:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240123223039.1471557-1-abhishekpandit@google.com> <20240123143026.v1.3.Idf7d373c3cbb54058403cb951d644f1f09973d15@changeid> In-Reply-To: From: Prashant Malani Date: Wed, 24 Jan 2024 11:34:17 -0800 Message-ID: Subject: Re: [PATCH v1 3/3] usb: typec: ucsi: Get PD revision for partner To: Abhishek Pandit-Subedi Cc: Abhishek Pandit-Subedi , 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 , Saranya Gopal , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 24, 2024 at 11:18=E2=80=AFAM Abhishek Pandit-Subedi wrote: > > On Wed, Jan 24, 2024 at 10:49=E2=80=AFAM Prashant Malani wrote: > > > > Hi Abhishek, > > > > On Tue, Jan 23, 2024 at 2:30=E2=80=AFPM Abhishek Pandit-Subedi > > wrote: > > > > > > From: Abhishek Pandit-Subedi > > > > > > PD major revision for the port partner is described in > > > GET_CONNECTOR_CAPABILITY and is only valid on UCSI 2.0 and newer. Upd= ate > > > 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 > > > > > > drivers/usb/typec/ucsi/ucsi.c | 25 +++++++++++++++++++++++++ > > > drivers/usb/typec/ucsi/ucsi.h | 3 +++ > > > 2 files changed, 28 insertions(+) > > > > > > diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/u= csi.c > > > index 4edf785d203b..8e0a512853ba 100644 > > > --- a/drivers/usb/typec/ucsi/ucsi.c > > > +++ b/drivers/usb/typec/ucsi/ucsi.c > > > @@ -782,6 +782,8 @@ static int ucsi_register_partner(struct ucsi_conn= ector *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_BCD(con->cap= flags); > > > > > > partner =3D typec_register_partner(con->port, &desc); > > > if (IS_ERR(partner)) { > > > @@ -856,6 +858,28 @@ static void ucsi_partner_change(struct ucsi_conn= ector *con) > > > con->num, u_role); > > > } > > > > > > +static int ucsi_check_connector_capability(struct ucsi_connector *co= n) > > > +{ > > > + u64 command; > > > + int ret; > > > + > > > + if (!con->partner && !IS_MIN_VERSION_2_0(con->ucsi)) > > > > (Mentioned side-band but reproducing here for consistency) > > This macro is unnecessary. It's just doing a comparison, which can be i= nlined > > without any perceptible change in readability (actually, I'd argue addi= ng the ! > > to an english idiom makes things *less* readable): > > I prefer the macro because it makes it easier to search where version > checks are being done. I don't see how searching for "IS_MIN_VERSION_2_0" is easier than just searching for "UCSI_VERSION_2_0". I didn't quite understand what you meant by > it keeps the `<` vs `<=3D` consistent. Perhaps I'm missing something... (are these comparisons being used elsewhere/in some other fashion?). In any case, I don't want to bike-shed so I'll defer to the maintainer's call on this. BR, -Prashant