aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-12-29 00:01:32 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-31 17:06:05 -0500
commite3a411a3dfc1d633504aa63efab32b7e00318454 (patch)
tree2ba6117448edd7056c8fa48cc6a696ae73a6c21a /drivers/video
parent6fc5bae797a6632bbccdd49a1b6a96121368a4b9 (diff)
[SPARC64]: Fix of_iounmap() region release.
We need to pass in the resource otherwise we cannot release the region properly. We must know whether it is an I/O or MEM resource. Spotted by Eric Brower. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/bw2.c18
-rw-r--r--drivers/video/cg14.c28
-rw-r--r--drivers/video/cg3.c22
-rw-r--r--drivers/video/cg6.c33
-rw-r--r--drivers/video/ffb.c25
-rw-r--r--drivers/video/leo.c29
-rw-r--r--drivers/video/p9100.c25
-rw-r--r--drivers/video/tcx.c33
8 files changed, 122 insertions, 91 deletions
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index c66e3d52cbf3..9bb6257d6918 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -320,7 +320,7 @@ static int __devinit bw2_init_one(struct of_device *op)
320 all->info.fbops = &bw2_ops; 320 all->info.fbops = &bw2_ops;
321 321
322 all->info.screen_base = 322 all->info.screen_base =
323 sbus_ioremap(&op->resource[0], 0, all->par.fbsize, "bw2 ram"); 323 of_ioremap(&op->resource[0], 0, all->par.fbsize, "bw2 ram");
324 all->info.par = &all->par; 324 all->info.par = &all->par;
325 325
326 bw2_blank(0, &all->info); 326 bw2_blank(0, &all->info);
@@ -329,8 +329,10 @@ static int __devinit bw2_init_one(struct of_device *op)
329 329
330 err= register_framebuffer(&all->info); 330 err= register_framebuffer(&all->info);
331 if (err < 0) { 331 if (err < 0) {
332 of_iounmap(all->par.regs, sizeof(struct bw2_regs)); 332 of_iounmap(&op->resource[0],
333 of_iounmap(all->info.screen_base, all->par.fbsize); 333 all->par.regs, sizeof(struct bw2_regs));
334 of_iounmap(&op->resource[0],
335 all->info.screen_base, all->par.fbsize);
334 kfree(all); 336 kfree(all);
335 return err; 337 return err;
336 } 338 }
@@ -351,18 +353,18 @@ static int __devinit bw2_probe(struct of_device *dev, const struct of_device_id
351 return bw2_init_one(op); 353 return bw2_init_one(op);
352} 354}
353 355
354static int __devexit bw2_remove(struct of_device *dev) 356static int __devexit bw2_remove(struct of_device *op)
355{ 357{
356 struct all_info *all = dev_get_drvdata(&dev->dev); 358 struct all_info *all = dev_get_drvdata(&op->dev);
357 359
358 unregister_framebuffer(&all->info); 360 unregister_framebuffer(&all->info);
359 361
360 of_iounmap(all->par.regs, sizeof(struct bw2_regs)); 362 of_iounmap(&op->resource[0], all->par.regs, sizeof(struct bw2_regs));
361 of_iounmap(all->info.screen_base, all->par.fbsize); 363 of_iounmap(&op->resource[0], all->info.screen_base, all->par.fbsize);
362 364
363 kfree(all); 365 kfree(all);
364 366
365 dev_set_drvdata(&dev->dev, NULL); 367 dev_set_drvdata(&op->dev, NULL);
366 368
367 return 0; 369 return 0;
368} 370}
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index 7f926c619b61..ec6a51a5822d 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -452,16 +452,20 @@ struct all_info {
452 struct cg14_par par; 452 struct cg14_par par;
453}; 453};
454 454
455static void cg14_unmap_regs(struct all_info *all) 455static void cg14_unmap_regs(struct of_device *op, struct all_info *all)
456{ 456{
457 if (all->par.regs) 457 if (all->par.regs)
458 of_iounmap(all->par.regs, sizeof(struct cg14_regs)); 458 of_iounmap(&op->resource[0],
459 all->par.regs, sizeof(struct cg14_regs));
459 if (all->par.clut) 460 if (all->par.clut)
460 of_iounmap(all->par.clut, sizeof(struct cg14_clut)); 461 of_iounmap(&op->resource[0],
462 all->par.clut, sizeof(struct cg14_clut));
461 if (all->par.cursor) 463 if (all->par.cursor)
462 of_iounmap(all->par.cursor, sizeof(struct cg14_cursor)); 464 of_iounmap(&op->resource[0],
465 all->par.cursor, sizeof(struct cg14_cursor));
463 if (all->info.screen_base) 466 if (all->info.screen_base)
464 of_iounmap(all->info.screen_base, all->par.fbsize); 467 of_iounmap(&op->resource[1],
468 all->info.screen_base, all->par.fbsize);
465} 469}
466 470
467static int __devinit cg14_init_one(struct of_device *op) 471static int __devinit cg14_init_one(struct of_device *op)
@@ -506,7 +510,7 @@ static int __devinit cg14_init_one(struct of_device *op)
506 510
507 if (!all->par.regs || !all->par.clut || !all->par.cursor || 511 if (!all->par.regs || !all->par.clut || !all->par.cursor ||
508 !all->info.screen_base) 512 !all->info.screen_base)
509 cg14_unmap_regs(all); 513 cg14_unmap_regs(op, all);
510 514
511 is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) == 515 is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) ==
512 (8 * 1024 * 1024)); 516 (8 * 1024 * 1024));
@@ -541,7 +545,7 @@ static int __devinit cg14_init_one(struct of_device *op)
541 __cg14_reset(&all->par); 545 __cg14_reset(&all->par);
542 546
543 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 547 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
544 cg14_unmap_regs(all); 548 cg14_unmap_regs(op, all);
545 kfree(all); 549 kfree(all);
546 return -ENOMEM; 550 return -ENOMEM;
547 } 551 }
@@ -552,7 +556,7 @@ static int __devinit cg14_init_one(struct of_device *op)
552 err = register_framebuffer(&all->info); 556 err = register_framebuffer(&all->info);
553 if (err < 0) { 557 if (err < 0) {
554 fb_dealloc_cmap(&all->info.cmap); 558 fb_dealloc_cmap(&all->info.cmap);
555 cg14_unmap_regs(all); 559 cg14_unmap_regs(op, all);
556 kfree(all); 560 kfree(all);
557 return err; 561 return err;
558 } 562 }
@@ -574,18 +578,18 @@ static int __devinit cg14_probe(struct of_device *dev, const struct of_device_id
574 return cg14_init_one(op); 578 return cg14_init_one(op);
575} 579}
576 580
577static int __devexit cg14_remove(struct of_device *dev) 581static int __devexit cg14_remove(struct of_device *op)
578{ 582{
579 struct all_info *all = dev_get_drvdata(&dev->dev); 583 struct all_info *all = dev_get_drvdata(&op->dev);
580 584
581 unregister_framebuffer(&all->info); 585 unregister_framebuffer(&all->info);
582 fb_dealloc_cmap(&all->info.cmap); 586 fb_dealloc_cmap(&all->info.cmap);
583 587
584 cg14_unmap_regs(all); 588 cg14_unmap_regs(op, all);
585 589
586 kfree(all); 590 kfree(all);
587 591
588 dev_set_drvdata(&dev->dev, NULL); 592 dev_set_drvdata(&op->dev, NULL);
589 593
590 return 0; 594 return 0;
591} 595}
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index 9c8c753ef454..ada6f7e3a891 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -403,8 +403,10 @@ static int __devinit cg3_init_one(struct of_device *op)
403 cg3_do_default_mode(&all->par); 403 cg3_do_default_mode(&all->par);
404 404
405 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 405 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
406 of_iounmap(all->par.regs, sizeof(struct cg3_regs)); 406 of_iounmap(&op->resource[0],
407 of_iounmap(all->info.screen_base, all->par.fbsize); 407 all->par.regs, sizeof(struct cg3_regs));
408 of_iounmap(&op->resource[0],
409 all->info.screen_base, all->par.fbsize);
408 kfree(all); 410 kfree(all);
409 return -ENOMEM; 411 return -ENOMEM;
410 } 412 }
@@ -415,8 +417,10 @@ static int __devinit cg3_init_one(struct of_device *op)
415 err = register_framebuffer(&all->info); 417 err = register_framebuffer(&all->info);
416 if (err < 0) { 418 if (err < 0) {
417 fb_dealloc_cmap(&all->info.cmap); 419 fb_dealloc_cmap(&all->info.cmap);
418 of_iounmap(all->par.regs, sizeof(struct cg3_regs)); 420 of_iounmap(&op->resource[0],
419 of_iounmap(all->info.screen_base, all->par.fbsize); 421 all->par.regs, sizeof(struct cg3_regs));
422 of_iounmap(&op->resource[0],
423 all->info.screen_base, all->par.fbsize);
420 kfree(all); 424 kfree(all);
421 return err; 425 return err;
422 } 426 }
@@ -436,19 +440,19 @@ static int __devinit cg3_probe(struct of_device *dev, const struct of_device_id
436 return cg3_init_one(op); 440 return cg3_init_one(op);
437} 441}
438 442
439static int __devexit cg3_remove(struct of_device *dev) 443static int __devexit cg3_remove(struct of_device *op)
440{ 444{
441 struct all_info *all = dev_get_drvdata(&dev->dev); 445 struct all_info *all = dev_get_drvdata(&op->dev);
442 446
443 unregister_framebuffer(&all->info); 447 unregister_framebuffer(&all->info);
444 fb_dealloc_cmap(&all->info.cmap); 448 fb_dealloc_cmap(&all->info.cmap);
445 449
446 of_iounmap(all->par.regs, sizeof(struct cg3_regs)); 450 of_iounmap(&op->resource[0], all->par.regs, sizeof(struct cg3_regs));
447 of_iounmap(all->info.screen_base, all->par.fbsize); 451 of_iounmap(&op->resource[0], all->info.screen_base, all->par.fbsize);
448 452
449 kfree(all); 453 kfree(all);
450 454
451 dev_set_drvdata(&dev->dev, NULL); 455 dev_set_drvdata(&op->dev, NULL);
452 456
453 return 0; 457 return 0;
454} 458}
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 64146be2eeb0..4dad23a28f58 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -658,21 +658,26 @@ struct all_info {
658 struct cg6_par par; 658 struct cg6_par par;
659}; 659};
660 660
661static void cg6_unmap_regs(struct all_info *all) 661static void cg6_unmap_regs(struct of_device *op, struct all_info *all)
662{ 662{
663 if (all->par.fbc) 663 if (all->par.fbc)
664 of_iounmap(all->par.fbc, 4096); 664 of_iounmap(&op->resource[0], all->par.fbc, 4096);
665 if (all->par.tec) 665 if (all->par.tec)
666 of_iounmap(all->par.tec, sizeof(struct cg6_tec)); 666 of_iounmap(&op->resource[0],
667 all->par.tec, sizeof(struct cg6_tec));
667 if (all->par.thc) 668 if (all->par.thc)
668 of_iounmap(all->par.thc, sizeof(struct cg6_thc)); 669 of_iounmap(&op->resource[0],
670 all->par.thc, sizeof(struct cg6_thc));
669 if (all->par.bt) 671 if (all->par.bt)
670 of_iounmap(all->par.bt, sizeof(struct bt_regs)); 672 of_iounmap(&op->resource[0],
673 all->par.bt, sizeof(struct bt_regs));
671 if (all->par.fhc) 674 if (all->par.fhc)
672 of_iounmap(all->par.fhc, sizeof(u32)); 675 of_iounmap(&op->resource[0],
676 all->par.fhc, sizeof(u32));
673 677
674 if (all->info.screen_base) 678 if (all->info.screen_base)
675 of_iounmap(all->info.screen_base, all->par.fbsize); 679 of_iounmap(&op->resource[0],
680 all->info.screen_base, all->par.fbsize);
676} 681}
677 682
678static int __devinit cg6_init_one(struct of_device *op) 683static int __devinit cg6_init_one(struct of_device *op)
@@ -720,7 +725,7 @@ static int __devinit cg6_init_one(struct of_device *op)
720 all->par.fbsize, "cgsix ram"); 725 all->par.fbsize, "cgsix ram");
721 if (!all->par.fbc || !all->par.tec || !all->par.thc || 726 if (!all->par.fbc || !all->par.tec || !all->par.thc ||
722 !all->par.bt || !all->par.fhc || !all->info.screen_base) { 727 !all->par.bt || !all->par.fhc || !all->info.screen_base) {
723 cg6_unmap_regs(all); 728 cg6_unmap_regs(op, all);
724 kfree(all); 729 kfree(all);
725 return -ENOMEM; 730 return -ENOMEM;
726 } 731 }
@@ -734,7 +739,7 @@ static int __devinit cg6_init_one(struct of_device *op)
734 cg6_blank(0, &all->info); 739 cg6_blank(0, &all->info);
735 740
736 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 741 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
737 cg6_unmap_regs(all); 742 cg6_unmap_regs(op, all);
738 kfree(all); 743 kfree(all);
739 return -ENOMEM; 744 return -ENOMEM;
740 } 745 }
@@ -744,7 +749,7 @@ static int __devinit cg6_init_one(struct of_device *op)
744 749
745 err = register_framebuffer(&all->info); 750 err = register_framebuffer(&all->info);
746 if (err < 0) { 751 if (err < 0) {
747 cg6_unmap_regs(all); 752 cg6_unmap_regs(op, all);
748 fb_dealloc_cmap(&all->info.cmap); 753 fb_dealloc_cmap(&all->info.cmap);
749 kfree(all); 754 kfree(all);
750 return err; 755 return err;
@@ -767,18 +772,18 @@ static int __devinit cg6_probe(struct of_device *dev, const struct of_device_id
767 return cg6_init_one(op); 772 return cg6_init_one(op);
768} 773}
769 774
770static int __devexit cg6_remove(struct of_device *dev) 775static int __devexit cg6_remove(struct of_device *op)
771{ 776{
772 struct all_info *all = dev_get_drvdata(&dev->dev); 777 struct all_info *all = dev_get_drvdata(&op->dev);
773 778
774 unregister_framebuffer(&all->info); 779 unregister_framebuffer(&all->info);
775 fb_dealloc_cmap(&all->info.cmap); 780 fb_dealloc_cmap(&all->info.cmap);
776 781
777 cg6_unmap_regs(all); 782 cg6_unmap_regs(op, all);
778 783
779 kfree(all); 784 kfree(all);
780 785
781 dev_set_drvdata(&dev->dev, NULL); 786 dev_set_drvdata(&op->dev, NULL);
782 787
783 return 0; 788 return 0;
784} 789}
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 949141bd44d4..15854aec3180 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -910,7 +910,8 @@ static int ffb_init_one(struct of_device *op)
910 all->par.dac = of_ioremap(&op->resource[1], 0, 910 all->par.dac = of_ioremap(&op->resource[1], 0,
911 sizeof(struct ffb_dac), "ffb dac"); 911 sizeof(struct ffb_dac), "ffb dac");
912 if (!all->par.dac) { 912 if (!all->par.dac) {
913 of_iounmap(all->par.fbc, sizeof(struct ffb_fbc)); 913 of_iounmap(&op->resource[2],
914 all->par.fbc, sizeof(struct ffb_fbc));
914 kfree(all); 915 kfree(all);
915 return -ENOMEM; 916 return -ENOMEM;
916 } 917 }
@@ -968,8 +969,10 @@ static int ffb_init_one(struct of_device *op)
968 969
969 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 970 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
970 printk(KERN_ERR "ffb: Could not allocate color map.\n"); 971 printk(KERN_ERR "ffb: Could not allocate color map.\n");
971 of_iounmap(all->par.fbc, sizeof(struct ffb_fbc)); 972 of_iounmap(&op->resource[2],
972 of_iounmap(all->par.dac, sizeof(struct ffb_dac)); 973 all->par.fbc, sizeof(struct ffb_fbc));
974 of_iounmap(&op->resource[1],
975 all->par.dac, sizeof(struct ffb_dac));
973 kfree(all); 976 kfree(all);
974 return -ENOMEM; 977 return -ENOMEM;
975 } 978 }
@@ -980,8 +983,10 @@ static int ffb_init_one(struct of_device *op)
980 if (err < 0) { 983 if (err < 0) {
981 printk(KERN_ERR "ffb: Could not register framebuffer.\n"); 984 printk(KERN_ERR "ffb: Could not register framebuffer.\n");
982 fb_dealloc_cmap(&all->info.cmap); 985 fb_dealloc_cmap(&all->info.cmap);
983 of_iounmap(all->par.fbc, sizeof(struct ffb_fbc)); 986 of_iounmap(&op->resource[2],
984 of_iounmap(all->par.dac, sizeof(struct ffb_dac)); 987 all->par.fbc, sizeof(struct ffb_fbc));
988 of_iounmap(&op->resource[1],
989 all->par.dac, sizeof(struct ffb_dac));
985 kfree(all); 990 kfree(all);
986 return err; 991 return err;
987 } 992 }
@@ -1003,19 +1008,19 @@ static int __devinit ffb_probe(struct of_device *dev, const struct of_device_id
1003 return ffb_init_one(op); 1008 return ffb_init_one(op);
1004} 1009}
1005 1010
1006static int __devexit ffb_remove(struct of_device *dev) 1011static int __devexit ffb_remove(struct of_device *op)
1007{ 1012{
1008 struct all_info *all = dev_get_drvdata(&dev->dev); 1013 struct all_info *all = dev_get_drvdata(&op->dev);
1009 1014
1010 unregister_framebuffer(&all->info); 1015 unregister_framebuffer(&all->info);
1011 fb_dealloc_cmap(&all->info.cmap); 1016 fb_dealloc_cmap(&all->info.cmap);
1012 1017
1013 of_iounmap(all->par.fbc, sizeof(struct ffb_fbc)); 1018 of_iounmap(&op->resource[2], all->par.fbc, sizeof(struct ffb_fbc));
1014 of_iounmap(all->par.dac, sizeof(struct ffb_dac)); 1019 of_iounmap(&op->resource[1], all->par.dac, sizeof(struct ffb_dac));
1015 1020
1016 kfree(all); 1021 kfree(all);
1017 1022
1018 dev_set_drvdata(&dev->dev, NULL); 1023 dev_set_drvdata(&op->dev, NULL);
1019 1024
1020 return 0; 1025 return 0;
1021} 1026}
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index f3a24338d9ac..a038aa5a9e1c 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -530,20 +530,21 @@ struct all_info {
530 struct leo_par par; 530 struct leo_par par;
531}; 531};
532 532
533static void leo_unmap_regs(struct all_info *all) 533static void leo_unmap_regs(struct of_device *op, struct all_info *all)
534{ 534{
535 if (all->par.lc_ss0_usr) 535 if (all->par.lc_ss0_usr)
536 of_iounmap(all->par.lc_ss0_usr, 0x1000); 536 of_iounmap(&op->resource[0], all->par.lc_ss0_usr, 0x1000);
537 if (all->par.ld_ss0) 537 if (all->par.ld_ss0)
538 of_iounmap(all->par.ld_ss0, 0x1000); 538 of_iounmap(&op->resource[0], all->par.ld_ss0, 0x1000);
539 if (all->par.ld_ss1) 539 if (all->par.ld_ss1)
540 of_iounmap(all->par.ld_ss1, 0x1000); 540 of_iounmap(&op->resource[0], all->par.ld_ss1, 0x1000);
541 if (all->par.lx_krn) 541 if (all->par.lx_krn)
542 of_iounmap(all->par.lx_krn, 0x1000); 542 of_iounmap(&op->resource[0], all->par.lx_krn, 0x1000);
543 if (all->par.cursor) 543 if (all->par.cursor)
544 of_iounmap(all->par.cursor, sizeof(struct leo_cursor)); 544 of_iounmap(&op->resource[0],
545 all->par.cursor, sizeof(struct leo_cursor));
545 if (all->info.screen_base) 546 if (all->info.screen_base)
546 of_iounmap(all->info.screen_base, 0x800000); 547 of_iounmap(&op->resource[0], all->info.screen_base, 0x800000);
547} 548}
548 549
549static int __devinit leo_init_one(struct of_device *op) 550static int __devinit leo_init_one(struct of_device *op)
@@ -592,7 +593,7 @@ static int __devinit leo_init_one(struct of_device *op)
592 !all->par.lx_krn || 593 !all->par.lx_krn ||
593 !all->par.cursor || 594 !all->par.cursor ||
594 !all->info.screen_base) { 595 !all->info.screen_base) {
595 leo_unmap_regs(all); 596 leo_unmap_regs(op, all);
596 kfree(all); 597 kfree(all);
597 return -ENOMEM; 598 return -ENOMEM;
598 } 599 }
@@ -607,7 +608,7 @@ static int __devinit leo_init_one(struct of_device *op)
607 leo_blank(0, &all->info); 608 leo_blank(0, &all->info);
608 609
609 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 610 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
610 leo_unmap_regs(all); 611 leo_unmap_regs(op, all);
611 kfree(all); 612 kfree(all);
612 return -ENOMEM;; 613 return -ENOMEM;;
613 } 614 }
@@ -617,7 +618,7 @@ static int __devinit leo_init_one(struct of_device *op)
617 err = register_framebuffer(&all->info); 618 err = register_framebuffer(&all->info);
618 if (err < 0) { 619 if (err < 0) {
619 fb_dealloc_cmap(&all->info.cmap); 620 fb_dealloc_cmap(&all->info.cmap);
620 leo_unmap_regs(all); 621 leo_unmap_regs(op, all);
621 kfree(all); 622 kfree(all);
622 return err; 623 return err;
623 } 624 }
@@ -638,18 +639,18 @@ static int __devinit leo_probe(struct of_device *dev, const struct of_device_id
638 return leo_init_one(op); 639 return leo_init_one(op);
639} 640}
640 641
641static int __devexit leo_remove(struct of_device *dev) 642static int __devexit leo_remove(struct of_device *op)
642{ 643{
643 struct all_info *all = dev_get_drvdata(&dev->dev); 644 struct all_info *all = dev_get_drvdata(&op->dev);
644 645
645 unregister_framebuffer(&all->info); 646 unregister_framebuffer(&all->info);
646 fb_dealloc_cmap(&all->info.cmap); 647 fb_dealloc_cmap(&all->info.cmap);
647 648
648 leo_unmap_regs(all); 649 leo_unmap_regs(op, all);
649 650
650 kfree(all); 651 kfree(all);
651 652
652 dev_set_drvdata(&dev->dev, NULL); 653 dev_set_drvdata(&op->dev, NULL);
653 654
654 return 0; 655 return 0;
655} 656}
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 56ac51d6a7f3..637b78bb4bf7 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -297,7 +297,8 @@ static int __devinit p9100_init_one(struct of_device *op)
297 all->info.screen_base = of_ioremap(&op->resource[2], 0, 297 all->info.screen_base = of_ioremap(&op->resource[2], 0,
298 all->par.fbsize, "p9100 ram"); 298 all->par.fbsize, "p9100 ram");
299 if (!all->info.screen_base) { 299 if (!all->info.screen_base) {
300 of_iounmap(all->par.regs, sizeof(struct p9100_regs)); 300 of_iounmap(&op->resource[0],
301 all->par.regs, sizeof(struct p9100_regs));
301 kfree(all); 302 kfree(all);
302 return -ENOMEM; 303 return -ENOMEM;
303 } 304 }
@@ -306,8 +307,10 @@ static int __devinit p9100_init_one(struct of_device *op)
306 p9100_blank(0, &all->info); 307 p9100_blank(0, &all->info);
307 308
308 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 309 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
309 of_iounmap(all->par.regs, sizeof(struct p9100_regs)); 310 of_iounmap(&op->resource[0],
310 of_iounmap(all->info.screen_base, all->par.fbsize); 311 all->par.regs, sizeof(struct p9100_regs));
312 of_iounmap(&op->resource[2],
313 all->info.screen_base, all->par.fbsize);
311 kfree(all); 314 kfree(all);
312 return -ENOMEM; 315 return -ENOMEM;
313 } 316 }
@@ -317,8 +320,10 @@ static int __devinit p9100_init_one(struct of_device *op)
317 err = register_framebuffer(&all->info); 320 err = register_framebuffer(&all->info);
318 if (err < 0) { 321 if (err < 0) {
319 fb_dealloc_cmap(&all->info.cmap); 322 fb_dealloc_cmap(&all->info.cmap);
320 of_iounmap(all->par.regs, sizeof(struct p9100_regs)); 323 of_iounmap(&op->resource[0],
321 of_iounmap(all->info.screen_base, all->par.fbsize); 324 all->par.regs, sizeof(struct p9100_regs));
325 of_iounmap(&op->resource[2],
326 all->info.screen_base, all->par.fbsize);
322 kfree(all); 327 kfree(all);
323 return err; 328 return err;
324 } 329 }
@@ -340,19 +345,19 @@ static int __devinit p9100_probe(struct of_device *dev, const struct of_device_i
340 return p9100_init_one(op); 345 return p9100_init_one(op);
341} 346}
342 347
343static int __devexit p9100_remove(struct of_device *dev) 348static int __devexit p9100_remove(struct of_device *op)
344{ 349{
345 struct all_info *all = dev_get_drvdata(&dev->dev); 350 struct all_info *all = dev_get_drvdata(&op->dev);
346 351
347 unregister_framebuffer(&all->info); 352 unregister_framebuffer(&all->info);
348 fb_dealloc_cmap(&all->info.cmap); 353 fb_dealloc_cmap(&all->info.cmap);
349 354
350 of_iounmap(all->par.regs, sizeof(struct p9100_regs)); 355 of_iounmap(&op->resource[0], all->par.regs, sizeof(struct p9100_regs));
351 of_iounmap(all->info.screen_base, all->par.fbsize); 356 of_iounmap(&op->resource[2], all->info.screen_base, all->par.fbsize);
352 357
353 kfree(all); 358 kfree(all);
354 359
355 dev_set_drvdata(&dev->dev, NULL); 360 dev_set_drvdata(&op->dev, NULL);
356 361
357 return 0; 362 return 0;
358} 363}
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index 6990ab11cd06..5a99669232ce 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -350,18 +350,23 @@ struct all_info {
350 struct tcx_par par; 350 struct tcx_par par;
351}; 351};
352 352
353static void tcx_unmap_regs(struct all_info *all) 353static void tcx_unmap_regs(struct of_device *op, struct all_info *all)
354{ 354{
355 if (all->par.tec) 355 if (all->par.tec)
356 of_iounmap(all->par.tec, sizeof(struct tcx_tec)); 356 of_iounmap(&op->resource[7],
357 all->par.tec, sizeof(struct tcx_tec));
357 if (all->par.thc) 358 if (all->par.thc)
358 of_iounmap(all->par.thc, sizeof(struct tcx_thc)); 359 of_iounmap(&op->resource[9],
360 all->par.thc, sizeof(struct tcx_thc));
359 if (all->par.bt) 361 if (all->par.bt)
360 of_iounmap(all->par.bt, sizeof(struct bt_regs)); 362 of_iounmap(&op->resource[8],
363 all->par.bt, sizeof(struct bt_regs));
361 if (all->par.cplane) 364 if (all->par.cplane)
362 of_iounmap(all->par.cplane, all->par.fbsize * sizeof(u32)); 365 of_iounmap(&op->resource[4],
366 all->par.cplane, all->par.fbsize * sizeof(u32));
363 if (all->info.screen_base) 367 if (all->info.screen_base)
364 of_iounmap(all->info.screen_base, all->par.fbsize); 368 of_iounmap(&op->resource[0],
369 all->info.screen_base, all->par.fbsize);
365} 370}
366 371
367static int __devinit tcx_init_one(struct of_device *op) 372static int __devinit tcx_init_one(struct of_device *op)
@@ -398,7 +403,7 @@ static int __devinit tcx_init_one(struct of_device *op)
398 all->par.fbsize, "tcx ram"); 403 all->par.fbsize, "tcx ram");
399 if (!all->par.tec || !all->par.thc || 404 if (!all->par.tec || !all->par.thc ||
400 !all->par.bt || !all->info.screen_base) { 405 !all->par.bt || !all->info.screen_base) {
401 tcx_unmap_regs(all); 406 tcx_unmap_regs(op, all);
402 kfree(all); 407 kfree(all);
403 return -ENOMEM; 408 return -ENOMEM;
404 } 409 }
@@ -409,7 +414,7 @@ static int __devinit tcx_init_one(struct of_device *op)
409 all->par.fbsize * sizeof(u32), 414 all->par.fbsize * sizeof(u32),
410 "tcx cplane"); 415 "tcx cplane");
411 if (!all->par.cplane) { 416 if (!all->par.cplane) {
412 tcx_unmap_regs(all); 417 tcx_unmap_regs(op, all);
413 kfree(all); 418 kfree(all);
414 return -ENOMEM; 419 return -ENOMEM;
415 } 420 }
@@ -461,7 +466,7 @@ static int __devinit tcx_init_one(struct of_device *op)
461 tcx_blank(FB_BLANK_UNBLANK, &all->info); 466 tcx_blank(FB_BLANK_UNBLANK, &all->info);
462 467
463 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 468 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
464 tcx_unmap_regs(all); 469 tcx_unmap_regs(op, all);
465 kfree(all); 470 kfree(all);
466 return -ENOMEM; 471 return -ENOMEM;
467 } 472 }
@@ -472,7 +477,7 @@ static int __devinit tcx_init_one(struct of_device *op)
472 err = register_framebuffer(&all->info); 477 err = register_framebuffer(&all->info);
473 if (err < 0) { 478 if (err < 0) {
474 fb_dealloc_cmap(&all->info.cmap); 479 fb_dealloc_cmap(&all->info.cmap);
475 tcx_unmap_regs(all); 480 tcx_unmap_regs(op, all);
476 kfree(all); 481 kfree(all);
477 return err; 482 return err;
478 } 483 }
@@ -495,18 +500,18 @@ static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id
495 return tcx_init_one(op); 500 return tcx_init_one(op);
496} 501}
497 502
498static int __devexit tcx_remove(struct of_device *dev) 503static int __devexit tcx_remove(struct of_device *op)
499{ 504{
500 struct all_info *all = dev_get_drvdata(&dev->dev); 505 struct all_info *all = dev_get_drvdata(&op->dev);
501 506
502 unregister_framebuffer(&all->info); 507 unregister_framebuffer(&all->info);
503 fb_dealloc_cmap(&all->info.cmap); 508 fb_dealloc_cmap(&all->info.cmap);
504 509
505 tcx_unmap_regs(all); 510 tcx_unmap_regs(op, all);
506 511
507 kfree(all); 512 kfree(all);
508 513
509 dev_set_drvdata(&dev->dev, NULL); 514 dev_set_drvdata(&op->dev, NULL);
510 515
511 return 0; 516 return 0;
512} 517}