From: Reka Norman <rekanorman@chromium.org>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Daisuke Nojiri <dnojiri@chromium.org>,
Neil Armstrong <narmstrong@baylibre.com>,
Stefan Adolfsson <sadolfsson@google.com>,
Reka Norman <rekanorman@chromium.org>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org
Subject: [PATCH v2 1/9] media: cros-ec-cec: Use cros_ec_cmd to send host commands
Date: Fri, 25 Aug 2023 12:43:54 +1000 [thread overview]
Message-ID: <20230825024735.1443836-2-rekanorman@chromium.org> (raw)
In-Reply-To: <20230825024735.1443836-1-rekanorman@chromium.org>
Use the cros_ec_cmd helper function to reduce the amount of boilerplate
when sending host commands.
Signed-off-by: Reka Norman <rekanorman@chromium.org>
---
(no changes since v1)
.../media/cec/platform/cros-ec/cros-ec-cec.c | 44 +++++++------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c
index c17faf002877..8dd95fb38546 100644
--- a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c
+++ b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c
@@ -95,18 +95,14 @@ static int cros_ec_cec_set_log_addr(struct cec_adapter *adap, u8 logical_addr)
{
struct cros_ec_cec *cros_ec_cec = adap->priv;
struct cros_ec_device *cros_ec = cros_ec_cec->cros_ec;
- struct {
- struct cros_ec_command msg;
- struct ec_params_cec_set data;
- } __packed msg = {};
+ struct ec_params_cec_set params = {
+ .cmd = CEC_CMD_LOGICAL_ADDRESS,
+ .val = logical_addr,
+ };
int ret;
- msg.msg.command = EC_CMD_CEC_SET;
- msg.msg.outsize = sizeof(msg.data);
- msg.data.cmd = CEC_CMD_LOGICAL_ADDRESS;
- msg.data.val = logical_addr;
-
- ret = cros_ec_cmd_xfer_status(cros_ec, &msg.msg);
+ ret = cros_ec_cmd(cros_ec, 0, EC_CMD_CEC_SET, ¶ms, sizeof(params),
+ NULL, 0);
if (ret < 0) {
dev_err(cros_ec->dev,
"error setting CEC logical address on EC: %d\n", ret);
@@ -121,17 +117,13 @@ static int cros_ec_cec_transmit(struct cec_adapter *adap, u8 attempts,
{
struct cros_ec_cec *cros_ec_cec = adap->priv;
struct cros_ec_device *cros_ec = cros_ec_cec->cros_ec;
- struct {
- struct cros_ec_command msg;
- struct ec_params_cec_write data;
- } __packed msg = {};
+ struct ec_params_cec_write params;
int ret;
- msg.msg.command = EC_CMD_CEC_WRITE_MSG;
- msg.msg.outsize = cec_msg->len;
- memcpy(msg.data.msg, cec_msg->msg, cec_msg->len);
+ memcpy(params.msg, cec_msg->msg, cec_msg->len);
- ret = cros_ec_cmd_xfer_status(cros_ec, &msg.msg);
+ ret = cros_ec_cmd(cros_ec, 0, EC_CMD_CEC_WRITE_MSG, ¶ms,
+ cec_msg->len, NULL, 0);
if (ret < 0) {
dev_err(cros_ec->dev,
"error writing CEC msg on EC: %d\n", ret);
@@ -145,18 +137,14 @@ static int cros_ec_cec_adap_enable(struct cec_adapter *adap, bool enable)
{
struct cros_ec_cec *cros_ec_cec = adap->priv;
struct cros_ec_device *cros_ec = cros_ec_cec->cros_ec;
- struct {
- struct cros_ec_command msg;
- struct ec_params_cec_set data;
- } __packed msg = {};
+ struct ec_params_cec_set params = {
+ .cmd = CEC_CMD_ENABLE,
+ .val = enable,
+ };
int ret;
- msg.msg.command = EC_CMD_CEC_SET;
- msg.msg.outsize = sizeof(msg.data);
- msg.data.cmd = CEC_CMD_ENABLE;
- msg.data.val = enable;
-
- ret = cros_ec_cmd_xfer_status(cros_ec, &msg.msg);
+ ret = cros_ec_cmd(cros_ec, 0, EC_CMD_CEC_SET, ¶ms, sizeof(params),
+ NULL, 0);
if (ret < 0) {
dev_err(cros_ec->dev,
"error %sabling CEC on EC: %d\n",
--
2.42.0.rc2.253.gd59a3bf2b4-goog
next prev parent reply other threads:[~2023-08-25 2:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 2:43 [PATCH v2 0/9] media: cros-ec-cec: Add support for multiple ports Reka Norman
2023-08-25 2:43 ` Reka Norman [this message]
2023-08-25 2:43 ` [PATCH v2 2/9] media: cros-ec-cec: Manage an array of ports Reka Norman
2023-08-25 2:43 ` [PATCH v2 3/9] media: cros-ec-cec: Support multiple ports in set/get host commands Reka Norman
2023-08-25 2:43 ` [PATCH v2 4/9] media: cros-ec-cec: Support multiple ports in write command Reka Norman
2023-08-25 2:43 ` [PATCH v2 5/9] media: cros-ec-cec: Support multiple ports in MKBP cec_events Reka Norman
2023-08-25 2:43 ` [PATCH v2 6/9] media: cros-ec-cec: Support receiving messages from multiple ports Reka Norman
2023-08-25 2:44 ` [PATCH v2 7/9] media: cros-ec-cec: Allow specifying multiple HDMI connectors Reka Norman
2023-08-25 2:44 ` [PATCH v2 8/9] media: cros-ec-cec: Get number of CEC ports from EC Reka Norman
2023-08-25 2:44 ` [PATCH v2 9/9] media: cros-ec-cec: Add Dibbi to the match table Reka Norman
2023-11-13 3:23 ` [PATCH v2 0/9] media: cros-ec-cec: Add support for multiple ports patchwork-bot+chrome-platform
2023-11-13 3:42 ` patchwork-bot+chrome-platform
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230825024735.1443836-2-rekanorman@chromium.org \
--to=rekanorman@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dnojiri@chromium.org \
--cc=groeck@chromium.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=narmstrong@baylibre.com \
--cc=sadolfsson@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox