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
This commit is contained in:
parent
020ee2dc9f
commit
6817e978cf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74530
@ -293,6 +293,7 @@ inserted(void *arg)
|
|||||||
slt->ctrl->power(slt);
|
slt->ctrl->power(slt);
|
||||||
|
|
||||||
printf("pccard: card inserted, slot %d\n", slt->slotnum);
|
printf("pccard: card inserted, slot %d\n", slt->slotnum);
|
||||||
|
pccard_insert_beep();
|
||||||
/*
|
/*
|
||||||
* Now start resetting the card.
|
* Now start resetting the card.
|
||||||
*/
|
*/
|
||||||
@ -325,7 +326,6 @@ pccard_event(struct slot *slt, enum card_event event)
|
|||||||
case card_inserted:
|
case card_inserted:
|
||||||
slt->insert_seq = 1;
|
slt->insert_seq = 1;
|
||||||
slt->insert_ch = timeout(inserted, (void *)slt, hz/4);
|
slt->insert_ch = timeout(inserted, (void *)slt, hz/4);
|
||||||
pccard_insert_beep();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,30 +26,30 @@ struct tone {
|
|||||||
|
|
||||||
|
|
||||||
static struct tone silent_beep[] = {
|
static struct tone silent_beep[] = {
|
||||||
{NULL, NULL}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tone success_beep[] = {
|
static struct tone success_beep[] = {
|
||||||
{1200, 40}, {NULL, NULL}
|
{1200, 40}, {0, 0}
|
||||||
};
|
};
|
||||||
static struct tone failure_beep[] = {
|
static struct tone failure_beep[] = {
|
||||||
{3200, 40}, {NULL, NULL}
|
{3200, 40}, {0, 0}
|
||||||
};
|
};
|
||||||
static struct tone insert_remove_beep[] = {
|
static struct tone insert_remove_beep[] = {
|
||||||
{1600, 20}, {NULL, NULL}
|
{1600, 20}, {0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tone success_melody_beep[] = {
|
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[] = {
|
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[] = {
|
static struct tone insert_melody_beep[] = {
|
||||||
{1600, 10}, {1200, 5}, {NULL, NULL}
|
{1600, 10}, {1200, 5}, {0, 0}
|
||||||
};
|
};
|
||||||
static struct tone remove_melody_beep[] = {
|
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] = {
|
static struct tone *melody_table[MAX_TONE_MODE][MAX_STATE] = {
|
||||||
@ -73,9 +73,9 @@ pccard_beep_sub(void *arg)
|
|||||||
struct tone *melody;
|
struct tone *melody;
|
||||||
melody = (struct tone *)arg;
|
melody = (struct tone *)arg;
|
||||||
|
|
||||||
if (melody->pitch != NULL) {
|
if (melody->pitch != 0) {
|
||||||
sysbeep(melody->pitch, melody->duration);
|
sysbeep(melody->pitch, melody->duration);
|
||||||
timeout(pccard_beep_sub, ++melody, melody->duration);
|
timeout(pccard_beep_sub, melody + 1, melody->duration);
|
||||||
} else
|
} else
|
||||||
allow_beep = BEEP_ON;
|
allow_beep = BEEP_ON;
|
||||||
}
|
}
|
||||||
@ -86,10 +86,10 @@ pccard_beep_start(void *arg)
|
|||||||
struct tone *melody;
|
struct tone *melody;
|
||||||
melody = (struct tone *)arg;
|
melody = (struct tone *)arg;
|
||||||
|
|
||||||
if (allow_beep == BEEP_ON && melody->pitch != NULL) {
|
if (allow_beep == BEEP_ON && melody->pitch != 0) {
|
||||||
allow_beep = BEEP_OFF;
|
allow_beep = BEEP_OFF;
|
||||||
sysbeep(melody->pitch, melody->duration);
|
sysbeep(melody->pitch, melody->duration);
|
||||||
timeout(pccard_beep_sub, ++melody, melody->duration);
|
timeout(pccard_beep_sub, melody + 1, melody->duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user