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 | /* RX device */ | 67 | /* RX device */ |
| 68 | struct i2c_client *c; | 68 | struct i2c_client *c; |
| 69 | 69 | ||
| 70 | /* RX device buffer & lock */ | 70 | /* RX device buffer */ |
| 71 | struct lirc_buffer buf; | 71 | struct lirc_buffer buf; |
| 72 | struct mutex buf_lock; | ||
| 73 | 72 | ||
| 74 | /* RX polling thread data */ | 73 | /* RX polling thread data */ |
| 75 | struct task_struct *task; | 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 | struct IR *ir = filep->private_data; | 717 | struct IR *ir = filep->private_data; |
| 719 | struct IR_rx *rx = ir->rx; | 718 | struct IR_rx *rx = ir->rx; |
| 720 | int ret = 0, written = 0; | 719 | int ret = 0, written = 0; |
| 720 | unsigned int m; | ||
| 721 | DECLARE_WAITQUEUE(wait, current); | 721 | DECLARE_WAITQUEUE(wait, current); |
| 722 | 722 | ||
| 723 | dprintk("read called\n"); | 723 | dprintk("read called\n"); |
| 724 | if (rx == NULL) | 724 | if (rx == NULL) |
| 725 | return -ENODEV; | 725 | return -ENODEV; |
| 726 | 726 | ||
| 727 | if (mutex_lock_interruptible(&rx->buf_lock)) | ||
| 728 | return -ERESTARTSYS; | ||
| 729 | |||
| 730 | if (n % rx->buf.chunk_size) { | 727 | if (n % rx->buf.chunk_size) { |
| 731 | dprintk("read result = -EINVAL\n"); | 728 | dprintk("read result = -EINVAL\n"); |
| 732 | mutex_unlock(&rx->buf_lock); | ||
| 733 | return -EINVAL; | 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 | set_current_state(TASK_INTERRUPTIBLE); | 763 | set_current_state(TASK_INTERRUPTIBLE); |
| 768 | } else { | 764 | } else { |
| 769 | unsigned char buf[rx->buf.chunk_size]; | 765 | unsigned char buf[rx->buf.chunk_size]; |
| 770 | lirc_buffer_read(&rx->buf, buf); | 766 | m = lirc_buffer_read(&rx->buf, buf); |
| 771 | ret = copy_to_user((void *)outbuf+written, buf, | 767 | if (m == rx->buf.chunk_size) { |
| 772 | rx->buf.chunk_size); | 768 | ret = copy_to_user((void *)outbuf+written, buf, |
| 773 | written += rx->buf.chunk_size; | 769 | rx->buf.chunk_size); |
| 770 | written += rx->buf.chunk_size; | ||
| 771 | } | ||
| 774 | } | 772 | } |
| 775 | } | 773 | } |
| 776 | 774 | ||
| 777 | remove_wait_queue(&rx->buf.wait_poll, &wait); | 775 | remove_wait_queue(&rx->buf.wait_poll, &wait); |
| 778 | set_current_state(TASK_RUNNING); | 776 | set_current_state(TASK_RUNNING); |
| 779 | mutex_unlock(&rx->buf_lock); | ||
| 780 | 777 | ||
| 781 | dprintk("read result = %s (%d)\n", | 778 | dprintk("read result = %d (%s)\n", ret, ret ? "Error" : "OK"); |
| 782 | ret ? "-EFAULT" : "OK", ret); | ||
| 783 | 779 | ||
| 784 | return ret ? ret : written; | 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 | if (ret) | 1323 | if (ret) |
| 1328 | goto out_free_xx; | 1324 | goto out_free_xx; |
| 1329 | 1325 | ||
| 1330 | mutex_init(&ir->rx->buf_lock); | ||
| 1331 | ir->rx->c = client; | 1326 | ir->rx->c = client; |
| 1332 | ir->rx->hdpvr_data_fmt = | 1327 | ir->rx->hdpvr_data_fmt = |
| 1333 | (id->driver_data & ID_FLAG_HDPVR) ? true : false; | 1328 | (id->driver_data & ID_FLAG_HDPVR) ? true : false; |