From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3CC2C54E49 for ; Wed, 6 May 2020 23:03:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC25220735 for ; Wed, 6 May 2020 23:03:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lfgwokHK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbgEFXDp (ORCPT ); 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-Google-Smtp-Source: APiQypJzs+W5WYsIPFMtcylCwrB5U4odFnrNJsA8N4YlUV03urAgiM46sr3oUpC6aJ8qe9h4yvm5KQ== 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