DEVICE_GET_PROPERTY(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… device_get_property β€” access device specific data πŸ’…

okay so bestie, we're in section 9 of the Kernel Developer's Manual today (that's the DEVICE_GET_PROPERTY(9) one, yes ma'am πŸ‘‘) and it's literally all about peeking at the device-specific data your parent bus handed you. no cap, it's giving "backstage pass to the hardware" energy.


✨ NAME ✨

device_get_property, device_has_property β€” access device specific data 🫢


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/bus.h>

ssize_t
device_get_property(device_t dev, const char *prop, void *val,
    size_t sz, device_property_type_t type);

bool
device_has_property(device_t dev, const char *prop);

look at those two little icons, so clean, so demure πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So the whole vibe here is: you get access to device specific data that the parent bus provides. Drivers can use these properties to obtain device capabilities and set necessary quirks. like, the bus is your bestie and it's handing you the tea 🍡

You tell it what kind of data you're expecting with the type argument. Currently the following types are supported:

  • DEVICE_PROP_BUFFER β€” the underlying property is a string of bytes. literally just bytes, iconic ✨
  • DEVICE_PROP_ANY β€” wildcard property type. anything goes, main character energy 🌈
  • DEVICE_PROP_HANDLE β€” following a reference, the underlying property is a handle of the respective bus.
  • DEVICE_PROP_UINT32 β€” the underlying property is an array of unsigned 32 bit integers. and heads up: the sz argument shall be a multiple of 4. that's not a suggestion bestie, that's the law 🚨
  • DEVICE_PROP_UINT64 β€” the underlying property is an array of unsigned 64 bit integers. same deal, the sz argument shall be a multiple of 8. do the math or get wrecked 😭

πŸŽ€ NOTES πŸŽ€

  • You can pass NULL as pointer to property's value when calling device_get_property() to obtain its size. cute little trick, zero-capitalism way to just ask "how big is it tho" πŸ™ˆ
  • Currently this interface is implemented by simplebus(4) and acpi(4). those are the two that showed up to the party πŸ’–

⭐ RETURN VALUES ⭐

  • device_get_property() β€” if successful returns property's size, otherwise returns -1. so either you get the size or you get the -1 of shame πŸ’€
  • device_has_property() β€” returns true if given property was found. simple, honest, no drama 🌸

πŸ”₯ SEE ALSO πŸ”₯

acpi(4), simplebus(4), device(9)


🧚 AUTHORS 🧚

This manual page was written by Bartlomiej Grzesik. absolute legend, ate and left no crumbs πŸ‘‘


and that's the whole page bestie, no gatekeeping πŸ’œ this beauty came to you from the Debian fam, dated September 29, 2022 β€” so yeah, she's got a lil vintage moment going on, but the info is still slaying fr fr πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from