enclosure_find(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 (NULL if 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:


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