diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-10-09 14:11:30 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-10-09 14:11:30 +0200 |
commit | 545633f6fecd240bfa50bb8e2db627eac76f9f8a (patch) | |
tree | 7b68d3d5d49e352c5d1eaecd5e0958db89bda09a /drivers/auxdisplay/charlcd.c | |
parent | 3a9fce327ff9cabf7f89d3f20616a83af28393da (diff) | |
parent | 5803b023881857db32ffefa0d269c90280a67ee0 (diff) | |
download | linux-545633f6fecd240bfa50bb8e2db627eac76f9f8a.tar.bz2 |
Merge branch 'for-linus' into for-next
Diffstat (limited to 'drivers/auxdisplay/charlcd.c')
-rw-r--r-- | drivers/auxdisplay/charlcd.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index cfeb049a01ef..642afd88870b 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -647,18 +647,25 @@ static ssize_t charlcd_write(struct file *file, const char __user *buf, static int charlcd_open(struct inode *inode, struct file *file) { struct charlcd_priv *priv = to_priv(the_charlcd); + int ret; + ret = -EBUSY; if (!atomic_dec_and_test(&charlcd_available)) - return -EBUSY; /* open only once at a time */ + goto fail; /* open only once at a time */ + ret = -EPERM; if (file->f_mode & FMODE_READ) /* device is write-only */ - return -EPERM; + goto fail; if (priv->must_clear) { charlcd_clear_display(&priv->lcd); priv->must_clear = false; } return nonseekable_open(inode, file); + + fail: + atomic_inc(&charlcd_available); + return ret; } static int charlcd_release(struct inode *inode, struct file *file) |