History

[media] lirc_zilog: Remove unneeded rx->buf_lock

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).

Andy Walls committed 15 years ago

Commit 8152b761 parent 915e5471 file · +9 −14Browse files

Showing the changes to drivers/staging/lirc (1 of 1 file). Show all

Unified · Split

drivers/staging/lirc/lirc_zilog.c+9−14
@@ -67,9 +67,8 @@ struct IR_rx { · 66 unmodified lines
6767 /* RX device */
6868 struct i2c_client *c;
6969
70− /* RX device buffer & lock */
70+ /* RX device buffer */
7171 struct lirc_buffer buf;
72− struct mutex buf_lock;
7372
7473 /* RX polling thread data */
7574 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
718717 struct IR *ir = filep->private_data;
719718 struct IR_rx *rx = ir->rx;
720719 int ret = 0, written = 0;
720+ unsigned int m;
721721 DECLARE_WAITQUEUE(wait, current);
722722
723723 dprintk("read called\n");
724724 if (rx == NULL)
725725 return -ENODEV;
726726
727− if (mutex_lock_interruptible(&rx->buf_lock))
728− return -ERESTARTSYS;
729−
730727 if (n % rx->buf.chunk_size) {
731728 dprintk("read result = -EINVAL\n");
732− mutex_unlock(&rx->buf_lock);
733729 return -EINVAL;
734730 }
735731
@@ -767,19 +763,19 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) · 31 unmodified lines
767763 set_current_state(TASK_INTERRUPTIBLE);
768764 } else {
769765 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+ }
774772 }
775773 }
776774
777775 remove_wait_queue(&rx->buf.wait_poll, &wait);
778776 set_current_state(TASK_RUNNING);
779− mutex_unlock(&rx->buf_lock);
780777
781− dprintk("read result = %s (%d)\n",
782− ret ? "-EFAULT" : "OK", ret);
778+ dprintk("read result = %d (%s)\n", ret, ret ? "Error" : "OK");
783779
784780 return ret ? ret : written;
785781 }
@@ -1327,7 +1323,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 541 unmodified lines
13271323 if (ret)
13281324 goto out_free_xx;
13291325
1330− mutex_init(&ir->rx->buf_lock);
13311326 ir->rx->c = client;
13321327 ir->rx->hdpvr_data_fmt =
13331328 (id->driver_data & ID_FLAG_HDPVR) ? true : false;