of_parse_pha...h_fixed_args(9)
π of_parse_phandle_with_fixed_args(9) β a Kernel API Manual moment β¨
okay so bestie, welcome to the Kernel API Manual, and today's main character is of_parse_phandle_with_fixed_args. it's giving device-tree-legend, no cap π
πΈ NAME πΈ
of_parse_phandle_with_fixed_args β find a node pointed by phandle in a list π
β¨ SYNOPSIS β¨
int of_parse_phandle_with_fixed_args (const struct device_node *np ,
const char *list_name , int cell_count , int index ,
struct of_phandle_args *out_args );
like, that's the whole signature, copy it exactly, don't be weird about it π«Ά
π¦ ARGUMENTS π¦
npβ pointer to a device tree node containing a listlist_nameβ the property name that contains a listcell_countβ number of argument cells following the phandleindexβ which phandle in the list you wanna parse out (the index, bestie)out_argsβ optional pointer to an output arguments structure β it will get filled π
π DESCRIPTION π
so this function is lowkey iconic for parsing lists of phandles and their arguments together. it returns 0 on success and fills out_args, and on error it returns the appropriate errno value π (yes, an actual errno, so check it, don't just vibe and move on).
β οΈ and listen β the caller is responsible for callingof_node_puton the returnedout_args->nppointer. that's on you, bestie. not on the function. do your cleanup, periodt π§Ήβ¨
Example, because seeing it is believing:
phandle1: node1 {
};
phandle2: node2 {
};
node3 {
list = <phandle1 0 2 phandle2 2 3>;
};
and to get a device_node of the node2 node you may call this:
of_parse_phandle_with_fixed_args(node3, "list", 2, 1, args);
the way that just works ππ₯
π SEE ALSO π
all the siblings and cousins, fr fr β go read these too:
- Kernel file
./include/linux/of.h of_node_init(9)of_machine_is_compatible(9)of_parse_phandle(9)of_parse_phandle_with_args(9)of_parse_phandle_with_optional_args(9)of_phandle_args_equal(9)of_property_count_u8_elems(9)of_property_count_u16_elems(9)of_property_count_u32_elems(9)of_property_count_u64_elems(9)of_property_read_string_array(9)of_property_count_strings(9)of_property_read_string_index(9)of_property_present(9)of_property_read_u8_array(9)of_property_read_u16_array(9)of_property_read_u32_array(9)of_property_read_u64_array(9)struct of_changeset_entry(9)struct of_changeset(9)of_device_is_system_power_controller(9)of_have_populated_dt(9)
and that's the tea π this lil gem lives over in ./include/linux, dated October 2026, and it's filed under of_parse_pha...h_fixed_args(9) in your friendly neighborhood Kernel API Manual. mwah π bye bestie, go put your nodes away ππ
π¦ 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