Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f97881fe authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mauro Carvalho Chehab
Browse files

[media] arv: fix sleep_on race



interruptible_sleep_on is racy and going away. In the arv driver that
race has probably never caused problems since it would require a whole
video frame to be captured before the read function has a chance to
go to sleep, but using wait_event_interruptible lets us kill off the
old interface. In order to do this, we have to slightly adapt the
meaning of the ar->start_capture field to distinguish between not having
started a frame and having completed it.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 111eeaa7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ extern struct cpuinfo_m32r boot_cpu_data;
struct ar {
	struct v4l2_device v4l2_dev;
	struct video_device vdev;
	unsigned int start_capture;	/* duaring capture in INT. mode. */
	int start_capture;	/* duaring capture in INT. mode. */
#if USE_INT
	unsigned char *line_buff;	/* DMA line buffer */
#endif
@@ -307,11 +307,11 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
	/*
	 * Okay, kick AR LSI to invoke an interrupt
	 */
	ar->start_capture = 0;
	ar->start_capture = -1;
	ar_outl(arvcr1 | ARVCR1_HIEN, ARVCR1);
	local_irq_restore(flags);
	/* .... AR interrupts .... */
	interruptible_sleep_on(&ar->wait);
	wait_event_interruptible(ar->wait, ar->start_capture == 0);
	if (signal_pending(current)) {
		printk(KERN_ERR "arv: interrupted while get frame data.\n");
		ret = -EINTR;