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

[media] return BUF_STATE_ERROR if streaming stopped during acquisition

When stop_streaming is called while a frame is currently being retrieved, the
buffer being filled will still be returned with BUF_STATE_DONE. By resetting
the sequence number and checking before returning the buffer, it can now
correctly be returned with BUF_STATE_ERROR.

Signed-off-by: Martin Kaltenbrunner <modin@yuri.at>
Signed-off-by: Florian Echtler <floe@butterbrot.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Florian Echtler and committed by
Mauro Carvalho Chehab
2b7eea83 0cfdfcc1

+5
+5
drivers/input/touchscreen/sur40.c
··· 438 438 439 439 dev_dbg(sur40->dev, "image acquired\n"); 440 440 441 + /* return error if streaming was stopped in the meantime */ 442 + if (sur40->sequence == -1) 443 + goto err_poll; 444 + 441 445 /* mark as finished */ 442 446 v4l2_get_timestamp(&new_buf->vb.v4l2_buf.timestamp); 443 447 new_buf->vb.v4l2_buf.sequence = sur40->sequence++; ··· 727 723 static void sur40_stop_streaming(struct vb2_queue *vq) 728 724 { 729 725 struct sur40_state *sur40 = vb2_get_drv_priv(vq); 726 + sur40->sequence = -1; 730 727 731 728 /* Release all active buffers */ 732 729 return_all_buffers(sur40, VB2_BUF_STATE_ERROR);