diff mbox series

[2/6] usb: gadget: Drop usb_udc_release()

Message ID 20240826143851.8020-2-marek.vasut+renesas@mailbox.org
State Accepted
Delegated to: Mattijs Korpershoek
Headers show
Series [1/6] usb: gadget: Inline usb_add_gadget_udc_release | expand

Commit Message

Marek Vasut Aug. 26, 2024, 2:38 p.m. UTC
This callback is never called, drop it. Instead, call kfree(udc)
in usb_del_gadget_udc() to free the struct usb_udc data.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: Zixun LI <admin@hifiphile.com>
---
 drivers/usb/gadget/udc/udc-core.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

Comments

Mattijs Korpershoek Aug. 29, 2024, 7:41 a.m. UTC | #1
Hi Marek,

Thank you for the patch.

On lun., août 26, 2024 at 16:38, Marek Vasut <marek.vasut+renesas@mailbox.org> wrote:

> This callback is never called, drop it. Instead, call kfree(udc)
> in usb_del_gadget_udc() to free the struct usb_udc data.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Neil Armstrong <neil.armstrong@linaro.org>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Zixun LI <admin@hifiphile.com>
> ---
>  drivers/usb/gadget/udc/udc-core.c | 19 +------------------
>  1 file changed, 1 insertion(+), 18 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
> index 37c0ee43c52..275d6fe7be8 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -41,7 +41,6 @@ struct usb_udc {
>  	struct list_head		list;
>  };
>  
> -static struct class *udc_class;
>  static LIST_HEAD(udc_list);
>  DEFINE_MUTEX(udc_lock);
>  
> @@ -150,21 +149,6 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc)
>  	udc->gadget->ops->udc_stop(udc->gadget);
>  }
>  
> -/**
> - * usb_udc_release - release the usb_udc struct
> - * @dev: the dev member within usb_udc
> - *
> - * This is called by driver's core in order to free memory once the last
> - * reference is released.
> - */
> -static void usb_udc_release(struct device *dev)
> -{
> -	struct usb_udc *udc;
> -
> -	udc = container_of(dev, struct usb_udc, dev);
> -	kfree(udc);
> -}
> -
>  /**
>   * usb_add_gadget_udc - adds a new gadget to the udc class driver list
>   * @parent: the parent device to this udc. Usually the controller driver's
> @@ -185,8 +169,6 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
>  	dev_set_name(&gadget->dev, "gadget");
>  	gadget->dev.parent = parent;
>  
> -	udc->dev.release = usb_udc_release;
> -	udc->dev.class = udc_class;
>  	udc->dev.parent = parent;
>  
>  	udc->gadget = gadget;
> @@ -247,6 +229,7 @@ found:
>  
>  	if (udc->driver)
>  		usb_gadget_remove_driver(udc);
> +	kfree(udc);
>  }
>  EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
>  
> -- 
> 2.45.2
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index 37c0ee43c52..275d6fe7be8 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -41,7 +41,6 @@  struct usb_udc {
 	struct list_head		list;
 };
 
-static struct class *udc_class;
 static LIST_HEAD(udc_list);
 DEFINE_MUTEX(udc_lock);
 
@@ -150,21 +149,6 @@  static inline void usb_gadget_udc_stop(struct usb_udc *udc)
 	udc->gadget->ops->udc_stop(udc->gadget);
 }
 
-/**
- * usb_udc_release - release the usb_udc struct
- * @dev: the dev member within usb_udc
- *
- * This is called by driver's core in order to free memory once the last
- * reference is released.
- */
-static void usb_udc_release(struct device *dev)
-{
-	struct usb_udc *udc;
-
-	udc = container_of(dev, struct usb_udc, dev);
-	kfree(udc);
-}
-
 /**
  * usb_add_gadget_udc - adds a new gadget to the udc class driver list
  * @parent: the parent device to this udc. Usually the controller driver's
@@ -185,8 +169,6 @@  int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
 	dev_set_name(&gadget->dev, "gadget");
 	gadget->dev.parent = parent;
 
-	udc->dev.release = usb_udc_release;
-	udc->dev.class = udc_class;
 	udc->dev.parent = parent;
 
 	udc->gadget = gadget;
@@ -247,6 +229,7 @@  found:
 
 	if (udc->driver)
 		usb_gadget_remove_driver(udc);
+	kfree(udc);
 }
 EXPORT_SYMBOL_GPL(usb_del_gadget_udc);