class_dev_iter_next(9)
β¨ class_dev_iter_next(9) β¨
okay so bestie, welcome to the Kernel API Manual π this one's a lil function that walks your device iterator forward one step at a time. it's giving "next, please!" energy and honestly? iconic.
πΈ NAME πΈ
class_dev_iter_next β iterate to the next device π¦
β¨ SYNOPSIS β¨
struct device * class_dev_iter_next (struct class_dev_iter *iter );
that's it. that's the whole vibe. no cap π
π ARGUMENTS π
iterβ the class iterator you wanna proceed forward, bestie. like, scoot it along to the next one π«Ά
π DESCRIPTION π
So what does it do? It proceeds iter to the next device and returns it. Simple, cute, slay. π₯
If iteration is complete, it returns NULL. That's your "we're done here, nothing left to see" moment π β not an error, just the end of the line, fr fr.
Now here's the part you actually need to remember, and I'm saying it with my whole chest: the returned device is referenced and it won't be released until the iterator is proceeded to the next device or exited. So it's holding onto that device for you the whole time π. The caller is free to do literally whatever it wants with the device β including calling back into class code. yes, even that. go off π β¨
π§ no notes, just don't forget that the reference hangs around until the iterator moves on or gets exited. that's the whole plot twist.
π SEE ALSO π
Kernel file ./drivers/base/class.c β and the whole friend group:
class_to_subsys(9)class_create(9)class_destroy(9)class_dev_iter_init(9)class_dev_iter_exit(9)class_for_each_device(9)class_find_device(9)class_compat_register(9)class_compat_unregister(9)class_compat_create_link(9)class_compat_remove_link(9)class_is_registered(9)
and that's the page, bestie π this lil gem lives in ./drivers/base and the version notes are dated October 2026, all filed under the name class_dev_iter_next(9). mwah π go iterate something cute β¨πΈ
π¦ 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