drv_video_init(): simplify logic
Simplify nesting of drv_video_init() and use a consistent way of indicating failure / success. Before, it took me some time to realize which of the returns was due to an error condition and which of them indicated success. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Anatolij Gustschin <agust@denx.de>
This commit is contained in:
parent
1699da6297
commit
f62f64692f
|
@ -1335,48 +1335,37 @@ int drv_video_init (void)
|
||||||
int skip_dev_init;
|
int skip_dev_init;
|
||||||
device_t console_dev;
|
device_t console_dev;
|
||||||
|
|
||||||
skip_dev_init = 0;
|
|
||||||
|
|
||||||
/* Init video chip - returns with framebuffer cleared */
|
/* Init video chip - returns with framebuffer cleared */
|
||||||
if (video_init () == -1)
|
skip_dev_init = (video_init () == -1);
|
||||||
skip_dev_init = 1;
|
|
||||||
|
|
||||||
#ifdef CONFIG_VGA_AS_SINGLE_DEVICE
|
#if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
|
||||||
/* Devices VGA and Keyboard will be assigned seperately */
|
|
||||||
/* Init vga device */
|
|
||||||
if (!skip_dev_init) {
|
|
||||||
memset (&console_dev, 0, sizeof (console_dev));
|
|
||||||
strcpy (console_dev.name, "vga");
|
|
||||||
console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
|
|
||||||
console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
|
|
||||||
console_dev.putc = video_putc; /* 'putc' function */
|
|
||||||
console_dev.puts = video_puts; /* 'puts' function */
|
|
||||||
console_dev.tstc = NULL; /* 'tstc' function */
|
|
||||||
console_dev.getc = NULL; /* 'getc' function */
|
|
||||||
|
|
||||||
if (device_register (&console_dev) == 0)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
PRINTD ("KBD: Keyboard init ...\n");
|
PRINTD ("KBD: Keyboard init ...\n");
|
||||||
if (VIDEO_KBD_INIT_FCT == -1)
|
skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
|
||||||
skip_dev_init = 1;
|
#endif
|
||||||
|
|
||||||
/* Init console device */
|
if (skip_dev_init)
|
||||||
if (!skip_dev_init) {
|
return 0;
|
||||||
memset (&console_dev, 0, sizeof (console_dev));
|
|
||||||
strcpy (console_dev.name, "vga");
|
|
||||||
console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
|
|
||||||
console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
|
|
||||||
console_dev.putc = video_putc; /* 'putc' function */
|
|
||||||
console_dev.puts = video_puts; /* 'puts' function */
|
|
||||||
console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
|
|
||||||
console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
|
|
||||||
|
|
||||||
if (device_register (&console_dev) == 0)
|
/* Init vga device */
|
||||||
return 1;
|
memset (&console_dev, 0, sizeof (console_dev));
|
||||||
}
|
strcpy (console_dev.name, "vga");
|
||||||
|
console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
|
||||||
|
console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
|
||||||
|
console_dev.putc = video_putc; /* 'putc' function */
|
||||||
|
console_dev.puts = video_puts; /* 'puts' function */
|
||||||
|
console_dev.tstc = NULL; /* 'tstc' function */
|
||||||
|
console_dev.getc = NULL; /* 'getc' function */
|
||||||
|
|
||||||
|
#if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
|
||||||
|
/* Also init console device */
|
||||||
|
console_dev.flags |= DEV_FLAGS_INPUT;
|
||||||
|
console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
|
||||||
|
console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
|
||||||
#endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
|
#endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
|
||||||
/* No console dev available */
|
|
||||||
return 0;
|
if (device_register (&console_dev) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue