Skip to contentSkip to conversation

drm: Add device registration documentation

PATCH New Thierry Reding 1 participant 2 messages Apr 23, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm: Add device registration documentation

From: Thierry Reding <[email protected]>

Describe how devices are registered using the drm_*_init() functions. Adding this to docbook requires a largish set of changes to the comments in drm_{pci,usb,platform}.c since they are doxygen-style rather than proper kernel-doc and therefore mess with the docbook generation.

---
 Documentation/DocBook/drm.tmpl |  9 +++++
 drivers/gpu/drm/drm_pci.c      | 80 ++++++++++++++++++++----------------------
 drivers/gpu/drm/drm_platform.c | 15 ++++----
 drivers/gpu/drm/drm_stub.c     | 19 +++++-----
 drivers/gpu/drm/drm_usb.c      | 20 ++++++++++-
 5 files changed, 81 insertions(+), 62 deletions(-)
Documentation/DocBook/drm.tmpl +9 -0
index 83dd0b043c28..ced203cef87d 100644
@@ -282,6 +282,15 @@ char *date;</synopsis>
       </sect3>
     </sect2>
     <sect2>
+      <title>Device Registration</title>
+      <para>
+        A number of functions are provided to help with device registration.
+        The functions deal with PCI, USB and platform devices, respectively.
+      </para>
+!Fdrivers/gpu/drm/drm_pci.c drm_pci_init drm_pci_exit
+!Fdrivers/gpu/drm/drm_usb.c drm_usb_init drm_usb_exit
+!Fdrivers/gpu/drm/drm_platform.c drm_platform_init
+    <sect2>
       <title>Driver Load</title>
       <para>
         The <methodname>load</methodname> method is the driver and device
drivers/gpu/drm/drm_pci.c +38 -42

136 lines not on this page · raw message

drivers/gpu/drm/drm_platform.c +7 -8
index 234e0bc1ae51..d5b76f148c12 100644
@@ -106,17 +106,16 @@ static struct drm_bus drm_platform_bus = {
 };
 
 /**
- * Platform device initialization. Called direct from modules.
+ * drm_platform_init - Register a platform device with the DRM subsystem
+ * @driver: DRM device driver
+ * @platform_device: platform device to register
  *
- * \return zero on success or a negative number on failure.
- *
- * Initializes a drm_device structures,registering the
- * stubs
+ * Registers the specified DRM device driver and platform device with the DRM
+ * subsystem, initializing a drm_device structure and calling the driver's
+ * .load() function.
  *
- * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
- * after the initialization for driver customization.
+ * Return: 0 on success or a negative error code on failure.
  */
-
 int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device)
 {
 	DRM_DEBUG("\n");
drivers/gpu/drm/drm_stub.c +8 -11
index d0c7c78aa7f4..5b88e6afe3df 100644
@@ -1,16 +1,11 @@
-/**
- * \file drm_stub.h
- * Stub support
- *
- * \author Rickard E. (Rik) Faith <[email protected]>
- */
-
 /*
  * Created: Fri Jan 19 10:48:35 2001 by [email protected]
  *
  * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
  * All Rights Reserved.
  *
+ * Author Rickard E. (Rik) Faith <[email protected]>
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
@@ -421,11 +416,12 @@ void drm_minor_release(struct drm_minor *minor)
 }
 
 /**
- * Called via drm_exit() at module unload time or when pci device is
- * unplugged.
+ * drm_put_dev - Unregister and release a DRM device
+ * @dev: DRM device
  *
- * Cleans up all DRM device, calling drm_lastclose().
+ * Called at module unload time or when a PCI device is unplugged.
  *
+ * Cleans up all DRM device, calling drm_lastclose().
  */
 void drm_put_dev(struct drm_device *dev)
 {
@@ -555,7 +551,7 @@ int drm_set_unique(struct drm_device *dev, const char *fmt, ...)
 EXPORT_SYMBOL(drm_set_unique);
 
 /**
- * drm_dev_alloc - Allocate new drm device
+ * drm_dev_alloc - Allocate new DRM device
  * @driver: DRM driver to allocate device for
  * @parent: Parent device object
  *
@@ -709,6 +705,7 @@ EXPORT_SYMBOL(drm_dev_unref);
 /**
  * drm_dev_register - Register DRM device
  * @dev: Device to register
+ * @flags: Flags passed to the driver's .load() function
  *
  * Register the DRM device @dev with the system, advertise device to user-space
  * and start normal device operation. @dev must be allocated via drm_dev_alloc()
drivers/gpu/drm/drm_usb.c +19 -1
index c6c7c29ad46f..f2fe94aab901 100644
@@ -45,7 +45,17 @@ static int drm_usb_set_busid(struct drm_device *dev,
 static struct drm_bus drm_usb_bus = {
 	.set_busid = drm_usb_set_busid,
 };
-    
+
+/**
+ * drm_usb_init - Register matching USB devices with the DRM subsystem
+ * @driver: DRM device driver
+ * @udriver: USB device driver
+ *
+ * Registers one or more devices matched by a USB driver with the DRM
+ * subsystem.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
 int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
 {
 	int res;
@@ -58,6 +68,14 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
 }
 EXPORT_SYMBOL(drm_usb_init);
 
+/**
+ * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
+ * @driver: DRM device driver
+ * @udriver: USB device driver
+ *
+ * Unregisters one or more devices matched by a USB driver from the DRM
+ * subsystem.
+ */
 void drm_usb_exit(struct drm_driver *driver,
 		  struct usb_driver *udriver)
 {
Signature · 6 lines
1.9.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 drm: Document how to register devices without struct drm_bus

From: Thierry Reding <[email protected]>

With the recent addition of the drm_set_unique() function, devices can now be registered without requiring a drm_bus. Add a brief description to the DRM docbook to show how that can be achieved.

---
 Documentation/DocBook/drm.tmpl | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
Documentation/DocBook/drm.tmpl +29 -0
index ced203cef87d..e47b275170ac 100644
@@ -142,6 +142,12 @@
       to register it with the DRM subsystem.
     </para>
     <para>
+      Newer drivers that no longer require a <structname>drm_bus</structname>
+      structure can alternatively use the low-level device initialization and
+      registration functions such as <function>drm_dev_alloc()</function> and
+      <function>drm_dev_register()</function> directly.
+    </para>
+    <para>
       The <structname>drm_driver</structname> structure contains static
       information that describes the driver and features it supports, and
       pointers to methods that the DRM core will call to implement the DRM API.
@@ -290,6 +296,29 @@ char *date;</synopsis>
 !Fdrivers/gpu/drm/drm_pci.c drm_pci_init drm_pci_exit
 !Fdrivers/gpu/drm/drm_usb.c drm_usb_init drm_usb_exit
 !Fdrivers/gpu/drm/drm_platform.c drm_platform_init
+      <para>
+        New drivers that no longer rely on the services provided by the
+        <structname>drm_bus</structname> structure can call the low-level
+        device registration functions directly. The
+        <function>drm_dev_alloc()</function> function can be used to allocate
+        and initialize a new <structname>drm_device</structname> structure.
+        Drivers will typically want to perform some additional setup on this
+        structure, such as allocating driver-specific data and storing a
+        pointer to it in the DRM device's <structfield>dev_private</structfield>
+        field. Drivers should also set the device's unique name using the
+        <function>drm_set_unique()</function> function. After it has been set up
+        a device can be registered with the DRM subsystem by calling
+        <function>drm_dev_register()</function>. This will cause the device to
+        be exposed to userspace and will call the driver's
+        <structfield>.load()</structfield> implementation. When a device is
+        removed, the DRM device can safely be unregistered and freed using a
+        call to <function>drm_put_dev()</function>.
+      </para>
+!Fdrivers/gpu/drm/drm_stub.c drm_dev_alloc
+!Fdrivers/gpu/drm/drm_stub.c drm_set_unique
+!Fdrivers/gpu/drm/drm_stub.c drm_dev_register
+!Fdrivers/gpu/drm/drm_stub.c drm_put_dev
+    </sect2>
     <sect2>
       <title>Driver Load</title>
       <para>
Signature · 1 line
1.9.2