[PATCH] libdvbv5: Retry FE_GET_PROPERTY ioctl if it returns EAGAIN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Retry the FE_GET_PROPERTY ioctl used to determine if we have a DVBv5 device
if it returns EAGAIN indicating the driver is currently locked by the kernel.

Also skip over subsequent information gathering calls to FE_GET_PROPERTY
that return EAGAIN.

Original-author: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxx>
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---
 dvb-fe.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
index 04ad907..3657334 100644
--- a/lib/libdvbv5/dvb-fe.c
+++ b/lib/libdvbv5/dvb-fe.c
@@ -171,9 +171,12 @@ struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
 	dtv_prop.props = parms->dvb_prop;
 
 	/* Detect a DVBv3 device */
-	if (ioctl(fd, FE_GET_PROPERTY, &dtv_prop) == -1) {
+	while (ioctl(fd, FE_GET_PROPERTY, &dtv_prop) == -1) {
+		if (errno == EAGAIN)
+			continue;
 		parms->dvb_prop[0].u.data = 0x300;
 		parms->dvb_prop[1].u.data = SYS_UNDEFINED;
+		break;
 	}
 	parms->p.version = parms->dvb_prop[0].u.data;
 	parms->p.current_sys = parms->dvb_prop[1].u.data;
@@ -1336,8 +1339,11 @@ int dvb_fe_get_stats(struct dvb_v5_fe_parms *p)
 		props.props = parms->stats.prop;
 
 		/* Do a DVBv5.10 stats call */
-		if (ioctl(parms->fd, FE_GET_PROPERTY, &props) == -1)
+		if (ioctl(parms->fd, FE_GET_PROPERTY, &props) == -1) {
+			if (errno == EAGAIN)
+				return 0;
 			goto dvbv3_fallback;
+		}
 
 		/*
 		 * All props with len=0 mean that this device doesn't have any
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux