From patchwork Mon Aug 14 04:29:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reka Norman X-Patchwork-Id: 135122 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2528403vqi; Sun, 13 Aug 2023 22:12:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX9dpl1isoRcT3ZMOMRVYWlBaj3hiIxfhez9N2xVIF08SNqzv9MPrKyz9rhR3OmKCwDavL X-Received: by 2002:a05:6a20:748d:b0:13e:3a7a:2d70 with SMTP id p13-20020a056a20748d00b0013e3a7a2d70mr13069060pzd.0.1691989939871; Sun, 13 Aug 2023 22:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691989939; cv=none; d=google.com; s=arc-20160816; b=LthP93wc1cQXPLqbpkz/eXpVLFxVc5+hqPmeFLF5q49WldEn8keukk55JzAUyIOGXb b2O6aq/Zkmz4RIY4Zd0VLUHY1iA4c9nylS4xTNH1rMTvI4ABzWLW5PgultOcPsONb89c EH5iAXauY76If/AemWiH20heVtpBxDJnNqOQsxJeycwvxR85/tr7E8M8MUvW69MDbXCh 2l2uu/O2eb/rYtHKTNU2aCDXJ0mzQ4zkyvXsiINCWqg0Msi7vmWBjxMtaih5IRySysWp VEyouzk8mPxmwXG0ArwuDSbyxChKMTdmxUGibNCxk2KmZaQic3vbJ7okUYx3UZE+io5s uqjg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y189-20020a6364c6000000b005644c5717c1si7835257pgb.252.2023.08.13.22.11.56; Sun, 13 Aug 2023 22:12:19 -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 S233081AbjHNEfG (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774180043394729303 X-GMAIL-MSGID: 1774180043394729303 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",