From 6817e978cfb63ed11372fa169dc49f0b0b2d7bd1 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Tue, 20 Mar 2001 18:10:19 +0000 Subject: Place the call to pccard_insert_beep() in the inserted() timeout routine instead of pccard_event(). This avoids spurious extra calls to pccard_insert_beep() at insert or remove time which could occur due to noise on the card-present lines. Clean up some code in pccard_beep.c; we were depending on the order of evaluation of function arguments, which is undefined in C. Also, use `0' rather than `NULL' for integer values. Reviewed by: sanpei, imp --- sys/pccard/pccard.c | 2 +- sys/pccard/pccard_beep.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index 62f0f7385394..98a820e4a88b 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -293,6 +293,7 @@ inserted(void *arg) slt->ctrl->power(slt); printf("pccard: card inserted, slot %d\n", slt->slotnum); + pccard_insert_beep(); /* * Now start resetting the card. */ @@ -325,7 +326,6 @@ pccard_event(struct slot *slt, enum card_event event) case card_inserted: slt->insert_seq = 1; slt->insert_ch = timeout(inserted, (void *)slt, hz/4); - pccard_insert_beep(); break; } } diff --git a/sys/pccard/pccard_beep.c b/sys/pccard/pccard_beep.c index 6336be9300cb..ca4b2cb3264f 100644 --- a/sys/pccard/pccard_beep.c +++ b/sys/pccard/pccard_beep.c @@ -26,30 +26,30 @@ struct tone { static struct tone silent_beep[] = { - {NULL, NULL} + {0, 0} }; static struct tone success_beep[] = { - {1200, 40}, {NULL, NULL} + {1200, 40}, {0, 0} }; static struct tone failure_beep[] = { - {3200, 40}, {NULL, NULL} + {3200, 40}, {0, 0} }; static struct tone insert_remove_beep[] = { - {1600, 20}, {NULL, NULL} + {1600, 20}, {0, 0} }; static struct tone success_melody_beep[] = { - {1200, 7}, {1000, 7}, { 800, 15}, {NULL, NULL} + {1200, 7}, {1000, 7}, { 800, 15}, {0, 0} }; static struct tone failure_melody_beep[] = { - {2000, 7}, {2400, 7}, {2800, 15}, {NULL, NULL} + {2000, 7}, {2400, 7}, {2800, 15}, {0, 0} }; static struct tone insert_melody_beep[] = { - {1600, 10}, {1200, 5}, {NULL, NULL} + {1600, 10}, {1200, 5}, {0, 0} }; static struct tone remove_melody_beep[] = { - {1200, 10}, {1600, 5}, {NULL, NULL} + {1200, 10}, {1600, 5}, {0, 0} }; static struct tone *melody_table[MAX_TONE_MODE][MAX_STATE] = { @@ -73,9 +73,9 @@ pccard_beep_sub(void *arg) struct tone *melody; melody = (struct tone *)arg; - if (melody->pitch != NULL) { + if (melody->pitch != 0) { sysbeep(melody->pitch, melody->duration); - timeout(pccard_beep_sub, ++melody, melody->duration); + timeout(pccard_beep_sub, melody + 1, melody->duration); } else allow_beep = BEEP_ON; } @@ -86,10 +86,10 @@ pccard_beep_start(void *arg) struct tone *melody; melody = (struct tone *)arg; - if (allow_beep == BEEP_ON && melody->pitch != NULL) { + if (allow_beep == BEEP_ON && melody->pitch != 0) { allow_beep = BEEP_OFF; sysbeep(melody->pitch, melody->duration); - timeout(pccard_beep_sub, ++melody, melody->duration); + timeout(pccard_beep_sub, melody + 1, melody->duration); } } -- cgit v1.2.3