DEVICE_ATTR_RW_NAMED(9)
π DEVICE_ATTR_RW_NAMED π
okay bestie, so this one lives in the Kernel API Manual and it's genuinely so cute β it's the macro that lets you make a read-write device attribute whose sysfs name is not the same as the function name. like, the glow-up where the vibe check name and the government name are two different things π¦
β¨ NAME β¨
DEVICE_ATTR_RW_NAMED β define a read-write device attribute where the sysfs name is lowkey different from the function name. that's the whole thing, no cap π
πΈ SYNOPSIS πΈ
DEVICE_ATTR_RW_NAMED (_name , _attrname );
π ARGUMENTS π
_nameβ the attribute function preface, aka the little name-bit that goes on the function side of things π«Ά_attrnameβ the attribute name as it wil be exposed in the sysfs. this is the name the world actually sees, so pick a good one β¨
π DESCRIPTION π
so it's literally like DEVICE_ATTR_RW, bestie β same energy, same read-write slay β except it also lets you reuse names under separate paths in the same driver. iconic behaviour honestly π
like yes you're reusing the name, but it's fine because the paths are different. it's giving "same name, different context," and it works π₯
π¦ SEE ALSO π¦
Kernel file ./include/linux/device.h β and then the whole extended friend group, all of them, no one left out of the group chat π
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_RO(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)
go read them all, i'll wait π
reminder bestie: this page ships out of ./include/linux, dated October 2026 β that's the source and the date, written down so we never forget ποΈπ
and that's the page!! mwah, go name some attributes, you're gonna slay π§ββοΈπβ π
π¦ 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