From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] fb: make fb device a pure device
Date: Tue, 6 Aug 2013 15:55:05 +0200 [thread overview]
Message-ID: <1375797305-5176-1-git-send-email-s.hauer@pengutronix.de> (raw)
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
reply other threads:[~2013-08-06 13:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1375797305-5176-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox