Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2710910imj; Mon, 18 Feb 2019 10:42:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IZr4daub0Hv+auXs/dbitWR5ziF4yLJLSsbUhg0fRhbZGqjX3sMZl6syXiBkmXAWHqXpL/f X-Received: by 2002:a63:1cd:: with SMTP id 196mr20230842pgb.58.1550515347188; Mon, 18 Feb 2019 10:42:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550515347; cv=none; d=google.com; s=arc-20160816; b=cSjLakw6SOBZJqWOG6UHheeOhpHGvZX7nRQx+iBHkIgeh05a2FqN3HWbKWS8GihxdP ZeaP0WXbaaWU9oBo/JKCIFIMe3kj1rcX+t3KMrxwJBj/+LgadXGVezPYAD5kHbawUAX1 zqkELc+yCqHakjzHEPPSc7zrMeDBkUU6OD3bkaNbIk6/xSiR+opgSbuSEfFXi6OVMaAg EXYU5E65Bj+DsL42GDGFIyyEnVNUQG2iG5yiWauUt6nPRaVltfyafXN+OUEoWqsx4utK glyKyvxwO3sU8J1Eni0gTqaErsILHz3SnYV+DlyUDc9OO6hHoYEXZSAb7TD66N5cV8Vv sdsQ== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=sW+skPBSDXhjR/i+ymKiI/0NKq2HBzgZ0oOkv/I9SDI=; b=K6sX9eSZekp5PB4mgWqY+nLpIwleMGPEhNN7e628WV3uiwnT3BshWonxTS1sTAfwZ3 oQun9yaslc1KvD2Q8Bu76FvFSEhqmYxlKQe/MjLkyVz7RYuvQsvUI0tzzAxFL913XKL8 hQmjg3HNwyWe65WHu9i77wLflJNK5LV0CP1/j7WF7gdsy8PvfPd00NjwIo5yOJzdiCrA C2/UJ0KdnJlv9GTdIa4CDu6DO3SYFMfAwmnI4DRbZUcVGBeLQ4ExqEnrJQqYBE5zz9Co hJHiE3rx3jNwdYn1keI0PeF5+ijelKjSt0jy7zwXalK6chNAvhmguOj2+phmw6iIleKD 7oww== 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 d11si3452025pls.255.2019.02.18.10.42.03; Mon, 18 Feb 2019 10:42:27 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731968AbfBRPWl (ORCPT + 99 others); Mon, 18 Feb 2019 10:22:41 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:58490 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731378AbfBRPWl (ORCPT ); Mon, 18 Feb 2019 10:22:41 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A7894BBA42A4FE0B69C4; Mon, 18 Feb 2019 23:22:36 +0800 (CST) Received: from localhost (10.47.94.189) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Mon, 18 Feb 2019 23:22:35 +0800 Date: Mon, 18 Feb 2019 15:22:24 +0000 From: Jonathan Cameron To: Sven Van Asbroeck CC: Robert Eshleman , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , "Linux Kernel Mailing List" , Subject: Re: [PATCH 1/3] iio: light: Add driver for ap3216c Message-ID: <20190218152224.00007920@huawei.com> In-Reply-To: References: <89716a4433cd83aea5f4200359b184b0ee2cc8bd.1549828313.git.bobbyeshleman@gmail.com> <20190213021753.GA19621@bobby.localdomain> Organization: Huawei X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.94.189] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Feb 2019 22:25:39 -0500 Sven Van Asbroeck wrote: > 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. As mentioned in the other thread. Can't do that. Then we don't get a readout for a normal read of the value. If we aren't above the threshold then we don't an interrupt, hence no value is ever read. So, what I'm reading above is worrying. The interrupt is cleared by the read of the data registers? I thought the datasheet allowed for an explicit clear? If it clears on a read, then we are on one of those rare and really annoying devices where we have to deal with them not really being able to do monitoring and polled reading at the same time and also not providing a dataready interrupt (which allows for the solution Sven gives) Basically we've only ever had one of these that I can recall and on that max1363 it was more a case of the format being really nasty to decode than the hardware not being capable of safely do it, so we didn't bother. Jonathan