Message ID | 1630588374-5169-4-git-send-email-quic_linyyuan@quicinc.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/5] usb: gadget: configfs: expose some struct from configfs.c | expand |
Hi Linyu,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on peter.chen-usb/for-usb-next next-20210902]
[cannot apply to balbi-usb/testing/next v5.14]
[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/Linyu-Yuan/usb-gadget-configfs-add-some-trace-event/20210902-211519
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: hexagon-randconfig-r045-20210901 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c9948e9254fbb6ea00f66c7b4542311d21e060be)
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
# https://github.com/0day-ci/linux/commit/855bbfeebfb8ad0859f690047753221b635d391a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Linyu-Yuan/usb-gadget-configfs-add-some-trace-event/20210902-211519
git checkout 855bbfeebfb8ad0859f690047753221b635d391a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=hexagon
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/usb/gadget/configfs.c:1203:26: warning: variable 'cfg' set but not used [-Wunused-but-set-variable]
struct config_usb_cfg *cfg;
^
1 warning generated.
vim +/cfg +1203 drivers/usb/gadget/configfs.c
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1190
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1191 int composite_dev_prepare(struct usb_composite_driver *composite,
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1192 struct usb_composite_dev *dev);
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1193
da4243145fb197 Andrzej Pietrasiewicz 2014-05-08 1194 int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,
da4243145fb197 Andrzej Pietrasiewicz 2014-05-08 1195 struct usb_ep *ep0);
da4243145fb197 Andrzej Pietrasiewicz 2014-05-08 1196
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1197 static void purge_configs_funcs(struct gadget_info *gi)
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1198 {
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1199 struct usb_configuration *c;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1200
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1201 list_for_each_entry(c, &gi->cdev.configs, list) {
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1202 struct usb_function *f, *tmp;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 @1203 struct config_usb_cfg *cfg;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1204
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1205 cfg = container_of(c, struct config_usb_cfg, c);
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1206
6cd0fe91387917 Chandana Kishori Chiluveru 2020-12-29 1207 list_for_each_entry_safe_reverse(f, tmp, &c->functions, list) {
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1208
855bbfeebfb8ad Linyu Yuan 2021-09-02 1209 list_del(&f->list);
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1210 if (f->unbind) {
da7b895d518cc1 Romain Izard 2016-08-29 1211 dev_dbg(&gi->cdev.gadget->dev,
a08f5dbf877a45 Romain Izard 2016-07-26 1212 "unbind function '%s'/%p\n",
a08f5dbf877a45 Romain Izard 2016-07-26 1213 f->name, f);
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1214 f->unbind(c, f);
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1215 }
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1216 }
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1217 c->next_interface_id = 0;
903124fe1aa284 Krzysztof Opasiak 2015-03-20 1218 memset(c->interface, 0, sizeof(c->interface));
554eead5436401 John Youn 2016-02-05 1219 c->superspeed_plus = 0;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1220 c->superspeed = 0;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1221 c->highspeed = 0;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1222 c->fullspeed = 0;
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1223 }
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1224 }
88af8bbe4ef781 Sebastian Andrzej Siewior 2012-12-23 1225
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 39b916a..c5b5c2f 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -354,7 +354,7 @@ static int config_usb_cfg_link( struct usb_function_instance *fi = container_of(group, struct usb_function_instance, group); struct usb_function_instance *a_fi; - struct usb_function *f; + struct config_usb_function *cf; int ret; mutex_lock(&gi->lock); @@ -372,21 +372,29 @@ static int config_usb_cfg_link( goto out; } - list_for_each_entry(f, &cfg->func_list, list) { - if (f->fi == fi) { + list_for_each_entry(cf, &cfg->func_list, list) { + if (cf->f->fi == fi) { ret = -EEXIST; goto out; } } - f = usb_get_function(fi); - if (IS_ERR(f)) { - ret = PTR_ERR(f); + cf = kzalloc(sizeof(*cf), GFP_KERNEL); + if (!cf) { + ret = -ENOMEM; + goto out; + } + INIT_LIST_HEAD(&cf->list); + + cf->f = usb_get_function(fi); + if (IS_ERR(cf->f)) { + ret = PTR_ERR(cf->f); + kfree(cf); goto out; } /* stash the function until we bind it to the gadget */ - list_add_tail(&f->list, &cfg->func_list); + list_add_tail(&cf->list, &cfg->func_list); ret = 0; out: mutex_unlock(&gi->lock); @@ -404,7 +412,7 @@ static void config_usb_cfg_unlink( struct config_group *group = to_config_group(usb_func_ci); struct usb_function_instance *fi = container_of(group, struct usb_function_instance, group); - struct usb_function *f; + struct config_usb_function *cf; /* * ideally I would like to forbid to unlink functions while a gadget is @@ -417,10 +425,11 @@ static void config_usb_cfg_unlink( unregister_gadget(gi); WARN_ON(gi->composite.gadget_driver.udc_name); - list_for_each_entry(f, &cfg->func_list, list) { - if (f->fi == fi) { - list_del(&f->list); - usb_put_function(f); + list_for_each_entry(cf, &cfg->func_list, list) { + if (cf->f->fi == fi) { + list_del(&cf->list); + usb_put_function(cf->f); + kfree(cf); mutex_unlock(&gi->lock); return; } @@ -1197,7 +1206,7 @@ static void purge_configs_funcs(struct gadget_info *gi) list_for_each_entry_safe_reverse(f, tmp, &c->functions, list) { - list_move(&f->list, &cfg->func_list); + list_del(&f->list); if (f->unbind) { dev_dbg(&gi->cdev.gadget->dev, "unbind function '%s'/%p\n", @@ -1299,8 +1308,7 @@ static int configfs_composite_bind(struct usb_gadget *gadget, /* Go through all configs, attach all functions */ list_for_each_entry(c, &gi->cdev.configs, list) { struct config_usb_cfg *cfg; - struct usb_function *f; - struct usb_function *tmp; + struct config_usb_function *cf, *tmp; struct gadget_config_name *cn; if (gadget_is_otg(gadget)) @@ -1324,13 +1332,10 @@ static int configfs_composite_bind(struct usb_gadget *gadget, c->iConfiguration = s[0].id; } - list_for_each_entry_safe(f, tmp, &cfg->func_list, list) { - list_del(&f->list); - ret = usb_add_function(c, f); - if (ret) { - list_add(&f->list, &cfg->func_list); + list_for_each_entry_safe(cf, tmp, &cfg->func_list, list) { + ret = usb_add_function(c, cf->f); + if (ret) goto err_purge_funcs; - } } ret = usb_gadget_check_config(cdev->gadget); if (ret) diff --git a/drivers/usb/gadget/configfs.h b/drivers/usb/gadget/configfs.h index a1dc513..103df1b 100644 --- a/drivers/usb/gadget/configfs.h +++ b/drivers/usb/gadget/configfs.h @@ -44,6 +44,11 @@ static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item) group); } +struct config_usb_function { + struct list_head list; + struct usb_function *f; +}; + struct gadget_strings { struct usb_gadget_strings stringtab_dev; struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX];
add a new list which link all usb_function at configfs layers, it means that after link a function a configuration, from configfs layer, we can still found all functions, it will allow trace all functions from configfs. Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com> --- drivers/usb/gadget/configfs.c | 47 ++++++++++++++++++++++++------------------- drivers/usb/gadget/configfs.h | 5 +++++ 2 files changed, 31 insertions(+), 21 deletions(-)