aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <[email protected]>2024-08-08 11:09:18 +0200
committerMauro Carvalho Chehab <[email protected]>2024-08-08 15:24:03 +0200
commit31aaa7d95e09892c81df0d7c49ae85640fa4e202 (patch)
tree7a7ce0c0f8442158f43974b68968f1b53f3598ad
parent599f6899051cb70c4e0aa9fd591b9ee220cb6f14 (diff)
media: cec: cec-adap.c: improve CEC_MSG_FL_REPLY_VENDOR_ID check
The new CEC_MSG_FL_REPLY_VENDOR_ID flag only makes sense in combination with CEC_MSG_VENDOR_COMMAND_WITH_ID. So rather than reporting an error if that flag is set with another command, just clear the flag instead. Only keep the message length check, since otherwise the flag would not make sense. Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
-rw-r--r--drivers/media/cec/core/cec-adap.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index c81b1ed7c08a..c7d36010c890 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -781,7 +781,8 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
{
struct cec_data *data;
bool is_raw = msg_is_raw(msg);
- bool reply_vendor_id = msg->flags & CEC_MSG_FL_REPLY_VENDOR_ID;
+ bool reply_vendor_id = (msg->flags & CEC_MSG_FL_REPLY_VENDOR_ID) &&
+ msg->len > 1 && msg->msg[1] == CEC_MSG_VENDOR_COMMAND_WITH_ID;
int err;
if (adap->devnode.unregistered)
@@ -797,7 +798,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
msg->tx_error_cnt = 0;
msg->sequence = 0;
msg->flags &= CEC_MSG_FL_REPLY_TO_FOLLOWERS | CEC_MSG_FL_RAW |
- CEC_MSG_FL_REPLY_VENDOR_ID;
+ (reply_vendor_id ? CEC_MSG_FL_REPLY_VENDOR_ID : 0);
if ((reply_vendor_id || msg->reply) && msg->timeout == 0) {
/* Make sure the timeout isn't 0. */
@@ -812,9 +813,9 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
dprintk(1, "%s: invalid length %d\n", __func__, msg->len);
return -EINVAL;
}
- if (reply_vendor_id &&
- (msg->len < 6 || msg->msg[1] != CEC_MSG_VENDOR_COMMAND_WITH_ID)) {
- dprintk(1, "%s: message too short or not <Vendor Command With ID>\n", __func__);
+ if (reply_vendor_id && msg->len < 6) {
+ dprintk(1, "%s: <Vendor Command With ID> message too short\n",
+ __func__);
return -EINVAL;
}