Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: sur40 - use guard notation when acquiring spinlock

Guard notation simplifies code.

Also use list_first_entry() instead of list_entry() to emphasize intent.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+11 -12
+11 -12
drivers/input/touchscreen/sur40.c
··· 538 538 return; 539 539 540 540 /* get a new buffer from the list */ 541 - spin_lock(&sur40->qlock); 542 - if (list_empty(&sur40->buf_list)) { 543 - dev_dbg(sur40->dev, "buffer queue empty\n"); 544 - spin_unlock(&sur40->qlock); 545 - return; 541 + scoped_guard(spinlock, &sur40->qlock) { 542 + if (list_empty(&sur40->buf_list)) { 543 + dev_dbg(sur40->dev, "buffer queue empty\n"); 544 + return; 545 + } 546 + new_buf = list_first_entry(&sur40->buf_list, 547 + struct sur40_buffer, list); 548 + list_del(&new_buf->list); 546 549 } 547 - new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list); 548 - list_del(&new_buf->list); 549 - spin_unlock(&sur40->qlock); 550 550 551 551 dev_dbg(sur40->dev, "buffer acquired\n"); 552 552 ··· 888 888 struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue); 889 889 struct sur40_buffer *buf = (struct sur40_buffer *)vb; 890 890 891 - spin_lock(&sur40->qlock); 891 + guard(spinlock)(&sur40->qlock); 892 892 list_add_tail(&buf->list, &sur40->buf_list); 893 - spin_unlock(&sur40->qlock); 894 893 } 895 894 896 895 static void return_all_buffers(struct sur40_state *sur40, ··· 897 898 { 898 899 struct sur40_buffer *buf, *node; 899 900 900 - spin_lock(&sur40->qlock); 901 + guard(spinlock)(&sur40->qlock); 902 + 901 903 list_for_each_entry_safe(buf, node, &sur40->buf_list, list) { 902 904 vb2_buffer_done(&buf->vb.vb2_buf, state); 903 905 list_del(&buf->list); 904 906 } 905 - spin_unlock(&sur40->qlock); 906 907 } 907 908 908 909 /*