]> err.no Git - linux-2.6/blobdiff - drivers/char/drm/drm_stub.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / drivers / char / drm / drm_stub.c
index 19408adcc7755c396f83839986013773eb0a48c9..d93a217f856a7303d185396ea2a376e8cc3c3e65 100644 (file)
@@ -49,16 +49,21 @@ MODULE_PARM_DESC(debug, "Enable debug output");
 module_param_named(cards_limit, drm_cards_limit, int, 0444);
 module_param_named(debug, drm_debug, int, 0600);
 
-drm_head_t **drm_heads;
+struct drm_head **drm_heads;
 struct class *drm_class;
 struct proc_dir_entry *drm_proc_root;
 
-static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
+static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
                           const struct pci_device_id *ent,
                           struct drm_driver *driver)
 {
        int retcode;
 
+       INIT_LIST_HEAD(&dev->filelist);
+       INIT_LIST_HEAD(&dev->ctxlist);
+       INIT_LIST_HEAD(&dev->vmalist);
+       INIT_LIST_HEAD(&dev->maplist);
+
        spin_lock_init(&dev->count_lock);
        spin_lock_init(&dev->drw_lock);
        spin_lock_init(&dev->tasklet_lock);
@@ -67,6 +72,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
        mutex_init(&dev->struct_mutex);
        mutex_init(&dev->ctxlist_mutex);
 
+       idr_init(&dev->drw_idr);
+
        dev->pdev = pdev;
        dev->pci_device = pdev->device;
        dev->pci_vendor = pdev->vendor;
@@ -76,12 +83,7 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
 #endif
        dev->irq = pdev->irq;
 
-       dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
-       if (dev->maplist == NULL)
-               return -ENOMEM;
-       INIT_LIST_HEAD(&dev->maplist->head);
        if (drm_ht_create(&dev->map_hash, 12)) {
-               drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
                return -ENOMEM;
        }
 
@@ -96,10 +98,6 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
 
        dev->driver = driver;
 
-       if (dev->driver->load)
-               if ((retcode = dev->driver->load(dev, ent->driver_data)))
-                       goto error_out_unreg;
-
        if (drm_core_has_AGP(dev)) {
                if (drm_device_is_agp(dev))
                        dev->agp = drm_agp_init(dev);
@@ -118,6 +116,10 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
                }
        }
 
+       if (dev->driver->load)
+               if ((retcode = dev->driver->load(dev, ent->driver_data)))
+                       goto error_out_unreg;
+
        retcode = drm_ctxbitmap_init(dev);
        if (retcode) {
                DRM_ERROR("Cannot allocate memory for context bitmap.\n");
@@ -143,9 +145,9 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
  * create the proc init entry via proc_init(). This routines assigns
  * minor numbers to secondary heads of multi-headed cards
  */
-static int drm_get_head(drm_device_t * dev, drm_head_t * head)
+static int drm_get_head(struct drm_device * dev, struct drm_head * head)
 {
-       drm_head_t **heads = drm_heads;
+       struct drm_head **heads = drm_heads;
        int ret;
        int minor;
 
@@ -154,7 +156,7 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head)
        for (minor = 0; minor < drm_cards_limit; minor++, heads++) {
                if (!*heads) {
 
-                       *head = (drm_head_t) {
+                       *head = (struct drm_head) {
                        .dev = dev,.device =
                                    MKDEV(DRM_MAJOR, minor),.minor = minor,};
 
@@ -166,11 +168,10 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head)
                                goto err_g1;
                        }
 
-                       head->dev_class = drm_sysfs_device_add(drm_class, head);
-                       if (IS_ERR(head->dev_class)) {
+                       ret = drm_sysfs_device_add(dev, head);
+                       if (ret) {
                                printk(KERN_ERR
                                       "DRM: Error sysfs_device_add.\n");
-                               ret = PTR_ERR(head->dev_class);
                                goto err_g2;
                        }
                        *heads = head;
@@ -184,7 +185,7 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head)
       err_g2:
        drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
       err_g1:
-       *head = (drm_head_t) {
+       *head = (struct drm_head) {
        .dev = NULL};
        return ret;
 }
@@ -203,7 +204,7 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head)
 int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
                struct drm_driver *driver)
 {
-       drm_device_t *dev;
+       struct drm_device *dev;
        int ret;
 
        DRM_DEBUG("\n");
@@ -216,13 +217,14 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
        if (ret)
                goto err_g1;
 
+       pci_set_master(pdev);
        if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
                printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
                goto err_g2;
        }
        if ((ret = drm_get_head(dev, &dev->primary)))
                goto err_g2;
-       
+
        DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
                 driver->name, driver->major, driver->minor, driver->patchlevel,
                 driver->date, dev->primary.minor);
@@ -246,7 +248,7 @@ err_g1:
  * "drm" data, otherwise unregisters the "drm" data, frees the dev list and
  * unregisters the character device.
  */
-int drm_put_dev(drm_device_t * dev)
+int drm_put_dev(struct drm_device * dev)
 {
        DRM_DEBUG("release primary %s\n", dev->driver->pci_driver.name);
 
@@ -274,16 +276,16 @@ int drm_put_dev(drm_device_t * dev)
  * last minor released.
  *
  */
-int drm_put_head(drm_head_t * head)
+int drm_put_head(struct drm_head * head)
 {
        int minor = head->minor;
 
        DRM_DEBUG("release secondary minor %d\n", minor);
 
        drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
-       drm_sysfs_device_remove(head->dev_class);
+       drm_sysfs_device_remove(head->dev);
 
-       *head = (drm_head_t) {.dev = NULL};
+       *head = (struct drm_head) {.dev = NULL};
 
        drm_heads[minor] = NULL;