diff options
Diffstat (limited to 'drivers/video/fbmem.c')
-rw-r--r-- | drivers/video/fbmem.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index d412a1ddc12f..f8a09bf8d0cd 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1462,6 +1462,16 @@ static int fb_check_foreignness(struct fb_info *fi) | |||
1462 | return 0; | 1462 | return 0; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | static bool fb_do_apertures_overlap(struct fb_info *gen, struct fb_info *hw) | ||
1466 | { | ||
1467 | /* is the generic aperture base the same as the HW one */ | ||
1468 | if (gen->aperture_base == hw->aperture_base) | ||
1469 | return true; | ||
1470 | /* is the generic aperture base inside the hw base->hw base+size */ | ||
1471 | if (gen->aperture_base > hw->aperture_base && gen->aperture_base <= hw->aperture_base + hw->aperture_size) | ||
1472 | return true; | ||
1473 | return false; | ||
1474 | } | ||
1465 | /** | 1475 | /** |
1466 | * register_framebuffer - registers a frame buffer device | 1476 | * register_framebuffer - registers a frame buffer device |
1467 | * @fb_info: frame buffer info structure | 1477 | * @fb_info: frame buffer info structure |
@@ -1485,6 +1495,23 @@ register_framebuffer(struct fb_info *fb_info) | |||
1485 | if (fb_check_foreignness(fb_info)) | 1495 | if (fb_check_foreignness(fb_info)) |
1486 | return -ENOSYS; | 1496 | return -ENOSYS; |
1487 | 1497 | ||
1498 | /* check all firmware fbs and kick off if the base addr overlaps */ | ||
1499 | for (i = 0 ; i < FB_MAX; i++) { | ||
1500 | if (!registered_fb[i]) | ||
1501 | continue; | ||
1502 | |||
1503 | if (registered_fb[i]->flags & FBINFO_MISC_FIRMWARE) { | ||
1504 | if (fb_do_apertures_overlap(registered_fb[i], fb_info)) { | ||
1505 | printk(KERN_ERR "fb: conflicting fb hw usage " | ||
1506 | "%s vs %s - removing generic driver\n", | ||
1507 | fb_info->fix.id, | ||
1508 | registered_fb[i]->fix.id); | ||
1509 | unregister_framebuffer(registered_fb[i]); | ||
1510 | break; | ||
1511 | } | ||
1512 | } | ||
1513 | } | ||
1514 | |||
1488 | num_registered_fb++; | 1515 | num_registered_fb++; |
1489 | for (i = 0 ; i < FB_MAX; i++) | 1516 | for (i = 0 ; i < FB_MAX; i++) |
1490 | if (!registered_fb[i]) | 1517 | if (!registered_fb[i]) |
@@ -1586,6 +1613,10 @@ unregister_framebuffer(struct fb_info *fb_info) | |||
1586 | device_destroy(fb_class, MKDEV(FB_MAJOR, i)); | 1613 | device_destroy(fb_class, MKDEV(FB_MAJOR, i)); |
1587 | event.info = fb_info; | 1614 | event.info = fb_info; |
1588 | fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); | 1615 | fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); |
1616 | |||
1617 | /* this may free fb info */ | ||
1618 | if (fb_info->fbops->fb_destroy) | ||
1619 | fb_info->fbops->fb_destroy(fb_info); | ||
1589 | done: | 1620 | done: |
1590 | return ret; | 1621 | return ret; |
1591 | } | 1622 | } |