This is the recommended way to create the drm_device structure, according to DRM documentation. Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx> --- drivers/staging/vboxvideo/vbox_drv.c | 110 +++++++++++--------------- drivers/staging/vboxvideo/vbox_drv.h | 17 ++-- drivers/staging/vboxvideo/vbox_fb.c | 19 ++--- drivers/staging/vboxvideo/vbox_irq.c | 8 +- drivers/staging/vboxvideo/vbox_main.c | 30 +++---- drivers/staging/vboxvideo/vbox_mode.c | 36 ++++----- drivers/staging/vboxvideo/vbox_ttm.c | 13 ++- 7 files changed, 111 insertions(+), 122 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index 410a1f35b746..c4290d4b4a53 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -51,35 +51,31 @@ MODULE_DEVICE_TABLE(pci, pciidlist); static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - struct vbox_private *vbox = NULL; - struct drm_device *dev = NULL; + struct vbox_private *vbox; int ret = 0; if (!vbox_check_supported(VBE_DISPI_ID_HGSMI)) return -ENODEV; - dev = drm_dev_alloc(&driver, &pdev->dev); - if (IS_ERR(dev)) - return PTR_ERR(dev); + vbox = kzalloc(sizeof(*vbox), GFP_KERNEL); + if (!vbox) + return -ENOMEM; - ret = pci_enable_device(pdev); - if (ret) - goto err_dev_put; - - dev->pdev = pdev; - pci_set_drvdata(pdev, dev); - - vbox = devm_kzalloc(&pdev->dev, sizeof(*vbox), GFP_KERNEL); - if (!vbox) { - ret = -ENOMEM; - goto err_pci_disable; + ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev); + if (ret) { + kfree(vbox); + return ret; } - dev->dev_private = vbox; - vbox->dev = dev; - + vbox->ddev.pdev = pdev; + vbox->ddev.dev_private = vbox; + pci_set_drvdata(pdev, vbox); mutex_init(&vbox->hw_mutex); + ret = pci_enable_device(pdev); + if (ret) + goto err_dev_put; + ret = vbox_hw_init(vbox); if (ret) goto err_pci_disable; @@ -88,7 +84,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto err_hw_fini; - ret = vbox_mode_init(dev); + ret = vbox_mode_init(vbox); if (ret) goto err_mm_fini; @@ -96,22 +92,22 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto err_mode_fini; - ret = vbox_fbdev_init(dev); + ret = vbox_fbdev_init(vbox); if (ret) goto err_irq_fini; - ret = drm_dev_register(dev, 0); + ret = drm_dev_register(&vbox->ddev, 0); if (ret) goto err_fbdev_fini; return 0; err_fbdev_fini: - vbox_fbdev_fini(dev); + vbox_fbdev_fini(vbox); err_irq_fini: vbox_irq_fini(vbox); err_mode_fini: - vbox_mode_fini(dev); + vbox_mode_fini(vbox); err_mm_fini: vbox_mm_fini(vbox); err_hw_fini: @@ -119,110 +115,100 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_pci_disable: pci_disable_device(pdev); err_dev_put: - drm_dev_put(dev); + drm_dev_put(&vbox->ddev); return ret; } static void vbox_pci_remove(struct pci_dev *pdev) { - struct drm_device *dev = pci_get_drvdata(pdev); - struct vbox_private *vbox = dev->dev_private; + struct vbox_private *vbox = pci_get_drvdata(pdev); - drm_dev_unregister(dev); - vbox_fbdev_fini(dev); + drm_dev_unregister(&vbox->ddev); + vbox_fbdev_fini(vbox); vbox_irq_fini(vbox); - vbox_mode_fini(dev); + vbox_mode_fini(vbox); vbox_mm_fini(vbox); vbox_hw_fini(vbox); - drm_dev_put(dev); + drm_dev_put(&vbox->ddev); } -static int vbox_drm_freeze(struct drm_device *dev) +static int vbox_drm_freeze(struct vbox_private *vbox) { - struct vbox_private *vbox = dev->dev_private; - - drm_kms_helper_poll_disable(dev); + drm_kms_helper_poll_disable(&vbox->ddev); - pci_save_state(dev->pdev); + pci_save_state(vbox->ddev.pdev); drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true); return 0; } -static int vbox_drm_thaw(struct drm_device *dev) +static int vbox_drm_thaw(struct vbox_private *vbox) { - struct vbox_private *vbox = dev->dev_private; - - drm_mode_config_reset(dev); - drm_helper_resume_force_mode(dev); + drm_mode_config_reset(&vbox->ddev); + drm_helper_resume_force_mode(&vbox->ddev); drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false); return 0; } -static int vbox_drm_resume(struct drm_device *dev) +static int vbox_drm_resume(struct vbox_private *vbox) { int ret; - if (pci_enable_device(dev->pdev)) + if (pci_enable_device(vbox->ddev.pdev)) return -EIO; - ret = vbox_drm_thaw(dev); + ret = vbox_drm_thaw(vbox); if (ret) return ret; - drm_kms_helper_poll_enable(dev); + drm_kms_helper_poll_enable(&vbox->ddev); return 0; } static int vbox_pm_suspend(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct drm_device *ddev = pci_get_drvdata(pdev); + struct vbox_private *vbox = dev_get_drvdata(dev); int error; - error = vbox_drm_freeze(ddev); + error = vbox_drm_freeze(vbox); if (error) return error; - pci_disable_device(pdev); - pci_set_power_state(pdev, PCI_D3hot); + pci_disable_device(vbox->ddev.pdev); + pci_set_power_state(vbox->ddev.pdev, PCI_D3hot); return 0; } static int vbox_pm_resume(struct device *dev) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct vbox_private *vbox = dev_get_drvdata(dev); - return vbox_drm_resume(ddev); + return vbox_drm_resume(vbox); } static int vbox_pm_freeze(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct drm_device *ddev = pci_get_drvdata(pdev); - - if (!ddev || !ddev->dev_private) - return -ENODEV; + struct vbox_private *vbox = dev_get_drvdata(dev); - return vbox_drm_freeze(ddev); + return vbox_drm_freeze(vbox); } static int vbox_pm_thaw(struct device *dev) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct vbox_private *vbox = dev_get_drvdata(dev); - return vbox_drm_thaw(ddev); + return vbox_drm_thaw(vbox); } static int vbox_pm_poweroff(struct device *dev) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct vbox_private *vbox = dev_get_drvdata(dev); - return vbox_drm_freeze(ddev); + return vbox_drm_freeze(vbox); } static const struct dev_pm_ops vbox_pm_ops = { diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index a8e0dd8b57bf..28ffdffe877a 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -75,7 +75,8 @@ struct vbox_fbdev; struct vbox_private { - struct drm_device *dev; + /* Must be first; or we must define our own release callback */ + struct drm_device ddev; u8 __iomem *guest_heap; u8 __iomem *vbva_buffers; @@ -179,8 +180,8 @@ bool vbox_check_supported(u16 id); int vbox_hw_init(struct vbox_private *vbox); void vbox_hw_fini(struct vbox_private *vbox); -int vbox_mode_init(struct drm_device *dev); -void vbox_mode_fini(struct drm_device *dev); +int vbox_mode_init(struct vbox_private *vbox); +void vbox_mode_fini(struct vbox_private *vbox); #define DRM_MODE_FB_CMD drm_mode_fb_cmd2 #define CRTC_FB(crtc) ((crtc)->primary->fb) @@ -193,13 +194,13 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, struct drm_clip_rect *rects, unsigned int num_rects); -int vbox_framebuffer_init(struct drm_device *dev, +int vbox_framebuffer_init(struct vbox_private *vbox, struct vbox_framebuffer *vbox_fb, const struct DRM_MODE_FB_CMD *mode_cmd, struct drm_gem_object *obj); -int vbox_fbdev_init(struct drm_device *dev); -void vbox_fbdev_fini(struct drm_device *dev); +int vbox_fbdev_init(struct vbox_private *vbox); +void vbox_fbdev_fini(struct vbox_private *vbox); void vbox_fbdev_set_base(struct vbox_private *vbox, unsigned long gpu_addr); struct vbox_bo { @@ -234,10 +235,10 @@ int vbox_dumb_mmap_offset(struct drm_file *file, int vbox_mm_init(struct vbox_private *vbox); void vbox_mm_fini(struct vbox_private *vbox); -int vbox_bo_create(struct drm_device *dev, int size, int align, +int vbox_bo_create(struct vbox_private *vbox, int size, int align, u32 flags, struct vbox_bo **pvboxbo); -int vbox_gem_create(struct drm_device *dev, +int vbox_gem_create(struct vbox_private *vbox, u32 size, bool iskernel, struct drm_gem_object **obj); int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr); diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c index 79814117e063..11b6364ed14a 100644 --- a/drivers/staging/vboxvideo/vbox_fb.c +++ b/drivers/staging/vboxvideo/vbox_fb.c @@ -71,7 +71,9 @@ static int vboxfb_create(struct drm_fb_helper *helper, { struct vbox_fbdev *fbdev = container_of(helper, struct vbox_fbdev, helper); - struct drm_device *dev = fbdev->helper.dev; + struct vbox_private *vbox = container_of(fbdev->helper.dev, + struct vbox_private, ddev); + struct pci_dev *pdev = vbox->ddev.pdev; struct DRM_MODE_FB_CMD mode_cmd; struct drm_framebuffer *fb; struct fb_info *info; @@ -89,13 +91,13 @@ static int vboxfb_create(struct drm_fb_helper *helper, size = pitch * mode_cmd.height; - ret = vbox_gem_create(fbdev->helper.dev, size, true, &gobj); + ret = vbox_gem_create(vbox, size, true, &gobj); if (ret) { DRM_ERROR("failed to create fbcon backing object %d\n", ret); return ret; } - ret = vbox_framebuffer_init(dev, &fbdev->afb, &mode_cmd, gobj); + ret = vbox_framebuffer_init(vbox, &fbdev->afb, &mode_cmd, gobj); if (ret) return ret; @@ -143,8 +145,8 @@ static int vboxfb_create(struct drm_fb_helper *helper, * This seems to be done for safety checking that the framebuffer * is not registered twice by different drivers. */ - info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0); - info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0); + info->apertures->ranges[0].base = pci_resource_start(pdev, 0); + info->apertures->ranges[0].size = pci_resource_len(pdev, 0); drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width, @@ -169,9 +171,8 @@ static struct drm_fb_helper_funcs vbox_fb_helper_funcs = { .fb_probe = vboxfb_create, }; -void vbox_fbdev_fini(struct drm_device *dev) +void vbox_fbdev_fini(struct vbox_private *vbox) { - struct vbox_private *vbox = dev->dev_private; struct vbox_fbdev *fbdev = vbox->fbdev; struct vbox_framebuffer *afb = &fbdev->afb; @@ -205,9 +206,9 @@ void vbox_fbdev_fini(struct drm_device *dev) drm_framebuffer_cleanup(&afb->base); } -int vbox_fbdev_init(struct drm_device *dev) +int vbox_fbdev_init(struct vbox_private *vbox) { - struct vbox_private *vbox = dev->dev_private; + struct drm_device *dev = &vbox->ddev; struct vbox_fbdev *fbdev; int ret; diff --git a/drivers/staging/vboxvideo/vbox_irq.c b/drivers/staging/vboxvideo/vbox_irq.c index 74abdf02d9fd..09f858ec1369 100644 --- a/drivers/staging/vboxvideo/vbox_irq.c +++ b/drivers/staging/vboxvideo/vbox_irq.c @@ -123,7 +123,7 @@ static void validate_or_set_position_hints(struct vbox_private *vbox) */ static void vbox_update_mode_hints(struct vbox_private *vbox) { - struct drm_device *dev = vbox->dev; + struct drm_device *dev = &vbox->ddev; struct drm_connector *connector; struct vbox_connector *vbox_conn; struct vbva_modehint *hints; @@ -179,7 +179,7 @@ static void vbox_hotplug_worker(struct work_struct *work) hotplug_work); vbox_update_mode_hints(vbox); - drm_kms_helper_hotplug_event(vbox->dev); + drm_kms_helper_hotplug_event(&vbox->ddev); } int vbox_irq_init(struct vbox_private *vbox) @@ -187,11 +187,11 @@ int vbox_irq_init(struct vbox_private *vbox) INIT_WORK(&vbox->hotplug_work, vbox_hotplug_worker); vbox_update_mode_hints(vbox); - return drm_irq_install(vbox->dev, vbox->dev->pdev->irq); + return drm_irq_install(&vbox->ddev, vbox->ddev.pdev->irq); } void vbox_irq_fini(struct vbox_private *vbox) { - drm_irq_uninstall(vbox->dev); + drm_irq_uninstall(&vbox->ddev); flush_work(&vbox->hotplug_work); } diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index 815292f1d7e6..95100c5976e4 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -155,16 +155,16 @@ static const struct drm_framebuffer_funcs vbox_fb_funcs = { .dirty = vbox_user_framebuffer_dirty, }; -int vbox_framebuffer_init(struct drm_device *dev, +int vbox_framebuffer_init(struct vbox_private *vbox, struct vbox_framebuffer *vbox_fb, const struct DRM_MODE_FB_CMD *mode_cmd, struct drm_gem_object *obj) { int ret; - drm_helper_mode_fill_fb_struct(dev, &vbox_fb->base, mode_cmd); + drm_helper_mode_fill_fb_struct(&vbox->ddev, &vbox_fb->base, mode_cmd); vbox_fb->obj = obj; - ret = drm_framebuffer_init(dev, &vbox_fb->base, &vbox_fb_funcs); + ret = drm_framebuffer_init(&vbox->ddev, &vbox_fb->base, &vbox_fb_funcs); if (ret) { DRM_ERROR("framebuffer init failed %d\n", ret); return ret; @@ -177,7 +177,7 @@ static int vbox_accel_init(struct vbox_private *vbox) { unsigned int i; - vbox->vbva_info = devm_kcalloc(vbox->dev->dev, vbox->num_crtcs, + vbox->vbva_info = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs, sizeof(*vbox->vbva_info), GFP_KERNEL); if (!vbox->vbva_info) return -ENOMEM; @@ -185,7 +185,7 @@ static int vbox_accel_init(struct vbox_private *vbox) /* Take a command buffer for each screen from the end of usable VRAM. */ vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE; - vbox->vbva_buffers = pci_iomap_range(vbox->dev->pdev, 0, + vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, vbox->available_vram_size, vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE); @@ -204,7 +204,7 @@ static int vbox_accel_init(struct vbox_private *vbox) static void vbox_accel_fini(struct vbox_private *vbox) { vbox_disable_accel(vbox); - pci_iounmap(vbox->dev->pdev, vbox->vbva_buffers); + pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers); } /** Do we support the 4.3 plus mode hint reporting interface? */ @@ -253,7 +253,7 @@ int vbox_hw_init(struct vbox_private *vbox) /* Map guest-heap at end of vram */ vbox->guest_heap = - pci_iomap_range(vbox->dev->pdev, 0, GUEST_HEAP_OFFSET(vbox), + pci_iomap_range(vbox->ddev.pdev, 0, GUEST_HEAP_OFFSET(vbox), GUEST_HEAP_SIZE); if (!vbox->guest_heap) return -ENOMEM; @@ -288,7 +288,7 @@ int vbox_hw_init(struct vbox_private *vbox) goto err_destroy_guest_pool; } - vbox->last_mode_hints = devm_kcalloc(vbox->dev->dev, vbox->num_crtcs, + vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs, sizeof(struct vbva_modehint), GFP_KERNEL); if (!vbox->last_mode_hints) { @@ -305,7 +305,7 @@ int vbox_hw_init(struct vbox_private *vbox) err_destroy_guest_pool: gen_pool_destroy(vbox->guest_pool); err_unmap_guest_heap: - pci_iounmap(vbox->dev->pdev, vbox->guest_heap); + pci_iounmap(vbox->ddev.pdev, vbox->guest_heap); return ret; } @@ -313,7 +313,7 @@ void vbox_hw_fini(struct vbox_private *vbox) { vbox_accel_fini(vbox); gen_pool_destroy(vbox->guest_pool); - pci_iounmap(vbox->dev->pdev, vbox->guest_heap); + pci_iounmap(vbox->ddev.pdev, vbox->guest_heap); } /** @@ -328,7 +328,7 @@ void vbox_driver_lastclose(struct drm_device *dev) drm_fb_helper_restore_fbdev_mode_unlocked(&vbox->fbdev->helper); } -int vbox_gem_create(struct drm_device *dev, +int vbox_gem_create(struct vbox_private *vbox, u32 size, bool iskernel, struct drm_gem_object **obj) { struct vbox_bo *vboxbo; @@ -340,7 +340,7 @@ int vbox_gem_create(struct drm_device *dev, if (size == 0) return -EINVAL; - ret = vbox_bo_create(dev, size, 0, 0, &vboxbo); + ret = vbox_bo_create(vbox, size, 0, 0, &vboxbo); if (ret) { if (ret != -ERESTARTSYS) DRM_ERROR("failed to allocate GEM object\n"); @@ -355,14 +355,16 @@ int vbox_gem_create(struct drm_device *dev, int vbox_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { - int ret; + struct vbox_private *vbox = + container_of(dev, struct vbox_private, ddev); struct drm_gem_object *gobj; u32 handle; + int ret; args->pitch = args->width * ((args->bpp + 7) / 8); args->size = args->pitch * args->height; - ret = vbox_gem_create(dev, args->size, false, &gobj); + ret = vbox_gem_create(vbox, args->size, false, &gobj); if (ret) return ret; diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 2587e6aecca2..13696ba19c4f 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -179,7 +179,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) * If so then screen layout can be deduced from the crtc offsets. * Same fall-back if this is the fbdev frame-buffer. */ - list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, head) { + list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) { if (!fb1) { fb1 = CRTC_FB(crtci); if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb) @@ -189,7 +189,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) } } if (single_framebuffer) { - list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, + list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) { if (to_vbox_crtc(crtci)->crtc_id != 0) continue; @@ -202,7 +202,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) } } /* Otherwise calculate the total span of all screens. */ - list_for_each_entry(connectori, &vbox->dev->mode_config.connector_list, + list_for_each_entry(connectori, &vbox->ddev.mode_config.connector_list, head) { struct vbox_connector *vbox_connector = to_vbox_connector(connectori); @@ -285,7 +285,7 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, if (mode && vbox_set_up_input_mapping(vbox)) { struct drm_crtc *crtci; - list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, + list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) { if (crtci == crtc) continue; @@ -324,8 +324,6 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc, uint32_t page_flip_flags, struct drm_modeset_acquire_ctx *ctx) { - struct vbox_private *vbox = crtc->dev->dev_private; - struct drm_device *drm = vbox->dev; unsigned long flags; int rc; @@ -333,12 +331,12 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc, if (rc) return rc; - spin_lock_irqsave(&drm->event_lock, flags); + spin_lock_irqsave(&crtc->dev->event_lock, flags); if (event) drm_crtc_send_vblank_event(crtc, event); - spin_unlock_irqrestore(&drm->event_lock, flags); + spin_unlock_irqrestore(&crtc->dev->event_lock, flags); return 0; } @@ -593,19 +591,19 @@ static int vbox_get_modes(struct drm_connector *connector) if (vbox_connector->vbox_crtc->x_hint != -1) drm_object_property_set_value(&connector->base, - vbox->dev->mode_config.suggested_x_property, + vbox->ddev.mode_config.suggested_x_property, vbox_connector->vbox_crtc->x_hint); else drm_object_property_set_value(&connector->base, - vbox->dev->mode_config.suggested_x_property, 0); + vbox->ddev.mode_config.suggested_x_property, 0); if (vbox_connector->vbox_crtc->y_hint != -1) drm_object_property_set_value(&connector->base, - vbox->dev->mode_config.suggested_y_property, + vbox->ddev.mode_config.suggested_y_property, vbox_connector->vbox_crtc->y_hint); else drm_object_property_set_value(&connector->base, - vbox->dev->mode_config.suggested_y_property, 0); + vbox->ddev.mode_config.suggested_y_property, 0); return num_modes; } @@ -701,6 +699,8 @@ static struct drm_framebuffer *vbox_user_framebuffer_create( struct drm_file *filp, const struct drm_mode_fb_cmd2 *mode_cmd) { + struct vbox_private *vbox = + container_of(dev, struct vbox_private, ddev); struct drm_gem_object *obj; struct vbox_framebuffer *vbox_fb; int ret = -ENOMEM; @@ -713,7 +713,7 @@ static struct drm_framebuffer *vbox_user_framebuffer_create( if (!vbox_fb) goto err_unref_obj; - ret = vbox_framebuffer_init(dev, vbox_fb, mode_cmd, obj); + ret = vbox_framebuffer_init(vbox, vbox_fb, mode_cmd, obj); if (ret) goto err_free_vbox_fb; @@ -730,9 +730,9 @@ static const struct drm_mode_config_funcs vbox_mode_funcs = { .fb_create = vbox_user_framebuffer_create, }; -int vbox_mode_init(struct drm_device *dev) +int vbox_mode_init(struct vbox_private *vbox) { - struct vbox_private *vbox = dev->dev_private; + struct drm_device *dev = &vbox->ddev; struct drm_encoder *encoder; struct vbox_crtc *vbox_crtc; unsigned int i; @@ -771,9 +771,9 @@ int vbox_mode_init(struct drm_device *dev) return ret; } -void vbox_mode_fini(struct drm_device *dev) +void vbox_mode_fini(struct vbox_private *vbox) { - drm_mode_config_cleanup(dev); + drm_mode_config_cleanup(&vbox->ddev); /* vbox_cursor_fini(dev); */ } @@ -824,7 +824,7 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv, /* Hide cursor. */ vbox_crtc->cursor_enabled = false; - list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, + list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) { if (to_vbox_crtc(crtci)->cursor_enabled) cursor_enabled = true; diff --git a/drivers/staging/vboxvideo/vbox_ttm.c b/drivers/staging/vboxvideo/vbox_ttm.c index 548edb7c494b..7b8eac30faca 100644 --- a/drivers/staging/vboxvideo/vbox_ttm.c +++ b/drivers/staging/vboxvideo/vbox_ttm.c @@ -169,7 +169,7 @@ static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev, return 0; case TTM_PL_VRAM: mem->bus.offset = mem->start << PAGE_SHIFT; - mem->bus.base = pci_resource_start(vbox->dev->pdev, 0); + mem->bus.base = pci_resource_start(vbox->ddev.pdev, 0); mem->bus.is_iomem = true; break; default: @@ -224,7 +224,7 @@ static struct ttm_bo_driver vbox_bo_driver = { int vbox_mm_init(struct vbox_private *vbox) { int ret; - struct drm_device *dev = vbox->dev; + struct drm_device *dev = &vbox->ddev; struct ttm_bo_device *bdev = &vbox->ttm.bdev; ret = vbox_ttm_global_init(vbox); @@ -269,8 +269,8 @@ void vbox_mm_fini(struct vbox_private *vbox) { #ifdef DRM_MTRR_WC drm_mtrr_del(vbox->fb_mtrr, - pci_resource_start(vbox->dev->pdev, 0), - pci_resource_len(vbox->dev->pdev, 0), DRM_MTRR_WC); + pci_resource_start(vbox->ddev.pdev, 0), + pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC); #else arch_phys_wc_del(vbox->fb_mtrr); #endif @@ -305,10 +305,9 @@ void vbox_ttm_placement(struct vbox_bo *bo, int domain) } } -int vbox_bo_create(struct drm_device *dev, int size, int align, +int vbox_bo_create(struct vbox_private *vbox, int size, int align, u32 flags, struct vbox_bo **pvboxbo) { - struct vbox_private *vbox = dev->dev_private; struct vbox_bo *vboxbo; size_t acc_size; int ret; @@ -317,7 +316,7 @@ int vbox_bo_create(struct drm_device *dev, int size, int align, if (!vboxbo) return -ENOMEM; - ret = drm_gem_object_init(dev, &vboxbo->gem, size); + ret = drm_gem_object_init(&vbox->ddev, &vboxbo->gem, size); if (ret) goto err_free_vboxbo; -- 2.19.0.rc1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel