Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5423087pxu; Thu, 22 Oct 2020 01:42:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0nCFsu49riKTbwTvhfyazxaw8s2+Cl5WGeGTF0kiXP4YwJAvuS8hm7WMwIHlERdCIKDUt X-Received: by 2002:a17:906:118f:: with SMTP id n15mr1302458eja.394.1603356140286; Thu, 22 Oct 2020 01:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603356140; cv=none; d=google.com; s=arc-20160816; b=JXNWlbXLipI/Hd7xUq0AZmnzlNAycrWlWg5yF8ThJMdL8xVgPn/FfzVXJYbifto+om nFSHxY6aI0hSRWZ8CurpZgYiUWQsPfX0tS1HkZu4G+v3kEkvqpcvx3rXs/m7IDmjIol+ 6BxfvfckgnDswxo/Zx8EXiHhxeJjZap72roVFtIXXFlsyouvNcZADID4dGGemBStwFLH ouZ4ajRR0uzFDSnQ9L3U0XEpTLca1FvDPBGEgZW8sWbEYuz4sEk5nAFIm8hYcRVNNnLs NhiexdG0QnwLfaxFZdBozuR7kzKsareVJJ1E5fmoaPLrhOVE43AOkOG/vW0tbFTOh1ET 0k0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6CqjqKPQye/EpkbrVTBcofSO5x8ArfPPAwuMAttQfeM=; b=b9fllIxjj4YEFBm8WHqpo98/t2tpdKNGZgFUqDGz54ZuAzal/n6IenLu0oZo1q9TP1 sdnmxLdFgXlC+SB8HtoClZIf+Z0S/TfOSILaGQwulsYhq8zedPfNi7FDRNHinyXE90FJ 7ev5nkhZEQwzPAHpVpVejLZZ8lJqES5VjYRkfPtgo0GenitS9ysKP5zckc9adXHAjcxG lqzZoXGKvJ2+ry+wO6EIAE5eA/xWj7uF680xyw1l+AR6fuCNZS7SCS6hjjlPQPa3QTQp LXdhDuqm3dute9B+tWz8SjRSZzYvB0ekg0RFElFlcFQLg5RQqv4Uk1Fg4fVIzD8wtAUL tWtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VjngR2jF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cd8si562683ejb.516.2020.10.22.01.41.58; Thu, 22 Oct 2020 01:42:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VjngR2jF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504674AbgJVG4t (ORCPT + 99 others); Thu, 22 Oct 2020 02:56:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:56544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409801AbgJVG4t (ORCPT ); Thu, 22 Oct 2020 02:56:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EDA86223FB; Thu, 22 Oct 2020 06:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603349806; bh=oQrX9JONzoZLZpeWwQAFwiY9lPCmvEjjgBYcdIQ4GSA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VjngR2jFlBi8Y3GpV6WZYd5EI1nLEnttm85MYqh6OTB4rsA5pDt91qVjZ9/O4oYTe Qmo5Lt8xiXoqVg1mycAREaKe+zfvG6t7cD2V2IiAGGAm+yt0WyDQ8IN5XZVLYVoPyt xSJEU+So5I/nyDw8zAae32xDLWlAnm9ME0/K43Ys= Date: Thu, 22 Oct 2020 08:57:19 +0200 From: Greg KH To: Prashant Malani Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Benson Leung , Heikki Krogerus Subject: Re: [PATCH v2] usb: typec: Expose Product Type VDOs via sysfs Message-ID: <20201022065719.GA1440360@kroah.com> References: <20201022061554.3418060-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201022061554.3418060-1-pmalani@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2020 at 11:15:54PM -0700, Prashant Malani wrote: > A PD-capable device can return up to 3 Product Type VDOs as part of its > DiscoverIdentity Response (USB PD Spec, Rev 3.0, Version 2.0, Section > 6.4.4.3.1). Add a sysfs attribute to expose these to userspace. > > Cc: Benson Leung > Cc: Heikki Krogerus > Signed-off-by: Prashant Malani > --- > > NOTE: I didn't include Benson's Reviewed-by from v1, since this version > introduced the sysfs_notify() call. > > Changes in v2: > - Added sysfs_notify() call for the attribute. > - Added description for the attribute in > Documentation/ABI/testing/sysfs-class-typec. > > Documentation/ABI/testing/sysfs-class-typec | 17 +++++++++++++++++ > drivers/usb/typec/class.c | 11 +++++++++++ > 2 files changed, 28 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec > index b834671522d6..16440a236b66 100644 > --- a/Documentation/ABI/testing/sysfs-class-typec > +++ b/Documentation/ABI/testing/sysfs-class-typec > @@ -170,6 +170,14 @@ Description: > will show 0 until Discover Identity command result becomes > available. The value can be polled. > > +What: /sys/class/typec/-partner/identity/product_type_vdo > +Date: October 2020 > +Contact: Prashant Malani > +Description: > + Product Type VDOs part of Discover Identity command result. 3 values > + are displayed (for the 3 possible Product Type VDOs), one per line. sysfs is "one value per file", not "one value per line". This is not ok. > + The values will show 0s until Discover Identity command result becomes > + available. The values can be polled. It can be polled? Did you try that? I don't see the logic for that in your patch. > > USB Type-C cable devices (eg. /sys/class/typec/port0-cable/) > > @@ -230,6 +238,15 @@ Description: > will show 0 until Discover Identity command result becomes > available. The value can be polled. > > +What: /sys/class/typec/-cable/identity/product_type_vdo > +Date: October 2020 > +Contact: Prashant Malani > +Description: > + Product Type VDOs part of Discover Identity command result. 3 values > + are displayed (for the 3 possible Product Type VDOs), one per line. > + The values will show 0s until Discover Identity command result becomes > + available. The values can be polled. Why are you describing the same value in two different locations? > + > > USB Type-C port alternate mode devices. > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index 35eec707cb51..37fa4501e75f 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -122,10 +122,20 @@ static ssize_t product_show(struct device *dev, struct device_attribute *attr, > } > static DEVICE_ATTR_RO(product); > > +static ssize_t product_type_vdo_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct usb_pd_identity *id = get_pd_identity(dev); > + > + return sprintf(buf, "0x%08x\n0x%08x\n0x%08x\n", id->vdo[0], id->vdo[1], id->vdo[2]); Note, for future sysfs stuff, always use sysfs_emit(). But again, this is not allowed as you have multiple values per a single file. thanks, greg k-h