diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-04-04 05:52:55 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-04-04 14:47:54 -0400 |
commit | e22717046a7da3cd0c0b0eec323e1dc38c777a42 (patch) | |
tree | 17ecfd3a2da47b87d070e64c66500101821be8ad | |
parent | 085c6c09c5c8529434a26107440bd28209b694d4 (diff) |
drm: Consolidate and document sysfs support
- remove docs for internal func, doesn't add value
- add short overview snippet instead explaining that drivers don't
have to bother themselves with reg/unreg concerns
- drop the ttm comment about drmP.h, drmP.h is disappearing ...
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170404095304.17599-2-daniel.vetter@ffwll.ch
-rw-r--r-- | Documentation/gpu/drm-uapi.rst | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_sysfs.c | 70 | ||||
-rw-r--r-- | include/drm/drmP.h | 5 | ||||
-rw-r--r-- | include/drm/drm_sysfs.h | 8 |
4 files changed, 42 insertions, 51 deletions
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 76356c86e358..8b0f0e403f0c 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst | |||
@@ -219,6 +219,16 @@ Debugfs Support | |||
219 | .. kernel-doc:: drivers/gpu/drm/drm_debugfs.c | 219 | .. kernel-doc:: drivers/gpu/drm/drm_debugfs.c |
220 | :export: | 220 | :export: |
221 | 221 | ||
222 | Sysfs Support | ||
223 | ============= | ||
224 | |||
225 | .. kernel-doc:: drivers/gpu/drm/drm_sysfs.c | ||
226 | :doc: overview | ||
227 | |||
228 | .. kernel-doc:: drivers/gpu/drm/drm_sysfs.c | ||
229 | :export: | ||
230 | |||
231 | |||
222 | VBlank event handling | 232 | VBlank event handling |
223 | ===================== | 233 | ===================== |
224 | 234 | ||
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 513288b5c2f6..1c5b5ce1fd7f 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
@@ -25,6 +25,20 @@ | |||
25 | #define to_drm_minor(d) dev_get_drvdata(d) | 25 | #define to_drm_minor(d) dev_get_drvdata(d) |
26 | #define to_drm_connector(d) dev_get_drvdata(d) | 26 | #define to_drm_connector(d) dev_get_drvdata(d) |
27 | 27 | ||
28 | /** | ||
29 | * DOC: overview | ||
30 | * | ||
31 | * DRM provides very little additional support to drivers for sysfs | ||
32 | * interactions, beyond just all the standard stuff. Drivers who want to expose | ||
33 | * additional sysfs properties and property groups can attach them at either | ||
34 | * &drm_device.dev or &drm_connector.kdev. | ||
35 | * | ||
36 | * Registration is automatically handled when calling drm_dev_register(), or | ||
37 | * drm_connector_register() in case of hot-plugged connectors. Unregistration is | ||
38 | * also automatically handled by drm_dev_unregister() and | ||
39 | * drm_connector_unregister(). | ||
40 | */ | ||
41 | |||
28 | static struct device_type drm_sysfs_device_minor = { | 42 | static struct device_type drm_sysfs_device_minor = { |
29 | .name = "drm_minor" | 43 | .name = "drm_minor" |
30 | }; | 44 | }; |
@@ -250,15 +264,6 @@ static const struct attribute_group *connector_dev_groups[] = { | |||
250 | NULL | 264 | NULL |
251 | }; | 265 | }; |
252 | 266 | ||
253 | /** | ||
254 | * drm_sysfs_connector_add - add a connector to sysfs | ||
255 | * @connector: connector to add | ||
256 | * | ||
257 | * Create a connector device in sysfs, along with its associated connector | ||
258 | * properties (so far, connection status, dpms, mode list and edid) and | ||
259 | * generate a hotplug event so userspace knows there's a new connector | ||
260 | * available. | ||
261 | */ | ||
262 | int drm_sysfs_connector_add(struct drm_connector *connector) | 267 | int drm_sysfs_connector_add(struct drm_connector *connector) |
263 | { | 268 | { |
264 | struct drm_device *dev = connector->dev; | 269 | struct drm_device *dev = connector->dev; |
@@ -285,19 +290,6 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
285 | return 0; | 290 | return 0; |
286 | } | 291 | } |
287 | 292 | ||
288 | /** | ||
289 | * drm_sysfs_connector_remove - remove an connector device from sysfs | ||
290 | * @connector: connector to remove | ||
291 | * | ||
292 | * Remove @connector and its associated attributes from sysfs. Note that | ||
293 | * the device model core will take care of sending the "remove" uevent | ||
294 | * at this time, so we don't need to do it. | ||
295 | * | ||
296 | * Note: | ||
297 | * This routine should only be called if the connector was previously | ||
298 | * successfully registered. If @connector hasn't been registered yet, | ||
299 | * you'll likely see a panic somewhere deep in sysfs code when called. | ||
300 | */ | ||
301 | void drm_sysfs_connector_remove(struct drm_connector *connector) | 293 | void drm_sysfs_connector_remove(struct drm_connector *connector) |
302 | { | 294 | { |
303 | if (!connector->kdev) | 295 | if (!connector->kdev) |
@@ -333,20 +325,6 @@ static void drm_sysfs_release(struct device *dev) | |||
333 | kfree(dev); | 325 | kfree(dev); |
334 | } | 326 | } |
335 | 327 | ||
336 | /** | ||
337 | * drm_sysfs_minor_alloc() - Allocate sysfs device for given minor | ||
338 | * @minor: minor to allocate sysfs device for | ||
339 | * | ||
340 | * This allocates a new sysfs device for @minor and returns it. The device is | ||
341 | * not registered nor linked. The caller has to use device_add() and | ||
342 | * device_del() to register and unregister it. | ||
343 | * | ||
344 | * Note that dev_get_drvdata() on the new device will return the minor. | ||
345 | * However, the device does not hold a ref-count to the minor nor to the | ||
346 | * underlying drm_device. This is unproblematic as long as you access the | ||
347 | * private data only in sysfs callbacks. device_del() disables those | ||
348 | * synchronously, so they cannot be called after you cleanup a minor. | ||
349 | */ | ||
350 | struct device *drm_sysfs_minor_alloc(struct drm_minor *minor) | 328 | struct device *drm_sysfs_minor_alloc(struct drm_minor *minor) |
351 | { | 329 | { |
352 | const char *minor_str; | 330 | const char *minor_str; |
@@ -384,15 +362,13 @@ err_free: | |||
384 | } | 362 | } |
385 | 363 | ||
386 | /** | 364 | /** |
387 | * drm_class_device_register - Register a struct device in the drm class. | 365 | * drm_class_device_register - register new device with the DRM sysfs class |
366 | * @dev: device to register | ||
388 | * | 367 | * |
389 | * @dev: pointer to struct device to register. | 368 | * Registers a new &struct device within the DRM sysfs class. Essentially only |
390 | * | 369 | * used by ttm to have a place for its global settings. Drivers should never use |
391 | * @dev should have all relevant members pre-filled with the exception | 370 | * this. |
392 | * of the class member. In particular, the device_type member must | ||
393 | * be set. | ||
394 | */ | 371 | */ |
395 | |||
396 | int drm_class_device_register(struct device *dev) | 372 | int drm_class_device_register(struct device *dev) |
397 | { | 373 | { |
398 | if (!drm_class || IS_ERR(drm_class)) | 374 | if (!drm_class || IS_ERR(drm_class)) |
@@ -403,6 +379,14 @@ int drm_class_device_register(struct device *dev) | |||
403 | } | 379 | } |
404 | EXPORT_SYMBOL_GPL(drm_class_device_register); | 380 | EXPORT_SYMBOL_GPL(drm_class_device_register); |
405 | 381 | ||
382 | /** | ||
383 | * drm_class_device_unregister - unregister device with the DRM sysfs class | ||
384 | * @dev: device to unregister | ||
385 | * | ||
386 | * Unregisters a &struct device from the DRM sysfs class. Essentially only used | ||
387 | * by ttm to have a place for its global settings. Drivers should never use | ||
388 | * this. | ||
389 | */ | ||
406 | void drm_class_device_unregister(struct device *dev) | 390 | void drm_class_device_unregister(struct device *dev) |
407 | { | 391 | { |
408 | return device_unregister(dev); | 392 | return device_unregister(dev); |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3bfafcdb8710..e1daa4f343cd 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <drm/drm_file.h> | 80 | #include <drm/drm_file.h> |
81 | #include <drm/drm_debugfs.h> | 81 | #include <drm/drm_debugfs.h> |
82 | #include <drm/drm_ioctl.h> | 82 | #include <drm/drm_ioctl.h> |
83 | #include <drm/drm_sysfs.h> | ||
83 | 84 | ||
84 | struct module; | 85 | struct module; |
85 | 86 | ||
@@ -512,10 +513,6 @@ static inline int drm_device_is_unplugged(struct drm_device *dev) | |||
512 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. | 513 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
513 | */ | 514 | */ |
514 | 515 | ||
515 | /* sysfs support (drm_sysfs.c) */ | ||
516 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | ||
517 | |||
518 | |||
519 | /*@}*/ | 516 | /*@}*/ |
520 | 517 | ||
521 | /* returns true if currently okay to sleep */ | 518 | /* returns true if currently okay to sleep */ |
diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h index 23418c1f10d1..70c9a1074aca 100644 --- a/include/drm/drm_sysfs.h +++ b/include/drm/drm_sysfs.h | |||
@@ -1,12 +1,12 @@ | |||
1 | #ifndef _DRM_SYSFS_H_ | 1 | #ifndef _DRM_SYSFS_H_ |
2 | #define _DRM_SYSFS_H_ | 2 | #define _DRM_SYSFS_H_ |
3 | 3 | ||
4 | /** | 4 | struct drm_device; |
5 | * This minimalistic include file is intended for users (read TTM) that | 5 | struct device; |
6 | * don't want to include the full drmP.h file. | ||
7 | */ | ||
8 | 6 | ||
9 | int drm_class_device_register(struct device *dev); | 7 | int drm_class_device_register(struct device *dev); |
10 | void drm_class_device_unregister(struct device *dev); | 8 | void drm_class_device_unregister(struct device *dev); |
11 | 9 | ||
10 | void drm_sysfs_hotplug_event(struct drm_device *dev); | ||
11 | |||
12 | #endif | 12 | #endif |