summaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-05-26 22:03:03 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-08-07 08:49:30 +0200
commit1fd45e07f2ff5ef6951092a19f3cb2da6c09624c (patch)
tree6c0b870728c630ff51676c3c41f0a54e0691957f /drivers/video
parent72826e747442142a64b865ca6e4a8b3c88acd5d2 (diff)
downloadbarebox-1fd45e07f2ff5ef6951092a19f3cb2da6c09624c.tar.gz
barebox-1fd45e07f2ff5ef6951092a19f3cb2da6c09624c.tar.xz
fb: make fb device a pure device
Makes the code simpler and makes the framebuffer layer independent of initcalls. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fb.c98
1 files changed, 35 insertions, 63 deletions
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index a4a8b00966..420e4e301c 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -1,4 +1,5 @@
#include <common.h>
+#include <malloc.h>
#include <fb.h>
#include <errno.h>
#include <command.h>
@@ -93,10 +94,31 @@ static struct file_operations fb_ops = {
.ioctl = fb_ioctl,
};
+static void fb_info(struct device_d *dev)
+{
+ struct fb_info *info = dev->priv;
+ int i;
+
+ if (!info->num_modes)
+ return;
+
+ printf("available modes:\n");
+
+ for (i = 0; i < info->num_modes; i++) {
+ struct fb_videomode *mode = &info->mode_list[i];
+
+ printf("%-10s %dx%d@%d\n", mode->name,
+ mode->xres, mode->yres, mode->refresh);
+ }
+
+ printf("\n");
+}
+
int register_framebuffer(struct fb_info *info)
{
int id = get_free_deviceid("fb");
struct device_d *dev;
+ int ret;
dev = &info->dev;
@@ -113,47 +135,13 @@ int register_framebuffer(struct fb_info *info)
dev->priv = info;
dev->id = id;
+ dev->info = fb_info;
sprintf(dev->name, "fb");
- info->dev.bus = &fb_bus;
- register_device(&info->dev);
-
- return 0;
-}
-
-static void fb_info(struct device_d *dev)
-{
- struct fb_info *info = dev->priv;
- int i;
-
- if (!info->num_modes)
- return;
-
- printf("available modes:\n");
-
- for (i = 0; i < info->num_modes; i++) {
- struct fb_videomode *mode = &info->mode_list[i];
-
- printf("%-10s %dx%d@%d\n", mode->name,
- mode->xres, mode->yres, mode->refresh);
- }
-
- printf("\n");
-}
-
-static struct driver_d fb_driver = {
- .name = "fb",
-};
-
-static int fb_match(struct device_d *dev, struct driver_d *drv)
-{
- return 0;
-}
-
-static int fb_probe(struct device_d *dev)
-{
- struct fb_info *info = dev->priv;
+ ret = register_device(&info->dev);
+ if (ret)
+ goto err_free;
dev_add_param_bool(dev, "enable", fb_enable_set, NULL,
&info->p_enable, info);
@@ -164,32 +152,16 @@ static int fb_probe(struct device_d *dev)
dev_set_param(dev, "mode_name", info->mode_list[0].name);
}
- dev->info = fb_info;
-
- return devfs_create(&info->cdev);
-}
-
-static void fb_remove(struct device_d *dev)
-{
-}
+ ret = devfs_create(&info->cdev);
+ if (ret)
+ goto err_unregister;
-struct bus_type fb_bus = {
- .name = "fb",
- .match = fb_match,
- .probe = fb_probe,
- .remove = fb_remove,
-};
+ return 0;
-static int fb_bus_init(void)
-{
- return bus_register(&fb_bus);
-}
-pure_initcall(fb_bus_init);
+err_unregister:
+ unregister_device(&info->dev);
+err_free:
+ free(dev->resource);
-static int fb_init_driver(void)
-{
- fb_driver.bus = &fb_bus;
- register_driver(&fb_driver);
- return 0;
+ return ret;
}
-device_initcall(fb_init_driver);