Received: by 10.213.65.68 with SMTP id h4csp470193imn; Fri, 16 Mar 2018 08:44:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELsk4+BLhELozr+y5210rX21Qa39ESgpaH21B3Qmr3ICN72/Flwr8ZBIp4uOUqkVLK5fKcAZ X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr2684577plc.222.1521215045059; Fri, 16 Mar 2018 08:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215045; cv=none; d=google.com; s=arc-20160816; b=cn4f1odONOq/ep3gozdzbeGGJBVMFG0IjIwLfUAkTa6M2m56vWsXbAAVd5+RItO+XH GrV+6e9heJxkA0rhZajp2pd5u+lLQjfjXtZYvPn9eP5AaY6DJScQTgtQtJldr2Ua4iBl dLUz/34TVClYuTCUASXpT65F7/s9p6yWbFuzYmgdDsojW99TxdRyJdyhF2KlUMkFfE+d 9ZpN5I76nHyP6vxVxl14NSCzKvJCQFnQuZ8onY+MVUOMeeUjVlIB+GOyzBNawGCZE86L E4gfmLsa9U8R00Ofgv+yeWS3O2DNIOdB/aeqsSYh7JJR+pIuWOLuomtPrwOd3Sgg0mzB 8hJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=k6rnElQP/EyY40/yj1yjyBD0NSoKxKKPT1OUpTRk3ws=; b=UfgYcryrtl0NxIbiFqi+6nQMIAYnUdYa4DvghRHojX7EMgRBYab4E8EZIYoscwoDpx jBedQLjjq78oBeDGxHtl3kVFSuRPEcQSGLMb0QQO2j+J8iz7+oEQjBIVTyE8IoZ9FJ0i Pr61yqloTyr7LB3Aq1aAkqWFzLMY4Lt34D6pkkDErxCf0Y6aHaM2SVDiO9lFXpXcCPn1 p9OxOVp8ffBsmJf7LRrhE4brPENrsK64YXKPStHzurf/XdzNhhJ3df5Htt+iWdJKWJ0f hhTPVfgyfwa2/DOB6dxT8SetWTxjbIj3Y3bCCec1YzR5qYW1GxtVJzWzt49h6GpDcBWr CfIw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si5653548pfs.116.2018.03.16.08.43.51; Fri, 16 Mar 2018 08:44:05 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934159AbeCPPmf (ORCPT + 99 others); Fri, 16 Mar 2018 11:42:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44486 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754912AbeCPPmb (ORCPT ); Fri, 16 Mar 2018 11:42:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id ECE59E98; Fri, 16 Mar 2018 15:42:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Meerwald-Stadler , Matt Ranostay , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.15 074/128] iio: health: max30102: Add power enable parameter to get_temp function Date: Fri, 16 Mar 2018 16:23:35 +0100 Message-Id: <20180316152340.389768937@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Meerwald-Stadler [ Upstream commit a9c47abbdd71dceeaf1b923e5ce10e700e036905 ] Chip must not be in shutdown for reading temperature, so briefly leave shutdown if buffer is not already running Signed-off-by: Peter Meerwald-Stadler Acked-by: Matt Ranostay Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iio/health/max30102.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) --- a/drivers/iio/health/max30102.c +++ b/drivers/iio/health/max30102.c @@ -329,20 +329,31 @@ static int max30102_read_temp(struct max return 0; } -static int max30102_get_temp(struct max30102_data *data, int *val) +static int max30102_get_temp(struct max30102_data *data, int *val, bool en) { int ret; + if (en) { + ret = max30102_set_powermode(data, true); + if (ret) + return ret; + } + /* start acquisition */ ret = regmap_update_bits(data->regmap, MAX30102_REG_TEMP_CONFIG, MAX30102_REG_TEMP_CONFIG_TEMP_EN, MAX30102_REG_TEMP_CONFIG_TEMP_EN); if (ret) - return ret; + goto out; msleep(35); + ret = max30102_read_temp(data, val); + +out: + if (en) + max30102_set_powermode(data, false); - return max30102_read_temp(data, val); + return ret; } static int max30102_read_raw(struct iio_dev *indio_dev, @@ -355,20 +366,19 @@ static int max30102_read_raw(struct iio_ switch (mask) { case IIO_CHAN_INFO_RAW: /* - * Temperature reading can only be acquired while engine - * is running + * Temperature reading can only be acquired when not in + * shutdown; leave shutdown briefly when buffer not running */ mutex_lock(&indio_dev->mlock); - if (!iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else { - ret = max30102_get_temp(data, val); - if (!ret) - ret = IIO_VAL_INT; - } - + ret = max30102_get_temp(data, val, true); + else + ret = max30102_get_temp(data, val, false); mutex_unlock(&indio_dev->mlock); + if (ret) + return ret; + + ret = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: *val = 1000; /* 62.5 */