Skip to content

Commit bb2eaba

Browse files
committed
drm/doc: Improve ioctl/fops docs a bit more
I spotted a markup issue, plus adding the descriptions in drm_driver. Plus a few more links while at it. I'm still mildly unhappy with the split between fops and ioctls, but I still think having the ioctls in the uapi chapter makes more sense. Oh well ... v2: Rebase. v3: Move misplace hunk to the right patch. Cc: Stefan Agner <stefan@agner.ch> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170531092045.3950-1-daniel.vetter@ffwll.ch
1 parent 10631d7 commit bb2eaba

5 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎Documentation/gpu/drm-internals.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ drivers.
198198
Open/Close, File Operations and IOCTLs
199199
======================================
200200

201+
.. _drm_driver_fops:
202+
201203
File Operations
202204
---------------
203205

‎Documentation/gpu/drm-uapi.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ other hand, a driver requires shared state between clients which is
160160
visible to user-space and accessible beyond open-file boundaries, they
161161
cannot support render nodes.
162162

163+
.. _drm_driver_ioctl:
164+
163165
IOCTL Support on Device Nodes
164166
=============================
165167

‎drivers/gpu/drm/drm_file.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ DEFINE_MUTEX(drm_global_mutex);
7575
* for drivers which use the CMA GEM helpers it's drm_gem_cma_mmap().
7676
*
7777
* No other file operations are supported by the DRM userspace API. Overall the
78-
* following is an example #file_operations structure::
78+
* following is an example &file_operations structure::
7979
*
8080
* static const example_drm_fops = {
8181
* .owner = THIS_MODULE,
@@ -92,6 +92,11 @@ DEFINE_MUTEX(drm_global_mutex);
9292
* For plain GEM based drivers there is the DEFINE_DRM_GEM_FOPS() macro, and for
9393
* CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make this
9494
* simpler.
95+
*
96+
* The driver's &file_operations must be stored in &drm_driver.fops.
97+
*
98+
* For driver-private IOCTL handling see the more detailed discussion in
99+
* :ref:`IOCTL support in the userland interfaces chapter<drm_driver_ioctl>`.
95100
*/
96101

97102
static int drm_open_helper(struct file *filp, struct drm_minor *minor);

‎drivers/gpu/drm/drm_ioctl.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
683683
*
684684
* DRM driver private IOCTL must be in the range from DRM_COMMAND_BASE to
685685
* DRM_COMMAND_END. Finally you need an array of &struct drm_ioctl_desc to wire
686-
* up the handlers and set the access rights:
686+
* up the handlers and set the access rights::
687687
*
688688
* static const struct drm_ioctl_desc my_driver_ioctls[] = {
689689
* DRM_IOCTL_DEF_DRV(MY_DRIVER_OPERATION, my_driver_operation,
@@ -692,6 +692,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
692692
*
693693
* And then assign this to the &drm_driver.ioctls field in your driver
694694
* structure.
695+
*
696+
* See the separate chapter on :ref:`file operations<drm_driver_fops>` for how
697+
* the driver-specific IOCTLs are wired up.
695698
*/
696699

697700
/**

‎include/drm/drm_drv.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,26 @@ struct drm_driver {
515515
char *date;
516516

517517
u32 driver_features;
518+
519+
/**
520+
* @ioctls:
521+
*
522+
* Array of driver-private IOCTL description entries. See the chapter on
523+
* :ref:`IOCTL support in the userland interfaces
524+
* chapter<drm_driver_ioctl>` for the full details.
525+
*/
526+
518527
const struct drm_ioctl_desc *ioctls;
528+
/** @num_ioctls: Number of entries in @ioctls. */
519529
int num_ioctls;
530+
531+
/**
532+
* @fops:
533+
*
534+
* File operations for the DRM device node. See the discussion in
535+
* :ref:`file operations<drm_driver_fops>` for in-depth coverage and
536+
* some examples.
537+
*/
520538
const struct file_operations *fops;
521539

522540
/* Everything below here is for legacy driver, never use! */

0 commit comments

Comments
 (0)