diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-04-25 06:12:33 -0400 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-06-20 04:07:14 -0400 |
commit | 16ad3b2ce8dd5840c7661990476c3693569dab5a (patch) | |
tree | 0b42d67878932b8d9188fdae08e95f0ed5b31e59 /drivers/gpu/drm/shmobile | |
parent | 2e7c9b351dee0c89e78c9a0432f71738a0ecc287 (diff) |
drm/shmobile: Use devm_* managed functions
This simplifies cleanup paths and fixes a probe time crash in the error
path when trying to cleanup mode setting before it was initialized.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Diffstat (limited to 'drivers/gpu/drm/shmobile')
-rw-r--r-- | drivers/gpu/drm/shmobile/shmob_drm_drv.c | 28 | ||||
-rw-r--r-- | drivers/gpu/drm/shmobile/shmob_drm_plane.c | 7 |
2 files changed, 10 insertions, 25 deletions
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index f6e0b5395051..29d15e3fe144 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c | |||
@@ -90,7 +90,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev, | |||
90 | return -EINVAL; | 90 | return -EINVAL; |
91 | } | 91 | } |
92 | 92 | ||
93 | clk = clk_get(sdev->dev, clkname); | 93 | clk = devm_clk_get(sdev->dev, clkname); |
94 | if (IS_ERR(clk)) { | 94 | if (IS_ERR(clk)) { |
95 | dev_err(sdev->dev, "cannot get dot clock %s\n", clkname); | 95 | dev_err(sdev->dev, "cannot get dot clock %s\n", clkname); |
96 | return PTR_ERR(clk); | 96 | return PTR_ERR(clk); |
@@ -106,21 +106,12 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev, | |||
106 | 106 | ||
107 | static int shmob_drm_unload(struct drm_device *dev) | 107 | static int shmob_drm_unload(struct drm_device *dev) |
108 | { | 108 | { |
109 | struct shmob_drm_device *sdev = dev->dev_private; | ||
110 | |||
111 | drm_kms_helper_poll_fini(dev); | 109 | drm_kms_helper_poll_fini(dev); |
112 | drm_mode_config_cleanup(dev); | 110 | drm_mode_config_cleanup(dev); |
113 | drm_vblank_cleanup(dev); | 111 | drm_vblank_cleanup(dev); |
114 | drm_irq_uninstall(dev); | 112 | drm_irq_uninstall(dev); |
115 | 113 | ||
116 | if (sdev->clock) | ||
117 | clk_put(sdev->clock); | ||
118 | |||
119 | if (sdev->mmio) | ||
120 | iounmap(sdev->mmio); | ||
121 | |||
122 | dev->dev_private = NULL; | 114 | dev->dev_private = NULL; |
123 | kfree(sdev); | ||
124 | 115 | ||
125 | return 0; | 116 | return 0; |
126 | } | 117 | } |
@@ -139,7 +130,7 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags) | |||
139 | return -EINVAL; | 130 | return -EINVAL; |
140 | } | 131 | } |
141 | 132 | ||
142 | sdev = kzalloc(sizeof(*sdev), GFP_KERNEL); | 133 | sdev = devm_kzalloc(&pdev->dev, sizeof(*sdev), GFP_KERNEL); |
143 | if (sdev == NULL) { | 134 | if (sdev == NULL) { |
144 | dev_err(dev->dev, "failed to allocate private data\n"); | 135 | dev_err(dev->dev, "failed to allocate private data\n"); |
145 | return -ENOMEM; | 136 | return -ENOMEM; |
@@ -156,29 +147,28 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags) | |||
156 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 147 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
157 | if (res == NULL) { | 148 | if (res == NULL) { |
158 | dev_err(&pdev->dev, "failed to get memory resource\n"); | 149 | dev_err(&pdev->dev, "failed to get memory resource\n"); |
159 | ret = -EINVAL; | 150 | return -EINVAL; |
160 | goto done; | ||
161 | } | 151 | } |
162 | 152 | ||
163 | sdev->mmio = ioremap_nocache(res->start, resource_size(res)); | 153 | sdev->mmio = devm_ioremap_nocache(&pdev->dev, res->start, |
154 | resource_size(res)); | ||
164 | if (sdev->mmio == NULL) { | 155 | if (sdev->mmio == NULL) { |
165 | dev_err(&pdev->dev, "failed to remap memory resource\n"); | 156 | dev_err(&pdev->dev, "failed to remap memory resource\n"); |
166 | ret = -ENOMEM; | 157 | return -ENOMEM; |
167 | goto done; | ||
168 | } | 158 | } |
169 | 159 | ||
170 | ret = shmob_drm_setup_clocks(sdev, pdata->clk_source); | 160 | ret = shmob_drm_setup_clocks(sdev, pdata->clk_source); |
171 | if (ret < 0) | 161 | if (ret < 0) |
172 | goto done; | 162 | return ret; |
173 | 163 | ||
174 | ret = shmob_drm_init_interface(sdev); | 164 | ret = shmob_drm_init_interface(sdev); |
175 | if (ret < 0) | 165 | if (ret < 0) |
176 | goto done; | 166 | return ret; |
177 | 167 | ||
178 | ret = shmob_drm_modeset_init(sdev); | 168 | ret = shmob_drm_modeset_init(sdev); |
179 | if (ret < 0) { | 169 | if (ret < 0) { |
180 | dev_err(&pdev->dev, "failed to initialize mode setting\n"); | 170 | dev_err(&pdev->dev, "failed to initialize mode setting\n"); |
181 | goto done; | 171 | return ret; |
182 | } | 172 | } |
183 | 173 | ||
184 | for (i = 0; i < 4; ++i) { | 174 | for (i = 0; i < 4; ++i) { |
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/shmobile/shmob_drm_plane.c index 22b1d45d82d3..060ae03e5f9b 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_plane.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_plane.c | |||
@@ -221,11 +221,8 @@ static int shmob_drm_plane_disable(struct drm_plane *plane) | |||
221 | 221 | ||
222 | static void shmob_drm_plane_destroy(struct drm_plane *plane) | 222 | static void shmob_drm_plane_destroy(struct drm_plane *plane) |
223 | { | 223 | { |
224 | struct shmob_drm_plane *splane = to_shmob_plane(plane); | ||
225 | |||
226 | shmob_drm_plane_disable(plane); | 224 | shmob_drm_plane_disable(plane); |
227 | drm_plane_cleanup(plane); | 225 | drm_plane_cleanup(plane); |
228 | kfree(splane); | ||
229 | } | 226 | } |
230 | 227 | ||
231 | static const struct drm_plane_funcs shmob_drm_plane_funcs = { | 228 | static const struct drm_plane_funcs shmob_drm_plane_funcs = { |
@@ -251,7 +248,7 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index) | |||
251 | struct shmob_drm_plane *splane; | 248 | struct shmob_drm_plane *splane; |
252 | int ret; | 249 | int ret; |
253 | 250 | ||
254 | splane = kzalloc(sizeof(*splane), GFP_KERNEL); | 251 | splane = devm_kzalloc(sdev->dev, sizeof(*splane), GFP_KERNEL); |
255 | if (splane == NULL) | 252 | if (splane == NULL) |
256 | return -ENOMEM; | 253 | return -ENOMEM; |
257 | 254 | ||
@@ -261,8 +258,6 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index) | |||
261 | ret = drm_plane_init(sdev->ddev, &splane->plane, 1, | 258 | ret = drm_plane_init(sdev->ddev, &splane->plane, 1, |
262 | &shmob_drm_plane_funcs, formats, | 259 | &shmob_drm_plane_funcs, formats, |
263 | ARRAY_SIZE(formats), false); | 260 | ARRAY_SIZE(formats), false); |
264 | if (ret < 0) | ||
265 | kfree(splane); | ||
266 | 261 | ||
267 | return ret; | 262 | return ret; |
268 | } | 263 | } |