Skip to content

Commit 327c225

Browse files
thomashvmwairlied
authored andcommitted
drm: Enable drm drivers to add drm sysfs devices.
Export utility functions for drivers to add specialized devices in the sysfs drm class subdirectory. Initially this will be needed form TTM to add a virtual device that handles power management. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
1 parent a0724fc commit 327c225

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

drivers/gpu/drm/drm_sysfs.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/kdev_t.h>
1717
#include <linux/err.h>
1818

19+
#include "drm_sysfs.h"
1920
#include "drm_core.h"
2021
#include "drmP.h"
2122

@@ -515,3 +516,27 @@ void drm_sysfs_device_remove(struct drm_minor *minor)
515516
{
516517
device_unregister(&minor->kdev);
517518
}
519+
520+
521+
/**
522+
* drm_class_device_register - Register a struct device in the drm class.
523+
*
524+
* @dev: pointer to struct device to register.
525+
*
526+
* @dev should have all relevant members pre-filled with the exception
527+
* of the class member. In particular, the device_type member must
528+
* be set.
529+
*/
530+
531+
int drm_class_device_register(struct device *dev)
532+
{
533+
dev->class = drm_class;
534+
return device_register(dev);
535+
}
536+
EXPORT_SYMBOL_GPL(drm_class_device_register);
537+
538+
void drm_class_device_unregister(struct device *dev)
539+
{
540+
return device_unregister(dev);
541+
}
542+
EXPORT_SYMBOL_GPL(drm_class_device_unregister);

include/drm/drm_sysfs.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _DRM_SYSFS_H_
2+
#define _DRM_SYSFS_H_
3+
4+
/**
5+
* This minimalistic include file is intended for users (read TTM) that
6+
* don't want to include the full drmP.h file.
7+
*/
8+
9+
extern int drm_class_device_register(struct device *dev);
10+
extern void drm_class_device_unregister(struct device *dev);
11+
12+
#endif

0 commit comments

Comments
 (0)