]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rust: device: Implement accessors for firmware properties
authorRemo Senekowitsch <remo@buenzli.dev>
Wed, 11 Jun 2025 10:29:05 +0000 (12:29 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Thu, 12 Jun 2025 22:58:53 +0000 (00:58 +0200)
commit2db611374cef12bd793b72d5728f0ecd1affeb17
tree64fca45b937222d32d8e657af5d4e1bada23f399
parent9bd791d9413b4b65e203c4ff84c8b8b2c8c3b770
rust: device: Implement accessors for firmware properties

Add methods to FwNode for reading several firmware property types like
strings, integers and arrays.

Most types are read with the generic `property_read` method. There are
two exceptions:

* `property_read_bool` cannot fail, so the fallible function signature
  of `property_read` would not make sense for reading booleans.

* `property_read_array_vec` can fail because of a dynamic memory
  allocation. This error must be handled separately, leading to a
  different function signature than `property_read`.

The traits `Property` and `PropertyInt` drive the generic behavior
of `property_read`. `PropertyInt` is necessary to associate
specific integer types with the C functions to read them. While
there is a C function to read integers of generic sizes called
`fwnode_property_read_int_array`, it was preferred not to make this
public.

Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Co-developed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Remo Senekowitsch <remo@buenzli.dev>
Link: https://lore.kernel.org/r/20250611102908.212514-7-remo@buenzli.dev
[ Properly include kernel::device::private::Sealed; add explicit type
  annotations for core::mem::transmute(). - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/device/property.rs