aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-21 08:11:49 -0500
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2012-01-28 14:56:27 -0500
commit857a8df9467a6dfe5d3aa309d9bdef31dc817647 (patch)
tree03f493385767003ee8961fc733c49c6f4a637a7e /drivers/video
parentf820917abae4a019b0357d3fe72b22c22a11b775 (diff)
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 <broonie@opensource.wolfsonmicro.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/s3c-fb.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index 0c63b69b6340..7c5158dda0bf 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -186,7 +186,6 @@ struct s3c_fb_vsync {
186 * struct s3c_fb - overall hardware state of the hardware 186 * struct s3c_fb - overall hardware state of the hardware
187 * @slock: The spinlock protection for this data sturcture. 187 * @slock: The spinlock protection for this data sturcture.
188 * @dev: The device that we bound to, for printing, etc. 188 * @dev: The device that we bound to, for printing, etc.
189 * @regs_res: The resource we claimed for the IO registers.
190 * @bus_clk: The clk (hclk) feeding our interface and possibly pixclk. 189 * @bus_clk: The clk (hclk) feeding our interface and possibly pixclk.
191 * @lcd_clk: The clk (sclk) feeding pixclk. 190 * @lcd_clk: The clk (sclk) feeding pixclk.
192 * @regs: The mapped hardware registers. 191 * @regs: The mapped hardware registers.
@@ -202,7 +201,6 @@ struct s3c_fb_vsync {
202struct s3c_fb { 201struct s3c_fb {
203 spinlock_t slock; 202 spinlock_t slock;
204 struct device *dev; 203 struct device *dev;
205 struct resource *regs_res;
206 struct clk *bus_clk; 204 struct clk *bus_clk;
207 struct clk *lcd_clk; 205 struct clk *lcd_clk;
208 void __iomem *regs; 206 void __iomem *regs;
@@ -1361,7 +1359,7 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
1361 return -EINVAL; 1359 return -EINVAL;
1362 } 1360 }
1363 1361
1364 sfb = kzalloc(sizeof(struct s3c_fb), GFP_KERNEL); 1362 sfb = devm_kzalloc(dev, sizeof(struct s3c_fb), GFP_KERNEL);
1365 if (!sfb) { 1363 if (!sfb) {
1366 dev_err(dev, "no memory for framebuffers\n"); 1364 dev_err(dev, "no memory for framebuffers\n");
1367 return -ENOMEM; 1365 return -ENOMEM;
@@ -1404,33 +1402,25 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
1404 goto err_lcd_clk; 1402 goto err_lcd_clk;
1405 } 1403 }
1406 1404
1407 sfb->regs_res = request_mem_region(res->start, resource_size(res), 1405 sfb->regs = devm_request_and_ioremap(dev, 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));
1416 if (!sfb->regs) { 1406 if (!sfb->regs) {
1417 dev_err(dev, "failed to map registers\n"); 1407 dev_err(dev, "failed to map registers\n");
1418 ret = -ENXIO; 1408 ret = -ENXIO;
1419 goto err_req_region; 1409 goto err_lcd_clk;
1420 } 1410 }
1421 1411
1422 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1412 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1423 if (!res) { 1413 if (!res) {
1424 dev_err(dev, "failed to acquire irq resource\n"); 1414 dev_err(dev, "failed to acquire irq resource\n");
1425 ret = -ENOENT; 1415 ret = -ENOENT;
1426 goto err_ioremap; 1416 goto err_lcd_clk;
1427 } 1417 }
1428 sfb->irq_no = res->start; 1418 sfb->irq_no = res->start;
1429 ret = request_irq(sfb->irq_no, s3c_fb_irq, 1419 ret = request_irq(sfb->irq_no, s3c_fb_irq,
1430 0, "s3c_fb", sfb); 1420 0, "s3c_fb", sfb);
1431 if (ret) { 1421 if (ret) {
1432 dev_err(dev, "irq request failed\n"); 1422 dev_err(dev, "irq request failed\n");
1433 goto err_ioremap; 1423 goto err_lcd_clk;
1434 } 1424 }
1435 1425
1436 dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs); 1426 dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs);
@@ -1486,12 +1476,6 @@ err_pm_runtime:
1486 pm_runtime_put_sync(sfb->dev); 1476 pm_runtime_put_sync(sfb->dev);
1487 free_irq(sfb->irq_no, sfb); 1477 free_irq(sfb->irq_no, sfb);
1488 1478
1489err_ioremap:
1490 iounmap(sfb->regs);
1491
1492err_req_region:
1493 release_mem_region(sfb->regs_res->start, resource_size(sfb->regs_res));
1494
1495err_lcd_clk: 1479err_lcd_clk:
1496 pm_runtime_disable(sfb->dev); 1480 pm_runtime_disable(sfb->dev);
1497 1481
@@ -1505,7 +1489,6 @@ err_bus_clk:
1505 clk_put(sfb->bus_clk); 1489 clk_put(sfb->bus_clk);
1506 1490
1507err_sfb: 1491err_sfb:
1508 kfree(sfb);
1509 return ret; 1492 return ret;
1510} 1493}
1511 1494
@@ -1529,8 +1512,6 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
1529 1512
1530 free_irq(sfb->irq_no, sfb); 1513 free_irq(sfb->irq_no, sfb);
1531 1514
1532 iounmap(sfb->regs);
1533
1534 if (!sfb->variant.has_clksel) { 1515 if (!sfb->variant.has_clksel) {
1535 clk_disable(sfb->lcd_clk); 1516 clk_disable(sfb->lcd_clk);
1536 clk_put(sfb->lcd_clk); 1517 clk_put(sfb->lcd_clk);
@@ -1539,12 +1520,9 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
1539 clk_disable(sfb->bus_clk); 1520 clk_disable(sfb->bus_clk);
1540 clk_put(sfb->bus_clk); 1521 clk_put(sfb->bus_clk);
1541 1522
1542 release_mem_region(sfb->regs_res->start, resource_size(sfb->regs_res));
1543
1544 pm_runtime_put_sync(sfb->dev); 1523 pm_runtime_put_sync(sfb->dev);
1545 pm_runtime_disable(sfb->dev); 1524 pm_runtime_disable(sfb->dev);
1546 1525
1547 kfree(sfb);
1548 return 0; 1526 return 0;
1549} 1527}
1550 1528