From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F59E13E02A for ; Sun, 21 Dec 2025 09:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766308319; cv=none; b=NvwXY7dvVhWSaVIBaOe3nFjhZ7mhHUQhxeaBFhenwF5YEfqGHIDfdclkngmFo32tStcC9g9w5bd7FcHF/QzcJx+jPRDGxpcBYjiMnLdYDTakQ+g4J3rPU6QsTY3W1VYi+w3K9uIWyBVXQPayvkC6n+sRUyHnWHIamHPjH6jZsdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766308319; c=relaxed/simple; bh=p4K6ZZ5UDbv6xtedRbkKqqzY+uDr3R/k1JkTcnv+oro=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dRQq49bplB9A+jQz8lzInf9sGhf1Prwog35MG90hNr5KtOQ3DybHXZ/ZRatDPL0ymJOEQvowp7dqNa3yj1cRexkzW9AqpCYobINarlTiojSIXjS5B4MGUaNipOhjJiaHLsaPdrZb8hE/ncrs4F94aWpdEqw10T7RM6ImsuL5Jhc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N6D1rLmk; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N6D1rLmk" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b7355f6ef12so573880466b.3 for ; Sun, 21 Dec 2025 01:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766308316; x=1766913116; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bJxTo1StsAPyAw5V2VT3FLs+d6cjUn62zSVYT6JS2So=; b=N6D1rLmk3gP51ACwD0tA1zW27UOIXVfe4Elg8MJkX2SwEKtjMUQkEt4H44vKWfBN3+ UuzKSSgyne5VGI0uqg82gJajSi/ckpvSznIc5IjQ+QCzCTNu99DS5S0kadt0X5ixbiDO lV8O2Ev5ss3qVIWEAx3J5HedVWbNK/JH2cqXbk3WPlP4vUAx0gd+NWIB1mggy1g4K8JA BG4DPBx8kdaqc/6sdcDOQfH4rH6x78N1Cz3OQdV4tP7FuNill8diV7DyKhuOdPPcAmdi 8JTyT2ph38kgqzE7NT58UmBDEEbctbg1VfqDa2ans/QKw4X6uA4qQD2Hhqvwn2WQE62k t2zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766308316; x=1766913116; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bJxTo1StsAPyAw5V2VT3FLs+d6cjUn62zSVYT6JS2So=; b=Lp0HF98ZMX47H14j+te6AHtpv7eFNooD+PiXOQ62NxQu1xkKfku+2Gygp3usHiJQoF 28diuLTEsBQ3NBqro+rbLjP410diuu/4zlenEBUHtBjsFnk4pr7i+WpwgVWOFK5t6OJT POzq1CAjmscupApmnW6lFWndUTB9Yn/fO7GYGBg+lpHNP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Received: by 2002:a17:907:3fa8:b0:b76:3548:cdef with SMTP id a640c23a62f3a-b8036f2abcbmr808495166b.25.1766308315612; Sun, 21 Dec 2025 01:11:55 -0800 (PST) Received: from ?IPV6:2003:df:bf2d:e300:9f8f:28b1:4136:8493? (p200300dfbf2de3009f8f28b141368493.dip0.t-ipconnect.de. [2003:df:bf2d:e300:9f8f:28b1:4136:8493]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037f37ee8sm704325366b.59.2025.12.21.01.11.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 21 Dec 2025 01:11:55 -0800 (PST) Message-ID: Date: Sun, 21 Dec 2025 10:11:53 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 3/4] samples: rust: add Rust serial device bus sample device driver To: Markus Probst , Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Kari Argillander Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org References: <20251220-rust_serdev-v1-0-e44645767621@posteo.de> <20251220-rust_serdev-v1-3-e44645767621@posteo.de> Content-Language: en-US From: Dirk Behme In-Reply-To: <20251220-rust_serdev-v1-3-e44645767621@posteo.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Markus, On 20.12.25 19:44, Markus Probst wrote: > Add a sample Rust serial device bus device driver illustrating the usage > of the platform bus abstractions. > > This drivers probes through either a match of device / driver name or a > match within the OF ID table. > --- > samples/rust/Kconfig | 10 +++ > samples/rust/Makefile | 1 + > samples/rust/rust_driver_serdev.rs | 175 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 186 insertions(+) ... > diff --git a/samples/rust/rust_driver_serdev.rs b/samples/rust/rust_driver_serdev.rs > new file mode 100644 > index 000000000000..f23b38a26c32 > --- /dev/null > +++ b/samples/rust/rust_driver_serdev.rs > @@ -0,0 +1,175 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +//! Rust Serial device bus device driver sample. > + > +use kernel::{ > + acpi, > + device::{ > + self, > + property::{ > + FwNodeReferenceArgs, > + NArgs, // > + }, > + Bound, > + Core, // > + }, > + of, > + prelude::*, > + serdev, > + str::CString, > + sync::aref::ARef, // > +}; > + > +struct SampleDriver { > + sdev: ARef, > +} > + > +struct Info(u32); > + > +kernel::of_device_table!( > + OF_TABLE, > + MODULE_OF_TABLE, > + ::IdInfo, > + [(of::DeviceId::new(c"test,rust_driver_serdev"), Info(42))] I stopped reading here regarding the new "rust_driver_serdev" but re-reading Rob's https://lore.kernel.org/rust-for-linux/20241022234712.GB1848992-robh@kernel.org/ adding "test," should be fine as-is without any documenation. > +); > + > +kernel::acpi_device_table!( > + ACPI_TABLE, > + MODULE_ACPI_TABLE, > + ::IdInfo, > + [(acpi::DeviceId::new(c"LNUXBEEF"), Info(0))] > +); > + > +#[vtable] > +impl serdev::Driver for SampleDriver { > + type IdInfo = Info; > + type InitialData = (); > + type LateProbeData = (); > + const OF_ID_TABLE: Option> = Some(&OF_TABLE); > + const ACPI_ID_TABLE: Option> = Some(&ACPI_TABLE); > + > + fn probe(sdev: &serdev::Device, info: Option<&Self::IdInfo>) -> impl PinInit { > + let dev = sdev.as_ref(); > + > + dev_dbg!(dev, "Probe Rust Serial device bus device driver sample.\n"); > + > + if let Some(info) = info { > + dev_info!(dev, "Probed with info: '{}'.\n", info.0); > + } Last time I had a look to the log output from rust_driver_platform.rs (where this is copied from?) I was slightly confused to see the "Probed with ..." in the log but not the "Probe Rust ...". Well, I hadn't DEBUG enabled. So I wonder if the combination of `dev_dbg!()` and `dev_info!()` this way should be improved? At least in rust_driver_platform.rs because we could drop that here completely? I mean in rust_driver_platform.rs it makes sense to demonstrate how `info` is supposed to work. But do we need that here? > + if dev.fwnode().is_some_and(|node| node.is_of_node()) { > + Self::properties_parse(dev)?; > + } This is a left over from copy & paste? I mean having all this `properties_parse()` below and calling it here does not make any sense here? And should be dropped completely? > + > + Ok(Self { sdev: sdev.into() }) > + } > + > + fn configure( > + sdev: &serdev::Device, > + _this: Pin<&Self>, > + _id_info: Option<&Self::IdInfo>, > + ) -> Result { > + dev_dbg!( > + sdev.as_ref(), > + "Configure Rust Serial device bus device driver sample.\n" > + ); > + > + sdev.set_baudrate(115200); > + sdev.set_flow_control(false); > + sdev.set_parity(serdev::Parity::None)?; > + Ok(()) > + } > + > + fn late_probe( > + sdev: &serdev::Device, > + _this: Pin<&Self>, > + _initial_data: Self::InitialData, > + ) -> impl PinInit { > + dev_dbg!( > + sdev.as_ref(), > + "Late Probe Rust Serial device bus device driver sample.\n" > + ); > + Ok(()) > + } > + > + fn receive( > + sdev: &serdev::Device, > + _this: Pin<&Self>, > + _late_probe_this: Pin<&Self::LateProbeData>, > + data: &[u8], > + ) -> usize { > + let _ = sdev.write_all(data, serdev::Timeout::MaxScheduleTimeout); Is it intended to have a function with the name `receive()`calling `write()`? > + data.len() > + } > +} > + > +impl SampleDriver { > + fn properties_parse(dev: &device::Device) -> Result { As mentioned above I think this is a left over from copy & paste and should be dropped? Cheers, Dirk