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=-8.6 required=3.0 tests=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_SANE_1 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 20890C49ED7 for ; Fri, 13 Sep 2019 08:44:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E96EB20830 for ; Fri, 13 Sep 2019 08:44:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="XVUeIcZW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387590AbfIMIoS (ORCPT ); Fri, 13 Sep 2019 04:44:18 -0400 Received: from first.geanix.com ([116.203.34.67]:48790 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387561AbfIMIoS (ORCPT ); Fri, 13 Sep 2019 04:44:18 -0400 Received: from [192.168.100.95] (unknown [95.138.208.137]) by first.geanix.com (Postfix) with ESMTPSA id 02E216E05C; Fri, 13 Sep 2019 08:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1568364210; bh=Ca7twcBPtUe888HE8NSKRzEJRASAPJF2BOEQM26TIb8=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=XVUeIcZWh/DzB2b9uI8KAER2T4VTwpmKnqyRxSHKAOAoCBqsMub7YKXwzzMQIl/Wy AQEKuvha8SDw5rQ0FPtcI2C45mrHOXswBIMwOTN9x72JZjjm26df36jRztuk2nXa3p Qo9OmiqH9zDhLrX9UiaciKKh/Vrlzv2oiFiFht2zLEZEz7I8qp46KAK68WetDOHoFX vYF96sCfPexV+Aa+LEQdS/4DxSqR3Ldrid94fAoyuUoLeQiR86Uny70beHcq2X0Esh XdTv0Y5p64eyLJ00IPO2jEIexZCE2rDIGOU8XuoKm9BIJaWwwjrhxH+d9AV7vY14Or yci5MQwbRPDPg== Subject: Re: [PATCH v7 3/5] iio: imu: st_lsm6dsx: add wakeup-source option To: Lorenzo Bianconi Cc: linux-iio@vger.kernel.org, jic23@kernel.org, lorenzo.bianconi83@gmail.com, denis.ciocca@st.com, mario.tesi@st.com, armando.visconti@st.com, martin@geanix.com References: <20190912070614.1144169-1-sean@geanix.com> <20190912070614.1144169-4-sean@geanix.com> <6eb3a60f-0712-4ad7-fe3c-fd76a3ea135f@geanix.com> <20190913082701.GA2698@localhost.localdomain> From: Sean Nyekjaer Message-ID: <66e35f99-780b-7063-37ad-3fb656a6dffc@geanix.com> Date: Fri, 13 Sep 2019 10:43:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.0 MIME-Version: 1.0 In-Reply-To: <20190913082701.GA2698@localhost.localdomain> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US-large Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On 13/09/2019 10.27, Lorenzo Bianconi wrote: >> >> >> On 12/09/2019 09.06, Sean Nyekjaer wrote: >>> This add ways for the SoC to wake from accelerometer wake events. >>> >>> In the suspend function we skip disabling the sensor if wakeup-source >>> and events are activated. >>> >>> Signed-off-by: Sean Nyekjaer >>> --- >>> Changes since v4: >>> * More devices supports wakeup >>> >>> Changes since v5: >>> * None >>> >>> Changes since v6: >>> * None >>> >>> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 14 ++++++++++++++ >>> 1 file changed, 14 insertions(+) >>> >>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c >>> index 4198ba263d03..f79978a2870f 100644 >>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c >>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c >>> @@ -1858,6 +1858,9 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, >>> return err; >>> } >>> + if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) >>> + device_init_wakeup(dev, true); >>> + >>> return 0; >>> } >>> EXPORT_SYMBOL(st_lsm6dsx_probe); >>> @@ -1876,6 +1879,12 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) >>> if (!(hw->enable_mask & BIT(sensor->id))) >>> continue; >>> + if (device_may_wakeup(dev) && i == ST_LSM6DSX_ID_ACC) { >>> + /* Enable wake from IRQ */ >>> + enable_irq_wake(hw->irq); >>> + continue; > > I guess here we need even to check hw->event_enable, don't we? Good idea :) > >>> + } >>> + >>> if (sensor->id == ST_LSM6DSX_ID_EXT0 || >>> sensor->id == ST_LSM6DSX_ID_EXT1 || >>> sensor->id == ST_LSM6DSX_ID_EXT2) >>> @@ -1908,6 +1917,11 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) >>> if (!(hw->suspend_mask & BIT(sensor->id))) >>> continue; >>> + if (device_may_wakeup(dev) && i == ST_LSM6DSX_ID_ACC) { >>> + disable_irq_wake(hw->irq); >>> + continue; >>> + } >>> + >> This section needs to move above: > > agree, and we probably do not need 'continue'. Moreover I guess we should check > hw->event_enable even here, right? Correct we don't need the 'continue' here... The 'hw->suspend_mask' is not set as we skip it in the resume part. I'll add the 'hw->enable_event' check here as well. Is there more stuff that blocks this series from your point of view? /Sean