Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3117541pxk; Mon, 7 Sep 2020 03:51:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK4W3nhzm3ee/oaPhnG+pVYkVv6pYgfRm72ecaqe+lWnhpmJBZogrb9ImcJ/YlWMrqOb1G X-Received: by 2002:a17:906:b317:: with SMTP id n23mr19942869ejz.6.1599475878797; Mon, 07 Sep 2020 03:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599475878; cv=none; d=google.com; s=arc-20160816; b=fJ0HQDlqmgqoqxMNnQ4Qotck+5l+aoFsaw9mgan27AeQeja+duAaTOQfUg7yZcaBCO JUfAZZj5dSRMnqtOBO1HRT/sgzSW/o6gLo05EtgKtRPMBYwYfbCbDSiRKi8ryooBJFj2 K+nRsi4d5e3XxCr8+4c818JQFyWxStJXz9AGhlkItGB6T1sGaiwaUGaFKhw2FbQ7SMWe GkdPBSH11VksSfkZDDaB6uEgk12t1JAOubJYT0RPZPtRqQ9GjOvliSbHWj9/fwBlgqv1 aMLzJPWigh6PUD7dnmkirr1YvtOt9CLE84ile58qu2Q3O1+gKFPYn6t3wAW1iwKdz/NA lboA== 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=6e8AEWRtNueqeAvJGbliZKe1RTk69UYqOZ1AQQJz7oU=; b=O8yLKlIdRjZKIvJ+fhG3MPTy9X0t6l3v98Cz5rEDSSz/jSFWDZ3DZlFHLzEc+YytcE 3MExsvLHP42eOHimKs48O7r6GHMaLs4hlLPNiUYThlq8sSAqwbY2rihbs9QXkmmt3PpO /afx4Gv+y0m5MDn/Ww7eL1oP1/fj1BkFnY04aornK4bf016CecZCrBJhvsN3jUJ0BG+Z ka4rsEfBAvO3UbAzfJBXEw4fcH0Eju++LsdTBjE+LKbx0I/+pipoE49kBQxkKDo63Ls4 stIQaXC04Zg+I31e6AUJKqhTTgDLXHjm59Lxb0M3QkJ9gkfiYFc3Yd6xRCxiIm//qb9p hRBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id b8si9526889edq.395.2020.09.07.03.50.56; Mon, 07 Sep 2020 03:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728589AbgIGKsV (ORCPT + 99 others); Mon, 7 Sep 2020 06:48:21 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:38216 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbgIGKsT (ORCPT ); Mon, 7 Sep 2020 06:48:19 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 8F5B9286125 Subject: Re: [PATCH 1/2] platform/chrome: cros_ec_proto: Update cros_ec_cmd_xfer() call-sites To: Prashant Malani , linux-kernel@vger.kernel.org Cc: gwendal@chromium.org, Benson Leung , Guenter Roeck References: <20200903095415.2572049-1-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: <1e2de378-5f5b-939e-39d8-00d6cc5ab6c8@collabora.com> Date: Mon, 7 Sep 2020 12:48:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200903095415.2572049-1-pmalani@chromium.org> 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, Thank you for your patch. On 3/9/20 11:54, Prashant Malani wrote: > Since all the other call-sites of cros_ec_cmd_xfer() have been converted > to use cros_ec_cmd_xfer_status() instead, update the remaining > call-sites to prepare for the merge of cros_ec_cmd_xfer() into > cros_ec_cmd_xfer_status(). > > As part of this update, change the error handling inside > cros_ec_get_sensor_count() such that the legacy LPC interface is tried > on all error values, not just when msg->result != EC_RESULT_SUCCESS. > > Signed-off-by: Prashant Malani Gwendal, I'd like to hear from you regarding this patch as you're the one that know most about the corner cases for the sensors in different hardware. Could you take a look and give us your Reviewed tag if all is good? Thanks, Enric > --- > drivers/platform/chrome/cros_ec_proto.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > index dda182132a6a..2cb1defcdd13 100644 > --- a/drivers/platform/chrome/cros_ec_proto.c > +++ b/drivers/platform/chrome/cros_ec_proto.c > @@ -650,7 +650,7 @@ static int get_next_event_xfer(struct cros_ec_device *ec_dev, > msg->insize = size; > msg->outsize = 0; > > - ret = cros_ec_cmd_xfer(ec_dev, msg); > + ret = cros_ec_cmd_xfer_status(ec_dev, msg); > if (ret > 0) { > ec_dev->event_size = ret - 1; > ec_dev->event_data = *event; > @@ -694,7 +694,7 @@ static int get_keyboard_state_event(struct cros_ec_device *ec_dev) > msg->insize = sizeof(ec_dev->event_data.data); > msg->outsize = 0; > > - ec_dev->event_size = cros_ec_cmd_xfer(ec_dev, msg); > + ec_dev->event_size = cros_ec_cmd_xfer_status(ec_dev, msg); > ec_dev->event_data.event_type = EC_MKBP_EVENT_KEY_MATRIX; > memcpy(&ec_dev->event_data.data, msg->data, > sizeof(ec_dev->event_data.data)); > @@ -883,11 +883,9 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec) > params = (struct ec_params_motion_sense *)msg->data; > params->cmd = MOTIONSENSE_CMD_DUMP; > > - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); > + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); > if (ret < 0) { > sensor_count = ret; > - } else if (msg->result != EC_RES_SUCCESS) { > - sensor_count = -EPROTO; > } else { > resp = (struct ec_response_motion_sense *)msg->data; > sensor_count = resp->dump.sensor_count; > @@ -898,9 +896,7 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec) > * Check legacy mode: Let's find out if sensors are accessible > * via LPC interface. > */ > - if (sensor_count == -EPROTO && > - ec->cmd_offset == 0 && > - ec_dev->cmd_readmem) { > + if (sensor_count < 0 && ec->cmd_offset == 0 && ec_dev->cmd_readmem) { > ret = ec_dev->cmd_readmem(ec_dev, EC_MEMMAP_ACC_STATUS, > 1, &status); > if (ret >= 0 && > @@ -915,9 +911,6 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec) > */ > sensor_count = 0; > } > - } else if (sensor_count == -EPROTO) { > - /* EC responded, but does not understand DUMP command. */ > - sensor_count = 0; > } > return sensor_count; > } >