mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
staging: vboxvideo: Fold driver_load/unload into probe/remove functions
Fold the driver_load / unload functions into the probe / remove functions now that we are no longer using the deprecated drm_get_pci_dev() mechanism. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
79815ee238
commit
d46709094d
3 changed files with 63 additions and 81 deletions
|
@ -51,48 +51,89 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
|
||||||
|
|
||||||
static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
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 drm_device *dev = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!vbox_check_supported(VBE_DISPI_ID_HGSMI))
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
dev = drm_dev_alloc(&driver, &pdev->dev);
|
dev = drm_dev_alloc(&driver, &pdev->dev);
|
||||||
if (IS_ERR(dev)) {
|
if (IS_ERR(dev))
|
||||||
ret = PTR_ERR(dev);
|
return PTR_ERR(dev);
|
||||||
goto err_drv_alloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = pci_enable_device(pdev);
|
ret = pci_enable_device(pdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_pci_enable;
|
goto err_dev_put;
|
||||||
|
|
||||||
dev->pdev = pdev;
|
dev->pdev = pdev;
|
||||||
pci_set_drvdata(pdev, dev);
|
pci_set_drvdata(pdev, dev);
|
||||||
|
|
||||||
ret = vbox_driver_load(dev);
|
vbox = devm_kzalloc(&pdev->dev, sizeof(*vbox), GFP_KERNEL);
|
||||||
|
if (!vbox) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_pci_disable;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->dev_private = vbox;
|
||||||
|
vbox->dev = dev;
|
||||||
|
|
||||||
|
mutex_init(&vbox->hw_mutex);
|
||||||
|
|
||||||
|
ret = vbox_hw_init(vbox);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_vbox_driver_load;
|
goto err_pci_disable;
|
||||||
|
|
||||||
|
ret = vbox_mm_init(vbox);
|
||||||
|
if (ret)
|
||||||
|
goto err_hw_fini;
|
||||||
|
|
||||||
|
ret = vbox_mode_init(dev);
|
||||||
|
if (ret)
|
||||||
|
goto err_mm_fini;
|
||||||
|
|
||||||
|
ret = vbox_irq_init(vbox);
|
||||||
|
if (ret)
|
||||||
|
goto err_mode_fini;
|
||||||
|
|
||||||
|
ret = vbox_fbdev_init(dev);
|
||||||
|
if (ret)
|
||||||
|
goto err_irq_fini;
|
||||||
|
|
||||||
ret = drm_dev_register(dev, 0);
|
ret = drm_dev_register(dev, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_drv_dev_register;
|
goto err_fbdev_fini;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
|
|
||||||
err_drv_dev_register:
|
err_fbdev_fini:
|
||||||
vbox_driver_unload(dev);
|
vbox_fbdev_fini(dev);
|
||||||
err_vbox_driver_load:
|
err_irq_fini:
|
||||||
|
vbox_irq_fini(vbox);
|
||||||
|
err_mode_fini:
|
||||||
|
vbox_mode_fini(dev);
|
||||||
|
err_mm_fini:
|
||||||
|
vbox_mm_fini(vbox);
|
||||||
|
err_hw_fini:
|
||||||
|
vbox_hw_fini(vbox);
|
||||||
|
err_pci_disable:
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
err_pci_enable:
|
err_dev_put:
|
||||||
drm_dev_put(dev);
|
drm_dev_put(dev);
|
||||||
err_drv_alloc:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vbox_pci_remove(struct pci_dev *pdev)
|
static void vbox_pci_remove(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = pci_get_drvdata(pdev);
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
||||||
|
struct vbox_private *vbox = dev->dev_private;
|
||||||
|
|
||||||
drm_dev_unregister(dev);
|
drm_dev_unregister(dev);
|
||||||
vbox_driver_unload(dev);
|
vbox_fbdev_fini(dev);
|
||||||
|
vbox_irq_fini(vbox);
|
||||||
|
vbox_mode_fini(dev);
|
||||||
|
vbox_mm_fini(vbox);
|
||||||
|
vbox_hw_fini(vbox);
|
||||||
drm_dev_put(dev);
|
drm_dev_put(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,8 +126,6 @@ struct vbox_private {
|
||||||
#undef CURSOR_PIXEL_COUNT
|
#undef CURSOR_PIXEL_COUNT
|
||||||
#undef CURSOR_DATA_SIZE
|
#undef CURSOR_DATA_SIZE
|
||||||
|
|
||||||
int vbox_driver_load(struct drm_device *dev);
|
|
||||||
void vbox_driver_unload(struct drm_device *dev);
|
|
||||||
void vbox_driver_lastclose(struct drm_device *dev);
|
void vbox_driver_lastclose(struct drm_device *dev);
|
||||||
|
|
||||||
struct vbox_gem_object;
|
struct vbox_gem_object;
|
||||||
|
@ -177,6 +175,10 @@ struct vbox_fbdev {
|
||||||
#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
|
#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
|
||||||
#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
|
#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
|
||||||
|
|
||||||
|
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);
|
int vbox_mode_init(struct drm_device *dev);
|
||||||
void vbox_mode_fini(struct drm_device *dev);
|
void vbox_mode_fini(struct drm_device *dev);
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ static bool have_hgsmi_mode_hints(struct vbox_private *vbox)
|
||||||
return have_hints == VINF_SUCCESS && have_cursor == VINF_SUCCESS;
|
return have_hints == VINF_SUCCESS && have_cursor == VINF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vbox_check_supported(u16 id)
|
bool vbox_check_supported(u16 id)
|
||||||
{
|
{
|
||||||
u16 dispi_id;
|
u16 dispi_id;
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ static bool vbox_check_supported(u16 id)
|
||||||
* Set up our heaps and data exchange buffers in VRAM before handing the rest
|
* Set up our heaps and data exchange buffers in VRAM before handing the rest
|
||||||
* to the memory manager.
|
* to the memory manager.
|
||||||
*/
|
*/
|
||||||
static int vbox_hw_init(struct vbox_private *vbox)
|
int vbox_hw_init(struct vbox_private *vbox)
|
||||||
{
|
{
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
|
@ -309,74 +309,13 @@ err_unmap_guest_heap:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vbox_hw_fini(struct vbox_private *vbox)
|
void vbox_hw_fini(struct vbox_private *vbox)
|
||||||
{
|
{
|
||||||
vbox_accel_fini(vbox);
|
vbox_accel_fini(vbox);
|
||||||
gen_pool_destroy(vbox->guest_pool);
|
gen_pool_destroy(vbox->guest_pool);
|
||||||
pci_iounmap(vbox->dev->pdev, vbox->guest_heap);
|
pci_iounmap(vbox->dev->pdev, vbox->guest_heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vbox_driver_load(struct drm_device *dev)
|
|
||||||
{
|
|
||||||
struct vbox_private *vbox;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!vbox_check_supported(VBE_DISPI_ID_HGSMI))
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
vbox = devm_kzalloc(dev->dev, sizeof(*vbox), GFP_KERNEL);
|
|
||||||
if (!vbox)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
dev->dev_private = vbox;
|
|
||||||
vbox->dev = dev;
|
|
||||||
|
|
||||||
mutex_init(&vbox->hw_mutex);
|
|
||||||
|
|
||||||
ret = vbox_hw_init(vbox);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = vbox_mm_init(vbox);
|
|
||||||
if (ret)
|
|
||||||
goto err_hw_fini;
|
|
||||||
|
|
||||||
ret = vbox_mode_init(dev);
|
|
||||||
if (ret)
|
|
||||||
goto err_drm_mode_cleanup;
|
|
||||||
|
|
||||||
ret = vbox_irq_init(vbox);
|
|
||||||
if (ret)
|
|
||||||
goto err_mode_fini;
|
|
||||||
|
|
||||||
ret = vbox_fbdev_init(dev);
|
|
||||||
if (ret)
|
|
||||||
goto err_irq_fini;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_irq_fini:
|
|
||||||
vbox_irq_fini(vbox);
|
|
||||||
err_mode_fini:
|
|
||||||
vbox_mode_fini(dev);
|
|
||||||
err_drm_mode_cleanup:
|
|
||||||
vbox_mm_fini(vbox);
|
|
||||||
err_hw_fini:
|
|
||||||
vbox_hw_fini(vbox);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vbox_driver_unload(struct drm_device *dev)
|
|
||||||
{
|
|
||||||
struct vbox_private *vbox = dev->dev_private;
|
|
||||||
|
|
||||||
vbox_fbdev_fini(dev);
|
|
||||||
vbox_irq_fini(vbox);
|
|
||||||
vbox_mode_fini(dev);
|
|
||||||
vbox_mm_fini(vbox);
|
|
||||||
vbox_hw_fini(vbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @note this is described in the DRM framework documentation. AST does not
|
* @note this is described in the DRM framework documentation. AST does not
|
||||||
* have it, but we get an oops on driver unload if it is not present.
|
* have it, but we get an oops on driver unload if it is not present.
|
||||||
|
|
Loading…
Add table
Reference in a new issue