mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
ALSA: hdsp: Break infinite MIDI input flush loop
[ Upstream commit c01f3815453e2d5f699ccd8c8c1f93a5b8669e59 ] The current MIDI input flush on HDSP and HDSPM drivers relies on the hardware reporting the right value. If the hardware doesn't give the proper value but returns -1, it may be stuck at an infinite loop. Add a counter and break if the loop is unexpectedly too long. Link: https://patch.msgid.link/20240808091513.31380-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
7a55740996
commit
6cc4e5eaad
2 changed files with 8 additions and 4 deletions
|
@ -1298,7 +1298,9 @@ static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id)
|
||||||
|
|
||||||
static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id)
|
static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id)
|
||||||
{
|
{
|
||||||
while (snd_hdsp_midi_input_available (hdsp, id))
|
int count = 256;
|
||||||
|
|
||||||
|
while (snd_hdsp_midi_input_available(hdsp, id) && --count)
|
||||||
snd_hdsp_midi_read_byte(hdsp, id);
|
snd_hdsp_midi_read_byte(hdsp, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1838,7 +1838,9 @@ static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id)
|
||||||
|
|
||||||
static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id)
|
static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id)
|
||||||
{
|
{
|
||||||
while (snd_hdspm_midi_input_available (hdspm, id))
|
int count = 256;
|
||||||
|
|
||||||
|
while (snd_hdspm_midi_input_available(hdspm, id) && --count)
|
||||||
snd_hdspm_midi_read_byte(hdspm, id);
|
snd_hdspm_midi_read_byte(hdspm, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue