From: David Herrmann <dh.herrmann@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
linux-fbdev@vger.kernel.org, David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org,
David Herrmann <dh.herrmann@googlemail.com>
Subject: [PATCH 4/9] video: vesafb: allow building as module
Date: Sun, 17 Feb 2013 17:59:06 +0000 [thread overview]
Message-ID: <1361123951-587-5-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1361123951-587-1-git-send-email-dh.herrmann@gmail.com>
From: David Herrmann <dh.herrmann@googlemail.com>
Fix the vesafb module to no longer use any static __init data. Also add a
module_exit() function that destroys the platform device.
Note that fbdev hotplugging is broken and the self-reference actually
prevents sane module-unloading. Anyway, this at least allows delayed
module loading of vesafb and helps debugging vesafb a lot.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
drivers/video/Kconfig | 2 +-
drivers/video/vesafb.c | 100 +++++++++++++++++++++++++++++++------------------
2 files changed, 64 insertions(+), 38 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index eac56ef..d5723c2 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -770,7 +770,7 @@ config FB_UVESA
If unsure, say N.
config FB_VESA
- bool "VESA VGA graphics support"
+ tristate "VESA VGA graphics support"
depends on (FB = y) && X86
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 501b340..4ad7b40 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -29,27 +29,10 @@
/* --------------------------------------------------------------------- */
-static struct fb_var_screeninfo vesafb_defined __initdata = {
- .activate = FB_ACTIVATE_NOW,
- .height = -1,
- .width = -1,
- .right_margin = 32,
- .upper_margin = 16,
- .lower_margin = 4,
- .vsync_len = 4,
- .vmode = FB_VMODE_NONINTERLACED,
-};
-
-static struct fb_fix_screeninfo vesafb_fix __initdata = {
- .id = "VESA VGA",
- .type = FB_TYPE_PACKED_PIXELS,
- .accel = FB_ACCEL_NONE,
-};
-
static int inverse __read_mostly;
static int mtrr __read_mostly; /* disable mtrr */
-static int vram_remap __initdata; /* Set amount of memory to be used */
-static int vram_total __initdata; /* Set total amount of memory */
+static int vram_remap; /* Set amount of memory to be used */
+static int vram_total; /* Set total amount of memory */
static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
static void (*pmi_start)(void) __read_mostly;
@@ -58,6 +41,11 @@ static int depth __read_mostly;
static int vga_compat __read_mostly;
/* --------------------------------------------------------------------- */
+struct vesafb_par {
+ struct fb_ops ops;
+ u32 palette[256];
+};
+
static int vesafb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info)
{
@@ -182,7 +170,7 @@ static void vesafb_destroy(struct fb_info *info)
framebuffer_release(info);
}
-static struct fb_ops vesafb_ops = {
+static const struct fb_ops vesafb_ops = {
.owner = THIS_MODULE,
.fb_destroy = vesafb_destroy,
.fb_setcolreg = vesafb_setcolreg,
@@ -192,7 +180,7 @@ static struct fb_ops vesafb_ops = {
.fb_imageblit = cfb_imageblit,
};
-static int __init vesafb_setup(char *options)
+static int vesafb_setup(char *options)
{
char *this_opt;
@@ -226,13 +214,29 @@ static int __init vesafb_setup(char *options)
return 0;
}
-static int __init vesafb_probe(struct platform_device *dev)
+static int vesafb_probe(struct platform_device *dev)
{
struct fb_info *info;
+ struct vesafb_par *par;
int i, err;
unsigned int size_vmode;
unsigned int size_remap;
unsigned int size_total;
+ struct fb_var_screeninfo vesafb_defined = {
+ .activate = FB_ACTIVATE_NOW,
+ .height = -1,
+ .width = -1,
+ .right_margin = 32,
+ .upper_margin = 16,
+ .lower_margin = 4,
+ .vsync_len = 4,
+ .vmode = FB_VMODE_NONINTERLACED,
+ };
+ struct fb_fix_screeninfo vesafb_fix = {
+ .id = "VESA VGA",
+ .type = FB_TYPE_PACKED_PIXELS,
+ .accel = FB_ACCEL_NONE,
+ };
if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
return -ENODEV;
@@ -287,13 +291,14 @@ static int __init vesafb_probe(struct platform_device *dev)
spaces our resource handlers simply don't know about */
}
- info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
+ info = framebuffer_alloc(sizeof(struct vesafb_par), &dev->dev);
if (!info) {
release_mem_region(vesafb_fix.smem_start, size_total);
return -ENOMEM;
}
- info->pseudo_palette = info->par;
- info->par = NULL;
+ par = info->par;
+ par->ops = vesafb_ops;
+ info->pseudo_palette = par->palette;
/* set vesafb aperture size for generic probing */
info->apertures = alloc_apertures(1);
@@ -466,7 +471,7 @@ static int __init vesafb_probe(struct platform_device *dev)
vesafb_fix.smem_start, info->screen_base,
size_remap/1024, size_total/1024);
- info->fbops = &vesafb_ops;
+ info->fbops = &par->ops;
info->var = vesafb_defined;
info->fix = vesafb_fix;
info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
@@ -486,6 +491,7 @@ static int __init vesafb_probe(struct platform_device *dev)
}
printk(KERN_INFO "fb%d: %s frame buffer device\n",
info->node, info->fix.id);
+ platform_set_drvdata(dev, info);
return 0;
err:
if (info->screen_base)
@@ -495,7 +501,17 @@ err:
return err;
}
+static int vesafb_remove(struct platform_device *dev)
+{
+ struct fb_info *info = platform_get_drvdata(dev);
+
+ unregister_framebuffer(info);
+ return 0;
+}
+
static struct platform_driver vesafb_driver = {
+ .probe = vesafb_probe,
+ .remove = vesafb_remove,
.driver = {
.name = "vesafb",
},
@@ -512,24 +528,34 @@ static int __init vesafb_init(void)
fb_get_options("vesafb", &option);
vesafb_setup(option);
- vesafb_device = platform_device_alloc("vesafb", 0);
+ vesafb_device = platform_device_alloc("vesafb", -1);
if (!vesafb_device)
return -ENOMEM;
+ ret = platform_driver_register(&vesafb_driver);
+ if (ret)
+ goto err_dev;
+
ret = platform_device_add(vesafb_device);
- if (!ret) {
- ret = platform_driver_probe(&vesafb_driver, vesafb_probe);
- if (ret)
- platform_device_del(vesafb_device);
- }
+ if (ret)
+ goto err_drv;
- if (ret) {
- platform_device_put(vesafb_device);
- vesafb_device = NULL;
- }
+ return 0;
+err_drv:
+ platform_driver_unregister(&vesafb_driver);
+err_dev:
+ platform_device_put(vesafb_device);
return ret;
}
-module_init(vesafb_init);
+static void __exit vesafb_exit(void)
+{
+ platform_device_del(vesafb_device);
+ platform_device_put(vesafb_device);
+ platform_driver_unregister(&vesafb_driver);
+}
+
+module_init(vesafb_init);
+module_exit(vesafb_exit);
MODULE_LICENSE("GPL");
--
1.8.1.3
WARNING: multiple messages have this Message-ID (diff)
From: David Herrmann <dh.herrmann@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
linux-fbdev@vger.kernel.org, David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org,
David Herrmann <dh.herrmann@googlemail.com>
Subject: [PATCH 4/9] video: vesafb: allow building as module
Date: Sun, 17 Feb 2013 18:59:06 +0100 [thread overview]
Message-ID: <1361123951-587-5-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1361123951-587-1-git-send-email-dh.herrmann@gmail.com>
From: David Herrmann <dh.herrmann@googlemail.com>
Fix the vesafb module to no longer use any static __init data. Also add a
module_exit() function that destroys the platform device.
Note that fbdev hotplugging is broken and the self-reference actually
prevents sane module-unloading. Anyway, this at least allows delayed
module loading of vesafb and helps debugging vesafb a lot.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
drivers/video/Kconfig | 2 +-
drivers/video/vesafb.c | 100 +++++++++++++++++++++++++++++++------------------
2 files changed, 64 insertions(+), 38 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index eac56ef..d5723c2 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -770,7 +770,7 @@ config FB_UVESA
If unsure, say N.
config FB_VESA
- bool "VESA VGA graphics support"
+ tristate "VESA VGA graphics support"
depends on (FB = y) && X86
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 501b340..4ad7b40 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -29,27 +29,10 @@
/* --------------------------------------------------------------------- */
-static struct fb_var_screeninfo vesafb_defined __initdata = {
- .activate = FB_ACTIVATE_NOW,
- .height = -1,
- .width = -1,
- .right_margin = 32,
- .upper_margin = 16,
- .lower_margin = 4,
- .vsync_len = 4,
- .vmode = FB_VMODE_NONINTERLACED,
-};
-
-static struct fb_fix_screeninfo vesafb_fix __initdata = {
- .id = "VESA VGA",
- .type = FB_TYPE_PACKED_PIXELS,
- .accel = FB_ACCEL_NONE,
-};
-
static int inverse __read_mostly;
static int mtrr __read_mostly; /* disable mtrr */
-static int vram_remap __initdata; /* Set amount of memory to be used */
-static int vram_total __initdata; /* Set total amount of memory */
+static int vram_remap; /* Set amount of memory to be used */
+static int vram_total; /* Set total amount of memory */
static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
static void (*pmi_start)(void) __read_mostly;
@@ -58,6 +41,11 @@ static int depth __read_mostly;
static int vga_compat __read_mostly;
/* --------------------------------------------------------------------- */
+struct vesafb_par {
+ struct fb_ops ops;
+ u32 palette[256];
+};
+
static int vesafb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info)
{
@@ -182,7 +170,7 @@ static void vesafb_destroy(struct fb_info *info)
framebuffer_release(info);
}
-static struct fb_ops vesafb_ops = {
+static const struct fb_ops vesafb_ops = {
.owner = THIS_MODULE,
.fb_destroy = vesafb_destroy,
.fb_setcolreg = vesafb_setcolreg,
@@ -192,7 +180,7 @@ static struct fb_ops vesafb_ops = {
.fb_imageblit = cfb_imageblit,
};
-static int __init vesafb_setup(char *options)
+static int vesafb_setup(char *options)
{
char *this_opt;
@@ -226,13 +214,29 @@ static int __init vesafb_setup(char *options)
return 0;
}
-static int __init vesafb_probe(struct platform_device *dev)
+static int vesafb_probe(struct platform_device *dev)
{
struct fb_info *info;
+ struct vesafb_par *par;
int i, err;
unsigned int size_vmode;
unsigned int size_remap;
unsigned int size_total;
+ struct fb_var_screeninfo vesafb_defined = {
+ .activate = FB_ACTIVATE_NOW,
+ .height = -1,
+ .width = -1,
+ .right_margin = 32,
+ .upper_margin = 16,
+ .lower_margin = 4,
+ .vsync_len = 4,
+ .vmode = FB_VMODE_NONINTERLACED,
+ };
+ struct fb_fix_screeninfo vesafb_fix = {
+ .id = "VESA VGA",
+ .type = FB_TYPE_PACKED_PIXELS,
+ .accel = FB_ACCEL_NONE,
+ };
if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
return -ENODEV;
@@ -287,13 +291,14 @@ static int __init vesafb_probe(struct platform_device *dev)
spaces our resource handlers simply don't know about */
}
- info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
+ info = framebuffer_alloc(sizeof(struct vesafb_par), &dev->dev);
if (!info) {
release_mem_region(vesafb_fix.smem_start, size_total);
return -ENOMEM;
}
- info->pseudo_palette = info->par;
- info->par = NULL;
+ par = info->par;
+ par->ops = vesafb_ops;
+ info->pseudo_palette = par->palette;
/* set vesafb aperture size for generic probing */
info->apertures = alloc_apertures(1);
@@ -466,7 +471,7 @@ static int __init vesafb_probe(struct platform_device *dev)
vesafb_fix.smem_start, info->screen_base,
size_remap/1024, size_total/1024);
- info->fbops = &vesafb_ops;
+ info->fbops = &par->ops;
info->var = vesafb_defined;
info->fix = vesafb_fix;
info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
@@ -486,6 +491,7 @@ static int __init vesafb_probe(struct platform_device *dev)
}
printk(KERN_INFO "fb%d: %s frame buffer device\n",
info->node, info->fix.id);
+ platform_set_drvdata(dev, info);
return 0;
err:
if (info->screen_base)
@@ -495,7 +501,17 @@ err:
return err;
}
+static int vesafb_remove(struct platform_device *dev)
+{
+ struct fb_info *info = platform_get_drvdata(dev);
+
+ unregister_framebuffer(info);
+ return 0;
+}
+
static struct platform_driver vesafb_driver = {
+ .probe = vesafb_probe,
+ .remove = vesafb_remove,
.driver = {
.name = "vesafb",
},
@@ -512,24 +528,34 @@ static int __init vesafb_init(void)
fb_get_options("vesafb", &option);
vesafb_setup(option);
- vesafb_device = platform_device_alloc("vesafb", 0);
+ vesafb_device = platform_device_alloc("vesafb", -1);
if (!vesafb_device)
return -ENOMEM;
+ ret = platform_driver_register(&vesafb_driver);
+ if (ret)
+ goto err_dev;
+
ret = platform_device_add(vesafb_device);
- if (!ret) {
- ret = platform_driver_probe(&vesafb_driver, vesafb_probe);
- if (ret)
- platform_device_del(vesafb_device);
- }
+ if (ret)
+ goto err_drv;
- if (ret) {
- platform_device_put(vesafb_device);
- vesafb_device = NULL;
- }
+ return 0;
+err_drv:
+ platform_driver_unregister(&vesafb_driver);
+err_dev:
+ platform_device_put(vesafb_device);
return ret;
}
-module_init(vesafb_init);
+static void __exit vesafb_exit(void)
+{
+ platform_device_del(vesafb_device);
+ platform_device_put(vesafb_device);
+ platform_driver_unregister(&vesafb_driver);
+}
+
+module_init(vesafb_init);
+module_exit(vesafb_exit);
MODULE_LICENSE("GPL");
--
1.8.1.3
next prev parent reply other threads:[~2013-02-17 17:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-17 17:59 [PATCH 0/9] System Framebuffer Bus (sysfb) David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 1/9] video: introduce system framebuffer bus David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 2/9] video: sysfb: new vbefb device type David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 3/9] video: sysfb: always provide vbefb device David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` David Herrmann [this message]
2013-02-17 17:59 ` [PATCH 4/9] video: vesafb: allow building as module David Herrmann
2013-02-17 17:59 ` [PATCH 5/9] video: vesafb: use sysfb bus David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 6/9] drm: new sysfb DRM bus module David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 7/9] drm: new VESA BIOS Extension DRM driver stub David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 8/9] drm: dvbe: implement VBE/VESA blitting backend David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 17:59 ` [PATCH 9/9] drm: dvbe: add optional fbdev frontend David Herrmann
2013-02-17 17:59 ` David Herrmann
2013-02-17 22:02 ` [PATCH 0/9] System Framebuffer Bus (sysfb) Dave Airlie
2013-02-17 22:02 ` Dave Airlie
2013-02-17 22:02 ` Dave Airlie
2013-02-17 23:35 ` David Herrmann
2013-02-17 23:35 ` David Herrmann
2013-02-17 23:35 ` David Herrmann
2013-02-17 23:47 ` Dave Airlie
2013-02-17 23:47 ` Dave Airlie
2013-02-28 12:20 ` David Herrmann
2013-02-28 12:20 ` David Herrmann
2013-02-28 13:22 ` Geert Uytterhoeven
2013-02-28 13:22 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361123951-587-5-git-send-email-dh.herrmann@gmail.com \
--to=dh.herrmann@gmail.com \
--cc=FlorianSchandinat@gmx.de \
--cc=airlied@linux.ie \
--cc=dh.herrmann@googlemail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.