aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/xilinxfb.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-06-03 06:13:20 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-06-26 06:31:29 -0400
commita8f045aa07b3d40f46e35536eeb54e3c5423c5c2 (patch)
treedb1d9fd00f71710c512cdd3b1e21d4ac19b4614d /drivers/video/xilinxfb.c
parentc88fafef0135e1e1c3e23c3e32ccbeeabc587f81 (diff)
video: xilinxfb: Group bus initialization
Move of_address_to_resource() to xilinxfb_assign() which simplify driver probing. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/xilinxfb.c')
-rw-r--r--drivers/video/xilinxfb.c56
1 files changed, 15 insertions, 41 deletions
diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index 1b55f18e0b42..bd3b85d890d4 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -227,33 +227,23 @@ static struct fb_ops xilinxfb_ops =
227 * Bus independent setup/teardown 227 * Bus independent setup/teardown
228 */ 228 */
229 229
230static int xilinxfb_assign(struct device *dev, 230static int xilinxfb_assign(struct platform_device *pdev,
231 struct xilinxfb_drvdata *drvdata, 231 struct xilinxfb_drvdata *drvdata,
232 unsigned long physaddr,
233 struct xilinxfb_platform_data *pdata) 232 struct xilinxfb_platform_data *pdata)
234{ 233{
235 int rc; 234 int rc;
235 struct device *dev = &pdev->dev;
236 int fbsize = pdata->xvirt * pdata->yvirt * BYTES_PER_PIXEL; 236 int fbsize = pdata->xvirt * pdata->yvirt * BYTES_PER_PIXEL;
237 237
238 if (drvdata->flags & BUS_ACCESS_FLAG) { 238 if (drvdata->flags & BUS_ACCESS_FLAG) {
239 /* 239 struct resource *res;
240 * Map the control registers in if the controller
241 * is on direct BUS interface.
242 */
243 if (!request_mem_region(physaddr, 8, DRIVER_NAME)) {
244 dev_err(dev, "Couldn't lock memory region at 0x%08lX\n",
245 physaddr);
246 rc = -ENODEV;
247 goto err_region;
248 }
249 240
250 drvdata->regs_phys = physaddr; 241 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
251 drvdata->regs = ioremap(physaddr, 8); 242 drvdata->regs_phys = res->start;
243 drvdata->regs = devm_request_and_ioremap(&pdev->dev, res);
252 if (!drvdata->regs) { 244 if (!drvdata->regs) {
253 dev_err(dev, "Couldn't lock memory region at 0x%08lX\n", 245 rc = -EADDRNOTAVAIL;
254 physaddr); 246 goto err_region;
255 rc = -ENODEV;
256 goto err_map;
257 } 247 }
258 } 248 }
259 249
@@ -349,11 +339,7 @@ err_cmap:
349 339
350err_fbmem: 340err_fbmem:
351 if (drvdata->flags & BUS_ACCESS_FLAG) 341 if (drvdata->flags & BUS_ACCESS_FLAG)
352 iounmap(drvdata->regs); 342 devm_iounmap(dev, drvdata->regs);
353
354err_map:
355 if (drvdata->flags & BUS_ACCESS_FLAG)
356 release_mem_region(drvdata->regs_phys, 8);
357 343
358err_region: 344err_region:
359 kfree(drvdata); 345 kfree(drvdata);
@@ -384,10 +370,8 @@ static int xilinxfb_release(struct device *dev)
384 xilinx_fb_out32(drvdata, REG_CTRL, 0); 370 xilinx_fb_out32(drvdata, REG_CTRL, 0);
385 371
386 /* Release the resources, as allocated based on interface */ 372 /* Release the resources, as allocated based on interface */
387 if (drvdata->flags & BUS_ACCESS_FLAG) { 373 if (drvdata->flags & BUS_ACCESS_FLAG)
388 iounmap(drvdata->regs); 374 devm_iounmap(dev, drvdata->regs);
389 release_mem_region(drvdata->regs_phys, 8);
390 }
391#ifdef CONFIG_PPC_DCR 375#ifdef CONFIG_PPC_DCR
392 else 376 else
393 dcr_unmap(drvdata->dcr_host, drvdata->dcr_len); 377 dcr_unmap(drvdata->dcr_host, drvdata->dcr_len);
@@ -408,8 +392,7 @@ static int xilinxfb_of_probe(struct platform_device *op)
408 const u32 *prop; 392 const u32 *prop;
409 u32 tft_access = 0; 393 u32 tft_access = 0;
410 struct xilinxfb_platform_data pdata; 394 struct xilinxfb_platform_data pdata;
411 struct resource res; 395 int size;
412 int size, rc;
413 struct xilinxfb_drvdata *drvdata; 396 struct xilinxfb_drvdata *drvdata;
414 397
415 /* Copy with the default pdata (not a ptr reference!) */ 398 /* Copy with the default pdata (not a ptr reference!) */
@@ -435,22 +418,17 @@ static int xilinxfb_of_probe(struct platform_device *op)
435 */ 418 */
436 if (tft_access) { 419 if (tft_access) {
437 drvdata->flags |= BUS_ACCESS_FLAG; 420 drvdata->flags |= BUS_ACCESS_FLAG;
438 rc = of_address_to_resource(op->dev.of_node, 0, &res);
439 if (rc) {
440 dev_err(&op->dev, "invalid address\n");
441 goto err;
442 }
443 } 421 }
444#ifdef CONFIG_PPC_DCR 422#ifdef CONFIG_PPC_DCR
445 else { 423 else {
446 int start; 424 int start;
447 res.start = 0;
448 start = dcr_resource_start(op->dev.of_node, 0); 425 start = dcr_resource_start(op->dev.of_node, 0);
449 drvdata->dcr_len = dcr_resource_len(op->dev.of_node, 0); 426 drvdata->dcr_len = dcr_resource_len(op->dev.of_node, 0);
450 drvdata->dcr_host = dcr_map(op->dev.of_node, start, drvdata->dcr_len); 427 drvdata->dcr_host = dcr_map(op->dev.of_node, start, drvdata->dcr_len);
451 if (!DCR_MAP_OK(drvdata->dcr_host)) { 428 if (!DCR_MAP_OK(drvdata->dcr_host)) {
452 dev_err(&op->dev, "invalid DCR address\n"); 429 dev_err(&op->dev, "invalid DCR address\n");
453 goto err; 430 kfree(drvdata);
431 return -ENODEV;
454 } 432 }
455 } 433 }
456#endif 434#endif
@@ -477,11 +455,7 @@ static int xilinxfb_of_probe(struct platform_device *op)
477 pdata.rotate_screen = 1; 455 pdata.rotate_screen = 1;
478 456
479 dev_set_drvdata(&op->dev, drvdata); 457 dev_set_drvdata(&op->dev, drvdata);
480 return xilinxfb_assign(&op->dev, drvdata, res.start, &pdata); 458 return xilinxfb_assign(op, drvdata, &pdata);
481
482 err:
483 kfree(drvdata);
484 return -ENODEV;
485} 459}
486 460
487static int xilinxfb_of_remove(struct platform_device *op) 461static int xilinxfb_of_remove(struct platform_device *op)