i2c-eg20t: change timeout value 50msec to 1000msec
[zen-stable.git] / drivers / gpu / drm / drm_usb.c
blob445003f4dc939cbc731a915551b509633f2f6769
1 #include "drmP.h"
2 #include <linux/usb.h>
3 #include <linux/export.h>
5 #ifdef CONFIG_USB
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 struct usb_device *usbdev;
12 int ret;
14 DRM_DEBUG("\n");
16 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
17 if (!dev)
18 return -ENOMEM;
20 usbdev = interface_to_usbdev(interface);
21 dev->usbdev = usbdev;
22 dev->dev = &usbdev->dev;
24 mutex_lock(&drm_global_mutex);
26 ret = drm_fill_in_dev(dev, NULL, driver);
27 if (ret) {
28 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
29 goto err_g1;
32 usb_set_intfdata(interface, dev);
33 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
34 if (ret)
35 goto err_g1;
37 ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY);
38 if (ret)
39 goto err_g2;
41 if (dev->driver->load) {
42 ret = dev->driver->load(dev, 0);
43 if (ret)
44 goto err_g3;
47 /* setup the grouping for the legacy output */
48 ret = drm_mode_group_init_legacy_group(dev,
49 &dev->primary->mode_group);
50 if (ret)
51 goto err_g3;
53 list_add_tail(&dev->driver_item, &driver->device_list);
55 mutex_unlock(&drm_global_mutex);
57 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
58 driver->name, driver->major, driver->minor, driver->patchlevel,
59 driver->date, dev->primary->index);
61 return 0;
63 err_g3:
64 drm_put_minor(&dev->primary);
65 err_g2:
66 drm_put_minor(&dev->control);
67 err_g1:
68 kfree(dev);
69 mutex_unlock(&drm_global_mutex);
70 return ret;
73 EXPORT_SYMBOL(drm_get_usb_dev);
75 static int drm_usb_get_irq(struct drm_device *dev)
77 return 0;
80 static const char *drm_usb_get_name(struct drm_device *dev)
82 return "USB";
85 static int drm_usb_set_busid(struct drm_device *dev,
86 struct drm_master *master)
88 return 0;
91 static struct drm_bus drm_usb_bus = {
92 .bus_type = DRIVER_BUS_USB,
93 .get_irq = drm_usb_get_irq,
94 .get_name = drm_usb_get_name,
95 .set_busid = drm_usb_set_busid,
98 int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
100 int res;
101 DRM_DEBUG("\n");
103 INIT_LIST_HEAD(&driver->device_list);
104 driver->kdriver.usb = udriver;
105 driver->bus = &drm_usb_bus;
107 res = usb_register(udriver);
108 return res;
110 EXPORT_SYMBOL(drm_usb_init);
112 void drm_usb_exit(struct drm_driver *driver,
113 struct usb_driver *udriver)
115 usb_deregister(udriver);
117 EXPORT_SYMBOL(drm_usb_exit);
118 #endif