STRUCT GPIOHANDLE_REQUEST(9)
π struct gpiohandle_request(9) β like, the whole kernel API manual vibe but make it make sense π
okay bestie so this is a page from the Kernel API Manual, and it's all about struct gpiohandle_request β literally the little info packet you hand over when you're asking the kernel for some GPIO lines. no cap, it's giving "permission slip for pins" energy π¦
β¨ NAME β¨
struct gpiohandle_request β the full rundown on what a GPIO handle request actually is π
πΈ SYNOPSIS πΈ
struct gpiohandle_request {
__u32 lineoffsets[GPIOHANDLES_MAX];
__u32 flags;
__u8 default_values[GPIOHANDLES_MAX];
char consumer_label[GPIO_MAX_NAME_SIZE];
__u32 lines;
int fd;
};
π Members π
lineoffsetsβ the glow-up list of lines you want, and you specify each one by its offset index for the GPIO device it belongs to. it's the "which pins tho" field π―flagsβ the flags you want for those GPIO lines, likeGPIOHANDLE_REQUEST_OUTPUT,GPIOHANDLE_REQUEST_ACTIVE_LOWetc, all added together. and here's the tea β: even if you're requesting multiple lines at once, the same flags have to work for every single one of them. so if you want different flags per line, sorry bestie, you gotta request them one by one π. you can batch a bunch of input lines or a bunch of output lines, but they all have to share the same characteristics β all inputs or all outputs, all active low, etc. no mixing, periodt β¨default_valuesβ ifGPIOHANDLE_REQUEST_OUTPUTis set for a line you're requesting, this is where you say what the default output value should be:0(inactive) or1(active). and the wild part? anything that isn't0or1gets interpreted as active. literally anything. so maybe just stick to0and1πconsumer_labelβ a desired consumer label for the GPIO line(s) you picked, like"my-bitbanged-relay"β it's the little name tag so you know who's using the pin π·οΈ adorable, honestly.linesβ how many lines you're requesting in this request, i.e. how many of the fields in those arrays above are actually valid. set it to1to request a single line πfdβ after a successfulGPIO_GET_LINEHANDLE_IOCTLoperation, this holds a valid anonymous file descriptor representing the request. congrats, you have a handle now π
β οΈ Note β οΈ
okay this is the important one, don't scroll past π«Ά β this struct is part of ABI v1 and it is deprecated. use ABI v2 and struct gpio_v2_line_request instead. the old one still exists, but it's giving "legacy" energy π
π SEE ALSO π
Kernel file ./include/uapi/linux/gpio.h and all the friends in the extended universe: struct gpiochip_info(9), enum gpio_v2_line_flag(9), struct gpio_v2_line_values(9), enum gpio_v2_line_attr_id(9), struct gpio_v2_line_attribute(9), struct gpio_v2_line_config_attribute(9), struct gpio_v2_line_config(9), struct gpio_v2_line_request(9), struct gpio_v2_line_info(9), enum gpio_v2_line_changed_type(9), struct gpio_v2_line_info_changed(9), enum gpio_v2_line_event_id(9), struct gpio_v2_line_event(9), struct gpioline_info(9), struct gpioline_info_changed(9), struct gpiohandle_config(9), struct gpiohandle_data(9), struct gpioevent_request(9), struct gpioevent_data(9) β
and that's the whole page, bestie π this one lives under ./include/uapi/linux, dated October 2026, and it's filed as struct gpiohandle_request(9) β go forth and request lines responsibly, ily π§π
π¦ 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