This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: cec tools: exit if device is disconnected
Author:  Johan Fjeldtvedt <jaf...@gmail.com>
Date:    Wed Aug 24 12:51:03 2016 +0200

If the CEC device is disconnected, ioctl will return ENODEV. This is
checked for in cec-ctl (when monitoring), cec-follower and
cec-compliance, to make these exit when the CEC device disappears.

Signed-off-by: Johan Fjeldtvedt <jaf...@gmail.com>
Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>

 utils/cec-compliance/cec-compliance.h |  9 +++++++--
 utils/cec-ctl/cec-ctl.cpp             |  7 ++++++-
 utils/cec-follower/cec-processing.cpp | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 5 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=20779622cabe7a1201f0debf735b37357ba0e6f9
diff --git a/utils/cec-compliance/cec-compliance.h 
b/utils/cec-compliance/cec-compliance.h
index cb236fdcb739..d59ec1db7925 100644
--- a/utils/cec-compliance/cec-compliance.h
+++ b/utils/cec-compliance/cec-compliance.h
@@ -334,10 +334,15 @@ static inline bool transmit_timeout(struct node *node, 
struct cec_msg *msg,
                                    unsigned timeout = 2000)
 {
        struct cec_msg original_msg = *msg;
+       int res;
 
        msg->timeout = timeout;
-       if (doioctl(node, CEC_TRANSMIT, msg) ||
-           !(msg->tx_status & CEC_TX_STATUS_OK))
+       res = doioctl(node, CEC_TRANSMIT, msg);
+       if (res == ENODEV) {
+               printf("Device was disconnected.\n");
+               exit(1);
+       }
+       if (res || !(msg->tx_status & CEC_TX_STATUS_OK))
                return false;
 
        if (((msg->rx_status & CEC_RX_STATUS_OK) || (msg->rx_status & 
CEC_RX_STATUS_FEATURE_ABORT))
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index f4a1b8a9404f..ea452dcb0c42 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -1874,7 +1874,12 @@ skip_la:
                                struct cec_msg msg = { };
                                __u8 from, to;
 
-                               if (doioctl(&node, CEC_RECEIVE, &msg))
+                               res = doioctl(&node, CEC_RECEIVE, &msg);
+                               if (res == ENODEV) {
+                                       printf("Device was disconnected.\n");
+                                       break;
+                               }
+                               if (res)
                                        continue;
 
                                from = cec_msg_initiator(&msg);
diff --git a/utils/cec-follower/cec-processing.cpp 
b/utils/cec-follower/cec-processing.cpp
index cdf6d88679ec..93f8549c0da7 100644
--- a/utils/cec-follower/cec-processing.cpp
+++ b/utils/cec-follower/cec-processing.cpp
@@ -1078,7 +1078,12 @@ void testProcessing(struct node *node)
                if (FD_ISSET(fd, &ex_fds)) {
                        struct cec_event ev;
 
-                       if (doioctl(node, CEC_DQEVENT, &ev))
+                       res = doioctl(node, CEC_DQEVENT, &ev);
+                       if (res == ENODEV) {
+                               printf("Device was disconnected.\n");
+                               break;
+                       }
+                       if (res)
                                continue;
                        log_event(ev);
                        if (ev.event == CEC_EVENT_STATE_CHANGE) {
@@ -1094,7 +1099,12 @@ void testProcessing(struct node *node)
                if (FD_ISSET(fd, &rd_fds)) {
                        struct cec_msg msg = { };
 
-                       if (doioctl(node, CEC_RECEIVE, &msg))
+                       res = doioctl(node, CEC_RECEIVE, &msg);
+                       if (res == ENODEV) {
+                               printf("Device was disconnected.\n");
+                               break;
+                       }
+                       if (res)
                                continue;
 
                        __u8 from = cec_msg_initiator(&msg);

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to