FreeBSD/sys/dev/drm2/drm_pci.c
/**
 * Register.
 *
 * \param pdev - PCI device structure
 * \param ent entry from the PCI ID table with device type flags
 * \return zero on success or a negative number on failure.
 *
 * Attempt to gets inter module "drm" information. If we are first
 * then register the character device and inter module information.
 * Try and register, if we fail to register, backout previous work.
 */
Register.
\param pdev - PCI device structure
\param ent entry from the PCI ID table with device type flags
\return zero on success or a negative number on failure.

Attempt to gets inter module "drm" information. If we are first
then register the character device and inter module information.
Try and register, if we fail to register, backout previous work.
Register . \ param pdev - PCI device structure \ param ent entry from the PCI ID table with device type flags \ return zero on success or a negative number on failure . Attempt to gets inter module " drm " information . If we are first then register the character device and inter module information . Try and register if we fail to register backout previous work .
int drm_get_pci_dev(device_t kdev, struct drm_device *dev,
		    struct drm_driver *driver)
{
	int ret;
	DRM_DEBUG("\n");
	driver->bus = &drm_pci_bus;
	dev->dev = kdev;
	dev->pci_domain = pci_get_domain(dev->dev);
	dev->pci_bus = pci_get_bus(dev->dev);
	dev->pci_slot = pci_get_slot(dev->dev);
	dev->pci_func = pci_get_function(dev->dev);
	dev->pci_vendor = pci_get_vendor(dev->dev);
	dev->pci_device = pci_get_device(dev->dev);
	dev->pci_subvendor = pci_get_subvendor(dev->dev);
	dev->pci_subdevice = pci_get_subdevice(dev->dev);
	sx_xlock(&drm_global_mutex);
	if ((ret = drm_fill_in_dev(dev, driver))) {
		DRM_ERROR("Failed to fill in dev: %d\n", ret);
		goto err_g1;
	}
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
		if (ret)
			goto err_g2;
	}
	if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
		goto err_g3;
	if (dev->driver->load) {
		ret = dev->driver->load(dev,
		    dev->id_entry->driver_private);
		if (ret)
			goto err_g4;
	}
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
		ret = drm_mode_group_init_legacy_group(dev,
						&dev->primary->mode_group);
		if (ret)
			goto err_g5;
	}
#ifdef FREEBSD_NOTYET
	list_add_tail(&dev->driver_item, &driver->device_list);
#endif 
	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
		 driver->name, driver->major, driver->minor, driver->patchlevel,
		 driver->date, device_get_nameunit(dev->dev), dev->primary->index);
	sx_xunlock(&drm_global_mutex);
	return 0;
err_g5:
	if (dev->driver->unload)
		dev->driver->unload(dev);
err_g4:
	drm_put_minor(&dev->primary);
err_g3:
	if (drm_core_check_feature(dev, DRIVER_MODESET))
		drm_put_minor(&dev->control);
err_g2:
	drm_cancel_fill_in_dev(dev);
err_g1:
	sx_xunlock(&drm_global_mutex);
	return ret;
}
int drm_get_pci_dev ( device_t kdev , struct drm_device * dev , struct drm_driver * driver ) { int ret ; DRM_DEBUG ( " \n " ) ; driver -> bus = & drm_pci_bus ; dev -> dev = kdev ; dev -> pci_domain = pci_get_domain ( dev -> dev ) ; dev -> pci_bus = pci_get_bus ( dev -> dev ) ; dev -> pci_slot = pci_get_slot ( dev -> dev ) ; dev -> pci_func = pci_get_function ( dev -> dev ) ; dev -> pci_vendor = pci_get_vendor ( dev -> dev ) ; dev -> pci_device = pci_get_device ( dev -> dev ) ; dev -> pci_subvendor = pci_get_subvendor ( dev -> dev ) ; dev -> pci_subdevice = pci_get_subdevice ( dev -> dev ) ; sx_xlock ( & drm_global_mutex ) ; if ( ( ret = drm_fill_in_dev ( dev , driver ) ) ) { DRM_ERROR ( " \n " , ret ) ; goto err_g1 ; } if ( drm_core_check_feature ( dev , DRIVER_MODESET ) ) { ret = drm_get_minor ( dev , & dev -> control , DRM_MINOR_CONTROL ) ; if ( ret ) goto err_g2 ; } if ( ( ret = drm_get_minor ( dev , & dev -> primary , DRM_MINOR_LEGACY ) ) ) goto err_g3 ; if ( dev -> driver -> load ) { ret = dev -> driver -> load ( dev , dev -> id_entry -> driver_private ) ; if ( ret ) goto err_g4 ; } if ( drm_core_check_feature ( dev , DRIVER_MODESET ) ) { ret = drm_mode_group_init_legacy_group ( dev , & dev -> primary -> mode_group ) ; if ( ret ) goto err_g5 ; } #ifdef FREEBSD_NOTYET list_add_tail ( & dev -> driver_item , & driver -> device_list ) ; #endif DRM_INFO ( " \n " , driver -> name , driver -> major , driver -> minor , driver -> patchlevel , driver -> date , device_get_nameunit ( dev -> dev ) , dev -> primary -> index ) ; sx_xunlock ( & drm_global_mutex ) ; return 0 ; err_g5 : if ( dev -> driver -> unload ) dev -> driver -> unload ( dev ) ; err_g4 : drm_put_minor ( & dev -> primary ) ; err_g3 : if ( drm_core_check_feature ( dev , DRIVER_MODESET ) ) drm_put_minor ( & dev -> control ) ; err_g2 : drm_cancel_fill_in_dev ( dev ) ; err_g1 : sx_xunlock ( & drm_global_mutex ) ; return ret ; }
Register.
Register .
/* setup the grouping for the legacy output */ /* FREEBSD_NOTYET */