aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/hgafb.c
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-01-09 23:53:06 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:45 -0500
commit1d204ef3e4ea61058e49453af393ca754b529b85 (patch)
treee915e9079be964b5d5681054516b301b49d87951 /drivers/video/hgafb.c
parent2a9f61702608b6ae7905063278b832439e608938 (diff)
[PATCH] fbdev: hgafb: Convert to platform device
- convert to platform device Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/hgafb.c')
-rw-r--r--drivers/video/hgafb.c107
1 files changed, 78 insertions, 29 deletions
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c
index b37cea7d1094..4e39035cf335 100644
--- a/drivers/video/hgafb.c
+++ b/drivers/video/hgafb.c
@@ -42,6 +42,7 @@
42#include <linux/fb.h> 42#include <linux/fb.h>
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/ioport.h> 44#include <linux/ioport.h>
45#include <linux/platform_device.h>
45#include <asm/io.h> 46#include <asm/io.h>
46#include <asm/vga.h> 47#include <asm/vga.h>
47 48
@@ -107,7 +108,7 @@ static DEFINE_SPINLOCK(hga_reg_lock);
107 108
108/* Framebuffer driver structures */ 109/* Framebuffer driver structures */
109 110
110static struct fb_var_screeninfo hga_default_var = { 111static struct fb_var_screeninfo __initdata hga_default_var = {
111 .xres = 720, 112 .xres = 720,
112 .yres = 348, 113 .yres = 348,
113 .xres_virtual = 720, 114 .xres_virtual = 720,
@@ -121,7 +122,7 @@ static struct fb_var_screeninfo hga_default_var = {
121 .width = -1, 122 .width = -1,
122}; 123};
123 124
124static struct fb_fix_screeninfo hga_fix = { 125static struct fb_fix_screeninfo __initdata hga_fix = {
125 .id = "HGA", 126 .id = "HGA",
126 .type = FB_TYPE_PACKED_PIXELS, /* (not sure) */ 127 .type = FB_TYPE_PACKED_PIXELS, /* (not sure) */
127 .visual = FB_VISUAL_MONO10, 128 .visual = FB_VISUAL_MONO10,
@@ -131,8 +132,6 @@ static struct fb_fix_screeninfo hga_fix = {
131 .accel = FB_ACCEL_NONE 132 .accel = FB_ACCEL_NONE
132}; 133};
133 134
134static struct fb_info fb_info;
135
136/* Don't assume that tty1 will be the initial current console. */ 135/* Don't assume that tty1 will be the initial current console. */
137static int release_io_port = 0; 136static int release_io_port = 0;
138static int release_io_ports = 0; 137static int release_io_ports = 0;
@@ -549,10 +548,9 @@ static struct fb_ops hgafb_ops = {
549 * Initialization 548 * Initialization
550 */ 549 */
551 550
552static int __init hgafb_init(void) 551static int __init hgafb_probe(struct device *device)
553{ 552{
554 if (fb_get_options("hgafb", NULL)) 553 struct fb_info *info;
555 return -ENODEV;
556 554
557 if (! hga_card_detect()) { 555 if (! hga_card_detect()) {
558 printk(KERN_INFO "hgafb: HGA card not detected.\n"); 556 printk(KERN_INFO "hgafb: HGA card not detected.\n");
@@ -564,41 +562,95 @@ static int __init hgafb_init(void)
564 printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n", 562 printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n",
565 hga_type_name, hga_vram_len/1024); 563 hga_type_name, hga_vram_len/1024);
566 564
565 info = framebuffer_alloc(0, NULL);
566 if (!info) {
567 iounmap(hga_vram);
568 return -ENOMEM;
569 }
570
567 hga_fix.smem_start = (unsigned long)hga_vram; 571 hga_fix.smem_start = (unsigned long)hga_vram;
568 hga_fix.smem_len = hga_vram_len; 572 hga_fix.smem_len = hga_vram_len;
569 573
570 fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 574 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
571 fb_info.var = hga_default_var; 575 info->var = hga_default_var;
572 fb_info.fix = hga_fix; 576 info->fix = hga_fix;
573 fb_info.monspecs.hfmin = 0; 577 info->monspecs.hfmin = 0;
574 fb_info.monspecs.hfmax = 0; 578 info->monspecs.hfmax = 0;
575 fb_info.monspecs.vfmin = 10000; 579 info->monspecs.vfmin = 10000;
576 fb_info.monspecs.vfmax = 10000; 580 info->monspecs.vfmax = 10000;
577 fb_info.monspecs.dpms = 0; 581 info->monspecs.dpms = 0;
578 fb_info.fbops = &hgafb_ops; 582 info->fbops = &hgafb_ops;
579 fb_info.screen_base = hga_vram; 583 info->screen_base = hga_vram;
580 584
581 if (register_framebuffer(&fb_info) < 0) { 585 if (register_framebuffer(info) < 0) {
586 framebuffer_release(info);
582 iounmap(hga_vram); 587 iounmap(hga_vram);
583 return -EINVAL; 588 return -EINVAL;
584 } 589 }
585 590
586 printk(KERN_INFO "fb%d: %s frame buffer device\n", 591 printk(KERN_INFO "fb%d: %s frame buffer device\n",
587 fb_info.node, fb_info.fix.id); 592 info->node, info->fix.id);
593 dev_set_drvdata(device, info);
588 return 0; 594 return 0;
589} 595}
590 596
591#ifdef MODULE 597static int hgafb_remove(struct device *device)
592static void __exit hgafb_exit(void)
593{ 598{
599 struct fb_info *info = dev_get_drvdata(device);
600
594 hga_txt_mode(); 601 hga_txt_mode();
595 hga_clear_screen(); 602 hga_clear_screen();
596 unregister_framebuffer(&fb_info); 603
604 if (info) {
605 unregister_framebuffer(info);
606 framebuffer_release(info);
607 }
608
597 iounmap(hga_vram); 609 iounmap(hga_vram);
598 if (release_io_ports) release_region(0x3b0, 12); 610
599 if (release_io_port) release_region(0x3bf, 1); 611 if (release_io_ports)
612 release_region(0x3b0, 12);
613
614 if (release_io_port)
615 release_region(0x3bf, 1);
616
617 return 0;
618}
619
620static struct device_driver hgafb_driver = {
621 .name = "hgafb",
622 .bus = &platform_bus_type,
623 .probe = hgafb_probe,
624 .remove = hgafb_remove,
625};
626
627static struct platform_device hgafb_device = {
628 .name = "hgafb",
629};
630
631static int __init hgafb_init(void)
632{
633 int ret;
634
635 if (fb_get_options("hgafb", NULL))
636 return -ENODEV;
637
638 ret = driver_register(&hgafb_driver);
639
640 if (!ret) {
641 ret = platform_device_register(&hgafb_device);
642 if (ret)
643 driver_unregister(&hgafb_driver);
644 }
645
646 return ret;
647}
648
649static void __exit hgafb_exit(void)
650{
651 platform_device_unregister(&hgafb_device);
652 driver_unregister(&hgafb_driver);
600} 653}
601#endif
602 654
603/* ------------------------------------------------------------------------- 655/* -------------------------------------------------------------------------
604 * 656 *
@@ -613,7 +665,4 @@ MODULE_LICENSE("GPL");
613module_param(nologo, bool, 0); 665module_param(nologo, bool, 0);
614MODULE_PARM_DESC(nologo, "Disables startup logo if != 0 (default=0)"); 666MODULE_PARM_DESC(nologo, "Disables startup logo if != 0 (default=0)");
615module_init(hgafb_init); 667module_init(hgafb_init);
616
617#ifdef MODULE
618module_exit(hgafb_exit); 668module_exit(hgafb_exit);
619#endif