Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp612747ybv; Wed, 5 Feb 2020 11:16:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxW2knwFYV+PdWWUFNGiRh+0mLNGyX3BGDD8eF0NNLYlZ3nrkF7cZRJTksfXQaWTnM+Wdhg X-Received: by 2002:aca:4ace:: with SMTP id x197mr4236633oia.23.1580930162445; Wed, 05 Feb 2020 11:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580930162; cv=none; d=google.com; s=arc-20160816; b=eLGpiUiNYjAtM5qmn9aw4MigIaHV2TfRWTxolk21LIFTJHo7IznAToqmr0rgP5C4ED Lj5DitqowX+YP7uucHjMQQXSjdz6Ivrx2nRphvBftj6Ur9dud5of+T36O6hj2XqHz/Qp ymEkMykMvl9wLdjDFVUTO3Q+3UEymsdxW6LsPvEtvkY/jZzFxlpzPw0LZ+GZrDBbfiGS iRycqXCb2UvRobSww5trDpaXEnMPp3ASUP1xA0FCbrUtQMqQKn2m1r11QGNX5TAuBZ9S b2JrlEdAsjY0IXu+cz4Yye/KkcB2vSsUWdmmcAyOeap+/nw4Ui2U4Mgf2XDuzqK+q1YJ KH7w== 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=oVfW9ZDni1DlH8qMCX1yHxGbDRXW3ULcuLJHVxLKcnE=; b=fzCA7pJJVmIq2y/QM86nKwHvt5QkIA85zVi42BWnBY1B3q+xoLxi6EQKMpnBZUz9dP bhwQO/kKK/JyeXv/6e+z1AU1T7XPZ4/AN9fPyOM19+89e0IdDEUJTaVeiWFr/Wc+n5Xr FpyeHlH88GaP9H9n5hw3kV0tOyj6x5dv1qG+gjCgikGkV4VNzNSM1c3InvoL3ZIiXLV3 9lyaHrZy716Xspbo6zYkY47p4WYOqh5dME4eu4Tr7GwKylB0lVu30+X4jFgDatKnib51 uDZLkSTGwCKM7d9ymVobEh0kQPp1c+IyvGUSbvSIUhdrDCpe3Ofd9YyySBPyuH85ME5h 75UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=adQzvvwU; 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 i10si290209otk.195.2020.02.05.11.15.49; Wed, 05 Feb 2020 11:16:02 -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=adQzvvwU; 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 S1727307AbgBETNw (ORCPT + 99 others); Wed, 5 Feb 2020 14:13:52 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:52133 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbgBETNw (ORCPT ); Wed, 5 Feb 2020 14:13:52 -0500 Received: by mail-pj1-f66.google.com with SMTP id fa20so1388439pjb.1 for ; Wed, 05 Feb 2020 11:13:51 -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=oVfW9ZDni1DlH8qMCX1yHxGbDRXW3ULcuLJHVxLKcnE=; b=adQzvvwU+OaHvm/k1t3ljfvwjtqX27BJkfXGeNkH5BOUh0R2RkI+0rZBpjG1cuGDCs lv6iltnlnDYBYjHg3PVOneyoPs4ijZRLe8sYytvTzs65IBNF8GhCxQrX7tWPEELe/cmp Z7nENynpBqM7UigYEzWqBXNLhVKkrVyXeZlO0= 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=oVfW9ZDni1DlH8qMCX1yHxGbDRXW3ULcuLJHVxLKcnE=; b=Pe2CCzMhzlC1fg0Do4r+z7ZiIYDvOCDMZ6poAv3HSBbp5lAelGZvW9s1OwK2E31RB5 hOdmaXo7POktpBkrAXOcEshcs2J1YAXXcS6QjwmTkZvKX3OAnSbEC4cDlLngX6+nVgeI JGHAXOo0jZGpbVHi+4fKnru2c6RGv6pcn5V0a73pFhGH1+Aw/EMq3IUofy/wRQycH3Qf AXIEqJq65NcOWtUtcR0kf34eYUIMhtJ508z7r5xg3AF0DokPrKlyzbjhvXhRCQA8a7wq tuscd48jIT1AC1Hz+mcdtj6sp4ABG2MTXvlQtwN3niHj8x4HioquvQ0ktl0yUTFt/VAc xF2A== X-Gm-Message-State: APjAAAU/3Sl8vax6+3MQRwEbpDleU9ShfSZoQ9A9Pu7rEbbVS4OwUkiR XxeXMN0XLjp4jV3r+OoBF2m8Lw8MRZ4MFg== X-Received: by 2002:a17:90a:23e5:: with SMTP id g92mr7594799pje.14.1580930030743; Wed, 05 Feb 2020 11:13:50 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id u23sm257224pfm.29.2020.02.05.11.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 11:13:50 -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 , Lee Jones , Fabien Lahoudere , linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS) Subject: [PATCH v2 10/17] iio: cros_ec: Use cros_ec_cmd() Date: Wed, 5 Feb 2020 11:00:13 -0800 Message-Id: <20200205190028.183069-11-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200205190028.183069-1-pmalani@chromium.org> References: <20200205190028.183069-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_cmd() which does the message buffer setup and cleanup. For one other usage, replace the cros_ec_cmd_xfer_status() call with a call to cros_ec_cmd_xfer(), in preparation for the removal of the former function. Signed-off-by: Prashant Malani --- Changes in v2: - Updated to use new function name and parameter list. - Used C99 element setting to initialize param struct. - For second usage, replaced cros_ec_cmd_xfer_status() with cros_ec_cmd_xfer() which is functionally similar. .../cros_ec_sensors/cros_ec_sensors_core.c | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 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 d3a3626c7cd834..94e22e7d927631 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 @@ -30,24 +30,15 @@ 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} + struct ec_params_get_cmd_versions params = { + .cmd = cmd, }; + struct ec_response_get_cmd_versions resp = {0}; - ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg); + ret = cros_ec_cmd(ec_dev, 0, EC_CMD_GET_CMD_VERSIONS + cmd_offset, + ¶ms, sizeof(params), &resp, sizeof(resp), NULL); if (ret >= 0) - *mask = buf.resp.version_mask; + *mask = resp.version_mask; return ret; } @@ -171,9 +162,11 @@ int cros_ec_motion_send_host_cmd(struct cros_ec_sensors_core_state *state, memcpy(state->msg->data, &state->param, sizeof(state->param)); - ret = cros_ec_cmd_xfer_status(state->ec, state->msg); + ret = cros_ec_cmd_xfer(state->ec, state->msg); if (ret < 0) return ret; + else if (state->msg->result != EC_RES_SUCCESS) + return -EPROTO; if (ret && state->resp != (struct ec_response_motion_sense *)state->msg->data) -- 2.25.0.341.g760bfbb309-goog