some code cleanups

This commit is contained in:
Stefan Lankes 2012-08-01 20:50:33 +02:00
parent 5dd40e8978
commit 80e01f8b9f
1 changed files with 13 additions and 13 deletions

View File

@ -36,12 +36,12 @@
#ifdef CONFIG_VGA
static uint32_t early_print = VGA_EARLY_PRINT;
static spinlock_irqsave_t vga_lock = SPINLOCK_IRQSAVE_INIT;
#elif defined(CONFIG_UART)
static uint32_t early_print = UART_EARLY_PRINT;
#else
static uint32_t early_print = NO_EARLY_PRINT;
#endif
static spinlock_irqsave_t olock = SPINLOCK_IRQSAVE_INIT;
static atomic_int32_t kmsg_counter = ATOMIC_INIT(0);
static unsigned char kmessages[KMSG_SIZE] __attribute__ ((section(".kmsg"))) = {[0 ... KMSG_SIZE-1] = 0x00};
@ -154,20 +154,24 @@ int kputchar(int c)
{
int pos;
if (early_print != NO_EARLY_PRINT)
spinlock_irqsave_lock(&olock);
pos = atomic_int32_inc(&kmsg_counter);
kmessages[pos % KMSG_SIZE] = (unsigned char) c;
#ifdef CONFIG_VGA
if (early_print == VGA_EARLY_PRINT) {
spinlock_irqsave_lock(&vga_lock);
if (early_print == VGA_EARLY_PRINT)
vga_putchar(c);
spinlock_irqsave_unlock(&vga_lock);
}
#endif
#ifdef CONFIG_UART
if (early_print == UART_EARLY_PRINT)
uart_putchar(c);
#endif
if (early_print != NO_EARLY_PRINT)
spinlock_irqsave_unlock(&olock);
return 1;
}
@ -175,10 +179,8 @@ int kputs(const char *str)
{
int pos, i;
#ifdef CONFIG_VGA
if (early_print == VGA_EARLY_PRINT)
spinlock_irqsave_lock(&vga_lock);
#endif
if (early_print != NO_EARLY_PRINT)
spinlock_irqsave_lock(&olock);
for(i=0; str[i] != '\0'; i++) {
pos = atomic_int32_inc(&kmsg_counter);
@ -193,10 +195,8 @@ int kputs(const char *str)
#endif
}
#ifdef CONFIG_VGA
if (early_print == VGA_EARLY_PRINT)
spinlock_irqsave_unlock(&vga_lock);
#endif
if (early_print != NO_EARLY_PRINT)
spinlock_irqsave_unlock(&olock);
return i;
}