Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2170085ybl; Thu, 30 Jan 2020 12:36:17 -0800 (PST) X-Google-Smtp-Source: APXvYqye1k6OkkNyyc3V+USUPXiw1KzPdaxdPRKeawX8/uulKvET90ED6gMoN+heuq1mucxMxBKB X-Received: by 2002:aca:e189:: with SMTP id y131mr3956365oig.111.1580416577128; Thu, 30 Jan 2020 12:36:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580416577; cv=none; d=google.com; s=arc-20160816; b=UrQ9X0N98Xg/v6wW6YJUknsXU7HfMT9LlSTwxh9QaIxLai4kHjpsbJQofIyp6QtBRJ k+AsekWTKyHRq6DoiwRVU8xlWit7esMqZmRZ3ExsTQjW0mvQK50ccIKDknDFGIgnjA4A KyMypl+0f2CxeYlYYuUM5Xs16yYeS6rIn5j+KtYzdoh3l/isK0ZFyITkuPnyTC6NVNqV Qh7MrJUAeGHujwV/gJbhDzyZWpCyHakanmkL6GH9/0RMM8++GeWmlxJFJqXg7dSMcLXR 7FkUPxkRt+DFhTe3CslgF1oSmx12IWylcggiv+C33c/wzQaI+UqX8MMhpGd5PyH/KAox JKoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wNvy6xwMxMabKrq0MY/fy2p6dAUXxsNgojqhZXniMoQ=; b=SIk1zUfhWmdfzhlW34Y6ICfIPkdn+vBAqDakcIg+Eql7u9OFxRizxWfKGVsw4UL+6o p1a5qtU9m6SNOzdEiJ/zahFi0c+/5LeeBrB60kBzJbGqKg9FLGWJm/ddaINB7OTGZMiy TYyDtcj3vCPe1XFI2Qo404JssIqVBkZAw+VfeHHZST5i1XAdgY3dPSVCwkbxlif6K2Wd xh6/3IttfnSbCD5xutrCzYySEJ1zwNhgkWoNQLJyaBnINjeMFICj+9pd6kUjIWc1oQ5d 90Bft2/dVynbPuf5ujqmR1M7CLaugW3Aby7Vp3u1XpdNq7Rx3CQLMbTjItYFlAbn9CNN fPUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JkyEhE+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si3548642otk.283.2020.01.30.12.36.04; Thu, 30 Jan 2020 12:36:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JkyEhE+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727737AbgA3Ueq (ORCPT + 99 others); Thu, 30 Jan 2020 15:34:46 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46782 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727618AbgA3Ueq (ORCPT ); Thu, 30 Jan 2020 15:34:46 -0500 Received: by mail-pl1-f194.google.com with SMTP id y8so1771165pll.13 for ; Thu, 30 Jan 2020 12:34:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wNvy6xwMxMabKrq0MY/fy2p6dAUXxsNgojqhZXniMoQ=; b=JkyEhE+s5+Wpe9JqeSPNRzRf/NSIQQ56u17SUmBOAa7egf0+ZaDkuoAvRhnnAG12ds bEdtqtp1BK2D3cPBgOqkNhVR6QHyoUi1YP6tLF8B7FVnhbU0Ov24O7JESM0XfWqcSGsG SDvrf0ATbPRbMVN7jDm8tF3mLtiRZTIaeNx4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wNvy6xwMxMabKrq0MY/fy2p6dAUXxsNgojqhZXniMoQ=; b=PwW0pKrTCvGcmsnInKlS2PeDnfxxew6e08MmEsH8X+QblDvKRZr+/p2tBGi8Mt5ntY Vih2LV4mbOtlHyyFsnQvAqGmF/O9rM/0f5+uWZAWjdicf3gFWqzcIl6kYI12vcgvT8he Ns6JU1nQFGm5MyHnbS3Wxaps2ZRUJsI8RQnzSLkcMIqau1hkecviPe27aOtKyOdw3UaX M0pbiTvoiUjqjy/1skeJwGCknblF3V9+3y4Wvfj6f6ipX9TTsbefc9z6Fps3K29WBorc 0akiRIAsO33GpbqncGP6ROagraO7+Kwmb3IvbG3GXgfL5aOGbnOG2jE7ZVlRqa60BLLE dhPg== X-Gm-Message-State: APjAAAX0Ur78ZKKCgqjAEl2ouWy7lPGBHy0+3X3YE6Yy7KfQUCddjPhB mqGnkdjj+UjSKY8LnqxgF5z9DzUTH6IuaQ== X-Received: by 2002:a17:90a:c20d:: with SMTP id e13mr8010288pjt.95.1580416485444; Thu, 30 Jan 2020 12:34:45 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id q12sm7469321pfh.158.2020.01.30.12.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 12:34:45 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , Gwendal Grignou , Fabien Lahoudere , Nick Vaccaro , linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS) Subject: [PATCH 10/17] iio: cros_ec: Use cros_ec_send_cmd_msg() Date: Thu, 30 Jan 2020 12:30:54 -0800 Message-Id: <20200130203106.201894-11-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200130203106.201894-1-pmalani@chromium.org> References: <20200130203106.201894-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace cros_ec_cmd_xfer_status() with cros_ec_send_cmd_msg() which does the message buffer setup and cleanup. Signed-off-by: Prashant Malani --- .../cros_ec_sensors/cros_ec_sensors_core.c | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index 81a7f692de2f37..f92032e97a84d7 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -31,24 +31,16 @@ static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev, u16 cmd_offset, u16 cmd, u32 *mask) { int ret; - struct { - struct cros_ec_command msg; - union { - struct ec_params_get_cmd_versions params; - struct ec_response_get_cmd_versions resp; - }; - } __packed buf = { - .msg = { - .command = EC_CMD_GET_CMD_VERSIONS + cmd_offset, - .insize = sizeof(struct ec_response_get_cmd_versions), - .outsize = sizeof(struct ec_params_get_cmd_versions) - }, - .params = {.cmd = cmd} - }; - - ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg); + struct ec_params_get_cmd_versions params = {0}; + struct ec_response_get_cmd_versions resp = {0}; + + params.cmd = cmd; + ret = cros_ec_send_cmd_msg(ec_dev, 0, + EC_CMD_GET_CMD_VERSIONS + cmd_offset, + ¶ms, sizeof(params), + &resp, sizeof(resp)); if (ret >= 0) - *mask = buf.resp.version_mask; + *mask = resp.version_mask; return ret; } @@ -164,15 +156,22 @@ int cros_ec_motion_send_host_cmd(struct cros_ec_sensors_core_state *state, u16 opt_length) { int ret; + struct cros_ec_command *msg = state->msg; if (opt_length) - state->msg->insize = min(opt_length, state->ec->max_response); + msg->insize = min(opt_length, state->ec->max_response); else - state->msg->insize = state->ec->max_response; + msg->insize = state->ec->max_response; - memcpy(state->msg->data, &state->param, sizeof(state->param)); - - ret = cros_ec_cmd_xfer_status(state->ec, state->msg); + /* + * In order to not disrupt the usage of struct cros_ec_command *msg, + * which is defined higher up in the call stack, we pass in its + * members to cros_ec_send_cmd_msg, instead of removing it at all + * calling locations. + */ + ret = cros_ec_send_cmd_msg(state->ec, msg->version, msg->command, + &state->param, sizeof(state->param), + msg->data, msg->insize); if (ret < 0) return ret; -- 2.25.0.341.g760bfbb309-goog