enclosure_find(9)
π enclosure_find(9) π
okay bestie, welcome to the enclosure_find(9) page from the Kernel API Manual β yes we are in kernel land, and yes it's giving very niche but very iconic. π§β¨
β¨ NAME β¨
enclosure_find β find an enclosure given a parent device π«Ά
πΈ SYNOPSIS πΈ
struct enclosure_device * enclosure_find (struct device *dev , struct
enclosure_device *start );
π ARGUMENTS π
devβ the parent to match against. literally the thing we're checking against, no cap.startβ Optional enclosure device to start from (NULLif none). iykyk, it's the "begin here" spot.
π¦ DESCRIPTION π¦
so the way this works: enclosure_find looks through the list of registered enclosures to find all those with dev as a parent. If no enclosure is found, it returns NULL β that's the vibe check failing, bestie π.
start can be used as a starting point to obtain multiple enclosures per parent. It should begin with NULL, and then be set to each returned enclosure device. That's the whole loop situation. π«
It obtains a reference to the enclosure class device, and that reference must be released with put_device β don't forget, or the kernel will be side-eyeing you fr fr.
If start is not NULL, a reference must be taken on it which is released before returning. This allows a loop through all enclosures to exit with only the reference on the enclosure of interest held. iconic behavior, honestly π.
Note that the dev may correspond to the actual device housing the enclosure, in which case no iteration via start is required. so don't do extra work for no reason, bestie π
.
π SEE ALSO π
Kernel file ./drivers/misc/enclosure.c and the whole friend group:
enclosure_for_each_device(9)enclosure_register(9)enclosure_unregister(9)enclosure_component_alloc(9)enclosure_component_register(9)enclosure_add_device(9)enclosure_remove_device(9)
kisses, this page is straight outta ./drivers/misc and dated October 2026 β bestie, that's the source and date, and we are done πβ¨
π¦ 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