if (new_ledstate != ledstate) { ledstate = LEDSTATE_UPDATE_PENDING;  if (kbd_cmd(KEYB_C_LEDS) != 0) { printf("pcvt: kbd led cmd timeout\n");
if (kbd_cmd(KEYB_C_LEDS) != 0) { printf("pcvt: kbd led cmd timeout\n"); goto bail; } ledstate = LEDSTATE_UPDATE_PENDING; if (cause == KEYB_R_RESEND) printf("pcvt: kbd led cmd resend\n");
update_led(void){#if !PCVT_NO_LED_UPDATE	/* Don't update LED's unless necessary. */	int opri, new_ledstate, response1, response2;	opri = spltty();	new_ledstate = ((vsp->scroll_lock) | (vsp->num_lock * 2) |			(vsp->caps_lock * 4));	if (new_ledstate != ledstate) {		ledstate = LEDSTATE_UPDATE_PENDING;		if (kbd_cmd(KEYB_C_LEDS) != 0) {			printf("pcvt: kbd led cmd timeout\n");			goto bail;		}		/*		 * For some keyboards or keyboard controllers, it is an		 * error to issue a command without waiting long enough		 * for an ACK for the previous command.  The keyboard		 * gets confused, and responds with KEYB_R_RESEND, but		 * we ignore that.  Wait for the ACK here.  The busy		 * waiting doesn't matter much, since we lose anyway by		 * busy waiting to send the command.		 *		 * XXX actually wait for any response, since we can't		 * handle normal scancodes here.		 *		 * XXX all this should be interrupt driven.  Issue only		 * one command at a time wait for a ACK before proceeding.		 * Retry after a timeout or on receipt of a KEYB_R_RESEND.		 * KEYB_R_RESENDs seem to be guaranteed by working		 * keyboard controllers with broken (or disconnected)		 * keyboards.  There is another code for keyboard		 * reconnects.  The keyboard hardware is very simple and		 * well designed :-).		 */		response1 = kbd_response();		if (kbd_cmd(new_ledstate) != 0) {			printf("pcvt: kbd led data timeout\n");			goto bail;		}		response2 = kbd_response();		if (response1 == KEYB_R_ACK && response2 == KEYB_R_ACK)			ledstate = new_ledstate;		else {			printf("pcvt: kbd led cmd not ack'd (resp %#x %#x)\n",			    response1, response2);		}#if PCVT_UPDLED_LOSES_INTR		timeout_add(&kbd_led_intr_to, hz);#endif /* PCVT_UPDLED_LOSES_INTR */	}bail:	splx(opri);#endif /* !PCVT_NO_LED_UPDATE */}