diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2020-07-30 15:52:00 +0200 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2020-08-03 09:04:01 +0200 |
commit | fbe01716ed4a93ff90a289c2b75313319bf08573 (patch) | |
tree | 48400ce7cfba6a9559429faeb7c9432cd3c0a52f /drivers | |
parent | d50ace1e72f05708cc5dbc89b9bbb9873f150092 (diff) | |
download | linux-fbe01716ed4a93ff90a289c2b75313319bf08573.tar.bz2 |
drm/ast: Replace driver load/unload functions with device create/destroy
The ast driver's load and unload functions are left-overs from when
struct drm_driver.load/unload was still in use. The PCI probe helper
allocated the DRM device and ran load to initialize it.
This patch replaces this code with device create and destroy. The
main difference is that the device's create function allocates the
DRM device and ast structures in the same place. This will be required
for switching ast to managed allocations.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-4-tzimmermann@suse.de
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/ast/ast_drv.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/ast/ast_drv.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/ast/ast_main.c | 24 |
3 files changed, 33 insertions, 21 deletions
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index 9d04f2b5225c..ad93c35b4cf7 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -109,6 +109,7 @@ static void ast_kick_out_firmware_fb(struct pci_dev *pdev) static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { + struct ast_private *ast; struct drm_device *dev; int ret; @@ -118,27 +119,23 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) return ret; - dev = drm_dev_alloc(&ast_driver, &pdev->dev); - if (IS_ERR(dev)) - return PTR_ERR(dev); - - dev->pdev = pdev; - pci_set_drvdata(pdev, dev); - - ret = ast_driver_load(dev, ent->driver_data); - if (ret) + ast = ast_device_create(&ast_driver, pdev, ent->driver_data); + if (IS_ERR(ast)) { + ret = PTR_ERR(ast); goto err_drm_dev_put; + } + dev = ast->dev; ret = drm_dev_register(dev, ent->driver_data); if (ret) - goto err_ast_driver_unload; + goto err_ast_device_destroy; drm_fbdev_generic_setup(dev, 32); return 0; -err_ast_driver_unload: - ast_driver_unload(dev); +err_ast_device_destroy: + ast_device_destroy(ast); err_drm_dev_put: drm_dev_put(dev); return ret; @@ -147,9 +144,10 @@ err_drm_dev_put: static void ast_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); + struct ast_private *ast = to_ast_private(dev); drm_dev_unregister(dev); - ast_driver_unload(dev); + ast_device_destroy(ast); drm_dev_put(dev); } diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index e7564055fa70..210d62f69fb9 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -159,8 +159,10 @@ static inline struct ast_private *to_ast_private(struct drm_device *dev) return dev->dev_private; } -int ast_driver_load(struct drm_device *dev, unsigned long flags); -void ast_driver_unload(struct drm_device *dev); +struct ast_private *ast_device_create(struct drm_driver *drv, + struct pci_dev *pdev, + unsigned long flags); +void ast_device_destroy(struct ast_private *ast); #define AST_IO_AR_PORT_WRITE (0x40) #define AST_IO_MISC_PORT_WRITE (0x42) diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index dd12b55d57a2..8d46166f8462 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -30,6 +30,7 @@ #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> #include <drm/drm_gem_vram_helper.h> @@ -378,15 +379,25 @@ static int ast_get_dram_info(struct drm_device *dev) return 0; } -int ast_driver_load(struct drm_device *dev, unsigned long flags) +struct ast_private *ast_device_create(struct drm_driver *drv, + struct pci_dev *pdev, + unsigned long flags) { + struct drm_device *dev; struct ast_private *ast; bool need_post; int ret = 0; + dev = drm_dev_alloc(drv, &pdev->dev); + if (IS_ERR(dev)) + return ERR_CAST(dev); + + dev->pdev = pdev; + pci_set_drvdata(pdev, dev); + ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); if (!ast) - return -ENOMEM; + return ERR_PTR(-ENOMEM); dev->dev_private = ast; ast->dev = dev; @@ -435,16 +446,17 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) if (ret) goto out_free; - return 0; + return ast; + out_free: kfree(ast); dev->dev_private = NULL; - return ret; + return ERR_PTR(ret); } -void ast_driver_unload(struct drm_device *dev) +void ast_device_destroy(struct ast_private *ast) { - struct ast_private *ast = to_ast_private(dev); + struct drm_device *dev = ast->dev; /* enable standard VGA decode */ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04); |