* fbdev driver and sysfs question.
@ 2004-02-11 22:26 James Simmons
2004-02-11 22:52 ` Greg KH
2004-02-11 22:57 ` viro
0 siblings, 2 replies; 4+ messages in thread
From: James Simmons @ 2004-02-11 22:26 UTC (permalink / raw)
To: Linux Kernel Mailing List; +Cc: Linux Fbdev development list
I attempted to port over the vesafb driver to show up in the sysfs tree.
Unfortunely it just hanges my box. From the code can someone tell me what
I'm doing wrong?
--- linus-2.6/drivers/video/vesafb.c 2004-01-27 19:48:12.000000000 -0800
+++ fbdev-2.6/drivers/video/vesafb.c 2004-02-10 19:43:38.000000000 -0800
@@ -19,6 +19,7 @@
#include <linux/fb.h>
#include <linux/ioport.h>
#include <linux/init.h>
+#include <linux/device.h>
#ifdef __i386__
#include <video/edid.h>
#endif
@@ -47,7 +48,6 @@
.accel = FB_ACCEL_NONE,
};
-static struct fb_info fb_info;
static u32 pseudo_palette[17];
static int inverse = 0;
@@ -214,8 +214,10 @@
return 0;
}
-int __init vesafb_init(void)
+static int __init vesafb_probe(struct device *_dev)
{
+ struct platform_device *dev = to_platform_device(_dev);
+ struct fb_info *info;
int video_cmap_len;
int i;
@@ -251,8 +253,13 @@
spaces our resource handlers simply don't know about */
}
- fb_info.screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
- if (!fb_info.screen_base) {
+ info = framebuffer_alloc(0, &dev->dev);
+ if (!info)
+ return -ENOMEM;
+ dev_set_drvdata(&dev->dev, info);
+
+ info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
+ if (!info->screen_base) {
release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len);
printk(KERN_ERR
"vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
@@ -261,7 +268,7 @@
}
printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, size %dk\n",
- vesafb_fix.smem_start, fb_info.screen_base, vesafb_fix.smem_len/1024);
+ vesafb_fix.smem_start, info->screen_base, vesafb_fix.smem_len/1024);
printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
@@ -358,22 +365,45 @@
}
}
- fb_info.fbops = &vesafb_ops;
- fb_info.var = vesafb_defined;
- fb_info.fix = vesafb_fix;
- fb_info.pseudo_palette = pseudo_palette;
- fb_info.flags = FBINFO_FLAG_DEFAULT;
+ info->fbops = &vesafb_ops;
+ info->var = vesafb_defined;
+ info->fix = vesafb_fix;
+ info->pseudo_palette = pseudo_palette;
+ info->flags = FBINFO_FLAG_DEFAULT;
- fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0);
+ fb_alloc_cmap(&info->cmap, video_cmap_len, 0);
- if (register_framebuffer(&fb_info)<0)
+ if (register_framebuffer(info) < 0)
return -EINVAL;
printk(KERN_INFO "fb%d: %s frame buffer device\n",
- fb_info.node, fb_info.fix.id);
+ info->node, info->fix.id);
return 0;
}
+static struct device_driver vesafb_driver = {
+ .name = "VESA framebuffer",
+ .probe = vesafb_probe,
+};
+
+static struct platform_device vesafb_device = {
+ .name = "VESA framebuffer",
+ .id = 0,
+};
+
+int __init vesafb_init(void)
+{
+ int ret;
+
+ ret = driver_register(&vesafb_driver);
+ if (!ret) {
+ ret = platform_device_register(&vesafb_device);
+ if (ret)
+ driver_unregister(&vesafb_driver);
+ }
+ return ret;
+}
+
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* ---------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fbdev driver and sysfs question.
2004-02-11 22:26 fbdev driver and sysfs question James Simmons
@ 2004-02-11 22:52 ` Greg KH
2004-02-11 22:57 ` viro
1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-02-11 22:52 UTC (permalink / raw)
To: James Simmons; +Cc: Linux Kernel Mailing List, Linux Fbdev development list
On Wed, Feb 11, 2004 at 10:26:45PM +0000, James Simmons wrote:
>
> I attempted to port over the vesafb driver to show up in the sysfs tree.
> Unfortunely it just hanges my box. From the code can someone tell me what
> I'm doing wrong?
>
>
> +static struct device_driver vesafb_driver = {
> + .name = "VESA framebuffer",
> + .probe = vesafb_probe,
> +};
> +
> +static struct platform_device vesafb_device = {
> + .name = "VESA framebuffer",
> + .id = 0,
> +};
No release function for this device? Brave...
> +int __init vesafb_init(void)
> +{
> + int ret;
> +
> + ret = driver_register(&vesafb_driver);
Woah, you are registering a driver that is associated with no bus?
Where would this driver show up in the driver model?
What are you trying to achieve here?
> + if (!ret) {
> + ret = platform_device_register(&vesafb_device);
What are you doing with this device? It will work this way, but would
be nicer if you hook it up to something. Can you have more than one
vesafb_device per system?
You also need to consider changing those .name fields to something that
looks sane in the sysfs tree.
thanks,
greg k-h
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fbdev driver and sysfs question.
2004-02-11 22:26 fbdev driver and sysfs question James Simmons
2004-02-11 22:52 ` Greg KH
@ 2004-02-11 22:57 ` viro
2004-02-13 18:44 ` James Simmons
1 sibling, 1 reply; 4+ messages in thread
From: viro @ 2004-02-11 22:57 UTC (permalink / raw)
To: James Simmons; +Cc: Linux Kernel Mailing List, Linux Fbdev development list
On Wed, Feb 11, 2004 at 10:26:45PM +0000, James Simmons wrote:
> + info = framebuffer_alloc(0, &dev->dev);
> + if (!info)
> + return -ENOMEM;
> + dev_set_drvdata(&dev->dev, info);
> +
> + info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
> + if (!info->screen_base) {
> release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len);
> printk(KERN_ERR
> "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
Who will free info?
> - fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0);
> + fb_alloc_cmap(&info->cmap, video_cmap_len, 0);
>
> - if (register_framebuffer(&fb_info)<0)
> + if (register_framebuffer(info) < 0)
Who will undo allocations? BTW, that applies to the old code too -
even if fb_alloc_cmap() doesn't require any actions on cleanup, ioremap()
definitely does.
> return -EINVAL;
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fbdev driver and sysfs question.
2004-02-11 22:57 ` viro
@ 2004-02-13 18:44 ` James Simmons
0 siblings, 0 replies; 4+ messages in thread
From: James Simmons @ 2004-02-13 18:44 UTC (permalink / raw)
To: viro; +Cc: Linux Kernel Mailing List, Linux Fbdev development list
> > + if (!info->screen_base) {
> > release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len);
> > printk(KERN_ERR
> > "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
>
> Who will free info?
...
> Who will undo allocations? BTW, that applies to the old code too -
> even if fb_alloc_cmap() doesn't require any actions on cleanup, ioremap()
> definitely does.
release_fb_info in fbsysfs.c. That happens in the struct class release
function. Also the fb_dealloc_cmap is called. No ioremap is called tho
since this is driver specific. So I have the ioremap and cleanup of it
done in the dev.remove function.
This makes sense since we could have one driver for the hardware with
multiple framebuffers on board. One driver and two devices.
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-13 18:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-11 22:26 fbdev driver and sysfs question James Simmons
2004-02-11 22:52 ` Greg KH
2004-02-11 22:57 ` viro
2004-02-13 18:44 ` James Simmons
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).