diff options
Diffstat (limited to 'ese/st33spi.c')
-rw-r--r-- | ese/st33spi.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ese/st33spi.c b/ese/st33spi.c index 825d186..d72ccbd 100644 --- a/ese/st33spi.c +++ b/ese/st33spi.c @@ -287,7 +287,10 @@ static ssize_t st33spi_read(struct file *filp, char __user *buf, size_t count, st33spi = filp->private_data; - if (st33spi == NULL || !st33spi->spi_state) { + if (st33spi == NULL) + return -ENODEV; + + if (!st33spi->spi_state) { dev_warn(&st33spi->spi->dev, "st33spi: spi is not enabled, abort read process\n"); return -EFAULT; } @@ -326,7 +329,10 @@ static ssize_t st33spi_write(struct file *filp, const char __user *buf, st33spi = filp->private_data; - if (st33spi == NULL || !st33spi->spi_state) { + if (st33spi == NULL) + return -ENODEV; + + if (!st33spi->spi_state) { dev_warn(&st33spi->spi->dev, "st33spi: spi is not enabled, abort write process\n"); return -EFAULT; } @@ -796,7 +802,7 @@ static long st33spi_compat_ioctl(struct file *filp, unsigned int cmd, static int st33spi_open(struct inode *inode, struct file *filp) { - struct st33spi_data *st33spi; + struct st33spi_data *st33spi = NULL; int status = -ENXIO; mutex_lock(&device_list_lock); @@ -808,13 +814,16 @@ static int st33spi_open(struct inode *inode, struct file *filp) } } + if (st33spi == NULL) + return -ENODEV; + if (status) { dev_dbg(&st33spi->spi->dev, "st33spi: nothing for minor %d\n", iminor(inode)); goto err_find_dev; } - if (st33spi == NULL || !st33spi->spi_state) { + if (!st33spi->spi_state) { dev_warn(&st33spi->spi->dev, "st33spi: spi is not enabled, abort open process\n"); mutex_unlock(&device_list_lock); |