Received: by 10.213.65.68 with SMTP id h4csp503035imn; Fri, 16 Mar 2018 09:43:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELvuH9xamhYth8PIkSmrceRuqQiFkpzkuTNn6I1HbwThKQIJ5sMk5Jd7Yw1Gs0P4IOywruaq X-Received: by 10.99.96.84 with SMTP id u81mr1958421pgb.231.1521218609947; Fri, 16 Mar 2018 09:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218609; cv=none; d=google.com; s=arc-20160816; b=h2Ltdv3QctV1JB2cVwT/+VQ1xtXDi1TQ5U1ubugbQ1l21O5imQKE/jyUcQi8hWL2bi GQwuV4rROBn/+r/2d2D96GKTv6ZMDu5PSfogcuubkr+pvSzKz6rlhzrfINbaGAZOp/1I JxDiTiw1HeZ21HTAinkp9JsOhJwZj0vqPi1Frlhczq3fQtSn92jGtBFMSVMMnNWy+DJ1 ESBNGURfLH2Y2GOulR6vH1YGsDaEb8/fUscqWB+HwcE2iNrgztu1ILxEv321emMh54N/ GU4GXgr39gR3yWHp4WgUU2pjqnJGxuJOUgHwUmcQ4BBKO0fv54tjLxMWElghplU5JJQy WlIg== 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=KY4YCBdnUdw8w1WdnpKFEePWqd68s8IDZX+llExnfbM=; b=ZPtYUuOL468cnGPYrXe9AUE1Z+XN1PbRaK42V0Xf4BwFLEtdTcQrvJIS5mMjleLSRB OvBduM5+lr/Ay9asLwecGkKalXXywhM9HANrNCDqPaGNcakDnOgyb9mMwc/NQPc9ecJg /TN6i1EgyydDSEmDp8o24ma3j/Zuamiu/WlaDfojqD/5BZa4j0nyrlrjfEp/P5VwMDxv Jl22ENho497Qf4nq74QgLR1oDjpU5XXbxofp18y4Bf3cmGIMz2FepDU4rok1AcolfWTe pO+0xTwAycTESpPKIaFe5MUE6On4gDrnC9FP1MgLystM37HaqqjeyMk1I7LRs5h0GIq5 Pa+w== 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 a100-v6si6497171pli.483.2018.03.16.09.43.15; Fri, 16 Mar 2018 09:43:29 -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 S934319AbeCPPgl (ORCPT + 99 others); Fri, 16 Mar 2018 11:36:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40362 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933422AbeCPPgh (ORCPT ); Fri, 16 Mar 2018 11:36:37 -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 C4481114D; Fri, 16 Mar 2018 15:36:36 +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.14 061/109] iio: health: max30102: Add power enable parameter to get_temp function Date: Fri, 16 Mar 2018 16:23:30 +0100 Message-Id: <20180316152333.272341014@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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 */