Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2940009rdb; Tue, 6 Feb 2024 02:19:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFd8pKDS/s5JrZIjIDysOXTQhQwBc+af83dGiDUcevLa3yEZOzxKTDbUUiXSnwDU+07TRrJ X-Received: by 2002:a2e:a9a7:0:b0:2d0:85eb:935f with SMTP id x39-20020a2ea9a7000000b002d085eb935fmr1694824ljq.49.1707214745551; Tue, 06 Feb 2024 02:19:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707214745; cv=pass; d=google.com; s=arc-20160816; b=iRrzTM3zPgqcAlz/VGILyiUWYnrngpSRtHtd1uzk1FlDih61JlvQsXb8nJunSbtdM+ oGEnyN6rbdB58gjeS9G1SDOgGETresgEOihw/0NdJwNO6Ss8QhI9fxF26NRYhyZG+j5B 1jenLVWZtsVf9H4tzs0Vr1svL/9HUb8z3p6ZOnIu5uU1bbj/FT3H6DPXujcrAx8+SHOJ E2zZDKkw1eEHgtBQ9YXy68fZfXamh6S2TOxekajuOAUig+RJdiAuCpzn45gY+BEKLjZd 831i4/1Lx0XSENucprgcuH1qq6ZhZP7TVMYKDeizBa11j85UcBrm8J9m3SEH3L9RGeQF gIyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rSNtE0THvP8mTHJhp4v+DvtdrFm/bxMu06mIcG5e8OA=; fh=vbmtwT5kW5pnAX+ZLqpHzRv5Q2B2x+T4jH3t/Gm6ZKk=; b=TKk0KkOswqEBZOqprQ/y8naeM09tiHvTGVJtRxTYVyxW9PMDyetiQ3GSDKCT+AMt2q FG4+XjVIA1qyOdgnTXo9/uuIxLNK2BO5dY5hpfFIkMqulWHQ82A9ag9DE+U/MrcDc1NY 8UM6HDIkJgz8K1QROtSrfKnMovlXBb2fItKYTbLUEA4aGVeIh2jh7XsIiNMsL0lCnDaT Ky6bZf3eof2xTzflct9xrvipkec3RrWXOq94Mt1GBmj7yblCIL9EhErYGATSXvszH5rh 5D3uL+PgOZ6k3sbKx6Gh99LWd/3OsvsImJb5GUHo34s4l5NwkdnQJqm1rrjjpV5KFlyw /oVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z88lnJLw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-54679-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54679-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCU2wHB+aUMdUmW0JDPMI4ZyqbM9niEjsmaP6T0cRIzLfU825Ydj1+O8kbO5p7lsdV9fYSAXAolL3jexBkCD4o9yuFfjH4J8LcKJTF5VEw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d20-20020a50f694000000b0056023592583si990341edn.396.2024.02.06.02.19.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 02:19:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54679-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z88lnJLw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-54679-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54679-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 209BA1F257AF for ; Tue, 6 Feb 2024 10:19:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE6E812E1E3; Tue, 6 Feb 2024 10:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Z88lnJLw" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7393212B14E; Tue, 6 Feb 2024 10:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707214721; cv=none; b=NWGQa/WhSFbT+Glkj+qPK3oBXp8n+S+uSpJWXaoCPX9lIpoCq3uZ9ZXg0fh7mu6y2hsoeUt0jPwXt1A9ep7pzrCFeMrPZAhYMm+oUnmghP8xh+aaP8vFJ7al+rM5ljeGkkrAbE7kjiVbpLjjsAkYMuqmLantfJRrLXvkEnIPdso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707214721; c=relaxed/simple; bh=8oScLxzw3aBc2CthwbejXgtiSm9NvZ9+lZg+kx+hQzs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NQ7RoumjzQUvg9186GhOj5rbGnESmNGKOWuxLt5iBxr7lnddIa55hm0oW6Hvq19dg5OStpwtX2+NoFESVF4iLdff8x5E3VvnHvd5SQICSxTRTSMUcGjWwQzO4wo58t8XYJmNCgh1cV4g5fDEWbPXGqyG5JcPyNeE2yk5EP4DfVM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Z88lnJLw; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707214719; x=1738750719; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=8oScLxzw3aBc2CthwbejXgtiSm9NvZ9+lZg+kx+hQzs=; b=Z88lnJLwojXrUze5ZzJniBDdGZU4KuQt/saa4AMEb5eZUHIIGHbX+huA Ov/LSyiDGfWvjzPuljVSDIjN2uz7VZXttvd9N5a5wUnzap5u/sZEY1J2T 3lqcPHZ9GSICokJbl6tDKxGfhUxJZ7WBeESbHWB/0cQRUzO2jqcbQuXlQ vIWmeoz30PwdTJhSMUaX+FE7AJodVzjR7rGVdmXMT8bXY2j8a8IFc6048 QD74h1x45dsM0jJlGDRbiNzOZRtAVWsxlsFmiPk1+dtg5dbGGlVjrjLdU 9DyGJjs+cX1h2+FCr+xMUg42rOxIPQwfXVeUw79GD8bZJYrFhoHreOuer A==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="598377" X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="598377" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 02:18:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="933419597" X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="933419597" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 06 Feb 2024 02:18:33 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 06 Feb 2024 12:18:32 +0200 Date: Tue, 6 Feb 2024 12:18:32 +0200 From: Heikki Krogerus To: Abhishek Pandit-Subedi Cc: Prashant Malani , 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 Subject: Re: [PATCH v3 3/3] usb: typec: ucsi: Get PD revision for partner Message-ID: References: <20240126183930.1170845-1-abhishekpandit@chromium.org> <20240126103859.v3.3.Idf7d373c3cbb54058403cb951d644f1f09973d15@changeid> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Abhishek, On Mon, Feb 05, 2024 at 02:05:38PM -0800, Abhishek Pandit-Subedi wrote: > Hi Heikki, > > Friendly ping to review this patch (I see you added Reviewed-by to the > other two in this series). I think Prashant said that he prefers macros with those version checks, and I kinda agree. But I'll leave this to you to decide. I think that's also something that can be improved later. > On Fri, Jan 26, 2024 at 12:25 PM Prashant Malani wrote: > > > > Hi Abhishek, > > > > On Fri, Jan 26, 2024 at 10:39 AM 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. Update > > > the pd_revision on the partner if the UCSI version is 2.0 or newer. > > > > > > Signed-off-by: Abhishek Pandit-Subedi So this okay by me: Reviewed-by: Heikki Krogerus > > > --- > > > $ 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/ucsi.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_connector *con) > > > } > > > > > > desc.usb_pd = pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD; > > > + desc.pd_revision = UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags); > > > > > > partner = typec_register_partner(con->port, &desc); > > > if (IS_ERR(partner)) { > > > @@ -856,6 +857,27 @@ static void ucsi_partner_change(struct ucsi_connector *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 = UCSI_GET_CONNECTOR_CAPABILITY | UCSI_CONNECTOR_NUMBER(con->num); > > > + ret = ucsi_send_command(con->ucsi, command, &con->cap, sizeof(con->cap)); > > > + if (ret < 0) { > > > + dev_err(con->ucsi->dev, "GET_CONNECTOR_CAPABILITY failed (%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 patch. > > > > [1] https://lore.kernel.org/linux-usb/CANFp7mXP=aN8bQi4akKKcoMZE8RaCBuFnwTa5hbp0MZvZe0hYQ@mail.gmail.com/ > > [2] https://lore.kernel.org/linux-usb/20240126103859.v3.1.Iacf5570a66b82b73ef03daa6557e2fc0db10266a@changeid/ > > [3] https://www.kernel.org/doc/html/latest/process/coding-style.html#printing-kernel-messages thanks, -- heikki