diff options
author | Jerome Glisse <jglisse@redhat.com> | 2009-12-09 12:21:55 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-12-10 00:09:07 -0500 |
commit | cf0fe4566dcc0c5bd9b7da8c9a53e712593db118 (patch) | |
tree | c9d5165a4a21c23316d7d2939fd8f79424ad90bb /drivers/gpu | |
parent | eaa5fd1a66fefd7cc918d80250d66fa48b10b81f (diff) |
drm/radeon/kms: cleanup structure and module if initialization fails
This would allow us to properly unload others module like TTM if
initialization fails after we initiliazed TTM structure.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_kms.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index ba128621057a..f23b05606eb5 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -30,10 +30,19 @@ | |||
30 | #include "radeon.h" | 30 | #include "radeon.h" |
31 | #include "radeon_drm.h" | 31 | #include "radeon_drm.h" |
32 | 32 | ||
33 | int radeon_driver_unload_kms(struct drm_device *dev) | ||
34 | { | ||
35 | struct radeon_device *rdev = dev->dev_private; | ||
36 | |||
37 | if (rdev == NULL) | ||
38 | return 0; | ||
39 | radeon_modeset_fini(rdev); | ||
40 | radeon_device_fini(rdev); | ||
41 | kfree(rdev); | ||
42 | dev->dev_private = NULL; | ||
43 | return 0; | ||
44 | } | ||
33 | 45 | ||
34 | /* | ||
35 | * Driver load/unload | ||
36 | */ | ||
37 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) | 46 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) |
38 | { | 47 | { |
39 | struct radeon_device *rdev; | 48 | struct radeon_device *rdev; |
@@ -62,31 +71,20 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
62 | */ | 71 | */ |
63 | r = radeon_device_init(rdev, dev, dev->pdev, flags); | 72 | r = radeon_device_init(rdev, dev, dev->pdev, flags); |
64 | if (r) { | 73 | if (r) { |
65 | DRM_ERROR("Fatal error while trying to initialize radeon.\n"); | 74 | dev_err(&dev->pdev->dev, "Fatal error during GPU init\n"); |
66 | return r; | 75 | goto out; |
67 | } | 76 | } |
68 | /* Again modeset_init should fail only on fatal error | 77 | /* Again modeset_init should fail only on fatal error |
69 | * otherwise it should provide enough functionalities | 78 | * otherwise it should provide enough functionalities |
70 | * for shadowfb to run | 79 | * for shadowfb to run |
71 | */ | 80 | */ |
72 | r = radeon_modeset_init(rdev); | 81 | r = radeon_modeset_init(rdev); |
73 | if (r) { | 82 | if (r) |
74 | return r; | 83 | dev_err(&dev->pdev->dev, "Fatal error during modeset init\n"); |
75 | } | 84 | out: |
76 | return 0; | 85 | if (r) |
77 | } | 86 | radeon_driver_unload_kms(dev); |
78 | 87 | return r; | |
79 | int radeon_driver_unload_kms(struct drm_device *dev) | ||
80 | { | ||
81 | struct radeon_device *rdev = dev->dev_private; | ||
82 | |||
83 | if (rdev == NULL) | ||
84 | return 0; | ||
85 | radeon_modeset_fini(rdev); | ||
86 | radeon_device_fini(rdev); | ||
87 | kfree(rdev); | ||
88 | dev->dev_private = NULL; | ||
89 | return 0; | ||
90 | } | 88 | } |
91 | 89 | ||
92 | 90 | ||