- return -EIO;
-
- /* copy queued events to read buffer */
- cnt = count;
- pos = 0;
- q = snd_seq_oss_readq_pick(readq, !is_nonblock_mode(dp->file_mode), &flags);
- if (q == NULL)
- return 0;
- do {
- int ev_len;
- /* tansfer the data */
- ev_len = ev_length(q);
- if (copy_to_user(buf + pos, q, ev_len)) {
+ return -ENXIO;
+
+ while (count >= SHORT_EVENT_SIZE) {
+ snd_seq_oss_readq_lock(readq, flags);
+ err = snd_seq_oss_readq_pick(readq, &rec);
+ if (err == -EAGAIN &&
+ !is_nonblock_mode(dp->file_mode) && result == 0) {
+ snd_seq_oss_readq_unlock(readq, flags);
+ snd_seq_oss_readq_wait(readq);
+ snd_seq_oss_readq_lock(readq, flags);
+ if (signal_pending(current))
+ err = -ERESTARTSYS;
+ else
+ err = snd_seq_oss_readq_pick(readq, &rec);
+ }
+ if (err < 0) {