usb: typec: tcpm: Export partner Source Capabilities
Subsystems (3)
PATCH v2 1/1 usb: typec: tcpm: Export partner Source Capabilities
Export a function for other drivers to get the partner Source Capabilities.
---
Changes since v1:
- add a put function to free the memory
drivers/usb/typec/tcpm/tcpm.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/usb/tcpm.h | 2 ++ 2 files changed, 36 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +34 -0
@@ -5739,6 +5739,40 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,return 0 ; } +/* +* Don't call this function in interrupt context. Caller needs to free the +* memory by calling tcpm_put_partner_src_caps. +*/ +int tcpm_get_partner_src_caps (struct tcpm_port *port,u32 **src_pdo) +{ +unsigned int nr_pdo; + +mutex_lock (&port->lock); +if (port->nr_source_caps ==0 ) { +mutex_unlock (&port->lock); +return -ENODATA ; + } + + *src_pdo =kcalloc (port->nr_source_caps,sizeof (u32),GFP_KERNEL ); +if (!src_pdo) { +mutex_unlock (&port->lock); +return -ENOMEM ; + } + + 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); + +void tcpm_put_partner_src_caps (u32 **src_pdo) +{ +kfree (*src_pdo); + *src_pdo =NULL ; +} +EXPORT_SYMBOL_GPL (tcpm_put_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 +2 -0
@@ -161,5 +161,7 @@ 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); +void tcpm_put_partner_src_caps (u32 **pdo);#endif /* __LINUX_USB_TCPM_H */
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Kyle,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.11-rc7 next-20210212]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Kyle-Tso/usb-typec-tcpm-Export-partner-Source-Capabilities/20210214-113553 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing config: i386-randconfig-m021-20210214 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/a80af7a2f4fa112b43e7b2b262729a8e1b28c132 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kyle-Tso/usb-typec-tcpm-Export-partner-Source-Capabilities/20210214-113553 git checkout a80af7a2f4fa112b43e7b2b262729a8e1b28c132 # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/usb/typec/tcpm/tcpm.c: In function 'tcpm_get_partner_src_caps':
>> drivers/usb/typec/tcpm/tcpm.c:5762:11: error: implicit declaration of function 'tcpm_copy_pdos' [-Werror=implicit-function-declaration]
5762 | nr_pdo = tcpm_copy_pdos(*src_pdo, port->source_caps,
| ^~~~~~~~~~~~~~
At top level:
drivers/usb/typec/tcpm/tcpm.c:2106:39: warning: 'tcpm_altmode_ops' defined but not used [-Wunused-const-variable=]
2106 | static const struct typec_altmode_ops tcpm_altmode_ops = {
| ^~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/tcpm_copy_pdos +5762 drivers/usb/typec/tcpm/tcpm.c
5741
5742 /*
5743 * Don't call this function in interrupt context. Caller needs to free the
5744 * memory by calling tcpm_put_partner_src_caps.
5745 */
5746 int tcpm_get_partner_src_caps(struct tcpm_port *port, u32 **src_pdo)
5747 {
5748 unsigned int nr_pdo;
5749
5750 mutex_lock(&port->lock);
5751 if (port->nr_source_caps == 0) {
5752 mutex_unlock(&port->lock);
5753 return -ENODATA;
5754 }
5755
5756 *src_pdo = kcalloc(port->nr_source_caps, sizeof(u32), GFP_KERNEL);
5757 if (!src_pdo) {
5758 mutex_unlock(&port->lock);
5759 return -ENOMEM;
5760 }
5761
> 5762 nr_pdo = tcpm_copy_pdos(*src_pdo, port->source_caps,
5763 port->nr_source_caps);
5764 mutex_unlock(&port->lock);
5765 return nr_pdo;
5766 }
5767 EXPORT_SYMBOL_GPL(tcpm_get_partner_src_caps);
5768
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Kyle,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.11-rc7 next-20210212]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Kyle-Tso/usb-typec-tcpm-Export-partner-Source-Capabilities/20210214-113553 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing config: x86_64-randconfig-a013-20210214 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project c9439ca36342fb6013187d0a69aef92736951476)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/a80af7a2f4fa112b43e7b2b262729a8e1b28c132
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Kyle-Tso/usb-typec-tcpm-Export-partner-Source-Capabilities/20210214-113553 git checkout a80af7a2f4fa112b43e7b2b262729a8e1b28c132
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/usb/typec/tcpm/tcpm.c:5762:11: error: implicit declaration of function 'tcpm_copy_pdos' [-Werror,-Wimplicit-function-declaration]
nr_pdo = tcpm_copy_pdos(*src_pdo, port->source_caps,
^1 error generated.
vim +/tcpm_copy_pdos +5762 drivers/usb/typec/tcpm/tcpm.c
5741
5742 /*
5743 * Don't call this function in interrupt context. Caller needs to free the
5744 * memory by calling tcpm_put_partner_src_caps.
5745 */
5746 int tcpm_get_partner_src_caps(struct tcpm_port *port, u32 **src_pdo)
5747 {
5748 unsigned int nr_pdo;
5749
5750 mutex_lock(&port->lock);
5751 if (port->nr_source_caps == 0) {
5752 mutex_unlock(&port->lock);
5753 return -ENODATA;
5754 }
5755
5756 *src_pdo = kcalloc(port->nr_source_caps, sizeof(u32), GFP_KERNEL);
5757 if (!src_pdo) {
5758 mutex_unlock(&port->lock);
5759 return -ENOMEM;
5760 }
5761
> 5762 nr_pdo = tcpm_copy_pdos(*src_pdo, port->source_caps,
5763 port->nr_source_caps);
5764 mutex_unlock(&port->lock);
5765 return nr_pdo;
5766 }
5767 EXPORT_SYMBOL_GPL(tcpm_get_partner_src_caps);
5768
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 4 lines · Kyle Tso
Export a function for other drivers to get the partner Source Capabilities.
Signed-off-by Kyle Tso <[email protected]>
Who is going to use this? Please submit any new export together with the actual user.