aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_pci.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-10-02 05:23:35 -0400
committerDave Airlie <airlied@redhat.com>2013-10-09 01:54:31 -0400
commitc22f0ace1926da399d9a16dfaf09174c1b03594c (patch)
tree9c82626f939917cba7ab3626a22fe61d52940ec9 /drivers/gpu/drm/drm_pci.c
parent1bb72532ac260a2d3982b40bdd4c936d779d0d16 (diff)
drm: merge device setup into drm_dev_register()
All bus drivers do device setup themselves. This requires us to adjust all of them if we introduce new core features. Thus, merge all these into a uniform drm_dev_register() helper. Note that this removes the drm_lastclose() error path for AGP as it is horribly broken. Moreover, no bus driver called this in any other error path either. Instead, we use the recently introduced AGP cleanup helpers. We also keep a DRIVER_MODESET condition around pci_set_drvdata() to keep semantics. [airlied: keep passing flags through so drivers don't oops on load] Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_pci.c')
-rw-r--r--drivers/gpu/drm/drm_pci.c56
1 files changed, 7 insertions, 49 deletions
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index d2758be37a93..743589dc47ce 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -328,7 +328,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
328 328
329 ret = pci_enable_device(pdev); 329 ret = pci_enable_device(pdev);
330 if (ret) 330 if (ret)
331 goto err_g1; 331 goto err_free;
332 332
333 dev->pdev = pdev; 333 dev->pdev = pdev;
334 dev->pci_device = pdev->device; 334 dev->pci_device = pdev->device;
@@ -338,65 +338,23 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
338 dev->hose = pdev->sysdata; 338 dev->hose = pdev->sysdata;
339#endif 339#endif
340 340
341 mutex_lock(&drm_global_mutex); 341 if (drm_core_check_feature(dev, DRIVER_MODESET))
342
343 if ((ret = drm_fill_in_dev(dev, ent, driver))) {
344 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
345 goto err_g2;
346 }
347
348 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
349 pci_set_drvdata(pdev, dev); 342 pci_set_drvdata(pdev, dev);
350 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
351 if (ret)
352 goto err_g2;
353 }
354
355 if (drm_core_check_feature(dev, DRIVER_RENDER) && drm_rnodes) {
356 ret = drm_get_minor(dev, &dev->render, DRM_MINOR_RENDER);
357 if (ret)
358 goto err_g21;
359 }
360 343
361 if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY))) 344 ret = drm_dev_register(dev, ent->driver_data);
362 goto err_g3; 345 if (ret)
363 346 goto err_pci;
364 if (dev->driver->load) {
365 ret = dev->driver->load(dev, ent->driver_data);
366 if (ret)
367 goto err_g4;
368 }
369
370 /* setup the grouping for the legacy output */
371 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
372 ret = drm_mode_group_init_legacy_group(dev,
373 &dev->primary->mode_group);
374 if (ret)
375 goto err_g4;
376 }
377
378 list_add_tail(&dev->driver_item, &driver->device_list);
379 347
380 DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", 348 DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
381 driver->name, driver->major, driver->minor, driver->patchlevel, 349 driver->name, driver->major, driver->minor, driver->patchlevel,
382 driver->date, pci_name(pdev), dev->primary->index); 350 driver->date, pci_name(pdev), dev->primary->index);
383 351
384 mutex_unlock(&drm_global_mutex);
385 return 0; 352 return 0;
386 353
387err_g4: 354err_pci:
388 drm_put_minor(&dev->primary);
389err_g3:
390 if (dev->render)
391 drm_put_minor(&dev->render);
392err_g21:
393 if (drm_core_check_feature(dev, DRIVER_MODESET))
394 drm_put_minor(&dev->control);
395err_g2:
396 pci_disable_device(pdev); 355 pci_disable_device(pdev);
397err_g1: 356err_free:
398 kfree(dev); 357 kfree(dev);
399 mutex_unlock(&drm_global_mutex);
400 return ret; 358 return ret;
401} 359}
402EXPORT_SYMBOL(drm_get_pci_dev); 360EXPORT_SYMBOL(drm_get_pci_dev);