summaryrefslogtreecommitdiff
path: root/sound/usb/line6/driver.c
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2020-05-02 22:31:19 +0300
committerTakashi Iwai <tiwai@suse.de>2020-05-02 23:31:03 +0300
commit5c2d0de544c39407bf286d33bdcc1fb06a892d8b (patch)
tree98ba931efb431902adb526d13520af14c5bb7932 /sound/usb/line6/driver.c
parent7f0d5053c5a9d23fe5c2d337495a9d79038d267b (diff)
downloadlinux-5c2d0de544c39407bf286d33bdcc1fb06a892d8b.tar.xz
ALSA: line6: hwdep: add support for O_NONBLOCK opening mode
Currently line6 hwdep interface ignores O_NONBLOCK flag when opening device and it renders it somewhat useless when using poll. Check for O_NONBLOCK flag when opening device and don't block read() if it is set. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Link: https://lore.kernel.org/r/20200502193120.79115-2-anarsoul@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6/driver.c')
-rw-r--r--sound/usb/line6/driver.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
index 4f096685ed65..86adf87d57f0 100644
--- a/sound/usb/line6/driver.c
+++ b/sound/usb/line6/driver.c
@@ -550,6 +550,7 @@ static int line6_hwdep_open(struct snd_hwdep *hw, struct file *file)
/* NOTE: hwdep layer provides atomicity here */
line6->messages.active = 1;
+ line6->messages.nonblock = file->f_flags & O_NONBLOCK ? 1 : 0;
return 0;
}
@@ -579,6 +580,9 @@ line6_hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
while (kfifo_len(&line6->messages.fifo) == 0) {
mutex_unlock(&line6->messages.read_lock);
+ if (line6->messages.nonblock)
+ return -EAGAIN;
+
rv = wait_event_interruptible(
line6->messages.wait_queue,
kfifo_len(&line6->messages.fifo) != 0);