Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp228546iob; Mon, 2 May 2022 17:51:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSXueASFuEXozWQDZdu8EVLkoQNEkdDa9cJeDoMFZCaS1m1r+1Zk0G/eumZgr9AF1KE/HR X-Received: by 2002:a63:4f1e:0:b0:3a6:68b7:cedc with SMTP id d30-20020a634f1e000000b003a668b7cedcmr11841709pgb.29.1651539107604; Mon, 02 May 2022 17:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651539107; cv=none; d=google.com; s=arc-20160816; b=hFUYwMCJgvtFjJiwAMGop8psQoCAfWEEscrNBBrk5rIaGVYTU1ac4R14Ir5suIC2C7 /Ht2xsEJbEtGewZ8CwdvYHS+LbfC6euWO7Nh19C5aPU1dQYyzWs1thGnan9EqZ3aivBt LbFRxwlPet5cXTrDZWhELQfU14xcyVwT+lXqQ6PDOBzglZgY7zE7vrt4R8OYBDyqF6Lw /D5hv84DXdVFh5+94fQjwse/h7v4nv0QKJ0jX5Sg1J1xvBujl1RXDa1XkSM99nh2T0HW LnRfYWHz6LibT1/eQnhcUhI4nBtE/3pKZCH85gxLj2vT9ePL9isbh8QwYwXyQSxPy1J5 /V+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=A0bEJs7qgg/eX6nUTN2NKhZYoTjWbfIDdjjcVr0MKn0=; b=ab6X85pD9GpuA0jtFL+cP5NS3A2pWJuq1hybbz5amcXfvvqlToCbyHepwK851GK4cv dZEl/gGjOjjYr7olNdCp+TNimtBNbRdgXfFEnj9G5WuO0e7QH5wqmIjUJ6sCq7cIDnKS oFV+Kt0PIxXrbTWP3qzq29skABOaTDS5t1yhP3mNTYjxwFTcnelCmgzAlvcQLkvfbz2j HZnt0rlwSNtqEa4VlbJvsjJTYcoUqDFmlogcrJUgB08GqfveiyLVeliKD8ZGMyr3MWZI oH9dcSNRTyj3kZ8ngM5cobyCVVv6jZALitcwLaIPU5K8HXWwdqOFiDY7GH4Wcb75LRea lAiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j+TvewDN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j14-20020a170903024e00b00158f817a251si16840412plh.180.2022.05.02.17.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j+TvewDN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 03E9545ADE; Mon, 2 May 2022 17:39:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354561AbiEAUbL (ORCPT + 99 others); Sun, 1 May 2022 16:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244899AbiEAUbJ (ORCPT ); Sun, 1 May 2022 16:31:09 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B71543EE7; Sun, 1 May 2022 13:27:42 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id gj17-20020a17090b109100b001d8b390f77bso14636202pjb.1; Sun, 01 May 2022 13:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A0bEJs7qgg/eX6nUTN2NKhZYoTjWbfIDdjjcVr0MKn0=; b=j+TvewDN/kI4TIXi0Uj6To92nH4CpMfaizm/t37LfhTx55UMcby1jK6vfE0cJ6gMKP FasRMems0yURB5dgj96Jyt2oaqWtAhW5YHGnhn3lJRBjSDbC7QoWIOcM0jKWcEtXwuNM wtl0XOD6AAj3u9B9jmDMSLGzzUkGueKu8uq3ch4YeeS8ecLtnz7xanl6ZLpRVObbGNOt ytuy6BqXgQ8FjVsfGGwkIZ7GE93TWk0ienpbJkAbbkK24JFIsvhnWjpUsiupqAYNpVRp ZQ8qgcLX1YxzjTx5/hegJJIv+mkOY0vpX/mXGEIX93s/P+SVcfGQR83hFY7Pa0wNOsf/ GMkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A0bEJs7qgg/eX6nUTN2NKhZYoTjWbfIDdjjcVr0MKn0=; b=SjHzu4f0doOT5BkvhHz3R/VmEzynoDaz/CvgWW5TraV89igSKqitfYfGEH6WoGNtQV sX5CvWrke/BLYzolBkuGOAjE2CMGdHmCK8uKTltgomCFT5IZgZvamYboL5f2reHb9V30 5b/tfp7cHwjeEPRJ7rtN5xkz3Ru4hhZ7clqJjMu4WVFGZIRd3EBJDPycgVoUsKPYTtIh Cr1DnkRy79qQEEEa+nHMRW8vEzpT5EzKofPYaOWRAVpH7u5Xha5x0z/cZ0tWD9HYE+ug /94HGRIloT8EWAEg+zsWPRF42biiz7yi2Wf5q/0URU2Py1ceeq27f7t2JDuu0nbDfOr2 rhKA== X-Gm-Message-State: AOAM532nlPqitKfipymgtWsf0ntFOsZt746JtWKOIdGAYntdwUc++LtG l5PFvYKdi6hK2PCgc6bpEJaqsXlQqINNHrBQEe8= X-Received: by 2002:a17:902:f547:b0:15d:10ce:e2ff with SMTP id h7-20020a170902f54700b0015d10cee2ffmr8441158plf.80.1651436861735; Sun, 01 May 2022 13:27:41 -0700 (PDT) MIME-Version: 1.0 References: <20220420211105.14654-1-jagathjog1996@gmail.com> <20220420211105.14654-7-jagathjog1996@gmail.com> <20220501173110.67a18bf9@jic23-huawei> In-Reply-To: <20220501173110.67a18bf9@jic23-huawei> From: Jagath Jog J Date: Mon, 2 May 2022 01:57:30 +0530 Message-ID: Subject: Re: [PATCH v4 6/9] iio: accel: bma400: Add step change event To: Jonathan Cameron Cc: Dan Robertson , Andy Shevchenko , linux-iio , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, On Sun, May 1, 2022 at 9:52 PM Jonathan Cameron wrote: > > On Thu, 21 Apr 2022 02:41:02 +0530 > Jagath Jog J wrote: > > > Added support for event when there is a detection of step change. > > INT1 pin is used to interrupt and event is pushed to userspace. > > > > Signed-off-by: Jagath Jog J > Hi Jagath, > > A query about handling of multiple interrupts... > > > --- > > drivers/iio/accel/bma400.h | 2 + > > drivers/iio/accel/bma400_core.c | 75 +++++++++++++++++++++++++++++++++ > > 2 files changed, 77 insertions(+) > > > > * Read-write configuration registers > > diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c > > index aafb5a40944d..fe101df7b773 100644 > > --- a/drivers/iio/accel/bma400_core.c > > +++ b/drivers/iio/accel/bma400_core.c > > > > > static const struct iio_trigger_ops bma400_trigger_ops = { > > @@ -971,6 +1035,7 @@ static irqreturn_t bma400_interrupt(int irq, void *private) > > { > > struct iio_dev *indio_dev = private; > > struct bma400_data *data = iio_priv(indio_dev); > > + s64 timestamp = iio_get_time_ns(indio_dev); > > int ret; > > > > /* Lock to protect the data->status */ > > @@ -981,6 +1046,16 @@ static irqreturn_t bma400_interrupt(int irq, void *private) > > if (ret) > > goto unlock_err; > > > > + if (FIELD_GET(BMA400_STEP_STAT_MASK, le16_to_cpu(data->status))) { > > + iio_push_event(indio_dev, > > + IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD, > > + IIO_EV_DIR_NONE, > > + IIO_EV_TYPE_CHANGE, 0, 0, 0), > > + timestamp); > > + mutex_unlock(&data->mutex); > > Is it possible for two interrupt sources to be active at the same time? Yeah, it is possible when multiple interrupts are enabled like data ready, step and generic interrupts. > Given the device is clearing interrupts on read (which is unusual enough to > make me check that on the datasheet) you will loose any other events. > > Normal trick is to act on all set bits and if any of them were acted on > return HANDLED. Then I will push all the events that occurred and then in the end I will return HANDLED so that none of the events are missed. I will change this in the next version. Thank you, Jagath > > > + return IRQ_HANDLED; > > + } > > + > > if (FIELD_GET(BMA400_INT_DRDY_MSK, le16_to_cpu(data->status))) { > > mutex_unlock(&data->mutex); > > iio_trigger_poll_chained(data->trig); >