drm: Goody bye, drm_bus!
[linux/fpc-iii.git] / drivers / gpu / drm / drm_usb.c
blob9c434905d37fbc82a45382325e4dc602a52efdaa
1 #include <drm/drmP.h>
2 #include <drm/drm_usb.h>
3 #include <linux/usb.h>
4 #include <linux/module.h>
6 int drm_get_usb_dev(struct usb_interface *interface,
7 const struct usb_device_id *id,
8 struct drm_driver *driver)
10 struct drm_device *dev;
11 int ret;
13 DRM_DEBUG("\n");
15 dev = drm_dev_alloc(driver, &interface->dev);
16 if (!dev)
17 return -ENOMEM;
19 dev->usbdev = interface_to_usbdev(interface);
20 usb_set_intfdata(interface, dev);
22 ret = drm_dev_register(dev, 0);
23 if (ret)
24 goto err_free;
26 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
27 driver->name, driver->major, driver->minor, driver->patchlevel,
28 driver->date, dev->primary->index);
30 return 0;
32 err_free:
33 drm_dev_unref(dev);
34 return ret;
37 EXPORT_SYMBOL(drm_get_usb_dev);
39 /**
40 * drm_usb_init - Register matching USB devices with the DRM subsystem
41 * @driver: DRM device driver
42 * @udriver: USB device driver
44 * Registers one or more devices matched by a USB driver with the DRM
45 * subsystem.
47 * Return: 0 on success or a negative error code on failure.
49 int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
51 int res;
52 DRM_DEBUG("\n");
54 res = usb_register(udriver);
55 return res;
57 EXPORT_SYMBOL(drm_usb_init);
59 /**
60 * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
61 * @driver: DRM device driver
62 * @udriver: USB device driver
64 * Unregisters one or more devices matched by a USB driver from the DRM
65 * subsystem.
67 void drm_usb_exit(struct drm_driver *driver,
68 struct usb_driver *udriver)
70 usb_deregister(udriver);
72 EXPORT_SYMBOL(drm_usb_exit);
74 MODULE_AUTHOR("David Airlie");
75 MODULE_DESCRIPTION("USB DRM support");
76 MODULE_LICENSE("GPL and additional rights");