lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9f08de79-4550-4b85-ba36-9615a300e32a@de.bosch.com>
Date: Thu, 24 Apr 2025 07:47:23 +0200
From: Dirk Behme <dirk.behme@...bosch.com>
To: Remo Senekowitsch <remo@...nzli.dev>, Rob Herring <robh@...nel.org>,
	Saravana Kannan <saravanak@...gle.com>, Miguel Ojeda <ojeda@...nel.org>,
	"Alex Gaynor" <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>,
	Gary Guo <gary@...yguo.net>, Björn Roy Baron
	<bjorn3_gh@...tonmail.com>, Benno Lossin <benno.lossin@...ton.me>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, "Trevor
 Gross" <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, "Greg
 Kroah-Hartman" <gregkh@...uxfoundation.org>, "Rafael J. Wysocki"
	<rafael@...nel.org>
CC: <linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
	<rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v2 5/5] samples: rust: platform: Add property read
 examples

On 23/04/2025 14:39, Dirk Behme wrote:
> Hi Remo,
> 
> On 14/04/2025 17:26, Remo Senekowitsch wrote:
>> Add some example usage of the device property read methods for
>> DT/ACPI/swnode properties.
>>
>> Co-developed-by: Rob Herring (Arm) <robh@...nel.org>
>> Signed-off-by: Rob Herring (Arm) <robh@...nel.org>
>> Signed-off-by: Remo Senekowitsch <remo@...nzli.dev>
>> ---
>>  drivers/of/unittest-data/tests-platform.dtsi |  3 +
>>  samples/rust/rust_driver_platform.rs         | 69 +++++++++++++++++++-
>>  2 files changed, 69 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/of/unittest-data/tests-platform.dtsi b/drivers/of/unittest-data/tests-platform.dtsi
>> index 4171f43cf..50a51f38a 100644
>> --- a/drivers/of/unittest-data/tests-platform.dtsi
>> +++ b/drivers/of/unittest-data/tests-platform.dtsi
>> @@ -37,6 +37,9 @@ dev@100 {
>>  			test-device@2 {
>>  				compatible = "test,rust-device";
>>  				reg = <0x2>;
>> +
>> +				test,u32-prop = <0xdeadbeef>;
>> +				test,i16-array = /bits/ 16 <1 2 (-3) (-4)>;
> 
> 
> Is "test,u32-required-prop" missing here? See below ...

Ah, no, sorry, "test,u32-required-prop" isn't there intentionally to
demonstrate the error handling on missing required properties. In this
case I would propose to just remove the '?' to make the sample code not
exit on this intended error:

diff --git a/samples/rust/rust_driver_platform.rs
b/samples/rust/rust_driver_platform.rs
index 01902956e1ca7..b6cbd721a8882 100644
--- a/samples/rust/rust_driver_platform.rs
+++ b/samples/rust/rust_driver_platform.rs
@@ -75,7 +75,7 @@ fn properties_parse(dev: &kernel::device::Device) ->
Result<()> {
         // Missing property without a default will print an error
         let _ = dev
             .property_read::<u32>(c_str!("test,u32-required-prop"))
-            .required()?;
+            .required();

         let prop: u32 =
dev.property_read(c_str!("test,u32-prop")).required()?;
         dev_info!(dev, "'test,u32-prop' is {:#x}\n", prop);

Best regards

Dirk

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ