Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Add device registration documentation

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.

While at it, mark usage of drm_put_dev() as discouraged in favour of
calling drm_dev_unregister() and drm_dev_unref() directly.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thierry Reding <treding@nvidia.com>

+85 -62
+10
Documentation/DocBook/drm.tmpl
··· 282 282 </sect3> 283 283 </sect2> 284 284 <sect2> 285 + <title>Device Registration</title> 286 + <para> 287 + A number of functions are provided to help with device registration. 288 + The functions deal with PCI, USB and platform devices, respectively. 289 + </para> 290 + !Edrivers/gpu/drm/drm_pci.c 291 + !Edrivers/gpu/drm/drm_usb.c 292 + !Edrivers/gpu/drm/drm_platform.c 293 + </sect2> 294 + <sect2> 285 295 <title>Driver Load</title> 286 296 <para> 287 297 The <methodname>load</methodname> method is the driver and device
+38 -42
drivers/gpu/drm/drm_pci.c
··· 1 - /* drm_pci.h -- PCI DMA memory management wrappers for DRM -*- linux-c -*- */ 2 - /** 3 - * \file drm_pci.c 4 - * \brief Functions and ioctls to manage PCI memory 5 - * 6 - * \warning These interfaces aren't stable yet. 7 - * 8 - * \todo Implement the remaining ioctl's for the PCI pools. 9 - * \todo The wrappers here are so thin that they would be better off inlined.. 10 - * 11 - * \author José Fonseca <jrfonseca@tungstengraphics.com> 12 - * \author Leif Delgass <ldelgass@retinalburn.net> 13 - */ 14 - 15 1 /* 16 2 * Copyright 2003 José Fonseca. 17 3 * Copyright 2003 Leif Delgass. ··· 28 42 #include <linux/export.h> 29 43 #include <drm/drmP.h> 30 44 31 - /**********************************************************************/ 32 - /** \name PCI memory */ 33 - /*@{*/ 34 - 35 45 /** 36 - * \brief Allocate a PCI consistent memory block, for DMA. 46 + * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA. 47 + * @dev: DRM device 48 + * @size: size of block to allocate 49 + * @align: alignment of block 50 + * 51 + * Return: A handle to the allocated memory block on success or NULL on 52 + * failure. 37 53 */ 38 54 drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align) 39 55 { ··· 76 88 77 89 EXPORT_SYMBOL(drm_pci_alloc); 78 90 79 - /** 80 - * \brief Free a PCI consistent memory block without freeing its descriptor. 91 + /* 92 + * Free a PCI consistent memory block without freeing its descriptor. 81 93 * 82 94 * This function is for internal use in the Linux-specific DRM core code. 83 95 */ ··· 99 111 } 100 112 101 113 /** 102 - * \brief Free a PCI consistent memory block 114 + * drm_pci_free - Free a PCI consistent memory block 115 + * @dev: DRM device 116 + * @dmah: handle to memory block 103 117 */ 104 118 void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) 105 119 { ··· 216 226 } 217 227 218 228 /** 219 - * Get interrupt from bus id. 220 - * 221 - * \param inode device inode. 222 - * \param file_priv DRM file private. 223 - * \param cmd command. 224 - * \param arg user argument, pointing to a drm_irq_busid structure. 225 - * \return zero on success or a negative number on failure. 229 + * drm_irq_by_busid - Get interrupt from bus ID 230 + * @dev: DRM device 231 + * @data: IOCTL parameter pointing to a drm_irq_busid structure 232 + * @file_priv: DRM file private. 226 233 * 227 234 * Finds the PCI device with the specified bus id and gets its IRQ number. 228 235 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal 229 236 * to that of the device that this DRM instance attached to. 237 + * 238 + * Return: 0 on success or a negative error code on failure. 230 239 */ 231 240 int drm_irq_by_busid(struct drm_device *dev, void *data, 232 241 struct drm_file *file_priv) ··· 274 285 }; 275 286 276 287 /** 277 - * Register. 278 - * 279 - * \param pdev - PCI device structure 280 - * \param ent entry from the PCI ID table with device type flags 281 - * \return zero on success or a negative number on failure. 288 + * drm_get_pci_dev - Register a PCI device with the DRM subsystem 289 + * @pdev: PCI device 290 + * @ent: entry from the PCI ID table that matches @pdev 291 + * @driver: DRM device driver 282 292 * 283 293 * Attempt to gets inter module "drm" information. If we are first 284 294 * then register the character device and inter module information. 285 295 * Try and register, if we fail to register, backout previous work. 296 + * 297 + * Return: 0 on success or a negative error code on failure. 286 298 */ 287 299 int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 288 300 struct drm_driver *driver) ··· 336 346 EXPORT_SYMBOL(drm_get_pci_dev); 337 347 338 348 /** 339 - * PCI device initialization. Called direct from modules at load time. 349 + * drm_pci_init - Register matching PCI devices with the DRM subsystem 350 + * @driver: DRM device driver 351 + * @pdriver: PCI device driver 340 352 * 341 - * \return zero on success or a negative number on failure. 353 + * Initializes a drm_device structures, registering the stubs and initializing 354 + * the AGP device. 342 355 * 343 - * Initializes a drm_device structures,registering the 344 - * stubs and initializing the AGP device. 345 - * 346 - * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and 347 - * after the initialization for driver customization. 356 + * Return: 0 on success or a negative error code on failure. 348 357 */ 349 358 int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) 350 359 { ··· 447 458 448 459 EXPORT_SYMBOL(drm_pci_init); 449 460 450 - /*@}*/ 461 + /** 462 + * drm_pci_exit - Unregister matching PCI devices from the DRM subsystem 463 + * @driver: DRM device driver 464 + * @pdriver: PCI device driver 465 + * 466 + * Unregisters one or more devices matched by a PCI driver from the DRM 467 + * subsystem. 468 + */ 451 469 void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) 452 470 { 453 471 struct drm_device *dev, *tmp;
+7 -8
drivers/gpu/drm/drm_platform.c
··· 106 106 }; 107 107 108 108 /** 109 - * Platform device initialization. Called direct from modules. 109 + * drm_platform_init - Register a platform device with the DRM subsystem 110 + * @driver: DRM device driver 111 + * @platform_device: platform device to register 110 112 * 111 - * \return zero on success or a negative number on failure. 113 + * Registers the specified DRM device driver and platform device with the DRM 114 + * subsystem, initializing a drm_device structure and calling the driver's 115 + * .load() function. 112 116 * 113 - * Initializes a drm_device structures,registering the 114 - * stubs 115 - * 116 - * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and 117 - * after the initialization for driver customization. 117 + * Return: 0 on success or a negative error code on failure. 118 118 */ 119 - 120 119 int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device) 121 120 { 122 121 DRM_DEBUG("\n");
+11 -11
drivers/gpu/drm/drm_stub.c
··· 1 - /** 2 - * \file drm_stub.h 3 - * Stub support 4 - * 5 - * \author Rickard E. (Rik) Faith <faith@valinux.com> 6 - */ 7 - 8 1 /* 9 2 * Created: Fri Jan 19 10:48:35 2001 by faith@acm.org 10 3 * 11 4 * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California. 12 5 * All Rights Reserved. 6 + * 7 + * Author Rickard E. (Rik) Faith <faith@valinux.com> 13 8 * 14 9 * Permission is hereby granted, free of charge, to any person obtaining a 15 10 * copy of this software and associated documentation files (the "Software"), ··· 420 425 } 421 426 422 427 /** 423 - * Called via drm_exit() at module unload time or when pci device is 424 - * unplugged. 428 + * drm_put_dev - Unregister and release a DRM device 429 + * @dev: DRM device 430 + * 431 + * Called at module unload time or when a PCI device is unplugged. 432 + * 433 + * Use of this function is discouraged. It will eventually go away completely. 434 + * Please use drm_dev_unregister() and drm_dev_unref() explicitly instead. 425 435 * 426 436 * Cleans up all DRM device, calling drm_lastclose(). 427 - * 428 437 */ 429 438 void drm_put_dev(struct drm_device *dev) 430 439 { ··· 535 536 } 536 537 537 538 /** 538 - * drm_dev_alloc - Allocate new drm device 539 + * drm_dev_alloc - Allocate new DRM device 539 540 * @driver: DRM driver to allocate device for 540 541 * @parent: Parent device object 541 542 * ··· 689 690 /** 690 691 * drm_dev_register - Register DRM device 691 692 * @dev: Device to register 693 + * @flags: Flags passed to the driver's .load() function 692 694 * 693 695 * Register the DRM device @dev with the system, advertise device to user-space 694 696 * and start normal device operation. @dev must be allocated via drm_dev_alloc()
+19 -1
drivers/gpu/drm/drm_usb.c
··· 45 45 static struct drm_bus drm_usb_bus = { 46 46 .set_busid = drm_usb_set_busid, 47 47 }; 48 - 48 + 49 + /** 50 + * drm_usb_init - Register matching USB devices with the DRM subsystem 51 + * @driver: DRM device driver 52 + * @udriver: USB device driver 53 + * 54 + * Registers one or more devices matched by a USB driver with the DRM 55 + * subsystem. 56 + * 57 + * Return: 0 on success or a negative error code on failure. 58 + */ 49 59 int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) 50 60 { 51 61 int res; ··· 68 58 } 69 59 EXPORT_SYMBOL(drm_usb_init); 70 60 61 + /** 62 + * drm_usb_exit - Unregister matching USB devices from the DRM subsystem 63 + * @driver: DRM device driver 64 + * @udriver: USB device driver 65 + * 66 + * Unregisters one or more devices matched by a USB driver from the DRM 67 + * subsystem. 68 + */ 71 69 void drm_usb_exit(struct drm_driver *driver, 72 70 struct usb_driver *udriver) 73 71 {