[PATCH 2/2] kdrive: Simplify logic in fbdev.c
Mikhail Gusarov
dottedmag at dottedmag.net
Mon Mar 15 15:48:31 PDT 2010
Kdrive fbdev initialization checked for ioctl FBGET_VSCREENINFO error. According
to kernel source code there are two possible errors, namely ENODEV "there is no
framebuffer" and EINVAL "you have passed wrong pointer". Both are fatal, so
just fail early and simplify logic down the road.
Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
---
hw/kdrive/fbdev/fbdev.c | 33 ++++++++++++++-------------------
1 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index d4604ad..7e9783d 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -158,31 +158,26 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
const KdMonitorTiming *t;
int k;
+ /*
+ * There are two possible errors: EFAULT (wrong arg passed) and ENODEV
+ * (framebuffer device is not present). Just fail if errored out.
+ */
k = ioctl (priv->fd, FBIOGET_VSCREENINFO, &var);
+ if (k < 0) {
+ perror("FBIOGET_VSCREENINFO");
+ return FALSE;
+ }
+
+ if (!screen->fb.depth)
+ screen->fb.depth = var.bits_per_pixel;
if (!screen->width || !screen->height)
{
- if (k >= 0)
- {
- screen->width = var.xres;
- screen->height = var.yres;
- }
- else
- {
- screen->width = 1024;
- screen->height = 768;
- }
+ screen->width = var.xres;
+ screen->height = var.yres;
screen->rate = 103; /* FIXME: should get proper value from fb driver */
}
- if (!screen->fb.depth)
- {
- if (k >= 0)
- screen->fb.depth = var.bits_per_pixel;
- else
- screen->fb.depth = 16;
- }
-
- if ((screen->width != var.xres) || (screen->height != var.yres))
+ else if ((screen->width != var.xres) || (screen->height != var.yres))
{
t = KdFindMode (screen, fbdevModeSupported);
screen->rate = t->rate;
--
1.6.3.3
More information about the xorg-devel
mailing list