blob: b95aaf23596e1a21ebe3b6d6ea2df30c01da1b67 [file] [log] [blame]
Greg Kroah-Hartman0650fd52006-01-20 14:08:59 -08001
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * drm_sysfs.c - Modifications to drm_sysfs_class.c to support
4 * extra sysfs attribute from DRM. Normal drm_sysfs_class
5 * does not allow adding attributes.
6 *
7 * Copyright (c) 2004 Jon Smirl <jonsmirl@gmail.com>
8 * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
9 * Copyright (c) 2003-2004 IBM Corp.
10 *
11 * This file is released under the GPLv2
12 *
13 */
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/device.h>
16#include <linux/kdev_t.h>
17#include <linux/err.h>
18
Thomas Hellstrom327c2252009-08-17 16:28:37 +020019#include "drm_sysfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "drm_core.h"
Dave Airlief2109732005-09-05 21:33:44 +100021#include "drmP.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Dave Airlie2c14f282008-04-21 16:47:32 +100023#define to_drm_minor(d) container_of(d, struct drm_minor, kdev)
Dave Airlief453ba02008-11-07 14:05:41 -080024#define to_drm_connector(d) container_of(d, struct drm_connector, kdev)
Jesse Barnese8b962b2007-11-22 14:02:38 +100025
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100026static struct device_type drm_sysfs_device_minor = {
27 .name = "drm_minor"
28};
29
Jesse Barnese8b962b2007-11-22 14:02:38 +100030/**
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100031 * drm_class_suspend - DRM class suspend hook
Jesse Barnese8b962b2007-11-22 14:02:38 +100032 * @dev: Linux device to suspend
33 * @state: power state to enter
34 *
35 * Just figures out what the actual struct drm_device associated with
36 * @dev is and calls its suspend hook, if present.
37 */
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100038static int drm_class_suspend(struct device *dev, pm_message_t state)
Jesse Barnese8b962b2007-11-22 14:02:38 +100039{
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100040 if (dev->type == &drm_sysfs_device_minor) {
41 struct drm_minor *drm_minor = to_drm_minor(dev);
42 struct drm_device *drm_dev = drm_minor->dev;
Jesse Barnese8b962b2007-11-22 14:02:38 +100043
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100044 if (drm_minor->type == DRM_MINOR_LEGACY &&
45 !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
46 drm_dev->driver->suspend)
47 return drm_dev->driver->suspend(drm_dev, state);
48 }
Jesse Barnese8b962b2007-11-22 14:02:38 +100049 return 0;
50}
51
52/**
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100053 * drm_class_resume - DRM class resume hook
Jesse Barnese8b962b2007-11-22 14:02:38 +100054 * @dev: Linux device to resume
55 *
56 * Just figures out what the actual struct drm_device associated with
57 * @dev is and calls its resume hook, if present.
58 */
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100059static int drm_class_resume(struct device *dev)
Jesse Barnese8b962b2007-11-22 14:02:38 +100060{
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100061 if (dev->type == &drm_sysfs_device_minor) {
62 struct drm_minor *drm_minor = to_drm_minor(dev);
63 struct drm_device *drm_dev = drm_minor->dev;
Jesse Barnese8b962b2007-11-22 14:02:38 +100064
Thomas Hellstrom08e4d532009-08-20 19:02:31 +100065 if (drm_minor->type == DRM_MINOR_LEGACY &&
66 !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
67 drm_dev->driver->resume)
68 return drm_dev->driver->resume(drm_dev);
69 }
Jesse Barnese8b962b2007-11-22 14:02:38 +100070 return 0;
71}
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073/* Display the version of drm_core. This doesn't work right in current design */
Andi Kleen28812fe2010-01-05 12:48:07 +010074static ssize_t version_show(struct class *dev, struct class_attribute *attr,
75 char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
77 return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR,
78 CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
79}
80
Kay Sieverse454cea2009-09-18 23:01:12 +020081static char *drm_devnode(struct device *dev, mode_t *mode)
Kay Sievers02200d02009-04-30 15:23:42 +020082{
83 return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
84}
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
87
88/**
89 * drm_sysfs_create - create a struct drm_sysfs_class structure
90 * @owner: pointer to the module that is to "own" this struct drm_sysfs_class
91 * @name: pointer to a string for the name of this class.
92 *
Jesse Barnese8b962b2007-11-22 14:02:38 +100093 * This is used to create DRM class pointer that can then be used
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 * in calls to drm_sysfs_device_add().
95 *
96 * Note, the pointer created here is to be destroyed when finished by making a
97 * call to drm_sysfs_destroy().
98 */
Greg Kroah-Hartman0650fd52006-01-20 14:08:59 -080099struct class *drm_sysfs_create(struct module *owner, char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Greg Kroah-Hartman0650fd52006-01-20 14:08:59 -0800101 struct class *class;
Jeff Garzik24f73c92006-10-10 14:23:37 -0700102 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Greg Kroah-Hartman0650fd52006-01-20 14:08:59 -0800104 class = class_create(owner, name);
Akinobu Mita94f060b2006-12-09 10:49:47 +1100105 if (IS_ERR(class)) {
106 err = PTR_ERR(class);
Jeff Garzik24f73c92006-10-10 14:23:37 -0700107 goto err_out;
108 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Thomas Hellstrom08e4d532009-08-20 19:02:31 +1000110 class->suspend = drm_class_suspend;
111 class->resume = drm_class_resume;
Jesse Barnese8b962b2007-11-22 14:02:38 +1000112
Jeff Garzik24f73c92006-10-10 14:23:37 -0700113 err = class_create_file(class, &class_attr_version);
114 if (err)
115 goto err_out_class;
116
Kay Sieverse454cea2009-09-18 23:01:12 +0200117 class->devnode = drm_devnode;
Kay Sievers02200d02009-04-30 15:23:42 +0200118
Greg Kroah-Hartman0650fd52006-01-20 14:08:59 -0800119 return class;
Jeff Garzik24f73c92006-10-10 14:23:37 -0700120
121err_out_class:
122 class_destroy(class);
123err_out:
124 return ERR_PTR(err);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125}
126
127/**
Jesse Barnese8b962b2007-11-22 14:02:38 +1000128 * drm_sysfs_destroy - destroys DRM class
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 *
Jesse Barnese8b962b2007-11-22 14:02:38 +1000130 * Destroy the DRM device class.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 */
Jesse Barnese8b962b2007-11-22 14:02:38 +1000132void drm_sysfs_destroy(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133{
Jesse Barnese8b962b2007-11-22 14:02:38 +1000134 if ((drm_class == NULL) || (IS_ERR(drm_class)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 return;
Jesse Barnese8b962b2007-11-22 14:02:38 +1000136 class_remove_file(drm_class, &class_attr_version);
137 class_destroy(drm_class);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138}
139
140/**
Jesse Barnese8b962b2007-11-22 14:02:38 +1000141 * drm_sysfs_device_release - do nothing
142 * @dev: Linux device
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 *
Jesse Barnese8b962b2007-11-22 14:02:38 +1000144 * Normally, this would free the DRM device associated with @dev, along
145 * with cleaning up any other stuff. But we do that in the DRM core, so
146 * this function can just return and hope that the core does its job.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 */
Jesse Barnese8b962b2007-11-22 14:02:38 +1000148static void drm_sysfs_device_release(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149{
Ma Ling77d26dc2009-04-16 17:51:25 +0800150 memset(dev, 0, sizeof(struct device));
Jesse Barnese8b962b2007-11-22 14:02:38 +1000151 return;
152}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Dave Airlief453ba02008-11-07 14:05:41 -0800154/*
155 * Connector properties
156 */
157static ssize_t status_show(struct device *device,
158 struct device_attribute *attr,
159 char *buf)
160{
161 struct drm_connector *connector = to_drm_connector(device);
162 enum drm_connector_status status;
163
164 status = connector->funcs->detect(connector);
Keith Packard75185c92009-05-30 20:42:25 -0700165 return snprintf(buf, PAGE_SIZE, "%s\n",
Dave Airlief453ba02008-11-07 14:05:41 -0800166 drm_get_connector_status_name(status));
167}
168
169static ssize_t dpms_show(struct device *device,
170 struct device_attribute *attr,
171 char *buf)
172{
173 struct drm_connector *connector = to_drm_connector(device);
174 struct drm_device *dev = connector->dev;
175 uint64_t dpms_status;
176 int ret;
177
178 ret = drm_connector_property_get_value(connector,
179 dev->mode_config.dpms_property,
180 &dpms_status);
181 if (ret)
182 return 0;
183
Keith Packard75185c92009-05-30 20:42:25 -0700184 return snprintf(buf, PAGE_SIZE, "%s\n",
Dave Airlief453ba02008-11-07 14:05:41 -0800185 drm_get_dpms_name((int)dpms_status));
186}
187
188static ssize_t enabled_show(struct device *device,
189 struct device_attribute *attr,
190 char *buf)
191{
192 struct drm_connector *connector = to_drm_connector(device);
193
Keith Packard75185c92009-05-30 20:42:25 -0700194 return snprintf(buf, PAGE_SIZE, "%s\n", connector->encoder ? "enabled" :
Dave Airlief453ba02008-11-07 14:05:41 -0800195 "disabled");
196}
197
198static ssize_t edid_show(struct kobject *kobj, struct bin_attribute *attr,
199 char *buf, loff_t off, size_t count)
200{
201 struct device *connector_dev = container_of(kobj, struct device, kobj);
202 struct drm_connector *connector = to_drm_connector(connector_dev);
203 unsigned char *edid;
204 size_t size;
205
206 if (!connector->edid_blob_ptr)
207 return 0;
208
209 edid = connector->edid_blob_ptr->data;
210 size = connector->edid_blob_ptr->length;
211 if (!edid)
212 return 0;
213
214 if (off >= size)
215 return 0;
216
217 if (off + count > size)
218 count = size - off;
219 memcpy(buf, edid + off, count);
220
221 return count;
222}
223
224static ssize_t modes_show(struct device *device,
225 struct device_attribute *attr,
226 char *buf)
227{
228 struct drm_connector *connector = to_drm_connector(device);
229 struct drm_display_mode *mode;
230 int written = 0;
231
232 list_for_each_entry(mode, &connector->modes, head) {
233 written += snprintf(buf + written, PAGE_SIZE - written, "%s\n",
234 mode->name);
235 }
236
237 return written;
238}
239
240static ssize_t subconnector_show(struct device *device,
241 struct device_attribute *attr,
242 char *buf)
243{
244 struct drm_connector *connector = to_drm_connector(device);
245 struct drm_device *dev = connector->dev;
246 struct drm_property *prop = NULL;
247 uint64_t subconnector;
248 int is_tv = 0;
249 int ret;
250
251 switch (connector->connector_type) {
252 case DRM_MODE_CONNECTOR_DVII:
253 prop = dev->mode_config.dvi_i_subconnector_property;
254 break;
255 case DRM_MODE_CONNECTOR_Composite:
256 case DRM_MODE_CONNECTOR_SVIDEO:
257 case DRM_MODE_CONNECTOR_Component:
Francisco Jerez74bd3c22009-08-02 04:19:18 +0200258 case DRM_MODE_CONNECTOR_TV:
Dave Airlief453ba02008-11-07 14:05:41 -0800259 prop = dev->mode_config.tv_subconnector_property;
260 is_tv = 1;
261 break;
262 default:
263 DRM_ERROR("Wrong connector type for this property\n");
264 return 0;
265 }
266
267 if (!prop) {
268 DRM_ERROR("Unable to find subconnector property\n");
269 return 0;
270 }
271
272 ret = drm_connector_property_get_value(connector, prop, &subconnector);
273 if (ret)
274 return 0;
275
276 return snprintf(buf, PAGE_SIZE, "%s", is_tv ?
277 drm_get_tv_subconnector_name((int)subconnector) :
278 drm_get_dvi_i_subconnector_name((int)subconnector));
279}
280
281static ssize_t select_subconnector_show(struct device *device,
282 struct device_attribute *attr,
283 char *buf)
284{
285 struct drm_connector *connector = to_drm_connector(device);
286 struct drm_device *dev = connector->dev;
287 struct drm_property *prop = NULL;
288 uint64_t subconnector;
289 int is_tv = 0;
290 int ret;
291
292 switch (connector->connector_type) {
293 case DRM_MODE_CONNECTOR_DVII:
294 prop = dev->mode_config.dvi_i_select_subconnector_property;
295 break;
296 case DRM_MODE_CONNECTOR_Composite:
297 case DRM_MODE_CONNECTOR_SVIDEO:
298 case DRM_MODE_CONNECTOR_Component:
Francisco Jerez74bd3c22009-08-02 04:19:18 +0200299 case DRM_MODE_CONNECTOR_TV:
Dave Airlief453ba02008-11-07 14:05:41 -0800300 prop = dev->mode_config.tv_select_subconnector_property;
301 is_tv = 1;
302 break;
303 default:
304 DRM_ERROR("Wrong connector type for this property\n");
305 return 0;
306 }
307
308 if (!prop) {
309 DRM_ERROR("Unable to find select subconnector property\n");
310 return 0;
311 }
312
313 ret = drm_connector_property_get_value(connector, prop, &subconnector);
314 if (ret)
315 return 0;
316
317 return snprintf(buf, PAGE_SIZE, "%s", is_tv ?
318 drm_get_tv_select_name((int)subconnector) :
319 drm_get_dvi_i_select_name((int)subconnector));
320}
321
322static struct device_attribute connector_attrs[] = {
323 __ATTR_RO(status),
324 __ATTR_RO(enabled),
325 __ATTR_RO(dpms),
326 __ATTR_RO(modes),
327};
328
329/* These attributes are for both DVI-I connectors and all types of tv-out. */
330static struct device_attribute connector_attrs_opt1[] = {
331 __ATTR_RO(subconnector),
332 __ATTR_RO(select_subconnector),
333};
334
335static struct bin_attribute edid_attr = {
336 .attr.name = "edid",
Keith Packarde36ebaf2009-05-30 20:42:26 -0700337 .attr.mode = 0444,
Dave Airlief453ba02008-11-07 14:05:41 -0800338 .size = 128,
339 .read = edid_show,
340};
341
342/**
343 * drm_sysfs_connector_add - add an connector to sysfs
344 * @connector: connector to add
345 *
346 * Create an connector device in sysfs, along with its associated connector
347 * properties (so far, connection status, dpms, mode list & edid) and
348 * generate a hotplug event so userspace knows there's a new connector
349 * available.
350 *
351 * Note:
352 * This routine should only be called *once* for each DRM minor registered.
353 * A second call for an already registered device will trigger the BUG_ON
354 * below.
355 */
356int drm_sysfs_connector_add(struct drm_connector *connector)
357{
358 struct drm_device *dev = connector->dev;
359 int ret = 0, i, j;
360
361 /* We shouldn't get called more than once for the same connector */
362 BUG_ON(device_is_registered(&connector->kdev));
363
364 connector->kdev.parent = &dev->primary->kdev;
365 connector->kdev.class = drm_class;
366 connector->kdev.release = drm_sysfs_device_release;
367
368 DRM_DEBUG("adding \"%s\" to sysfs\n",
369 drm_get_connector_name(connector));
370
Kay Sievers2ead0542009-03-24 16:38:22 -0700371 dev_set_name(&connector->kdev, "card%d-%s",
372 dev->primary->index, drm_get_connector_name(connector));
Dave Airlief453ba02008-11-07 14:05:41 -0800373 ret = device_register(&connector->kdev);
374
375 if (ret) {
376 DRM_ERROR("failed to register connector device: %d\n", ret);
377 goto out;
378 }
379
380 /* Standard attributes */
381
382 for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) {
383 ret = device_create_file(&connector->kdev, &connector_attrs[i]);
384 if (ret)
385 goto err_out_files;
386 }
387
388 /* Optional attributes */
389 /*
390 * In the long run it maybe a good idea to make one set of
391 * optionals per connector type.
392 */
393 switch (connector->connector_type) {
394 case DRM_MODE_CONNECTOR_DVII:
395 case DRM_MODE_CONNECTOR_Composite:
396 case DRM_MODE_CONNECTOR_SVIDEO:
397 case DRM_MODE_CONNECTOR_Component:
Francisco Jerez74bd3c22009-08-02 04:19:18 +0200398 case DRM_MODE_CONNECTOR_TV:
Dave Airlief453ba02008-11-07 14:05:41 -0800399 for (i = 0; i < ARRAY_SIZE(connector_attrs_opt1); i++) {
400 ret = device_create_file(&connector->kdev, &connector_attrs_opt1[i]);
401 if (ret)
402 goto err_out_files;
403 }
404 break;
405 default:
406 break;
407 }
408
409 ret = sysfs_create_bin_file(&connector->kdev.kobj, &edid_attr);
410 if (ret)
411 goto err_out_files;
412
413 /* Let userspace know we have a new connector */
414 drm_sysfs_hotplug_event(dev);
415
416 return 0;
417
418err_out_files:
419 if (i > 0)
420 for (j = 0; j < i; j++)
421 device_remove_file(&connector->kdev,
422 &connector_attrs[i]);
423 device_unregister(&connector->kdev);
424
425out:
426 return ret;
427}
428EXPORT_SYMBOL(drm_sysfs_connector_add);
429
430/**
431 * drm_sysfs_connector_remove - remove an connector device from sysfs
432 * @connector: connector to remove
433 *
434 * Remove @connector and its associated attributes from sysfs. Note that
435 * the device model core will take care of sending the "remove" uevent
436 * at this time, so we don't need to do it.
437 *
438 * Note:
439 * This routine should only be called if the connector was previously
440 * successfully registered. If @connector hasn't been registered yet,
441 * you'll likely see a panic somewhere deep in sysfs code when called.
442 */
443void drm_sysfs_connector_remove(struct drm_connector *connector)
444{
445 int i;
446
447 DRM_DEBUG("removing \"%s\" from sysfs\n",
448 drm_get_connector_name(connector));
449
450 for (i = 0; i < ARRAY_SIZE(connector_attrs); i++)
451 device_remove_file(&connector->kdev, &connector_attrs[i]);
452 sysfs_remove_bin_file(&connector->kdev.kobj, &edid_attr);
453 device_unregister(&connector->kdev);
454}
455EXPORT_SYMBOL(drm_sysfs_connector_remove);
456
457/**
458 * drm_sysfs_hotplug_event - generate a DRM uevent
459 * @dev: DRM device
460 *
461 * Send a uevent for the DRM device specified by @dev. Currently we only
462 * set HOTPLUG=1 in the uevent environment, but this could be expanded to
463 * deal with other types of events.
464 */
465void drm_sysfs_hotplug_event(struct drm_device *dev)
466{
467 char *event_string = "HOTPLUG=1";
468 char *envp[] = { event_string, NULL };
469
470 DRM_DEBUG("generating hotplug event\n");
471
472 kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, envp);
473}
Jesse Barnes5ca58282009-03-31 14:11:15 -0700474EXPORT_SYMBOL(drm_sysfs_hotplug_event);
Dave Airlief453ba02008-11-07 14:05:41 -0800475
Jesse Barnese8b962b2007-11-22 14:02:38 +1000476/**
477 * drm_sysfs_device_add - adds a class device to sysfs for a character driver
478 * @dev: DRM device to be added
479 * @head: DRM head in question
480 *
481 * Add a DRM device to the DRM's device model class. We use @dev's PCI device
482 * as the parent for the Linux device, and make sure it has a file containing
483 * the driver we're using (for userspace compatibility).
484 */
Dave Airlie2c14f282008-04-21 16:47:32 +1000485int drm_sysfs_device_add(struct drm_minor *minor)
Jesse Barnese8b962b2007-11-22 14:02:38 +1000486{
487 int err;
Dave Airlie2c14f282008-04-21 16:47:32 +1000488 char *minor_str;
Jesse Barnese8b962b2007-11-22 14:02:38 +1000489
Dave Airlie2c14f282008-04-21 16:47:32 +1000490 minor->kdev.parent = &minor->dev->pdev->dev;
491 minor->kdev.class = drm_class;
492 minor->kdev.release = drm_sysfs_device_release;
493 minor->kdev.devt = minor->device;
Thomas Hellstrom08e4d532009-08-20 19:02:31 +1000494 minor->kdev.type = &drm_sysfs_device_minor;
Dave Airlief453ba02008-11-07 14:05:41 -0800495 if (minor->type == DRM_MINOR_CONTROL)
496 minor_str = "controlD%d";
497 else if (minor->type == DRM_MINOR_RENDER)
498 minor_str = "renderD%d";
499 else
500 minor_str = "card%d";
Jesse Barnese8b962b2007-11-22 14:02:38 +1000501
Kay Sievers8f4bbd92009-01-06 10:44:41 -0800502 dev_set_name(&minor->kdev, minor_str, minor->index);
Dave Airlie2c14f282008-04-21 16:47:32 +1000503
504 err = device_register(&minor->kdev);
Jesse Barnese8b962b2007-11-22 14:02:38 +1000505 if (err) {
506 DRM_ERROR("device add failed: %d\n", err);
Jeff Garzik24f73c92006-10-10 14:23:37 -0700507 goto err_out;
508 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
Jesse Barnese8b962b2007-11-22 14:02:38 +1000510 return 0;
Jeff Garzik24f73c92006-10-10 14:23:37 -0700511
Jeff Garzik24f73c92006-10-10 14:23:37 -0700512err_out:
Jesse Barnese8b962b2007-11-22 14:02:38 +1000513 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514}
515
516/**
Jesse Barnese8b962b2007-11-22 14:02:38 +1000517 * drm_sysfs_device_remove - remove DRM device
518 * @dev: DRM device to remove
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 *
520 * This call unregisters and cleans up a class device that was created with a
521 * call to drm_sysfs_device_add()
522 */
Dave Airlie2c14f282008-04-21 16:47:32 +1000523void drm_sysfs_device_remove(struct drm_minor *minor)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524{
Dave Airlie2c14f282008-04-21 16:47:32 +1000525 device_unregister(&minor->kdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526}
Thomas Hellstrom327c2252009-08-17 16:28:37 +0200527
528
529/**
530 * drm_class_device_register - Register a struct device in the drm class.
531 *
532 * @dev: pointer to struct device to register.
533 *
534 * @dev should have all relevant members pre-filled with the exception
535 * of the class member. In particular, the device_type member must
536 * be set.
537 */
538
539int drm_class_device_register(struct device *dev)
540{
541 dev->class = drm_class;
542 return device_register(dev);
543}
544EXPORT_SYMBOL_GPL(drm_class_device_register);
545
546void drm_class_device_unregister(struct device *dev)
547{
548 return device_unregister(dev);
549}
550EXPORT_SYMBOL_GPL(drm_class_device_unregister);