aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2009-10-21 03:12:26 -0400
committerTakashi Iwai <tiwai@suse.de>2009-11-10 10:32:10 -0500
commit91d12c485b8949cce6c13ab641147c5bc86ce8b9 (patch)
tree2f5d3b031e1a3920561f514f5387890f7b4e1419 /sound/core
parent3f225c07c7d0559f65b41250edd01a577fdba426 (diff)
sound: rawmidi: fix opened substreams count
The substream_opened field is to count the number of opened substreams, not the number of times that any substreams have been opened. Furthermore, all substreams being opened does not imply that the next open would fail, due to the possibility of O_APPEND. With this wrong check, opening a substream multiple times would succeed only if the device had more unopened substreams. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/rawmidi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 4e26563431c8..818b1299ed91 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -242,8 +242,6 @@ static int assign_substream(struct snd_rawmidi *rmidi, int subdevice,
242 return -ENXIO; 242 return -ENXIO;
243 if (subdevice >= 0 && subdevice >= s->substream_count) 243 if (subdevice >= 0 && subdevice >= s->substream_count)
244 return -ENODEV; 244 return -ENODEV;
245 if (s->substream_opened >= s->substream_count)
246 return -EAGAIN;
247 245
248 list_for_each_entry(substream, &s->substreams, list) { 246 list_for_each_entry(substream, &s->substreams, list) {
249 if (substream->opened) { 247 if (substream->opened) {
@@ -280,9 +278,9 @@ static int open_substream(struct snd_rawmidi *rmidi,
280 substream->active_sensing = 0; 278 substream->active_sensing = 0;
281 if (mode & SNDRV_RAWMIDI_LFLG_APPEND) 279 if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
282 substream->append = 1; 280 substream->append = 1;
281 rmidi->streams[substream->stream].substream_opened++;
283 } 282 }
284 substream->use_count++; 283 substream->use_count++;
285 rmidi->streams[substream->stream].substream_opened++;
286 return 0; 284 return 0;
287} 285}
288 286
@@ -466,7 +464,6 @@ static void close_substream(struct snd_rawmidi *rmidi,
466 struct snd_rawmidi_substream *substream, 464 struct snd_rawmidi_substream *substream,
467 int cleanup) 465 int cleanup)
468{ 466{
469 rmidi->streams[substream->stream].substream_opened--;
470 if (--substream->use_count) 467 if (--substream->use_count)
471 return; 468 return;
472 469
@@ -491,6 +488,7 @@ static void close_substream(struct snd_rawmidi *rmidi,
491 snd_rawmidi_runtime_free(substream); 488 snd_rawmidi_runtime_free(substream);
492 substream->opened = 0; 489 substream->opened = 0;
493 substream->append = 0; 490 substream->append = 0;
491 rmidi->streams[substream->stream].substream_opened--;
494} 492}
495 493
496static void rawmidi_release_priv(struct snd_rawmidi_file *rfile) 494static void rawmidi_release_priv(struct snd_rawmidi_file *rfile)