Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp610608lqs; Tue, 5 Mar 2024 10:54:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4e1YtNXpUFwcFi4f4gAoCzpWNMNjr9O1e76cGrbc9ZwR1s6PgPkMMaTu6Oh/TfmeAbl/3m8yiCqxIthBMnNVzfW9zbceb4sGYNCUFBA== X-Google-Smtp-Source: AGHT+IHdtkBPySSXxPyVAMIkXR0BbL9VA9fTTsKE1Q/Qko1iS58s2G8zXuMCK096DThcOc7Kcd6p X-Received: by 2002:a05:6a00:1808:b0:6e5:6e40:a0ac with SMTP id y8-20020a056a00180800b006e56e40a0acmr14293916pfa.6.1709664895341; Tue, 05 Mar 2024 10:54:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709664895; cv=pass; d=google.com; s=arc-20160816; b=J304ce16nsM7JtuU84M0h3hzEaF6ClQljuGxbIePwUGOUqsAGEwQHvw+qZD6+CRiAf f6HtiKuwtwN8aH1CtaoX6bO/+ANWpkWHgTYHky6HIfnJ8/eWREeWGmnZsy/ToncC2IR8 BTPHfEaLhSI14pGdh8J4hw3931afx45VO6IIwyZ0F3AftO1ZPYGsvAPeJ6syjmP7qDL6 QxvaVyb8Cd6vjh0xNf2TZTSOsFLnLdbH1kh2qfJsflIJJ3jRp24N0XmU9Qu9x005T8KA DDc9KqF7dC4rAcsctiTFqW9kfRpwdbPG+eQI5GQfj0gVuhdOuf1KD6dKGGAc2MVWxLwT h0Iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=smEnDw1iDeBsm7OWKZul3/JCo3QrVo/nFFRvio7e+IU=; fh=D/OCz6yFKDecQWzV6+YqJ+fQD5KaWV34gq7HTTSdbQg=; b=DcNewKVIY8dwL1zSRpdGDc6fLXk8Ao8sABicTKbQM/7y5N4ljnlF9c6uenvKcZ3iA5 LrZevZr6NYJGsO/eZnEHdezE8Qk0Zh8fFwKepznVRKbHGcn0FNp69SedULCEjz/OaijW zfgCi5J6FDYstZRazihX//OvOMm6ZslAqUST1L9zg5dx1Mr/K9vnM5Svv4LfIdarhEtl 0kwHTilPTbGpBxoK9s3sGhFpCcRd0nh/+jheJ6zN+8MOk9lX+sUkoVFtBHrhJ9AKL81J NmHvgICfY9U8WICIBV0sMwHa17VtiCSlV7U8078OmchRRxwt0kjis0X2lvZ/DMcNt2Mf 5RgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=My9YfPPF; 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-92858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bx37-20020a056a02052500b005e44b47f272si11186645pgb.410.2024.03.05.10.54.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:54:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=My9YfPPF; 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-92858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92858-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 03D9E28437A for ; Tue, 5 Mar 2024 18:54:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3444F1B972; Tue, 5 Mar 2024 18:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="My9YfPPF" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 E08091AAC4 for ; Tue, 5 Mar 2024 18:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709664884; cv=none; b=nr9HPyT3iKS2pwZsp0+TIYGJ9YnVtW02hma6ohpNutPp4aNuhBx4TrOaAsxRhYGvZ7e7l3XlYP3/kQIU7+b/qpXYmaZHh+Yj1wB9ooF2coJGbEEZ5kkxz8CmDG1BpNph4nZG4ljzIhNgYxyJV0nBqH0nK7qesckXeWo46nQL5iY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709664884; c=relaxed/simple; bh=vSbegJ/mfKJlAVFDjG5b7omrS1QW3UlmocGh5VJ7JEo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=owKelSMPdD0QgJKXJdNMMTObXFW4y4wQGZKvgr5RAwHGzohkZu/513HPQXeR2T9Aj5rt9Lh6IMpaePlPjSllkZcb/pdBYtURM7WjRlVGCy5iFoeMvbcRs3RobywJjqm6Yg7bCS34EaLwLTeJD+wxvJuLzyLBdB6TEUZKI3XfDF8= 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=My9YfPPF; arc=none smtp.client-ip=209.85.214.176 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-pl1-f176.google.com with SMTP id d9443c01a7336-1d7232dcb3eso44525485ad.2 for ; Tue, 05 Mar 2024 10:54:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709664881; x=1710269681; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=smEnDw1iDeBsm7OWKZul3/JCo3QrVo/nFFRvio7e+IU=; b=My9YfPPFtj84Ezs5+jqbZ3TkvsEBG7SUfW71+KXSgXoxmP1Ga6bgP+/BXzW2PSnmj0 unhiLceJrOaPH8pjJGeqSG64ispIHC6U/Z5GmQVeizqKeuHfksR9xeo/OOzSe/2sEPeF uoxAXvCbXkGaOBluYkmVro44H/jA4MuSVd/q4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664881; x=1710269681; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=smEnDw1iDeBsm7OWKZul3/JCo3QrVo/nFFRvio7e+IU=; b=VrLNp8cjJ+rm9G26jmxSgNho0HwMf6mqsZvMBhkoP4rUGHhZAGBuVohRgf4XKC2eHS JdPefQxqno+k2jP2hDiDtSgGZlBSw39wjgESPGFOwLRrKo4KY2vEEgPx524M7xj7cLpC 4X6apmJbLqbOqFTOBOIe3sLhVXpodi6rHfdVPoaDU2BsOJEUVjFSayy2Z/Q13eJVXyjA Zqg8E8t06+dKalbqil6qQ5qOUrDtgoap0Nmdw+DtLJAj0wxWFSyA9jka277ILiueh73e nRTdF/IKQSNq3P6x9EZ4XxomBrgawKrX/lhqaKwc+K5ag0cFQNwAy+cPZzBtpUQb7DQA 9msw== X-Forwarded-Encrypted: i=1; AJvYcCXYAHsTTxGUpOR7HEI69EVen2KM2gmlp+IvcWD4SjBOffwdDiKyVOcuOJW78zsGWZAoQXJHbvrYpiVBQaj8SSztx3WnX4UyYslxekxV X-Gm-Message-State: AOJu0Yzujv5ikYbTjW62is3UXVy7rsAGpG1TSwOAgsl5EDEuFonxQo49 EJBow8l6orbmF+FlTfWLqhgD35YO41vyLqGDbNEogLnuTIXkFRDxq8Ij4Ls19A== X-Received: by 2002:a17:902:6b07:b0:1dc:f7cb:bbaf with SMTP id o7-20020a1709026b0700b001dcf7cbbbafmr2523098plk.22.1709664881047; Tue, 05 Mar 2024 10:54:41 -0800 (PST) Received: from chromium.org (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001dcb654d1a5sm10886409plg.21.2024.03.05.10.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:54:40 -0800 (PST) Date: Tue, 5 Mar 2024 18:54:39 +0000 From: Prashant Malani To: Jameson Thies Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.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 Subject: Re: [PATCH v4 3/4] usb: typec: ucsi: Register SOP/SOP' Discover Identity Responses Message-ID: References: <20240305025804.1290919-1-jthies@google.com> <20240305025804.1290919-4-jthies@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240305025804.1290919-4-jthies@google.com> On Mar 05 02:58, Jameson Thies wrote: > Register SOP and SOP' Discover Identity responses with the USB Type-C > Connector Class as partner and cable identities, respectively. Discover > Identity responses are requested from the PPM using the GET_PD_MESSAGE > UCSI command. > > Signed-off-by: Jameson Thies Mostly line splitting nits (which I have listed below). Once those are addressed, please feel free to add: Reviewed-by: Prashant Malani > diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c > index 7c84687b5d1a3..3b64a0f51041c 100644 > --- a/drivers/usb/typec/ucsi/ucsi.c > +++ b/drivers/usb/typec/ucsi/ucsi.c > @@ -646,6 +646,108 @@ static int ucsi_get_src_pdos(struct ucsi_connector *con) > return ret; > } > > +static int ucsi_read_identity(struct ucsi_connector *con, u8 recipient, > + u8 offset, u8 bytes, void *resp) > +{ > + struct ucsi *ucsi = con->ucsi; > + u64 command; > + int ret; > + > + command = UCSI_COMMAND(UCSI_GET_PD_MESSAGE) | > + UCSI_CONNECTOR_NUMBER(con->num); > + command |= UCSI_GET_PD_MESSAGE_RECIPIENT(recipient); > + command |= UCSI_GET_PD_MESSAGE_OFFSET(offset); > + command |= UCSI_GET_PD_MESSAGE_BYTES(bytes); > + command |= UCSI_GET_PD_MESSAGE_TYPE(UCSI_GET_PD_MESSAGE_TYPE_IDENTITY); > + > + ret = ucsi_send_command(ucsi, command, resp, bytes); > + if (ret < 0) > + dev_err(ucsi->dev, "UCSI_GET_PD_MESSAGE failed (%d)\n", ret); > + > + return ret; > +} > + > +static int ucsi_get_identity(struct ucsi_connector *con, u8 recipient, > + struct usb_pd_identity *id) nit: Line limits are 100 now [1], so this can fit on one line. > +{ > + struct ucsi *ucsi = con->ucsi; > + struct ucsi_pd_message_disc_id resp = {}; > + int ret; > + > + if (ucsi->version < UCSI_VERSION_2_0) { > + /* > + * Before UCSI v2.0, MESSAGE_IN is 16 bytes which cannot fit > + * the 28 byte identity response including the VDM header. > + * First request the VDM header, ID Header VDO, Cert Stat VDO > + * and Product VDO. > + */ > + ret = ucsi_read_identity(con, recipient, 0, 0x10, &resp); > + if (ret < 0) > + return ret; > + > + > + /* Then request Product Type VDO1 through Product Type VDO3. */ > + ret = ucsi_read_identity(con, recipient, 0x10, 0xc, > + &resp.vdo[0]); nit: Can fit on one line. > + if (ret < 0) > + return ret; > + > + } else { > + /* > + * In UCSI v2.0 and after, MESSAGE_IN is large enough to request > + * the large enough to request the full Discover Identity > + * response at once. > + */ > + ret = ucsi_read_identity(con, recipient, 0x0, 0x1c, &resp); > + if (ret < 0) > + return ret; > + } > + > + id->id_header = resp.id_header; > + id->cert_stat = resp.cert_stat; > + id->product = resp.product; > + id->vdo[0] = resp.vdo[0]; > + id->vdo[1] = resp.vdo[1]; > + id->vdo[2] = resp.vdo[2]; > + return 0; > +} > + > +static int ucsi_get_partner_identity(struct ucsi_connector *con) > +{ > + int ret; > + > + ret = ucsi_get_identity(con, UCSI_RECIPIENT_SOP, > + &con->partner_identity); nit: One line please. > + if (ret < 0) > + return ret; > + > + ret = typec_partner_set_identity(con->partner); > + if (ret < 0) { > + dev_err(con->ucsi->dev, "Failed to set partner identity (%d)\n", > + ret); nit: One line (100 is the limit now). > + } > + > + return ret; > +} > + > +static int ucsi_get_cable_identity(struct ucsi_connector *con) > +{ > + int ret; > + > + ret = ucsi_get_identity(con, UCSI_RECIPIENT_SOP_P, > + &con->cable_identity); nit: One line. > + if (ret < 0) > + return ret; > + > + ret = typec_cable_set_identity(con->cable); > + if (ret < 0) { > + dev_err(con->ucsi->dev, "Failed to set cable identity (%d)\n", > + ret); nit: One line. Best regards, -Prashant [1] https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl#L59