FROMGIT: usb: typec: Add number of altmodes partner attr

Add a user-visible attribute for the number of alternate modes available
in a partner. This allows userspace to determine whether there are any
remaining alternate modes left to be registered by the kernel driver. It
can begin executing any policy state machine after all available
alternate modes have been registered with the connector class framework.

This value is set to "-1" initially, signifying that a valid number of
alternate modes haven't been set for the partner.

Also add a sysfs file which exposes this attribute. The file remains
hidden as long as the attribute value is -1.

Bug: 174347172
Cc: Benson Leung <bleung@chromium.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20201116201150.2919178-3-pmalani@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a0ccdc4a77
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Cc: Badhri Jagan Sridharan <badhri@google.com>
Cc: Will McVicker <willmcvicker@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Id33c6eb2a4a293589ca7d085d3fccafd3c2708d5
This commit is contained in:
Prashant Malani
2020-11-16 12:11:40 -08:00
committed by Greg Kroah-Hartman
parent e670fd9917
commit a889946388
3 changed files with 74 additions and 1 deletions

View File

@@ -126,6 +126,7 @@ struct typec_altmode_desc {
enum typec_port_data roles;
};
int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes);
struct typec_altmode
*typec_partner_register_altmode(struct typec_partner *partner,
const struct typec_altmode_desc *desc);