diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2022-02-07 10:49:50 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-02-08 09:13:58 +0100 |
commit | 5da1c3066a33a193a3fd92c022b6339d447d2d7e (patch) | |
tree | 5560c041dd0c7e02458c6556077166980226298e /drivers/usb | |
parent | 62f3df2fcdb693680dd5fa6b70eecdb07806c324 (diff) | |
download | barebox-5da1c3066a33a193a3fd92c022b6339d447d2d7e.tar.gz barebox-5da1c3066a33a193a3fd92c022b6339d447d2d7e.tar.xz |
driver: Add functions to free devices
struct device_d has some dynamically allocated members, namely .name and
.unique_name. These are normally not freed when a device is freed. Add
two functions to free these resources. free_device_res() only frees the
allocated members, but not the device itself. This is suitable for cases
where the device is embedded in another struct. free_device() frees the
allocated members along with the device itself. This can be called when
the device itself has been directly allocated.
Some users which should use these functions are also fixed in this
patch.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20220207094953.949868-5-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/usb.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 4eede13a11..34a0f004f7 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -534,6 +534,7 @@ void usb_free_device(struct usb_device *usbdev) { dma_free(usbdev->descriptor); dma_free(usbdev->setup_packet); + free_device_res(&usbdev->dev); free(usbdev); } |