usb: typec: tcpm: Export partner Source Capabilities
Subsystems (3)
PATCH 1/1 usb: typec: tcpm: Export partner Source Capabilities
Provide a function to get the partner Source Capabilities.
--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +23 -0
@@ -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); +/* Power Supply access to expose source power information */ enum tcpm_psy_online_states {TCPM_PSY_OFFLINE =0 ,
include/linux/usb/tcpm.h +1 -0
@@ -173,5 +173,6 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port, enum tcpm_transmit_status status);void tcpm_pd_hard_reset (struct tcpm_port *port);void tcpm_tcpc_reset (struct tcpm_port *port); +int tcpm_get_partner_src_caps (struct tcpm_port *port,u32 **pdo);#endif /* __LINUX_USB_TCPM_H */
Greg KH
maintainerQuoted 28 lines · Kyle Tso
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)drivers/usb/typec/tcpm/tcpm.c +12
-0@@ -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 );
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+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 :(
Quoted 28 lines · Greg KH
Quoted 27 lines · Kyle Tso
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)drivers/usb/typec/tcpm/tcpm.c +11
-0@@ -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 ; +
Quoted 8 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4515
Quoted 8 lines
drivers/usb/typec/tcpm/tcpm.c +8
-0+ *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);
The mutex use here suggests that the data can be updated while being copied. But that suggests that port->nr_source_caps can change as well and may no longer be current after mutex_lock().
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 3 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0+return nr_pdo; +} +EXPORT_SYMBOL_GPL (tcpm_get_partner_src_caps);We don't add new functions that no one uses :(
I am also concerned about the API itself; passing a pointer to be freed by the caller invites memory leaks.
Guenter
Quoted 34 lines · Guenter Roeck
Quoted 32 lines · Greg KH
Quoted 31 lines · Kyle Tso
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)drivers/usb/typec/tcpm/tcpm.c +15
-0@@ -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 ; +
Quoted 9 lines
Quoted 4 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4515
Quoted 4 lines
drivers/usb/typec/tcpm/tcpm.c +4
-0+mutex_lock (&port->lock); + nr_pdo =tcpm_copy_pdos (*src_pdo, port->source_caps, + port->nr_source_caps); +mutex_unlock (&port->lock);The mutex use here suggests that the data can be updated while being copied. But that suggests that
port->nr_source_capscan change as well and may no longer be current aftermutex_lock().
Thanks for pointing out the bug. I will fix this in the next version.
Quoted 11 lines
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 3 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0+return nr_pdo; +} +EXPORT_SYMBOL_GPL (tcpm_get_partner_src_caps);We don't add new functions that no one uses :(
I am also concerned about the API itself; passing a pointer to be freed by the caller invites memory leaks.
Guenter
What is the better way to implement this? How about providing a function (say "tcpm_put_partner_src_caps") for the caller to free the memory?
Quoted 34 lines · Greg KH
Quoted 32 lines · Kyle Tso
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)drivers/usb/typec/tcpm/tcpm.c +16
-0@@ -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);
Quoted 9 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +6
-0+ 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.
A message that is not in the archive (sent off-list or not yet received): CAGZ6i=07EOHqd3r9y1MpYn_e1nFeYGt_wp9arhMZWWeTBm-udA@mail.gmail.com
Greg KH
maintainerQuoted 48 lines · Kyle Tso
Quoted 36 lines · Greg KH
Review
Quoted 9 lines · Kyle Tso
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)(quoted diff) +0
-0
b/drivers/usb/typec/tcpm/tcpm.cdrivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct
Quoted 4 lines
index
f1d3e54210df..29cd84ba9960100644drivers/usb/typec/tcpm/tcpm.c +0
-0@@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct
tcpm_port*port, const u32 *pdo,drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
Quoted 5 lines
drivers/usb/typec/tcpm/tcpm.c +2
-0}EXPORT_SYMBOL_GPL (tcpm_update_sink_capabilities); +/* +* Don't call this function in interrupt context. Caller needs to free the
Quoted 14 lines
drivers/usb/typec/tcpm/tcpm.c +14
-0+* 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);Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +6
-0+ 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 :(
Quoted 5 lines
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.
And where is that code?
Quoted 4 lines
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.
Great, let's go delete them now, we should not have apis that no one uses. This isn't a new thing...
thanks,
greg k-h
Quoted 49 lines · Greg KH
Quoted 48 lines · Kyle Tso
Quoted 46 lines · Greg KH
Review
Quoted 9 lines · Kyle Tso
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)(quoted diff) +0
-0
b/drivers/usb/typec/tcpm/tcpm.cdrivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct
Quoted 4 lines
index
f1d3e54210df..29cd84ba9960100644drivers/usb/typec/tcpm/tcpm.c +0
-0@@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct
tcpm_port*port, const u32 *pdo,drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
Quoted 5 lines
drivers/usb/typec/tcpm/tcpm.c +2
-0}EXPORT_SYMBOL_GPL (tcpm_update_sink_capabilities); +/* +* Don't call this function in interrupt context. Caller needs to free the
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+* 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 );drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+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 :(
Quoted 8 lines
Quoted 5 lines
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.And where is that code?
Agreed - that code should be sent upstream as well to let us see the entire context.
Quoted 8 lines
Quoted 4 lines
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.Great, let's go delete them now, we should not have apis that no one uses. This isn't a new thing...
I sent a patch to do just that. Quite frankly I don't recal why I thought those functions might be needed.
Guenter
Quoted 68 lines · Guenter Roeck
Quoted 2 lines · Greg KH
Quoted 1 line · Kyle Tso
On Thu, Jan 31, 2019 at 3:02 PM Greg KH <[email protected]>
Quoted 48 lines · wrote:
Quoted 48 lines
Quoted 48 lines · Kyle Tso
Review
Quoted 9 lines
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)(quoted diff) +0
-0
b/drivers/usb/typec/tcpm/tcpm.cdrivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct
Quoted 4 lines
index
f1d3e54210df..29cd84ba9960100644drivers/usb/typec/tcpm/tcpm.c +0
-0@@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct
tcpm_port*port, const u32 *pdo,drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0}EXPORT_SYMBOL_GPL (tcpm_update_sink_capabilities); +/* +* Don't call this function in interrupt context. Caller needs to +free the
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+* 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 );drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+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 :(
Quoted 7 lines
Quoted 4 lines
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.And where is that code?
Agreed - that code should be sent upstream as well to let us see the entire context.
Quoted 5 lines
Quoted 4 lines
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.
Quoted 6 lines
Quoted 3 lines
Great, let's go delete them now, we should not have apis that no one uses. This isn't a new thing...
I sent a patch to do just that. Quite frankly I don't recal why I thought those functions might be needed.
As a mind jog - https://lkml.org/lkml/2017/11/27/1256 :)
Greg KH
maintainerQuoted 70 lines · Adam Thomson
Quoted 68 lines · Guenter Roeck
Quoted 2 lines · Greg KH
Quoted 1 line · Kyle Tso
On Thu, Jan 31, 2019 at 3:02 PM Greg KH <[email protected]>
Quoted 48 lines · wrote:
Quoted 48 lines
Quoted 48 lines · Kyle Tso
Review
Quoted 9 lines
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)(quoted diff) +0
-0
b/drivers/usb/typec/tcpm/tcpm.cdrivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct
Quoted 4 lines
index
f1d3e54210df..29cd84ba9960100644drivers/usb/typec/tcpm/tcpm.c +0
-0@@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct
tcpm_port*port, const u32 *pdo,drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0}EXPORT_SYMBOL_GPL (tcpm_update_sink_capabilities); +/* +* Don't call this function in interrupt context. Caller needs to +free the
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+* 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 );drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+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 :(
Quoted 7 lines
Quoted 4 lines
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.And where is that code?
Agreed - that code should be sent upstream as well to let us see the entire context.
Quoted 5 lines
Quoted 4 lines
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.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Great, let's go delete them now, we should not have apis that no one uses. This isn't a new thing...
I sent a patch to do just that. Quite frankly I don't recal why I thought those functions might be needed.
As a mind jog - https://lkml.org/lkml/2017/11/27/1256 :)
Nice find :)
Given that no one used these functions in over a year, we should be safe deleting them. If not, it's trivial to do 'git revert'.
thanks,
greg k-h
Quoted 80 lines · Greg KH
Quoted 31 lines · Adam Thomson
Quoted 29 lines · Guenter Roeck
Quoted 3 lines · Greg KH
Quoted 2 lines · Kyle Tso
On Thu, Jan 31, 2019 at 3:02 PM Greg KH
<[email protected]>Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 24 lines · Kyle Tso
Review
Quoted 9 lines
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)(quoted diff) +0
-0
b/drivers/usb/typec/tcpm/tcpm.cdrivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct
Quoted 4 lines
index
f1d3e54210df..29cd84ba9960100644drivers/usb/typec/tcpm/tcpm.c +0
-0@@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct
tcpm_port*port, const u32 *pdo,drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct · line 4499
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0}EXPORT_SYMBOL_GPL (tcpm_update_sink_capabilities); +/* +* Don't call this function in interrupt context. Caller needs +to free the
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct · line 4509
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+* 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);Quoted 37 lines
Quoted 36 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct · line 4519
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+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 :(
Quoted 7 lines
Quoted 4 lines
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.And where is that code?
Agreed - that code should be sent upstream as well to let us see the entire context.
Quoted 8 lines
Quoted 4 lines
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.Great, let's go delete them now, we should not have apis that no one uses. This isn't a new thing...
I sent a patch to do just that. Quite frankly I don't recal why I thought those functions might be needed.
Quoted 6 lines
Quoted 1 line
As a mind jog - https://lkml.org/lkml/2017/11/27/1256 :)
Nice find :)
Given that no one used these functions in over a year, we should be safe deleting them. If not, it's trivial to do 'git revert'.
Yep, agreed.
Quoted 70 lines · Adam Thomson
Quoted 68 lines · Guenter Roeck
Quoted 2 lines · Greg KH
Quoted 1 line · Kyle Tso
On Thu, Jan 31, 2019 at 3:02 PM Greg KH <[email protected]>
Quoted 48 lines · wrote:
Quoted 48 lines
Quoted 48 lines · Kyle Tso
Review
Quoted 9 lines
Provide a function to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 23 +++++++++++++++++++++++ include/linux/usb/tcpm.h | 1 + 2 files changed, 24 insertions(+)(quoted diff) +0
-0
b/drivers/usb/typec/tcpm/tcpm.cdrivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct
Quoted 4 lines
index
f1d3e54210df..29cd84ba9960100644drivers/usb/typec/tcpm/tcpm.c +0
-0@@ -4494,6 +4494,29 @@ int tcpm_update_sink_capabilities(struct
tcpm_port*port, const u32 *pdo,drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0}EXPORT_SYMBOL_GPL (tcpm_update_sink_capabilities); +/* +* Don't call this function in interrupt context. Caller needs to +free the
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+* 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 );drivers/usb/typec/tcpm/tcpm.c int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, · line 4518
Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +10
-0+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 :(
Quoted 7 lines
Quoted 4 lines
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.And where is that code?
Agreed - that code should be sent upstream as well to let us see the entire context.
Quoted 5 lines
Quoted 4 lines
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.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Great, let's go delete them now, we should not have apis that no one uses. This isn't a new thing...
I sent a patch to do just that. Quite frankly I don't recal why I thought those functions might be needed.
As a mind jog - https://lkml.org/lkml/2017/11/27/1256 :)
Nice find. However, since the code using it was never implemented, I think it is prudent at this point to remove the code. It can be reintroduced if/when needed, and at that point be tested properly.
Thanks,
Guenter