Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp557280ybt; Wed, 1 Jul 2020 05:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY3BHDDHDi//Sy+KtsO0timHbTAqe6r2HyK7wevoFc9F+XKsrlD1wkFnYcHK30pgxl66z3 X-Received: by 2002:a17:906:7f90:: with SMTP id f16mr22233439ejr.507.1593604953519; Wed, 01 Jul 2020 05:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593604953; cv=none; d=google.com; s=arc-20160816; b=L7NbBmiOwdnDixkeCEBZYSTMmOim6Cmo7qZHI87p+w6N/NyqZtMbBo9P2qzzHLLUg8 z3CRvraCsrwaYxvLbVQBgY/hacDtc7NBDGRRLbaDM3HyTybn5Q6XM844oqV1VtMKVIL4 W7lmB2M8mGzjn5SK26R+md0Zx4Q70UjFf8342AOXvA2gdp1yFxOwQwEC5YImMIKCuQn9 yDTVnG9o3j3k/bwx4O9hyYNi1j0mGPw4SDWFbpFul+SWh8cotRjoJoxcbTVcM6FYrhNF svopPxd8Z3r5odVLyEKw/H4Nmcml0jtLKsjwuHqBBzsIUS9LbRyyhmGUVdCVqiFLIOpy HgrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5vzBdXnQUus3hD5G4d1ejfnM91RWinlGiSAZW9wZ8Gs=; b=u8SFmacmCpDJpImWYZBbR2PsQudisVJq3U2q5u+67dIy0UsJzf1Ya35tFX9Vb2vsYl Or6DcJOoZP5QbQksbYzLY+J/W1c6STTvWNbncgZVLCWaprwCQolY35Mibvm8rVzDaloC 4eWP+5EUmWdpmbQFMF2TsI41CZ8TUyyBB4bDvEgLC+uN/MdhgeQGNoOPnYRktsD6HvyD wKzOmizcbxcOAAYxUw5J1rSnCUWA9znHyXYFMGMx20914n9MW6zArbEytizc75/2+/R/ +EEd/oZw3U1AreoXbr7Iu/586tzc/Iek+z6EnZm28AB/1EbqKfgnSkUra3QP0kXJ1pFx 9laA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uUbTEgBY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si3552748eds.173.2020.07.01.05.02.09; Wed, 01 Jul 2020 05:02:33 -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=uUbTEgBY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730466AbgGAMBq (ORCPT + 99 others); Wed, 1 Jul 2020 08:01:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:48306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730103AbgGAMBq (ORCPT ); Wed, 1 Jul 2020 08:01:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 0FDCF206B6; Wed, 1 Jul 2020 12:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593604905; bh=QKcT0eftuynQwl8bQ8Sy2DfoL4gw7pFgfGufIC0v47k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uUbTEgBYXPpk93oGdn1jAtGSgdTJW4t8pdSCJEJHGiCeBuprLp3JlhGpwjK4ahAej QKPH1RQqgpEnwbdx5ns39hQfkIjKXI++KDRonv1WFbpxkvmJ+c0LAE/OAgkclHew7s pDzDkr/ux5VdvCg3I9IIBLwPkUCDaGWvNj+vSE7o= Date: Wed, 1 Jul 2020 14:01:31 +0200 From: Greg Kroah-Hartman To: Prashant Malani Cc: linux-kernel@vger.kernel.org, Benson Leung , Heikki Krogerus , "open list:USB TYPEC CLASS" Subject: Re: [PATCH] usb: typec: Add num_altmodes partner attribute Message-ID: <20200701120131.GC2184169@kroah.com> References: <20200701003149.3101219-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200701003149.3101219-1-pmalani@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 05:31:48PM -0700, Prashant Malani wrote: > Add a user-visible attribute for the number of alt modes available in a > partner. This allows userspace to determine whether there are any > remaining alt modes left to be registered by the kernel driver. It can > begin implementing any policy state machine after all available alt > modes have been registered with the connector class framework. > > This value is set to "-1" initially, which is an invalid value, > signifying that a valid number of alt modes haven't been set for the > partner. > > Signed-off-by: Prashant Malani > Cc: Benson Leung > --- > drivers/usb/typec/class.c | 34 ++++++++++++++++++++++++++++++++++ > include/linux/usb/typec.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index c9234748537a..680cbcfbd427 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -33,6 +33,7 @@ struct typec_partner { > struct usb_pd_identity *identity; > enum typec_accessory accessory; > struct ida mode_ids; > + int num_altmodes; > }; > > struct typec_port { > @@ -532,9 +533,18 @@ static ssize_t supports_usb_power_delivery_show(struct device *dev, > } > static DEVICE_ATTR_RO(supports_usb_power_delivery); > > +static ssize_t num_altmodes_show(struct device *dev, struct device_attribute *attr, char *buf) > +{ > + struct typec_partner *p = to_typec_partner(dev); > + > + return sprintf(buf, "%d\n", p->num_altmodes); > +} > +static DEVICE_ATTR_RO(num_altmodes); > + > static struct attribute *typec_partner_attrs[] = { > &dev_attr_accessory_mode.attr, > &dev_attr_supports_usb_power_delivery.attr, > + &dev_attr_num_altmodes.attr, > NULL > }; > ATTRIBUTE_GROUPS(typec_partner); > @@ -570,6 +580,29 @@ int typec_partner_set_identity(struct typec_partner *partner) > } > EXPORT_SYMBOL_GPL(typec_partner_set_identity); > > +/** > + * typec_partner_set_num_altmodes - Update number of available altmodes > + * @partner: The partner to be updated > + * @num_alt_modes: The number of altmodes we want to specify as available > + * > + * This routine is used to report the number of alternate modes supported by the > + * partner. This value is *not* enforced in alt mode registration routines. > + * > + * @partner.num_altmodes is set to -1 on partner registration, denoting that > + * a valid value has not been set for it yet. > + */ > +int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes) > +{ > + if (num_altmodes < 0) > + return -EINVAL; > + > + partner->num_altmodes = num_altmodes; > + sysfs_notify(&partner->dev.kobj, NULL, "num_altmodes"); > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(typec_partner_set_num_altmodes); Who is calling this? We need a user before we can add a newly exported function. thanks, greg k-h