Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2390470rdg; Mon, 14 Aug 2023 00:21:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2Szxs8pHJmTaCmN4CFkzowSTcMUt5iNDqgzFD4K2A3yTxxyK0upaurErCJeRCdunX5aTR X-Received: by 2002:a17:906:304b:b0:99b:484b:21b5 with SMTP id d11-20020a170906304b00b0099b484b21b5mr7350418ejd.8.1691997711322; Mon, 14 Aug 2023 00:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691997711; cv=none; d=google.com; s=arc-20160816; b=hT2v74V+t/D1BBCHpLzSCR1icUQravvwywXMGP5trr9j73Y2PHyOuy6kb++As48ZYa gjLBO2+63EFp9/F0OEBYk7/vycEIa1oRT0m4YA1XoXl0fZaO6HcxB4vAZN+T+PL5T90G /yBlJYkYKASuondW+q3jpP6o17aYdvsmpwhFb7w9DsPfPM0D+upt2+3ccrmfEhn/lJQj FGTL89cfpJHwz7KsBAPyD4w3ko6AeIXXKNEG6VtMV+PAxSIIGJwEeiQZWtb0CU9lQJNw vB4bekN38phsl7Eg1XGbnYcm54XxtjnxfYtR4sgNVRr4KUXPtXZ3ataw50p2dzWhrcr0 zJfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HYvNk0F6tYkddjPM1gjr6zJLDh3fOJZ+v63cRgPJjfA=; fh=Z54ABTjWKY0UM+xzbKZvDcqrpuAhT1VnH73TfCDbJK4=; b=K5bXn6TCLGxO0u9Q6FtLfpdbbuP4OJDFjjGfJ75eyZVHTjQnwm/M02TQ6BiwK0IZbP oo0mTWrrdK4dBFUlqKGLo5/hQBAh9b9fZT53Me3JS19Z+5rJeoL9H51i7kqpAnTosH3Q J7YJc13w8u7l1oHFts9djhoGnhef32Kv30cDXJTHrIua9hT6Va0XAfja2SVPrVWNtnX8 ihPQDAzxkYPIQlVUjXqZjdehP1DYxVPbqfyi8IBU0p0lMZ/OJH3XugxDv2kKGT3OGmHn uExdwgjNTJMV2tA7GYtPIxoDRo16wbQClyYOT8F6A13AR+Rs4aFXKfcZ1tE//1fEgF4z aXFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H7zzWBlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx14-20020a170906af0e00b00997e79e646esi7643564ejb.557.2023.08.14.00.21.26; Mon, 14 Aug 2023 00:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H7zzWBlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233080AbjHNEfG (ORCPT + 99 others); Mon, 14 Aug 2023 00:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233082AbjHNEeg (ORCPT ); Mon, 14 Aug 2023 00:34:36 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC7A7E6F for ; Sun, 13 Aug 2023 21:34:34 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bdb801c667so21754295ad.1 for ; Sun, 13 Aug 2023 21:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691987674; x=1692592474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HYvNk0F6tYkddjPM1gjr6zJLDh3fOJZ+v63cRgPJjfA=; b=H7zzWBlWpbodL7W+6k8K70XBLbZ/RNtZxtCDAwQhN7RZrum1aHa1NFieQVQkx+VpYk +Jh6j44slWPePa7rpDNelCk+yrvPWugPSBBVUJjNvy7QJdc49CdUcPqp5+iuQwlVE8bT W6MhOBUBugTeZ7OGaaUeVZkLK7jvEkHPB3TT0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691987674; x=1692592474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HYvNk0F6tYkddjPM1gjr6zJLDh3fOJZ+v63cRgPJjfA=; b=JxMW0muSz8w8DxY7DKyNBfTxtWViPnsU43pPaMkdRf2DZM8d9ihvjCipeZgYp7dXki fbat7P1bdz98rK4BsgrJNd/OMzipkdts4FHOD4Pw4kRZF8o1ulASD+qg+7CR0azKkFLW 3AgJY7hJihruWLNdux4dz9TosNEjKnMsF4eU/XedOwuFUG3CyqEE4SLwBWsO77pL7CZY tMPUsCnTp7819f5aGCiPhkHpy4boH67Knu79ofnqAs2SPQKf752Mtu1piXftD20bMmPn BmTBd/PJ3isfaXA2jyg5riBWVzfJsIDcJ6xF/IHpEsGEKflvSwcEF283vAa9pBBGSlAc 5OJg== X-Gm-Message-State: AOJu0Ywy1p+kjVwsMZ0ntYEMc9iUn/2grVAo24g8ts99Gzdh9VlcdzRn QoB0NMOeYYmsyY+vq6FwGB/Hsg== X-Received: by 2002:a17:903:2d0:b0:1b8:a697:3719 with SMTP id s16-20020a17090302d000b001b8a6973719mr10622994plk.25.1691987674497; Sun, 13 Aug 2023 21:34:34 -0700 (PDT) Received: from rekanorman3.syd.corp.google.com ([2401:fa00:9:14:4ae6:d1a4:27c2:80ff]) by smtp.gmail.com with ESMTPSA id ju17-20020a170903429100b001bdb0483e65sm6761865plb.265.2023.08.13.21.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 21:34:34 -0700 (PDT) From: Reka Norman To: Hans Verkuil Cc: Neil Armstrong , Daisuke Nojiri , Stefan Adolfsson , Reka Norman , Benson Leung , Guenter Roeck , Mauro Carvalho Chehab , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 1/9] media: cros-ec-cec: Use cros_ec_cmd to send host commands Date: Mon, 14 Aug 2023 14:29:10 +1000 Message-ID: <20230814043140.1108917-2-rekanorman@chromium.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230814043140.1108917-1-rekanorman@chromium.org> References: <20230814043140.1108917-1-rekanorman@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the cros_ec_cmd helper function to reduce the amount of boilerplate when sending host commands. Signed-off-by: Reka Norman --- .../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.41.0.640.ga95def55d0-goog