Remove the rx->buf_lock that protected the rx->buf lirc_buffer. The underlying operations on the objects within the lirc_buffer are already protected by spinlocks, or the objects are constant (e.g. chunk_size).
Showing the changes to drivers/staging/lirc (1 of 1 file). Show all
Unified · Split
| @@ -67,9 +67,8 @@ struct IR_rx { · 66 unmodified lines | ||
| 67 | 67 | /* RX device */ |
| 68 | 68 | struct i2c_client *c; |
| 69 | 69 | |
| 70 | − /* RX device buffer & lock */ | |
| 70 | + /* RX device buffer */ | |
| 71 | 71 | struct lirc_buffer buf; |
| 72 | − struct mutex buf_lock; | |
| 73 | 72 | |
| 74 | 73 | /* RX polling thread data */ |
| 75 | 74 | struct task_struct *task; |
| @@ -718,18 +717,15 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) · 642 unmodified lines | ||
| 718 | 717 | struct IR *ir = filep->private_data; |
| 719 | 718 | struct IR_rx *rx = ir->rx; |
| 720 | 719 | int ret = 0, written = 0; |
| 720 | + unsigned int m; | |
| 721 | 721 | DECLARE_WAITQUEUE(wait, current); |
| 722 | 722 | |
| 723 | 723 | dprintk("read called\n"); |
| 724 | 724 | if (rx == NULL) |
| 725 | 725 | return -ENODEV; |
| 726 | 726 | |
| 727 | − if (mutex_lock_interruptible(&rx->buf_lock)) | |
| 728 | − return -ERESTARTSYS; | |
| 729 | − | |
| 730 | 727 | if (n % rx->buf.chunk_size) { |
| 731 | 728 | dprintk("read result = -EINVAL\n"); |
| 732 | − mutex_unlock(&rx->buf_lock); | |
| 733 | 729 | return -EINVAL; |
| 734 | 730 | } |
| 735 | 731 | |
| @@ -767,19 +763,19 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) · 31 unmodified lines | ||
| 767 | 763 | set_current_state(TASK_INTERRUPTIBLE); |
| 768 | 764 | } else { |
| 769 | 765 | unsigned char buf[rx->buf.chunk_size]; |
| 770 | − lirc_buffer_read(&rx->buf, buf); | |
| 771 | − ret = copy_to_user((void *)outbuf+written, buf, | |
| 772 | − rx->buf.chunk_size); | |
| 773 | − written += rx->buf.chunk_size; | |
| 766 | + m = lirc_buffer_read(&rx->buf, buf); | |
| 767 | + if (m == rx->buf.chunk_size) { | |
| 768 | + ret = copy_to_user((void *)outbuf+written, buf, | |
| 769 | + rx->buf.chunk_size); | |
| 770 | + written += rx->buf.chunk_size; | |
| 771 | + } | |
| 774 | 772 | } |
| 775 | 773 | } |
| 776 | 774 | |
| 777 | 775 | remove_wait_queue(&rx->buf.wait_poll, &wait); |
| 778 | 776 | set_current_state(TASK_RUNNING); |
| 779 | − mutex_unlock(&rx->buf_lock); | |
| 780 | 777 | |
| 781 | − dprintk("read result = %s (%d)\n", | |
| 782 | − ret ? "-EFAULT" : "OK", ret); | |
| 778 | + dprintk("read result = %d (%s)\n", ret, ret ? "Error" : "OK"); | |
| 783 | 779 | |
| 784 | 780 | return ret ? ret : written; |
| 785 | 781 | } |
| @@ -1327,7 +1323,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 541 unmodified lines | ||
| 1327 | 1323 | if (ret) |
| 1328 | 1324 | goto out_free_xx; |
| 1329 | 1325 | |
| 1330 | − mutex_init(&ir->rx->buf_lock); | |
| 1331 | 1326 | ir->rx->c = client; |
| 1332 | 1327 | ir->rx->hdpvr_data_fmt = |
| 1333 | 1328 | (id->driver_data & ID_FLAG_HDPVR) ? true : false; |