lkml.org 
[lkml]   [2019]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] usb: typec: tcpm: Export partner Source Capabilities
On Thu, Jan 31, 2019 at 3:02 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Thu, Jan 31, 2019 at 11:54:11AM +0800, Kyle Tso wrote:
> > Provide a function to get the partner Source Capabilities.
> >
> > Signed-off-by: Kyle Tso <kyletso@google.com>
> > ---
> > drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++
> > include/linux/usb/tcpm.h | 1 +
> > 2 files changed, 24 insertions(+)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index f1d3e54210df..29cd84ba9960 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
> > }
> > EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities);
> >
> > +/*
> > + * Don't call this function in interrupt context. Caller needs to free the
> > + * memory itself.
> > + */
> > +int tcpm_get_partner_src_caps(struct tcpm_port *port, u32 **src_pdo)
> > +{
> > + unsigned int nr_pdo;
> > +
> > + if (port->nr_source_caps == 0)
> > + return -ENODATA;
> > +
> > + *src_pdo = kcalloc(port->nr_source_caps, sizeof(u32), GFP_KERNEL);
> > + if (!src_pdo)
> > + return -ENOMEM;
> > +
> > + mutex_lock(&port->lock);
> > + nr_pdo = tcpm_copy_pdos(*src_pdo, port->source_caps,
> > + port->nr_source_caps);
> > + mutex_unlock(&port->lock);
> > + return nr_pdo;
> > +}
> > +EXPORT_SYMBOL_GPL(tcpm_get_partner_src_caps);
>
> We don't add new functions that no one uses :(
>

This function is useful if the PD Device Policy Manager is implemented
outside of TCPM.
In this situation, Device Policy Manager needs to know the partner
capabilities to optimize
the charging process.

Take existing functions in TCPM for example:
Function "tcpm_update_sink_capabilities" and
"tcpm_update_source_capabilities" are exposed
as well. And no one uses them now.

\
 
 \ /
  Last update: 2019-02-12 11:33    [W:0.053 / U:0.148 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site