Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp353638ybj; Wed, 6 May 2020 19:51:41 -0700 (PDT) X-Google-Smtp-Source: APiQypILTD2kKWCebYZ8RlgbUj6QFi6NV8HrT0vqpQHxAyxcGdU0ZQn3dAsPn22ZP5Y4vxA4KHCf X-Received: by 2002:aa7:cd59:: with SMTP id v25mr9223952edw.135.1588819901718; Wed, 06 May 2020 19:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588819901; cv=none; d=google.com; s=arc-20160816; b=ygHxET+ThCT9mJfI4CyL73hA3fZRZsWzqxtJAhVvwTTIe6oP4MfOL0RYK4TCIcz/4X pva91KVZmknHEqRqv8YqIDySkC+YmUeROgqCmdzOvngejBCKuE95Tu8Eq99P+bLcHj+m aZ52/+BOC9rfVWIT5LZ0YlW9pPozjHZa9rNSNT338AYpRcAPhh0rpZHU9j6S8NnvYjmk FTu08ohXJZlDVrUWGlH8lqjRIk60S4caVn3oVKhpy3fBCS+jGo3tomS3Pw3RmUzhhusk jtXhd81GprDmuNIPYVy4P+oFPPp0hUt4dCw0JQ0zFyVM5+CWi1zqddlBnmWNlAVFgtM1 gNng== 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=fykYEAZBREXkb37+0Le9Kbmd8C0bOVDbkDBjBlbVUGs=; b=PCA6oZAHONq8zor9q2Ita7PvPV97BsieaVe1upiZyyxYDAxbDjZqs93dICNVlB7n8d VSHbc87v5OiZshCb3Y55E8PwfsuxgT2LcG3ma3jjrOZBt/6jj375LF+RN8DspaKlAwT6 AMzK3PEIdvMI0KKSmtd9FK9ivqilSQT/4xrgn2CvomrkFYlRXPsG2rBWM6dRb120rhZs vSr4KHQF78KJIQj/NkR4csi+7uA4LzRpK3OBP8sVKEp/2R/gSFcPrPCkl/IEEOl8e+wD 935gEtqAYclEAHvQIb07dvm3ikbgW3zERXLG8g0rZtf22Wnhho280D81EsHE205O+avV +Eag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lfgwokHK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si2051895edn.565.2020.05.06.19.51.19; Wed, 06 May 2020 19:51:41 -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; dkim=pass header.i=@chromium.org header.s=google header.b=lfgwokHK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbgEFXDp (ORCPT + 99 others); Wed, 6 May 2020 19:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbgEFXDf (ORCPT ); Wed, 6 May 2020 19:03:35 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C96C061A0F for ; Wed, 6 May 2020 16:03:35 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x15so1951851pfa.1 for ; Wed, 06 May 2020 16:03:35 -0700 (PDT) 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=fykYEAZBREXkb37+0Le9Kbmd8C0bOVDbkDBjBlbVUGs=; b=lfgwokHK0Brklpzmvej4JY8UQXjySJzJ+cT+2XjoIkDqqZjSbOTNZ6iPY8vjZi9La1 akivu/sXiwoKnL4CijDaXD1urZM8fMii/n8Xu0NMSP+goA0/yhjTXDuxVTfoo1Bn0cmK azlsh4ZzLuWf0l/Ut5hrPMr6DfpcJbBBQHiLU= 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=fykYEAZBREXkb37+0Le9Kbmd8C0bOVDbkDBjBlbVUGs=; b=KzHI5PHC0xrKSrBmgcYSoDK081cG/LlahaBgDA9cN6bbEpjCi8vwBL6Ki9s5A63dUe OEn1emn9gvS0jH3R+UQ5q449KI7E9ziFL/suBGgv0F2CraY/m9fLr85sLtjJIkCgWucs 4HjRvytVtMw9l36MBcVlG3V2N66BVhA/5ilTCOBl0W1HrbglMzF/9hf32c3s5NYpD9pm hxP5y8+ObZ+dREqzB4R8TCxnh3oy28cEvG7UyO66LYuHD9HlRZ4uQNVbjZfLAmh7jdSz Nu+UoR2jYtnr1aEjOPYfhMHC013PwY0upj1sirYOgJQZ9XA+4mSF5XN3I+U0l19D8Wv2 Uq/Q== X-Gm-Message-State: AGi0PuYAdOBXw774FRWpNGl0n2FGqS5/ycFS+I8OdRQq5aZAyZ44p6I9 0vZe4JBheQQaSonScrONuwXV5w== X-Received: by 2002:a62:fc82:: with SMTP id e124mr10932061pfh.126.1588806215221; Wed, 06 May 2020 16:03:35 -0700 (PDT) Received: from localhost ([2620:15c:202:1:4cc0:7eee:97c9:3c1a]) by smtp.gmail.com with ESMTPSA id e2sm5555852pjt.2.2020.05.06.16.03.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 May 2020 16:03:34 -0700 (PDT) From: Gwendal Grignou To: enric.balletbo@collabora.com, jic23@kernel.org Cc: bleung@chromium.org, groeck@chromium.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Gwendal Grignou Subject: [PATCH v2 2/3] iio: cros_ec: Allow enabling/disabling calibration mode Date: Wed, 6 May 2020 16:03:23 -0700 Message-Id: <20200506230324.139241-3-gwendal@chromium.org> X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog In-Reply-To: <20200506230324.139241-1-gwendal@chromium.org> References: <20200506230324.139241-1-gwendal@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 calibration was a one-shot event sent to the sensor to calibrate itself. It is used on Bosch sensors (BMI160, BMA254). For TCS3400 light sensor, we need to stay in calibration mode to run tests. Accept boolean true and false (not just true) to enter/exit calibration. Signed-off-by: Gwendal Grignou --- .../common/cros_ec_sensors/cros_ec_sensors_core.c | 3 +-- include/linux/platform_data/cros_ec_commands.h | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 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 c831915ca7e56..3d8b25ee9d80c 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 @@ -411,11 +411,10 @@ static ssize_t cros_ec_sensors_calibrate(struct iio_dev *indio_dev, ret = strtobool(buf, &calibrate); if (ret < 0) return ret; - if (!calibrate) - return -EINVAL; mutex_lock(&st->cmd_lock); st->param.cmd = MOTIONSENSE_CMD_PERFORM_CALIB; + st->param.perform_calib.enable = calibrate; ret = cros_ec_motion_send_host_cmd(st, 0); if (ret != 0) { dev_warn(&indio_dev->dev, "Unable to calibrate sensor\n"); diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 451885c697cc3..395c9b2b05c66 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -2517,13 +2517,19 @@ struct ec_params_motion_sense { /* * Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA - * and MOTIONSENSE_CMD_PERFORM_CALIB. */ struct __ec_todo_unpacked { uint8_t sensor_num; - } info, info_3, data, fifo_flush, perform_calib, - list_activities; + } info, info_3, data, fifo_flush, list_activities; + /* + * Used for MOTIONSENSE_CMD_PERFORM_CALIB: + * Allow entering/exiting the calibration mode. + */ + struct __ec_todo_unpacked { + uint8_t sensor_num; + uint8_t enable; + } perform_calib; /* * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR * and MOTIONSENSE_CMD_SENSOR_RANGE. -- 2.26.2.526.g744177e7f7-goog