From 0ac89f0fe059f1985e9ad39c15794938b5eda7fd Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 20 May 2010 10:21:36 -0400 Subject: [PATCH] USe interruptible version of down. --- hellochar.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hellochar.c b/hellochar.c index 85510f7..628f53c 100644 --- a/hellochar.c +++ b/hellochar.c @@ -39,7 +39,8 @@ static DECLARE_MUTEX(hello_mtx); static int hello_open(struct inode *ino, struct file *fp) { - down(&hello_mtx); + if (down_interruptible(&hello_mtx)) + return -ERESTARTSYS; if (fp->f_flags & O_TRUNC) { memset(hello->buffer, 0, MAXLEN); hello->len = 0; @@ -54,7 +55,8 @@ static ssize_t hello_read(struct file *fp, char __user *buf, size_t sz, loff_t *pos) { int r; - down(&hello_mtx); + if (down_interruptible(&hello_mtx)) + return -ERESTARTSYS; if (sz + *pos > hello->len) sz = hello->len - *pos; r = copy_to_user(buf, hello->buffer + *pos, sz); @@ -69,7 +71,8 @@ static ssize_t hello_write(struct file *fp, const char __user *buf, size_t sz, loff_t *pos) { int r; - down(&hello_mtx); + if (down_interruptible(&hello_mtx)) + return -ERESTARTSYS; if (sz + *pos > MAXLEN) sz = MAXLEN - *pos; r = copy_from_user(hello->buffer + *pos, buf, sz); -- 2.20.1