/* Add a DRM device to the DRM's device model class. We use @dev's PCI device as the parent for the Linux device, and make sure it has a file containing the driver we're using (for userspace compatibility).  */
int drm_sysfs_device_add(struct drm_minor *minor)
/* Add a DRM device to the DRM's device model class. We use @dev's PCI device as the parent for the Linux device, and make sure it has a file containing the driver we're using (for userspace compatibility).  */
int drm_sysfs_device_add(struct drm_minor *minor)
{
	int err;
	char *minor_str;
	minor->kdev.parent = &minor->dev->pdev->dev;
	minor->kdev.class = drm_class;
	minor->kdev.release = drm_sysfs_device_release;
	minor->kdev.devt = minor->device;
	minor->kdev.type = &drm_sysfs_device_minor;
	if (minor->type == DRM_MINOR_CONTROL)
		minor_str = "controlD%d";
        else if (minor->type == DRM_MINOR_RENDER)
                minor_str = "renderD%d";
        else
                minor_str = "card%d";
	dev_set_name(&minor->kdev, minor_str, minor->index);
	err = device_register(&minor->kdev);
	if (err) {
		DRM_ERROR("device add failed: %d\n", err);
		goto err_out;
	}
	return 0;
err_out:
	return err;
}