Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4805457imj; Wed, 13 Feb 2019 01:08:03 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibg/m8wlciYjaqyBhTldTJoWZAwVu+LTEUd5v5aqjetRnqPFrN/7h8f8HX5LLDrAMT+0SMM X-Received: by 2002:a17:902:a7:: with SMTP id a36mr7910553pla.295.1550048883791; Wed, 13 Feb 2019 01:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550048883; cv=none; d=google.com; s=arc-20160816; b=j7aqnPmF4Czur4vkqyuqqx7CkbySucLsgVOGLLuCe3MMp/+5sGUASIjU1qfV/uMMS7 AP9AeEevLPND7GkVKRAINjXW/yp/41vTdxpM+GTjA5hzWlRTBx/GFNqfYD4wEVmt2vgb gB455d/K/c/Jzzn0GsXtSCp3uqnMOsV/4iOZrjyg4/e9btYOvxloWhcNkLcoHic1tzDR 0iV31udZOSTk9pviH4VekJBivTEdqHGXEEKFfmdIDqZYA1Q3HHWTjHvySrIVvqMT5B6H w8TxiY+HN2r/apu2GfyOSAo9Qzg1u4bjk6o6/Kuwea/8cAyX0kdA9N144FH4T2B/U1QM Dm3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4bkgZFc/8Q3xOXDvpsueCN2/ExuocXIiElyX/Xh257c=; b=AQjuyRGITAXRxNkVRsWIRLaLhVDCSkDzvPtfk2aL8Yj7NYx7i+VEGDBIMdb79lbtMd ks2P5PwbY2tudBvASvOt4PLr4C7OxCwyqYVvoWJcFBJaEmLRs26Et2gr2LLoJnPQPSf7 rG4fN95o013fXI41ZBdefz5JTymDykZMYr3p8nwixAsNc45Kc75VtT6v3bFB72EJKJqn Pc2hNxi/wZYBlbk6O1tMhv4oGjztnrIdFmSzQEqPHGPaAJRoCvHdA9jwAJLRv/qHr9UE 1s7XQ1cADD/Qm+l4ma8YBCRvaSyorRwn5qq71Q0awWJHnVekY3K2BOim/3bX6i9jP0bo mvvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WBno6xkn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si4292137pfc.162.2019.02.13.01.07.44; Wed, 13 Feb 2019 01:08:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WBno6xkn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730368AbfBMDZw (ORCPT + 99 others); Tue, 12 Feb 2019 22:25:52 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:44687 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727346AbfBMDZw (ORCPT ); Tue, 12 Feb 2019 22:25:52 -0500 Received: by mail-ot1-f68.google.com with SMTP id g1so1559784otj.11; Tue, 12 Feb 2019 19:25:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4bkgZFc/8Q3xOXDvpsueCN2/ExuocXIiElyX/Xh257c=; b=WBno6xknNk8YySAGU/UUuhbJuFAt5fCigADkR+WKghxGoKm65tWx1sG7XMIeuXLazR Pk7tCdlvtBSfxFo8sRik3vPi7gSoCQDsoHGmIjmfCwAE3Y/UiExs6WmLVu80cOPRwnfh iGVVAwtz0lYdylwuy7LL6d+XAksOQMkp0UMAmLHaq4Ju6DUUAj/Nmw5mSyK0om0keynB 3MtXc5Jh93JAfRYae06qdBqiqIjMUYOVCSy/l3XKSJ3+nbQCNe2/4eFckLZp5vf3bO8M Zq5t/bJBCxs3WirVEf0UhPGMPgP1NTqW+jHlfibHQISG4r8yj6ZzVvFGaBSEEgzufBzp p2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4bkgZFc/8Q3xOXDvpsueCN2/ExuocXIiElyX/Xh257c=; b=MHMoxd/yJsgmFlItBfFbHkCBELN486T0AaLIk0f+jY3vxgcean1mEh9B8cNIaqv7G3 E9LF141WpDmnspRP/6PT5WodEmmeMo209Cg+5VeaIFfQTTpLQqbrbVGsNTTfDoWph+1f USOfQoQU3UvrYWGWFC8mocbRvo9AxZ9kKQECnuMLz6eqnuiHhHM5KXBy6QWGaKXHOVUQ RJpzp4Thu6e5PIzWLxoQkBlS2Bw0hDJpdX15d150DEqMb3Ov5F6kqhMMj6Htwssg2Sx+ PChSjUomt7Kf3L2DYqH9dxcmU+KoXobHImtzExys18wRcBP4NucA8QyabJJ4zBueuoJn smSg== X-Gm-Message-State: AHQUAua4uZGbj0Dpd0RLyuEzcbrpvf+OrmLvvp9WQgkDbq8YNYaVGpgC wmuadsaYtSbEOdcedRsWyobABIdKaG+VDBAUIx0= X-Received: by 2002:a05:6830:1317:: with SMTP id p23mr7323846otq.55.1550028350950; Tue, 12 Feb 2019 19:25:50 -0800 (PST) MIME-Version: 1.0 References: <89716a4433cd83aea5f4200359b184b0ee2cc8bd.1549828313.git.bobbyeshleman@gmail.com> <20190213021753.GA19621@bobby.localdomain> In-Reply-To: <20190213021753.GA19621@bobby.localdomain> From: Sven Van Asbroeck Date: Tue, 12 Feb 2019 22:25:39 -0500 Message-ID: Subject: Re: [PATCH 1/3] iio: light: Add driver for ap3216c To: Robert Eshleman Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Linux Kernel Mailing List , linux-iio@vger.kernel.org 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 Hi Bobby, On Tue, Feb 12, 2019 at 9:17 PM Robert Eshleman wrote: > > First, thank you for the feedback. First of all, thank _you_ for doing the hard work on this driver ! I very much respect what you've done here. > > I had initially went with a similar design, but there is > the case in which the interrupt fires and then before the status > register is read by the handler a user process reads the data and > clears the interrupt. When the handler continues execution it will > read a zero status and return IRQ_NONE. My understanding of how > Linux handles IRQ_NONE is pretty poor, but I felt that this behavior > is incorrect even if inconsequential. This could be avoided by > doing a status register read with every data read, and buffering > that as well, but then we lose the benefit altogether by increasing > I2C reads. > > In the approach you describe here, it seems like that would > work if this driver wasn't supporting shared interrupts. In the > case that a user-space read happens to clear the interrupt before > the handler reads the status register, I think we would end up > falsely returning IRQ_NONE. > > Is my understanding of this correct? It's very possible I'm > misunderstanding IRQ_NONE and shared interrupts. > Yes, I can see how one can run into those issues. I believe that this whole class of problems goes away if PS/ALS are _exclusively_ read inside the interrupt, and cached. Then, whenever a user process wants to read the data, the function does not touch the h/w, but simply return the cached value. But hang on, I will have more to say on this when replying to Jonathan's feedback.