public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
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	[thread overview]
Message-ID: <review-patch2-20260531-rust_serdev-v11-2-dee8e0d830f1@posteo.de> (raw)
In-Reply-To: <20260531-rust_serdev-v11-2-dee8e0d830f1@posteo.de>

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(EINVAL)`, 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 worth noting in a comment that the asymmetry is intentional. The `set_baudrate` API returns the actual rate set on failure rather than an error code — 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<Bound>,
    _this: Pin<&Self>,
    data: &[u8],
) -> usize {
    let _ = sdev.write_all(data, serdev::Timeout::Max);
    data.len()
}
```

This is an echo server — 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<serdev::Device>`:**

```rust
struct SampleDriver {
    sdev: ARef<serdev::Device>,
}
```

This takes a reference-counted reference to the device in `probe`:
```rust
Ok(Self { sdev: sdev.into() })
```

This is fine — it stores a `Device<Normal>` (via the `impl_device_context_into_aref!` conversion) for use in `Drop` to print a debug message.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-06-04  5:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-30 22:51 [PATCH v11 0/3] rust: add basic serial device bus abstractions Markus Probst via B4 Relay
2026-05-30 22:51 ` [PATCH v11 1/3] " Markus Probst via B4 Relay
2026-05-30 23:51   ` Danilo Krummrich
2026-05-31  6:58     ` Onur Özkan
2026-05-31  7:01       ` Onur Özkan
2026-05-31 16:37       ` Markus Probst
2026-05-31 17:57         ` Danilo Krummrich
2026-05-31 19:42     ` Markus Probst
2026-05-31 21:49       ` Danilo Krummrich
2026-05-31 22:00         ` Markus Probst
2026-05-31 22:32           ` Danilo Krummrich
2026-06-01  0:13             ` Markus Probst
2026-06-04  5:07   ` Claude review: " Claude Code Review Bot
2026-05-30 22:51 ` [PATCH v11 2/3] samples: rust: add Rust serial device bus sample device driver Markus Probst via B4 Relay
2026-06-04  5:07   ` Claude Code Review Bot [this message]
2026-05-30 22:51 ` [PATCH v11 3/3] MAINTAINERS: serdev: Add self for serdev Markus Probst via B4 Relay
2026-06-04  5:07   ` Claude review: " Claude Code Review Bot
2026-06-04  5:07 ` Claude review: rust: add basic serial device bus abstractions Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-06-03 15:56 [PATCH v12 0/3] " Markus Probst via B4 Relay
2026-06-03 15:56 ` [PATCH v12 2/3] samples: rust: add Rust serial device bus sample device driver Markus Probst via B4 Relay
2026-06-04  1:33   ` Claude review: " Claude Code Review Bot
2026-05-30 19:25 [PATCH v10 0/5] rust: add basic serial device bus abstractions Markus Probst
2026-05-30 19:25 ` [PATCH v10 4/5] samples: rust: add Rust serial device bus sample device driver Markus Probst
2026-06-04  5:18   ` Claude review: " Claude Code Review Bot
2026-05-30 17:36 [PATCH v9 0/3] rust: add basic serial device bus abstractions Markus Probst
2026-05-30 17:36 ` [PATCH v9 2/3] samples: rust: add Rust serial device bus sample device driver Markus Probst
2026-06-04  5:28   ` Claude review: " Claude Code Review Bot
2026-05-30  1:13 [PATCH v8 0/5] rust: add basic serial device bus abstractions Markus Probst via B4 Relay
2026-05-30  1:13 ` [PATCH v8 4/5] samples: rust: add Rust serial device bus sample device driver Markus Probst via B4 Relay
2026-06-04  5:57   ` Claude review: " Claude Code Review Bot
2026-04-29 18:21 [PATCH v7 0/4] rust: add basic serial device bus abstractions Markus Probst via B4 Relay
2026-04-29 18:21 ` [PATCH v7 4/4] samples: rust: add Rust serial device bus sample device driver Markus Probst via B4 Relay
2026-05-05  1:18   ` Claude review: " Claude Code Review Bot
2026-04-27 18:05 [PATCH v6 0/4] rust: add basic serial device bus abstractions Markus Probst via B4 Relay
2026-04-27 18:05 ` [PATCH v6 4/4] samples: rust: add Rust serial device bus sample device driver Markus Probst via B4 Relay
2026-04-28  4:14   ` Claude review: " Claude Code Review Bot
2026-04-20 20:07 [PATCH v5 0/4] rust: add basic serial device bus abstractions Markus Probst
2026-04-20 20:07 ` [PATCH v5 4/4] samples: rust: add Rust serial device bus sample device driver Markus Probst
2026-04-22 23:21   ` Claude review: " Claude Code Review Bot
2026-04-11 15:10 [PATCH v4 0/4] rust: add basic serial device bus abstractions Markus Probst via B4 Relay
2026-04-11 15:10 ` [PATCH v4 4/4] samples: rust: add Rust serial device bus sample device driver Markus Probst via B4 Relay
2026-04-11 22:55   ` Claude review: " Claude Code Review Bot
2026-03-13 18:12 [PATCH v3 0/4] rust: add basic serial device bus abstractions Markus Probst
2026-03-13 18:12 ` [PATCH v3 4/4] samples: rust: add Rust serial device bus sample device driver Markus Probst
2026-03-16  2:17   ` Claude review: " Claude Code Review Bot
2026-03-06 19:35 [PATCH v2 0/4] rust: add basic serial device bus abstractions Markus Probst
2026-03-06 19:35 ` [PATCH v2 4/4] samples: rust: add Rust serial device bus sample device driver Markus Probst
2026-03-08 22:21   ` Claude review: " Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch2-20260531-rust_serdev-v11-2-dee8e0d830f1@posteo.de \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox