Skip to content

Commit e7e2296

Browse files
dwlsalmeidagregkh
authored andcommitted
rust: usb: add basic USB abstractions
Add basic USB abstractions, consisting of usb::{Device, Interface, Driver, Adapter, DeviceId} and the module_usb_driver macro. This is the first step in being able to write USB device drivers, which paves the way for USB media drivers - for example - among others. This initial support will then be used by a subsequent sample driver, which constitutes the only user of the USB abstractions so far. Signed-off-by: Daniel Almeida <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ force USB = y for now - gregkh ] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a446baa commit e7e2296

File tree

5 files changed

+469
-0
lines changed

5 files changed

+469
-0
lines changed

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#include <linux/slab.h>
7575
#include <linux/task_work.h>
7676
#include <linux/tracepoint.h>
77+
#include <linux/usb.h>
7778
#include <linux/wait.h>
7879
#include <linux/workqueue.h>
7980
#include <linux/xarray.h>

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "task.c"
4949
#include "time.c"
5050
#include "uaccess.c"
51+
#include "usb.c"
5152
#include "vmalloc.c"
5253
#include "wait.c"
5354
#include "workqueue.c"

rust/helpers/usb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/usb.h>
4+
5+
struct usb_device *rust_helper_interface_to_usbdev(struct usb_interface *intf)
6+
{
7+
return interface_to_usbdev(intf);
8+
}

rust/kernel/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub mod time;
127127
pub mod tracepoint;
128128
pub mod transmute;
129129
pub mod types;
130+
#[cfg(CONFIG_USB = "y")]
131+
pub mod usb;
130132
pub mod uaccess;
131133
pub mod workqueue;
132134
pub mod xarray;

0 commit comments

Comments
 (0)