Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2300974imb; Mon, 4 Mar 2019 01:18:57 -0800 (PST) X-Google-Smtp-Source: APXvYqw8+U89mK545XkHk/ylPbYVcTOULCLRg4ZwV2oUUyKwBAogjz8j1eKZGOsvXT6+0KfhWjhT X-Received: by 2002:a17:902:581:: with SMTP id f1mr19650004plf.210.1551691137831; Mon, 04 Mar 2019 01:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551691137; cv=none; d=google.com; s=arc-20160816; b=f5H1pOo/zidLSg8ovHwnIMKxlOnFjucJ+nnjHMyy78jeV4vnXaWVBP8PeQkfYonSX9 0WYn7y83S14FHVgel0vFNLstJtTCpoRyGX6Ub4PipjVOJxLrNDCg17hYv8rbOlyFTtyf Q5gqxrcTF/7ECiTuO1m0s3R3xdELmKkiPI8S5elpnHQKoGLVfwzcoCa8sdY3PZ5+m7lO lyBsVOWMIRUpmeFproBhlBf9CejGFZfijUCNapqvEOLt2MIFv/0NP79QyHWOZ1FgriA/ Yl98BrhoY8tKZOx6ra9/H3jgH9MlP6JCxwi4hh4Rlqpr2KjAYS+m0A+1UiWF/IhYpgfp NWTA== 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=3QVCLm5iQKFGA8gH1slkcdVXsupDUT1byrelsmj7Nl4=; b=AD01WRFl7vyVkds5x2pZymUUKcww434z936HljqdCUHdlGoU/rQF45PQ8WcV3xCCpa +Su+8l+8t7OaqqI+XlGG2owkqI78hNcuRrPkTwpdPBjvWIa4XiH2VVxjW/TGS8gDFLZ9 RlwghUPiG4C5RddFmVnc4OxY0QUmAvmKF9XWTE0bNxPFXy/suyk78SoqvFmu2WXYK/hD I+YaClFXlFSwU7aanrD96N45rq451o7OzYus8FOxgVYkeJf14FrfMLdQu7OC0qCxrmzy Hbs6o7VHiF36uaC5341pOYpGao41sisWDr7fRPDzfFHn7nl0vWxwhRx1Twju7CdUxbQb r7lg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si4861084pfm.219.2019.03.04.01.18.42; Mon, 04 Mar 2019 01:18:57 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbfCDJRA (ORCPT + 99 others); Mon, 4 Mar 2019 04:17:00 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:37978 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfCDJRA (ORCPT ); Mon, 4 Mar 2019 04:17:00 -0500 Received: by mail-ed1-f65.google.com with SMTP id h58so3621219edb.5 for ; Mon, 04 Mar 2019 01:16:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3QVCLm5iQKFGA8gH1slkcdVXsupDUT1byrelsmj7Nl4=; b=Zo+2sCmmbLM6CQ7EutCxN+eTIrYaJOhAQn/bNrR8t2bjfL9D1gjFHH1m5m8GGa/XCy peiVMFI/+4MEH+2p6/lw4T6Ec1UyikIU7mxM+Jxklorsq9N+wuTUVZWpSK5VAwVaMbS0 xd8uX36Q6zv1ewpwwMFWq7Pruno/apAvrIDuk7lyTuImLRtywGqltxFFD7X/EBh3KLBO jp/MqMxD0MqK7oAVYoQ9C8vaUQK/PSPAv+VqqBAzuPNaOwQOggWJ9xdf7ZaRJpK7TfY/ MQu82/u5ehOwib4UhFq0z1Dpa6qrtfwBdsYCUq792IcAM1nVWewG2cH9JfyOCQdJLWV6 CbNA== X-Gm-Message-State: APjAAAUcn15XrltIT/NUJ6VpsBZOAo4Uei+eryevffx7jvOW7Fb5HmGd 00RduKvWZhtFdZiudk7oNpWXDfooumE= X-Received: by 2002:a50:eb0c:: with SMTP id y12mr14078704edp.237.1551691017725; Mon, 04 Mar 2019 01:16:57 -0800 (PST) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id gl18sm1091066ejb.49.2019.03.04.01.16.56 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 01:16:56 -0800 (PST) Subject: Re: [PATCH v2] io: accel: kxcjk1013: restore the range after resume. To: "Chen, Hu" Cc: bo.he@intel.com, Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephan Gerhold , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190303161728.3571869e@archlinux> <20190304070556.24681-1-hu1.chen@intel.com> From: Hans de Goede Message-ID: <23ced5ac-b0a0-7d87-76d7-bdec0c3e0e15@redhat.com> Date: Mon, 4 Mar 2019 10:16:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190304070556.24681-1-hu1.chen@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed 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, On 04-03-19 08:05, Chen, Hu wrote: > From: "he, bo" > > On some laptops, kxcjk1013 is powered off when system enters S3. We need > restore the range regiter during resume. Otherwise, the sensor doesn't > work properly after S3. > > Signed-off-by: he, bo > Signed-off-by: Chen, Hu Thank you for the patch. > --- > Changes in v2: > - Handle return value independently in resume callback. > > drivers/iio/accel/kxcjk-1013.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c > index 7096e577b23f..17837e26bcf2 100644 > --- a/drivers/iio/accel/kxcjk-1013.c > +++ b/drivers/iio/accel/kxcjk-1013.c > @@ -1437,6 +1437,11 @@ static int kxcjk1013_resume(struct device *dev) > > mutex_lock(&data->mutex); > ret = kxcjk1013_set_mode(data, OPERATION); > + if (ret < 0) { > + mutex_unlock(&data->mutex); > + return ret; > + } > + ret = kxcjk1013_set_range(data, data->range); > mutex_unlock(&data->mutex); > > return ret; I'm not a fan of the extra unlock, IMHO it would be better to instead do: mutex_lock(&data->mutex); ret = kxcjk1013_set_mode(data, OPERATION); if (ret == 0) ret = kxcjk1013_set_range(data, data->range); mutex_unlock(&data->mutex); Regards, Hans