[PATCH v2 1/3] drm: Add USB helpers
Thomas Zimmermann
tzimmermann at suse.de
Tue Nov 3 10:36:54 UTC 2020
DRM drivers for USB devices can share a few helpers. It's currently only
a function to retrieve the USB device's structure from the DRM device.
Putting this code next to the DRM device would make all of DRM depend on
USB headers. So it's in a separate header file.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
Documentation/gpu/drm-internals.rst | 5 +++++
include/drm/drm_usb_helper.h | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 include/drm/drm_usb_helper.h
diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
index 12272b168580..642679407f36 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -197,6 +197,11 @@ Utilities
.. kernel-doc:: include/drm/drm_util.h
:internal:
+USB helpers
+-----------
+
+.. kernel-doc:: include/drm/drm_usb_helper.h
+ :internal:
Legacy Support Code
===================
diff --git a/include/drm/drm_usb_helper.h b/include/drm/drm_usb_helper.h
new file mode 100644
index 000000000000..6e8feff890ac
--- /dev/null
+++ b/include/drm/drm_usb_helper.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+
+#ifndef DRM_USB_HELPER_H
+#define DRM_USB_HELPER_H
+
+#include <linux/usb.h>
+
+#include <drm/drm_device.h>
+
+/**
+ * drm_dev_get_usb_device - Returns a DRM device's USB device
+ * @dev: The DRM device
+ *
+ * For USB-based DRM devices, returns the corresponding USB device. The
+ * DRM device must store the USB interface's device in its dev field.
+ *
+ * RETURNS:
+ * The USB device
+ */
+static inline struct usb_device *drm_dev_get_usb_device(struct drm_device *dev)
+{
+ return interface_to_usbdev(to_usb_interface(dev->dev));
+}
+
+#endif
--
2.29.0
More information about the dri-devel
mailing list