DEVICE_ATTR_RO(9)
π DEVICE_ATTR_RO(9) π
ok so this is a page from the Kernel API Manual (yes, that's the manual name, and yes it's giving very serious business) and it's about one tiny macro that makes your life so much easier, bestie. buckle up π
β¨ NAME β¨
DEVICE_ATTR_RO β Define a readable device attribute. literally that's it, that's the whole job π«Ά
πΈ SYNOPSIS πΈ
DEVICE_ATTR_RO (_name );
that's the whole call. one argument. no drama. icon behavior honestly π
π¦ ARGUMENTS π¦
_nameβ Attribute name. that's it. that's the parameter. it's the name of your attribute and it absolutely eats π
π DESCRIPTION π
okay so here's the tea: this macro is Like DEVICE_ATTR, but with two little differences that make it supremely chill:
_modeis0444_showis<_name>_show
periodt. read-only, and the show function gets named after whatever you passed in. no cap, you literally don't have to spell anything out yourself β the macro handles the naming and the permissions for you, and honestly? obsessed πβ¨
fr fr double-check your <_name>_show function actually exists before you go compiling, iykyk π
π SEE ALSO π
okay this list is LONG and honestly lowkey iconic, so we're doing zero skipping. every single one, in order, exactly as written, no cap:
Kernel file ./include/linux/device.h
struct subsys_interface(9)struct device_attribute(9)struct dev_ext_attribute(9)DEVICE_ATTR(9)DEVICE_ATTR_RW(9)DEVICE_ATTR_ADMIN_RW(9)DEVICE_ATTR_RW_NAMED(9)DEVICE_ATTR_ADMIN_RO(9)DEVICE_ATTR_RO_NAMED(9)DEVICE_ATTR_WO(9)DEVICE_ATTR_WO_NAMED(9)DEVICE_ULONG_ATTR(9)DEVICE_INT_ATTR(9)DEVICE_BOOL_ATTR(9)DEVICE_STRING_ATTR_RO(9)enum device_link_state(9)enum dl_dev_state(9)enum device_removable(9)struct dev_links_info(9)struct dev_msi_info(9)enum device_physical_location_panel(9)enum device_physical_location_vertical_position(9)enum device_physical_location_horizontal_position(9)struct device_physical_location(9)enum struct_device_flags(9)struct device(9)struct device_link(9)device_set_driver_override(9)device_has_driver_override(9)device_match_driver_override(9)device_iommu_mapped(9)dev_name(9)dev_bus_name(9)device_find_child_by_name(9)device_find_any_child(9)device_lock_set_class(9)device_lock_reset_class(9)
like, that's a whole friend group right there and they all slay in their own way ππ
and that's the whole page, bestie!! π§ββοΈ this one came from the good people over at ./include/linux, dated October 2026, and the manual itself answers to the name DEVICE_ATTR_RO(9) β go read it again if you forgot already, no judgment, it's a lot ππ π
π¦ 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