devres_destroy(9)
π devres_destroy(9) β from the Kernel API Manual, bestie π
okay so this is devres_destroy(9), straight out of the Kernel API Manual, and it's about finding a device resource and justβ¦ yeeting it. no cap. let's get into it β¨
πΈ NAME πΈ
devres_destroy β bestie, it finds a device resource and destroys it. that's the whole vibe. π
β¨ SYNOPSIS β¨
int devres_destroy (struct device *dev , dr_release_t release ,
dr_match_t match , void *match_data );
like, look at that signature. iconic. four args, one int back. periodt. π
π«Ά ARGUMENTS π«Ά
devβ the device you're pulling the resource out of. this is your main character. πreleaseβ look for resources associated with this release function. that's the little tag you're matching on, iykyk. π·οΈmatchβ the match function, and heads up: it's optional. yes bestie, optional, we love a flexible queen. πmatch_dataβ the data you're feeding into that match function. π
π DESCRIPTION π
so what this does is: it finds the latest devres of dev that's associated with release and for which match returns 1. and if match is NULL? it's considered to match all β no filter, we're accepting everyone at the door. π
if it finds one, the resource is removed atomically and freed. boom. gone. slay. π₯
β οΈ but bestie, listen, this part is important: the release function for the resource will not be called. only the devres-allocated data gets freed. so the caller β that's you β becomes responsible for freeing any other data. no cap, don't forget. π
β RETURN β
0if the devres is found and freed. ate. π-ENOENTif it's not found. she wasn't there, we looked, moving on. π¦
π§ SEE ALSO π§
the whole friend group, honestly β first up, the kernel file ./drivers/base/devres.c, and then:
__devres_alloc_node(9)devres_for_each_res(9)devres_free(9)devres_add(9)devres_find(9)devres_get(9)devres_remove(9)devres_release(9)devres_release_all(9)devres_open_group(9)devres_close_group(9)devres_remove_group(9)devres_release_group(9)__devm_add_action(9)devm_remove_action_nowarn(9)devm_release_action(9)devm_kmalloc(9)devm_krealloc(9)devm_kstrdup(9)devm_kstrdup_const(9)devm_kvasprintf(9)devm_kasprintf(9)devm_kfree(9)devm_kmemdup(9)devm_kmemdup_const(9)devm_get_free_pages(9)devm_free_pages(9)__devm_alloc_percpu(9)
okay that's the whole page, ily, go free your memory responsibly π
sign-off szn: this one lives under ./drivers/base, dated October 2026, and it's devres_destroy(9) β catch you in the next one, bestie π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms