of_property_read_u16_array(9)
π of_property_read_u16_array(9) π
okay so this is a page straight out of the Kernel API Manual, bestie β yes the actual kernel API manual, we're in the big leagues now π β and it's all about of_property_read_u16_array, which is the little function that goes "hey, does this device node have that property? cool, gimme the 16-bit numbers in it" β¨
πΈ NAME πΈ
of_property_read_u16_array β find and read an array of u16 from a property. that's it, that's the whole vibe π«Ά
π¦ SYNOPSIS π¦
int of_property_read_u16_array (const struct device_node *np , const
char *propname , u16 *out_values , size_t sz );
literally just copy that exactly, no cap π
β¨ ARGUMENTS β¨
npβ the device node you're reading the property value from. your starting point, your main character π«Άpropnameβ the name of the property we're searching for, iykyk πout_valuesβ pointer to the return value. heads up: it only gets modified if the return value is0, so don't go reading it before you check πszβ how many array elements to read. the count, the amount, the numbers, periodt π
π§ DESCRIPTION π§
so what it does is: it searches for a property inside a device node and reads 16-bit value(s) out of it. simple, iconic, does exactly what it says π
the dts entry of the array should look like this, exactly:
property = /bits/ 16 <0x5000 0x6000 0x7000>;
and one thing to really internalize: out_values is modified only if a valid u16 value can be decoded π like, it's not gonna half-fill your buffer with nonsense and dip β no valid decode, no touch. respect.
π₯ RETURN π₯
0on success β slay, we ate π-EINVALif the property does not exist β it's not there, bestie, it's giving nothing π-ENODATAif the property does not have a value β the property exists but it's empty inside, relatable π-EOVERFLOWif the property data isn't large enough β not enough bytes to go around, overflow behavior, no cap β οΈ
π SEE ALSO π
kernel file ./include/linux/of.h, plus the whole friend group:
of_node_init(9)of_machine_is_compatible(9)of_parse_phandle(9)of_parse_phandle_with_args(9)of_parse_phandle_with_fixed_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_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 whole page, bestie π₯° sourced from ./include/linux, dated October 2026, still signed of_property_read_u16_array(9) β mwah, go read some device trees, 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