diff options
author | Saranya Gopal <saranya.gopal@intel.com> | 2021-11-16 16:06:13 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-11-17 14:59:11 +0100 |
commit | 4616dddcfaf75cfbfbff7ce8a468038c697444ce (patch) | |
tree | 9f1ea17c991aa449c30e5ce0704db377ce97fa45 /drivers/usb/typec/ucsi/ucsi.c | |
parent | 0d8cfeeef3f5a5966abce1903f80308be33280cb (diff) | |
download | linux-4616dddcfaf75cfbfbff7ce8a468038c697444ce.tar.gz linux-4616dddcfaf75cfbfbff7ce8a468038c697444ce.tar.bz2 linux-4616dddcfaf75cfbfbff7ce8a468038c697444ce.zip |
usb: typec: ucsi: Expose number of alternate modes in partner
Type-c class provides an option to expose the number of alternate
modes in the port partner as a sysfs interface. Use that to
expose the number of alternate modes in the port partner from
the ucsi driver.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Rajaram Regupathy <rajaram.regupathy@intel.com>
Signed-off-by: Saranya Gopal <saranya.gopal@intel.com>
Link: https://lore.kernel.org/r/20211116103613.31349-1-saranya.gopal@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/typec/ucsi/ucsi.c')
-rw-r--r-- | drivers/usb/typec/ucsi/ucsi.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 6aa28384f77f..9d6b7e02d6ef 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -303,6 +303,17 @@ static int ucsi_next_altmode(struct typec_altmode **alt) return -ENOENT; } +static int ucsi_get_num_altmode(struct typec_altmode **alt) +{ + int i; + + for (i = 0; i < UCSI_MAX_ALTMODES; i++) + if (!alt[i]) + break; + + return i; +} + static int ucsi_register_altmode(struct ucsi_connector *con, struct typec_altmode_desc *desc, u8 recipient) @@ -607,7 +618,7 @@ static int ucsi_get_src_pdos(struct ucsi_connector *con) static int ucsi_check_altmodes(struct ucsi_connector *con) { - int ret; + int ret, num_partner_am; ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP); if (ret && ret != -ETIMEDOUT) @@ -617,6 +628,9 @@ static int ucsi_check_altmodes(struct ucsi_connector *con) /* Ignoring the errors in this case. */ if (con->partner_altmode[0]) { + num_partner_am = ucsi_get_num_altmode(con->partner_altmode); + if (num_partner_am > 0) + typec_partner_set_num_altmodes(con->partner, num_partner_am); ucsi_altmode_update_active(con); return 0; } |