On 10/27/23 04:15, Greg Kroah-Hartman wrote:
On Thu, Oct 26, 2023 at 09:34:51PM -0300, Martin Rodriguez Reboredo wrote:
[...]
+
+config USB_RUST
+ bool "Rust USB bindings"
+ depends on USB && RUST
+ default n
Nit, "n" is the default, this line is not needed.
Also, if you want to get really picky, _which_ USB is this for, the
"host" apis (you plug a USB device into a Linux maching), or the
"gadget" apis (i.e. Linux is running in the device that you plug into a
USB host)? Linux supports both :)
Nice one! I'll probably target host APIs as of now due to what I have in
my hands.
+ help
+ Enables Rust bindings for USB.
[...]
+//! Rust USB sample.
+
+use kernel::prelude::*;
+
+module! {
+ type: UsbSimple,
+ name: "rust_usb_simple",
+ author: "Martin Rodriguez Reboredo",
+ description: "Rust USB sample",
+ license: "GPL v2",
+}
+
+struct UsbSimple;
"USBSimple" please.
+
+impl kernel::Module for UsbSimple {
+ fn init(_module: &'static ThisModule) -> Result<Self> {
+ pr_info!("usb enabled: {}", !usb::disabled());
+ Ok(UsbSimple)
+ }
+}
I know this is just a fake patch to test the bindings logic, so sorry
for the noise, just wanted to get terminology right :)
thanks,
greg k-h
No, you are right. Because Rust uses upper camel case for struct names
there's the tendency of lowering initialisms, so you can either leave it
as `USBSimple` or as `UsbSimple`. When I publish my USB host bindings
I'll take your comment into account for sure.