mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fb: make fb device a pure device
@ 2013-08-06 13:55 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2013-08-06 13:55 UTC (permalink / raw)
  To: barebox

Makes the code simpler and makes the framebuffer layer independent
of initcalls.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/video/fb.c | 98 +++++++++++++++++++-----------------------------------
 1 file changed, 35 insertions(+), 63 deletions(-)

diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index a4a8b00..420e4e3 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);
-- 
1.8.4.rc1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-08-06 13:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-06 13:55 [PATCH] fb: make fb device a pure device Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox