diff mbox series

[v5,2/3] usb: gadget: configfs: add gadget_info for config group

Message ID 1630976977-13938-3-git-send-email-quic_linyyuan@quicinc.com
State New
Headers show
Series usb: gadget: configfs: add some trace event | expand

Commit Message

Linyu Yuan Sept. 7, 2021, 1:09 a.m. UTC
add gadget_info pointer in struct config_usb_cfg
to allow common gadget info trace from configfs layer.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
v2: no change
v3: change struct inside configfs.c
v4: no change
v5: no change

 drivers/usb/gadget/configfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Greg KH Oct. 5, 2021, 11:11 a.m. UTC | #1
On Tue, Sep 07, 2021 at 09:09:36AM +0800, Linyu Yuan wrote:
> add gadget_info pointer in struct config_usb_cfg

> to allow common gadget info trace from configfs layer.


Again, I do not understand this description, can you please try to
reword it?

> 

> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>

> ---

> v2: no change

> v3: change struct inside configfs.c

> v4: no change

> v5: no change

> 

>  drivers/usb/gadget/configfs.c | 8 ++++----

>  1 file changed, 4 insertions(+), 4 deletions(-)

> 

> diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c

> index 5b2e6f9..cea12c3 100644

> --- a/drivers/usb/gadget/configfs.c

> +++ b/drivers/usb/gadget/configfs.c

> @@ -70,6 +70,7 @@ struct config_usb_cfg {

>  	struct usb_configuration c;

>  	struct list_head func_list;

>  	struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];

> +	struct gadget_info *gi;


You add a pointer, where are you removing it?

thanks,

greg k-h
Linyu Yuan Oct. 9, 2021, 5:32 a.m. UTC | #2
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Sent: Tuesday, October 5, 2021 7:12 PM

> To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>

> Cc: Felipe Balbi <balbi@kernel.org>; linux-usb@vger.kernel.org

> Subject: Re: [PATCH v5 2/3] usb: gadget: configfs: add gadget_info for config

> group

> 

> On Tue, Sep 07, 2021 at 09:09:36AM +0800, Linyu Yuan wrote:

> > add gadget_info pointer in struct config_usb_cfg

> > to allow common gadget info trace from configfs layer.

> 

> Again, I do not understand this description, can you please try to

> reword it?

> 

> >

> > Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>

> > ---

> > v2: no change

> > v3: change struct inside configfs.c

> > v4: no change

> > v5: no change

> >

> >  drivers/usb/gadget/configfs.c | 8 ++++----

> >  1 file changed, 4 insertions(+), 4 deletions(-)

> >

> > diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c

> > index 5b2e6f9..cea12c3 100644

> > --- a/drivers/usb/gadget/configfs.c

> > +++ b/drivers/usb/gadget/configfs.c

> > @@ -70,6 +70,7 @@ struct config_usb_cfg {

> >  	struct usb_configuration c;

> >  	struct list_head func_list;

> >  	struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];

> > +	struct gadget_info *gi;

> 

> You add a pointer, where are you removing it?

Currently configfs layer seem do nothing when configfs drop of config group...
(it assume the configuration group will not remove)
Need to test rmdir operation  and send patch if possible later.
> 

> thanks,

> 

> greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 5b2e6f9..cea12c3 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -70,6 +70,7 @@  struct config_usb_cfg {
 	struct usb_configuration c;
 	struct list_head func_list;
 	struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];
+	struct gadget_info *gi;
 };
 
 static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item)
@@ -418,8 +419,7 @@  static int config_usb_cfg_link(
 	struct config_item *usb_func_ci)
 {
 	struct config_usb_cfg *cfg = to_config_usb_cfg(usb_cfg_ci);
-	struct usb_composite_dev *cdev = cfg->c.cdev;
-	struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
+	struct gadget_info *gi = cfg->gi;
 
 	struct config_group *group = to_config_group(usb_func_ci);
 	struct usb_function_instance *fi = container_of(group,
@@ -477,8 +477,7 @@  static void config_usb_cfg_unlink(
 	struct config_item *usb_func_ci)
 {
 	struct config_usb_cfg *cfg = to_config_usb_cfg(usb_cfg_ci);
-	struct usb_composite_dev *cdev = cfg->c.cdev;
-	struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
+	struct gadget_info *gi = cfg->gi;
 
 	struct config_group *group = to_config_group(usb_func_ci);
 	struct usb_function_instance *fi = container_of(group,
@@ -717,6 +716,7 @@  static struct config_group *config_desc_make(
 	cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
 	if (!cfg)
 		return ERR_PTR(-ENOMEM);
+	cfg->gi = gi;
 	cfg->c.label = kstrdup(buf, GFP_KERNEL);
 	if (!cfg->c.label) {
 		ret = -ENOMEM;