diff options
Diffstat (limited to 'drivers/spi/spidev.c')
| -rw-r--r-- | drivers/spi/spidev.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 799337f7fde1..f5b60c70389b 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
| @@ -167,14 +167,14 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) | |||
| 167 | 167 | ||
| 168 | mutex_lock(&spidev->buf_lock); | 168 | mutex_lock(&spidev->buf_lock); |
| 169 | status = spidev_sync_read(spidev, count); | 169 | status = spidev_sync_read(spidev, count); |
| 170 | if (status == 0) { | 170 | if (status > 0) { |
| 171 | unsigned long missing; | 171 | unsigned long missing; |
| 172 | 172 | ||
| 173 | missing = copy_to_user(buf, spidev->buffer, count); | 173 | missing = copy_to_user(buf, spidev->buffer, status); |
| 174 | if (count && missing == count) | 174 | if (missing == status) |
| 175 | status = -EFAULT; | 175 | status = -EFAULT; |
| 176 | else | 176 | else |
| 177 | status = count - missing; | 177 | status = status - missing; |
| 178 | } | 178 | } |
| 179 | mutex_unlock(&spidev->buf_lock); | 179 | mutex_unlock(&spidev->buf_lock); |
| 180 | 180 | ||
| @@ -200,8 +200,6 @@ spidev_write(struct file *filp, const char __user *buf, | |||
| 200 | missing = copy_from_user(spidev->buffer, buf, count); | 200 | missing = copy_from_user(spidev->buffer, buf, count); |
| 201 | if (missing == 0) { | 201 | if (missing == 0) { |
| 202 | status = spidev_sync_write(spidev, count); | 202 | status = spidev_sync_write(spidev, count); |
| 203 | if (status == 0) | ||
| 204 | status = count; | ||
| 205 | } else | 203 | } else |
| 206 | status = -EFAULT; | 204 | status = -EFAULT; |
| 207 | mutex_unlock(&spidev->buf_lock); | 205 | mutex_unlock(&spidev->buf_lock); |
