summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_usb.c
blob: 9c434905d37fbc82a45382325e4dc602a52efdaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <drm/drmP.h>
#include <drm/drm_usb.h>
#include <linux/usb.h>
#include <linux/module.h>

int drm_get_usb_dev(struct usb_interface *interface,
		    const struct usb_device_id *id,
		    struct drm_driver *driver)
{
	struct drm_device *dev;
	int ret;

	DRM_DEBUG("\n");

	dev = drm_dev_alloc(driver, &interface->dev);
	if (!dev)
		return -ENOMEM;

	dev->usbdev = interface_to_usbdev(interface);
	usb_set_intfdata(interface, dev);

	ret = drm_dev_register(dev, 0);
	if (ret)
		goto err_free;

	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
		 driver->name, driver->major, driver->minor, driver->patchlevel,
		 driver->date, dev->primary->index);

	return 0;

err_free:
	drm_dev_unref(dev);
	return ret;

}
EXPORT_SYMBOL(drm_get_usb_dev);

/**
 * drm_usb_init - Register matching USB devices with the DRM subsystem
 * @driver: DRM device driver
 * @udriver: USB device driver
 *
 * Registers one or more devices matched by a USB driver with the DRM
 * subsystem.
 *
 * Return: 0 on success or a negative error code on failure.
 */
int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
{
	int res;
	DRM_DEBUG("\n");

	res = usb_register(udriver);
	return res;
}
EXPORT_SYMBOL(drm_usb_init);

/**
 * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
 * @driver: DRM device driver
 * @udriver: USB device driver
 *
 * Unregisters one or more devices matched by a USB driver from the DRM
 * subsystem.
 */
void drm_usb_exit(struct drm_driver *driver,
		  struct usb_driver *udriver)
{
	usb_deregister(udriver);
}
EXPORT_SYMBOL(drm_usb_exit);

MODULE_AUTHOR("David Airlie");
MODULE_DESCRIPTION("USB DRM support");
MODULE_LICENSE("GPL and additional rights");