summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2024-08-15 00:38:11 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2026-03-25 17:53:59 +0300
commitdc05a01180814440aee1959721528012dcda4461 (patch)
tree76410d0872384b6afa8b3ddc84d108a598045d03
parent8665ceb926ec9d302ca94e46a2fe07afc08f56d0 (diff)
downloadlinux-dc05a01180814440aee1959721528012dcda4461.tar.xz
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>
-rw-r--r--drivers/input/touchscreen/sur40.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 877eae34fb5a..fe63d53d56db 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -538,15 +538,15 @@ static void sur40_process_video(struct sur40_state *sur40)
return;
/* get a new buffer from the list */
- spin_lock(&sur40->qlock);
- if (list_empty(&sur40->buf_list)) {
- dev_dbg(sur40->dev, "buffer queue empty\n");
- spin_unlock(&sur40->qlock);
- return;
+ scoped_guard(spinlock, &sur40->qlock) {
+ if (list_empty(&sur40->buf_list)) {
+ dev_dbg(sur40->dev, "buffer queue empty\n");
+ return;
+ }
+ new_buf = list_first_entry(&sur40->buf_list,
+ struct sur40_buffer, list);
+ list_del(&new_buf->list);
}
- new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list);
- list_del(&new_buf->list);
- spin_unlock(&sur40->qlock);
dev_dbg(sur40->dev, "buffer acquired\n");
@@ -888,9 +888,8 @@ static void sur40_buffer_queue(struct vb2_buffer *vb)
struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue);
struct sur40_buffer *buf = (struct sur40_buffer *)vb;
- spin_lock(&sur40->qlock);
+ guard(spinlock)(&sur40->qlock);
list_add_tail(&buf->list, &sur40->buf_list);
- spin_unlock(&sur40->qlock);
}
static void return_all_buffers(struct sur40_state *sur40,
@@ -898,12 +897,12 @@ static void return_all_buffers(struct sur40_state *sur40,
{
struct sur40_buffer *buf, *node;
- spin_lock(&sur40->qlock);
+ guard(spinlock)(&sur40->qlock);
+
list_for_each_entry_safe(buf, node, &sur40->buf_list, list) {
vb2_buffer_done(&buf->vb.vb2_buf, state);
list_del(&buf->list);
}
- spin_unlock(&sur40->qlock);
}
/*