Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1529842ybv; Thu, 6 Feb 2020 05:46:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxoVi1WFnb6u8Fyw4um8MPcQDfLSTlED6VRJ41/PDC1pjYoevJT8bIWIpmBMt4zaFSQLnk8 X-Received: by 2002:aca:eccd:: with SMTP id k196mr6627102oih.95.1580996785485; Thu, 06 Feb 2020 05:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580996785; cv=none; d=google.com; s=arc-20160816; b=fPN7cb2+zUUg7uRQzJUjj1VsUR985aKbbuOpo4LQP3rSk7JFMTTaUMTXrJGp/Wjd6X fCdpPkcqgDd3OPdJ8h1VutGKzp59a/UowDCptVDt3sQpNblDucQCtCnolcoYuZ5mjztW 4A0eXwF3F+iMIvwo8vXJihP/CJy9O4PXOhW9PYlXXVB7R8WFVVMBXbSMOXypm4/VjbI2 KE84d+hc9lCT3JwDKyGbCQGTGjQ0ICCueXIZBjZ2CJVNtROwqNygeg9neeCPOuhWq+EU x4I2BJIYrTaFWJTDWdx1Bc6RxUhNYIzNOGEkFh51m7BrOzGjUQIobmDAxZZew0LPo3fJ XIJA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=E7TQXmdaUpmStGh85dqVtm89PS2SqL3yBRtmHpJmJ4c=; b=cnXJeKThoNvepEixMl4+G1+N97icirXWcrCGn4KQQK5IYrRZ823GCXxBiJ7wtwLeep pHJ+yEGzMCBZnbuACI/Zi3ot5gK0OFS1tRwTyvR8QsKYpEHLuQhW149nIXWzVp5WzJ3Q D6bDp+m4TiApfR21phoKMuT5NvBL/zciSTDYd4DPvGSfXqIeWzgyYstpgKSw8ckVFet0 8xH+SBngUcdyfl4knaBMhP/JdUUQWuLgTlEQH5CYuDWwLy4Yq9oOqzlr8rSh4gOe76So BlyYXUmTA9VY7M7EjI/t/SXKOotEL9kZ/Sf39U7MjVPLkkCUnnjT8bY9l9+9dg/yRtVN Q9/Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y19si1826323oto.102.2020.02.06.05.46.11; Thu, 06 Feb 2020 05:46:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgBFNpL (ORCPT + 99 others); Thu, 6 Feb 2020 08:45:11 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40142 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727361AbgBFNpL (ORCPT ); Thu, 6 Feb 2020 08:45:11 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 88AFF295177 Subject: Re: [PATCH v2 10/17] iio: cros_ec: Use cros_ec_cmd() To: Jonathan Cameron , Prashant Malani Cc: linux-kernel@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Benson Leung , Guenter Roeck , Gwendal Grignou , Lee Jones , Fabien Lahoudere , "open list:IIO SUBSYSTEM AND DRIVERS" References: <20200205190028.183069-1-pmalani@chromium.org> <20200205190028.183069-11-pmalani@chromium.org> <20200206121753.7b809631@archlinux> From: Enric Balletbo i Serra Message-ID: <671a55aa-1e5e-4e21-4a62-55db4dee368a@collabora.com> Date: Thu, 6 Feb 2020 14:45:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20200206121753.7b809631@archlinux> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prashant, On 6/2/20 13:17, Jonathan Cameron wrote: > On Wed, 5 Feb 2020 11:00:13 -0800 > Prashant Malani wrote: > >> 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 > > Acked-by: Jonathan Cameron > >> --- >> >> 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; >> There is no way to use the new cros_ec_cmd here? >> if (ret && >> state->resp != (struct ec_response_motion_sense *)state->msg->data) >