From patchwork Thu Aug 8 09:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 817862 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 102B72575F for ; Thu, 8 Aug 2024 09:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723108675; cv=none; b=shZjuVg3iT6E3NFgODWBbwGgtzQ3+5RcgHShqJ1l4/oM8rzccYh5DS7TcdjiMumdC/AnZekA2Jnbs2Kr2b0df2rBdB+wJ0fGWqDwauWVTzF4R0E1ToEGVPR71kwTcWbrhAAFuSLuR/dgrC0ZgRV5t7AsrQiGoAG0JQuyuOKzz34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723108675; c=relaxed/simple; bh=Aj2Yox6wS+yFsCaz6yghEH8M7zPl9j66nXSp+6hym6Q=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=jCZc15JFJzMEk49R08vyR3kH9Jx0Qlb+iCJ/s4xEQiM1+ynGDZQahx0GIwso9hleWAp4h1+kwf8lEjY5Fy1NPLMvb8KFcREbZ7aCvk49c8lcwRdgjBNdrnllmBkIebwFuWkxBCAzeWz+hS0thkUF4QF4BKdrGJfQkNrwz86nILg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F4DDC32782 for ; Thu, 8 Aug 2024 09:17:54 +0000 (UTC) Message-ID: Date: Thu, 8 Aug 2024 11:17:52 +0200 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US, nl To: Linux Media Mailing List From: Hans Verkuil Subject: [PATCH] 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 --- drivers/media/cec/core/cec-adap.c | 11 ++++++----- 1 file 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 \n", __func__); + if (reply_vendor_id && msg->len < 6) { + dprintk(1, "%s: message too short\n", + __func__); return -EINVAL; }