Hi, (please break your lines at 80-columns) "Westermann, Oliver" <Oliver.Westermann@xxxxxxxxxx> writes: > Hey, > > I'm trying to use a composite gadget on a embedded linux platform > using configfs. The kernel-doc was fine and I can now create my > gadgets as needed. One big drawback is that the host_addr and dev_addr > change on every start. > > So I tried to change them, without success: > > * Most web documentation applies only to g_ether (eg setting > module/kernel parameters) > > * ${CONFIGFS}/usb_gadget/g1/functions/rndis.0/host_addr reports EBUSY > if I try to write it because the gadget is already configured. > * I checked the sources of my kernel (4.19) and the current ones to > check if I can somehow add a MAC to the dtb of my system: It seems > that there is no such binding. you can write host_addr and dev_addr via configufs, but according to code, you have to do it before adding the functions to the gadget. This, to me, seems a bit odd. Does this patch help the situation in any way? diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index 6ce044008cf6..31279aaf3f3b 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -530,14 +530,19 @@ static int ecm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct f_ecm *ecm = func_to_ecm(f); + struct f_ecm_opts *ecm_opts; struct usb_composite_dev *cdev = f->config->cdev; + ecm_opts = container_of(f->fi, struct f_ecm_opts, func_inst); + /* Control interface has only altsetting 0 */ if (intf == ecm->ctrl_id) { if (alt != 0) goto fail; VDBG(cdev, "reset ecm control %d\n", intf); + + ecm_opts->running = false; usb_ep_disable(ecm->notify); if (!(ecm->notify->desc)) { VDBG(cdev, "init ecm ctrl %d\n", intf); @@ -545,6 +550,7 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) goto fail; } usb_ep_enable(ecm->notify); + ecm_opts->running = true; /* Data interface has two altsettings, 0 and 1 */ } else if (intf == ecm->data_id) { @@ -553,6 +559,7 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) if (ecm->port.in_ep->enabled) { DBG(cdev, "reset ecm\n"); + ecm_opts->running = false; gether_disconnect(&ecm->port); } @@ -585,6 +592,7 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) net = gether_connect(&ecm->port); if (IS_ERR(net)) return PTR_ERR(net); + ecm_opts->running = true; } /* NOTE this can be a minor disagreement with the ECM spec, diff --git a/drivers/usb/gadget/function/u_ecm.h b/drivers/usb/gadget/function/u_ecm.h index 050aa672ee7f..752258dd1c3e 100644 --- a/drivers/usb/gadget/function/u_ecm.h +++ b/drivers/usb/gadget/function/u_ecm.h @@ -19,6 +19,7 @@ struct f_ecm_opts { struct usb_function_instance func_inst; struct net_device *net; bool bound; + bool running; /* * Read/write access to configfs attributes is handled by configfs. diff --git a/drivers/usb/gadget/function/u_ether_configfs.h b/drivers/usb/gadget/function/u_ether_configfs.h index cd33cee4d78b..7fe0a7fa4e7a 100644 --- a/drivers/usb/gadget/function/u_ether_configfs.h +++ b/drivers/usb/gadget/function/u_ether_configfs.h @@ -46,7 +46,7 @@ int ret; \ \ mutex_lock(&opts->lock); \ - if (opts->refcnt) { \ + if (opts->running) { \ mutex_unlock(&opts->lock); \ return -EBUSY; \ } \ @@ -81,7 +81,7 @@ int ret; \ \ mutex_lock(&opts->lock); \ - if (opts->refcnt) { \ + if (opts->running) { \ mutex_unlock(&opts->lock); \ return -EBUSY; \ } \ -- balbi
Attachment:
signature.asc
Description: PGP signature