From e1e2bc96d2c2a83a431fe9478de7613158865cc7 Mon Sep 17 00:00:00 2001 From: rlfnb Date: Wed, 3 Jun 2015 07:56:35 +0200 Subject: [PATCH] handle lack of pckbd more gracefully kb_init() panics, if no keyboard controller is found during self-test. Instead of panic, the driver should quit the init process and tell it the SEF . Change-Id: Icdfb7125f5d4062f46cfbbdbbb9e54ac4b273642 --- minix/drivers/hid/pckbd/pckbd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/minix/drivers/hid/pckbd/pckbd.c b/minix/drivers/hid/pckbd/pckbd.c index b6a41f2b4..236cef088 100644 --- a/minix/drivers/hid/pckbd/pckbd.c +++ b/minix/drivers/hid/pckbd/pckbd.c @@ -250,7 +250,7 @@ kbc_read(void) /* * Initialize the keyboard hardware. */ -static void +static int kb_init(void) { int r, ccb; @@ -272,8 +272,10 @@ kb_init(void) /* Execute Controller Self Test. */ kbc_cmd0(0xAA); r = kbc_read(); - if (r != 0x55) - panic("PCKBD: Controller self-test failed.\n"); + if (r != 0x55){ + printf("PCKBD: Controller self-test failed.\n"); + return EGENERIC; + } /* Set interrupt handler and enable keyboard IRQ. */ irq_hook_id = KEYBOARD_IRQ; /* id to be returned on interrupt */ @@ -316,6 +318,7 @@ kb_init(void) kb_wait(); set_leds(0); + return OK; } /* @@ -466,7 +469,10 @@ pckbd_init(int UNUSED(type), sef_init_info_t *UNUSED(info)) init_timer(&tmr_kbd_wd); /* Initialize the keyboard. */ - kb_init(); + int r; + if((r = kb_init())!=OK){ + return r; + } /* Announce the driver's presence. */ if (aux_available != 0)