Skip to content

Commit 857a8df

Browse files
broonieschandinat
authored andcommitted
video: s3c-fb: Convert to devm style allocation
Saves some code, especially useful as the code saved is mostly in the infrequently tested error paths. Signed-off-by: Mark Brown <[email protected]> Acked-by: Jingoo Han <[email protected]> Signed-off-by: Florian Tobias Schandinat <[email protected]>
1 parent f820917 commit 857a8df

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

drivers/video/s3c-fb.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ struct s3c_fb_vsync {
186186
* struct s3c_fb - overall hardware state of the hardware
187187
* @slock: The spinlock protection for this data sturcture.
188188
* @dev: The device that we bound to, for printing, etc.
189-
* @regs_res: The resource we claimed for the IO registers.
190189
* @bus_clk: The clk (hclk) feeding our interface and possibly pixclk.
191190
* @lcd_clk: The clk (sclk) feeding pixclk.
192191
* @regs: The mapped hardware registers.
@@ -202,7 +201,6 @@ struct s3c_fb_vsync {
202201
struct s3c_fb {
203202
spinlock_t slock;
204203
struct device *dev;
205-
struct resource *regs_res;
206204
struct clk *bus_clk;
207205
struct clk *lcd_clk;
208206
void __iomem *regs;
@@ -1361,7 +1359,7 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
13611359
return -EINVAL;
13621360
}
13631361

1364-
sfb = kzalloc(sizeof(struct s3c_fb), GFP_KERNEL);
1362+
sfb = devm_kzalloc(dev, sizeof(struct s3c_fb), GFP_KERNEL);
13651363
if (!sfb) {
13661364
dev_err(dev, "no memory for framebuffers\n");
13671365
return -ENOMEM;
@@ -1404,33 +1402,25 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
14041402
goto err_lcd_clk;
14051403
}
14061404

1407-
sfb->regs_res = request_mem_region(res->start, resource_size(res),
1408-
dev_name(dev));
1409-
if (!sfb->regs_res) {
1410-
dev_err(dev, "failed to claim register region\n");
1411-
ret = -ENOENT;
1412-
goto err_lcd_clk;
1413-
}
1414-
1415-
sfb->regs = ioremap(res->start, resource_size(res));
1405+
sfb->regs = devm_request_and_ioremap(dev, res);
14161406
if (!sfb->regs) {
14171407
dev_err(dev, "failed to map registers\n");
14181408
ret = -ENXIO;
1419-
goto err_req_region;
1409+
goto err_lcd_clk;
14201410
}
14211411

14221412
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
14231413
if (!res) {
14241414
dev_err(dev, "failed to acquire irq resource\n");
14251415
ret = -ENOENT;
1426-
goto err_ioremap;
1416+
goto err_lcd_clk;
14271417
}
14281418
sfb->irq_no = res->start;
14291419
ret = request_irq(sfb->irq_no, s3c_fb_irq,
14301420
0, "s3c_fb", sfb);
14311421
if (ret) {
14321422
dev_err(dev, "irq request failed\n");
1433-
goto err_ioremap;
1423+
goto err_lcd_clk;
14341424
}
14351425

14361426
dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs);
@@ -1486,12 +1476,6 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
14861476
pm_runtime_put_sync(sfb->dev);
14871477
free_irq(sfb->irq_no, sfb);
14881478

1489-
err_ioremap:
1490-
iounmap(sfb->regs);
1491-
1492-
err_req_region:
1493-
release_mem_region(sfb->regs_res->start, resource_size(sfb->regs_res));
1494-
14951479
err_lcd_clk:
14961480
pm_runtime_disable(sfb->dev);
14971481

@@ -1505,7 +1489,6 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
15051489
clk_put(sfb->bus_clk);
15061490

15071491
err_sfb:
1508-
kfree(sfb);
15091492
return ret;
15101493
}
15111494

@@ -1529,8 +1512,6 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
15291512

15301513
free_irq(sfb->irq_no, sfb);
15311514

1532-
iounmap(sfb->regs);
1533-
15341515
if (!sfb->variant.has_clksel) {
15351516
clk_disable(sfb->lcd_clk);
15361517
clk_put(sfb->lcd_clk);
@@ -1539,12 +1520,9 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
15391520
clk_disable(sfb->bus_clk);
15401521
clk_put(sfb->bus_clk);
15411522

1542-
release_mem_region(sfb->regs_res->start, resource_size(sfb->regs_res));
1543-
15441523
pm_runtime_put_sync(sfb->dev);
15451524
pm_runtime_disable(sfb->dev);
15461525

1547-
kfree(sfb);
15481526
return 0;
15491527
}
15501528

0 commit comments

Comments
 (0)