for_each_hwgpio_in_range(9)
π for_each_hwgpio_in_range(9) β from the Kernel API Manual, bestie β¨
Okay so picture this: it's you, a gpio_chip, and a whole range of GPIOs that need iterating. This macro is your girl. It iterates over all GPIOs in a given range, no cap, and honestly? Iconic behaviour. π
πΈ SYNOPSIS πΈ
for_each_hwgpio_in_range (_chip , _i , _base , _size , _label );
That's literally the whole invocation. Five args. Eat it up. π
β¨ ARGUMENTS β¨
_chipβ the chip you're iterating over. The motherboard main character energy. π_iβ the loop counter. She's counting, she's keeping track, she's doing the work behind the scenes. π_baseβ the first GPIO in the ranger. (And yes, the manpage really says "ranger" β not range β that's canon now, we're keeping it, love her for it π«Ά)_sizeβ how many GPIOs to check, starting from_base. Like, the size of the squad. π_labelβ the place where you store the address of the label if the GPIO is requested. Aka: if somebody's using it, you get the name. And for unused GPIOs? Set it toNULL. Empty slot, no drama, moving on. β
π Real talk:_labelonly gets a label when the GPIO is requested β for unused ones it'sNULL. Don't go reading it expecting a name that isn't there.
π SEE ALSO π
All the besties in the same friend group:
- Kernel file
./include/linux/gpio/driver.h struct gpio_irq_chip(9)struct gpio_chip(9)for_each_hwgpio(9)for_each_requested_gpio_in_range(9)gpiochip_add_data(9)struct gpio_pin_range(9)
π that's the page, bestie β go iterate slayfully π
Dropping this from ./include/linux/gpio, dated October 2026, and it's signed the for_each_hwgpio_in_range(9) way. π¦ Not me getting emotional over a kernel macro. π
π¦ 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