|
23 | 23 | #include <drm/drm_fourcc.h>
|
24 | 24 | #include <drm/drm_gem_dma_helper.h>
|
25 | 25 | #include <drm/drm_gem_framebuffer_helper.h>
|
| 26 | +#include <drm/drm_managed.h> |
26 | 27 | #include <drm/drm_modeset_helper.h>
|
27 | 28 | #include <drm/drm_module.h>
|
28 | 29 | #include <drm/drm_of.h>
|
@@ -716,11 +717,13 @@ static int malidp_bind(struct device *dev)
|
716 | 717 | int ret = 0, i;
|
717 | 718 | u32 version, out_depth = 0;
|
718 | 719 |
|
719 |
| - malidp = devm_kzalloc(dev, sizeof(*malidp), GFP_KERNEL); |
720 |
| - if (!malidp) |
721 |
| - return -ENOMEM; |
| 720 | + malidp = devm_drm_dev_alloc(dev, &malidp_driver, typeof(*malidp), base); |
| 721 | + if (IS_ERR(malidp)) |
| 722 | + return PTR_ERR(malidp); |
| 723 | + |
| 724 | + drm = &malidp->base; |
722 | 725 |
|
723 |
| - hwdev = devm_kzalloc(dev, sizeof(*hwdev), GFP_KERNEL); |
| 726 | + hwdev = drmm_kzalloc(drm, sizeof(*hwdev), GFP_KERNEL); |
724 | 727 | if (!hwdev)
|
725 | 728 | return -ENOMEM;
|
726 | 729 |
|
@@ -753,12 +756,6 @@ static int malidp_bind(struct device *dev)
|
753 | 756 | if (ret && ret != -ENODEV)
|
754 | 757 | return ret;
|
755 | 758 |
|
756 |
| - drm = drm_dev_alloc(&malidp_driver, dev); |
757 |
| - if (IS_ERR(drm)) { |
758 |
| - ret = PTR_ERR(drm); |
759 |
| - goto alloc_fail; |
760 |
| - } |
761 |
| - |
762 | 759 | drm->dev_private = malidp;
|
763 | 760 | dev_set_drvdata(dev, drm);
|
764 | 761 |
|
@@ -887,8 +884,6 @@ static int malidp_bind(struct device *dev)
|
887 | 884 | malidp_runtime_pm_suspend(dev);
|
888 | 885 | drm->dev_private = NULL;
|
889 | 886 | dev_set_drvdata(dev, NULL);
|
890 |
| - drm_dev_put(drm); |
891 |
| -alloc_fail: |
892 | 887 | of_reserved_mem_device_release(dev);
|
893 | 888 |
|
894 | 889 | return ret;
|
@@ -917,7 +912,6 @@ static void malidp_unbind(struct device *dev)
|
917 | 912 | malidp_runtime_pm_suspend(dev);
|
918 | 913 | drm->dev_private = NULL;
|
919 | 914 | dev_set_drvdata(dev, NULL);
|
920 |
| - drm_dev_put(drm); |
921 | 915 | of_reserved_mem_device_release(dev);
|
922 | 916 | }
|
923 | 917 |
|
|
0 commit comments