summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-02-07 10:49:50 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-02-08 09:13:58 +0100
commit5da1c3066a33a193a3fd92c022b6339d447d2d7e (patch)
tree5560c041dd0c7e02458c6556077166980226298e /include
parent62f3df2fcdb693680dd5fa6b70eecdb07806c324 (diff)
downloadbarebox-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 'include')
-rw-r--r--include/driver.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/driver.h b/include/driver.h
index 859a0958ab..4937091ca9 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -141,6 +141,10 @@ void device_detect_all(void);
*/
int unregister_device(struct device_d *);
+void free_device_res(struct device_d *dev);
+void free_device(struct device_d *dev);
+
+
/* Iterate over a devices children
*/
#define device_for_each_child(dev, child) \