From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: samples: rust: add Rust serial device bus sample device driver Date: Thu, 04 Jun 2026 15:07:55 +1000 Message-ID: In-Reply-To: <20260531-rust_serdev-v11-2-dee8e0d830f1@posteo.de> References: <20260531-rust_serdev-v11-0-dee8e0d830f1@posteo.de> <20260531-rust_serdev-v11-2-dee8e0d830f1@posteo.de> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Inconsistent error handling for `set_baudrate`:** ```rust if sdev .set_baudrate( dev.fwnode() .and_then(|fwnode| fwnode.property_read(c"baudrate").optional()) .unwrap_or(115200), ) .is_err() { return Err(EINVAL); } sdev.set_flow_control(false); sdev.set_parity(serdev::Parity::None)?; ``` `set_baudrate` uses an explicit `if .is_err()` check and returns `Err(EINVA= L)`, while `set_parity` uses `?` to propagate the error. This inconsistency= is because `set_baudrate` returns `Result<(), u32>` (where the error value= is the actual baudrate set, which can't use `?` with `Error`), but it's wo= rth noting in a comment that the asymmetry is intentional. The `set_baudrat= e` API returns the actual rate set on failure rather than an error code =E2= =80=94 this is a reasonable Rust wrapper for the C semantics where `serdev_= device_set_baudrate` returns the actual baudrate (0 if not set). **The `receive` callback echoes all data back:** ```rust fn receive<'bound>( sdev: &'bound serdev::Device, _this: Pin<&Self>, data: &[u8], ) -> usize { let _ =3D sdev.write_all(data, serdev::Timeout::Max); data.len() } ``` This is an echo server =E2=80=94 fine for a sample. Ignoring the `write_all= ` error with `let _` is acceptable in a sample, though it always claims to = have consumed all bytes regardless of whether the write succeeded. This is = a reasonable simplification for demonstration purposes. **`SampleDriver` stores `ARef`:** ```rust struct SampleDriver { sdev: ARef, } ``` This takes a reference-counted reference to the device in `probe`: ```rust Ok(Self { sdev: sdev.into() }) ``` This is fine =E2=80=94 it stores a `Device` (via the `impl_device_c= ontext_into_aref!` conversion) for use in `Drop` to print a debug message. --- Generated by Claude Code Patch Reviewer