for_each_old...tor_in_state(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… for_each_oldnew_connector_in_state(9) β€” the Kernel API Manual, but make it make sense πŸŽ€

okay bestie so you're in the Linux kernel API manual (yep, the Kernel API Manual) and you clicked on for_each_old...tor_in_state(9) β€” no worries, the full name is for_each_oldnew_connector_in_state, the header just truncates it because apparently man page headers have a character limit and no chill 😭 anyway. This one's a macro. It's giving "loop over everything" energy. Let's go πŸ¦‹


✨ NAME ✨

for_each_oldnew_connector_in_state β€” iterate over all connectors in an atomic update.

That's it. That's the whole vibe. It's a for-each loop but for connectors, and it's atomic about it. Iconic. πŸ‘‘


🌸 SYNOPSIS 🌸

for_each_oldnew_connector_in_state (__state , connector ,
       old_connector_state , new_connector_state , __i );

Five things go in. Do not lose track of them, bestie, I'm serious πŸ™ˆ


πŸŽ€ ARGUMENTS πŸŽ€

  • __state β€” a struct drm_atomic_commit pointer. The whole atomic update situation lives in here, and this is the thing you're iterating over. Main character energy fr fr πŸ’–
  • connector β€” a struct drm_connector iteration cursor. Like, this is the little pointer that walks down the list as the loop runs. It's the cursor. It scrolls. Slay. πŸ–±οΈ
  • old_connector_state β€” a struct drm_connector_state iteration cursor, specifically for the old state. The before pic πŸ“Έ
  • new_connector_state β€” a struct drm_connector_state iteration cursor, specifically for the new state. The after pic ✨
  • __i β€” an int iteration cursor, and it is explicitly "for macro-internal use" only. So like… hands off, bestie. That's the macro's business, not yours. Don't touch the internals πŸ™…β€β™€οΈ (iykyk)

πŸ’œ DESCRIPTION πŸ’œ

So what does it do?

It iterates over all connectors in an atomic update, tracking both the old state and the new state at the same time. Two cursors, one loop, zero crumbs. πŸ’…

Why would you even want that? Because sometimes you actually need to consider the state delta β€” like, what changed between old and new β€” and this macro hands you both sides so you can compare without doing extra work. Literally so convenient.

The manpage calls out one specific place this matters: atomic check functions. That's the exact spot where you'd be looking at the difference between the old and new state, so this is your macro. Periodt. πŸ”₯


🌈 SEE ALSO 🌈

The kernel file this baby lives in: ./include/drm/drm_atomic.h πŸ“

And the whole extended friend group (this list is long, bestie, but we ride for every single one of them, no skipping 🫢):

lowkey that's a whole group chat right there πŸ’€ but they're all relevant, I promise β€” go read them, they ate πŸ“

and that's the page, bestie!! 🌟 this cutie comes to you from ./include/drm and it's dated October 2026 β€” mwah, go write some atomic check functions, you've got this πŸ’–βœ¨πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from