From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Prashant Malani <pmalani@chromium.org>
Cc: linux-kernel@vger.kernel.org, Benson Leung <bleung@chromium.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
"open list:USB TYPEC CLASS" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH] usb: typec: Add num_altmodes partner attribute
Date: Wed, 1 Jul 2020 14:01:31 +0200 [thread overview]
Message-ID: <20200701120131.GC2184169@kroah.com> (raw)
In-Reply-To: <20200701003149.3101219-1-pmalani@chromium.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 <pmalani@chromium.org>
> Cc: Benson Leung <bleung@chromium.org>
> ---
> 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
next prev parent reply other threads:[~2020-07-01 12:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 0:31 [PATCH] usb: typec: Add num_altmodes partner attribute Prashant Malani
2020-07-01 8:22 ` Heikki Krogerus
2020-07-01 14:40 ` Prashant Malani
2020-07-01 12:01 ` Greg Kroah-Hartman [this message]
2020-07-01 14:37 ` Prashant Malani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200701120131.GC2184169@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=bleung@chromium.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pmalani@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).