Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1276695ybs; Mon, 25 May 2020 11:33:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoT+TuHGeBkcbfUQ8xMGTQDFDcCUKKGKr+VMkeAOUoHxbEnPUtM6Yc50mECzbUc9FvDnnx X-Received: by 2002:a05:6402:709:: with SMTP id w9mr15901432edx.255.1590431589882; Mon, 25 May 2020 11:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590431589; cv=none; d=google.com; s=arc-20160816; b=dUV3b8zd/gS6IbhAgdz02rfjhTH7ECJtzh9mT7bqbHB2tydSxOrbQ5s85TDB1XVuCu 9Tr8fDn3gW3KNh3QGrY185u73yVompXvigZzdkr0L27wvVRxjHlfyS4yW+0KHOAA7bJ9 MU5QKcspIEBVcQ81sl7cqz5L2lQ/xQIOzGK1ju5KPppuD5WDK9age0pQ/TxsokaZnBA4 VK48NtVMdbAB9YjgWIiDZo41xOCxBIl3jYxMZO8tOIL5O4/FXAoY+w4FVSIOemHH+RBV spq3IBcx01r/Azv37/mZVT6tfhrGeMSjrOKxBBeS2rG4YiZW903dius5wZujxOYkr55u VKHg== 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=f8DvzM1LUfYPJBdMAba0GyfRQVQc3MJGiW7Qheov8do=; b=cQIUHjUmg2Q8EwhU4FeLPS2WyDsAtQE505QgMPq8MAqYAW1rhgyermvtSYDSz2Iv76 gzHnX81PihFgFi6e9JV2UU+//6STR/Wa69bhw61gnuURPlMq/2RX5E0D9bon4//GQOqz 0+MqxTb4JpiK2kCOLybUTdA/9Y+dNqpPwFka7XfULnZmuzQrpyOUTyu1g5wqDVfPGKTI f+ijkwqx8BfL8OyrJKhiZaTQkmHOf/5QO7gHqJMz90/+Q7O7hssuwmin3n4zGHW9AyZc 9XL35I4t+rY1CF0NeIK0gbofcLdPAjckIk+o1HYyc2bZbodwY7LS7xT9pPblHO3fTrNV ndvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O1USJP9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si10193570edd.252.2020.05.25.11.32.47; Mon, 25 May 2020 11:33:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O1USJP9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390503AbgEYMRy (ORCPT + 99 others); Mon, 25 May 2020 08:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390196AbgEYMRy (ORCPT ); Mon, 25 May 2020 08:17:54 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE84CC061A0E for ; Mon, 25 May 2020 05:17:53 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id c12so10396050lfc.10 for ; Mon, 25 May 2020 05:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=f8DvzM1LUfYPJBdMAba0GyfRQVQc3MJGiW7Qheov8do=; b=O1USJP9FRD9ErvJk3j1Wo8/HZnbUh1dbudkEcMZXs9b3+JA5YSohAmpC2l0A5R4WWL 8so9pDmwPcsjzarfj/TurajHvn8PinNRJqIzYAWXoRh0o1P/KZMjN4gHRfQ5L29Ag0S8 gH6mlXvB0OpNB2GH/Q2fzreA9V5QYcgyCSL7cX+gKpcFGo2YdciQwGo3SwkV7SzIJYOG Erprmj3VK8nXAAkN9QAixd6ql85fBt1oCgyLo/uhDq6g3ytZUFFkorM0ixnpGxe0cJVy MYUZulcB6jGK/7mCxKWXDk7u4tlfjSwT7Onm2xSYpVCTm9qTZnFmMs5B7VVxzUIwRjRe 17aQ== 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=f8DvzM1LUfYPJBdMAba0GyfRQVQc3MJGiW7Qheov8do=; b=cbnWZP14rXZPywd6Rnv4URWDJEFezIHQv5xMR8W7q9ZLcsnb8XBAlWENDj5sPWp29V upeQsvFjYXVVvEJ4VTTs7RzCgoe35y9C7xUrm8haao7J2OwGHWTtTsew7+eFCMB2rsJA 0K/oTjGpL1xj+vo160GkDPITk2JiJquRgAmf18rrwnVum5q5lddwGVbcUS5ttOGk2GCu xoCXSK5LQSmNvbYx9Y9+IdWoNFZCC4A4q38P5Nr4YMHuaYKShocFohoN8jwfBfvezPYw cmISJwK57f2otcNT+t42pmlGkmYGpsH7pjzxuxAPzoqD2IupMjFvVVqfyeJeczeAJirv T7Yg== X-Gm-Message-State: AOAM530sdxOfY5aK6SlSvjnBIXE8mILo+2/AzEnSeQuQhlGHFevyRLXH 8/xOJDDvg3TWwp9V8M+W2KgjO2hoxSmlsAGgj8jWwA== X-Received: by 2002:a19:be87:: with SMTP id o129mr10724914lff.217.1590409072296; Mon, 25 May 2020 05:17:52 -0700 (PDT) MIME-Version: 1.0 References: <20200419001858.105281-1-hector.bujanda@digi.com> <20200525022252.GA22956@sol> In-Reply-To: <20200525022252.GA22956@sol> From: Linus Walleij Date: Mon, 25 May 2020 14:17:41 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: add GPIO_SET_DEBOUNCE_IOCTL To: Kent Gibson Cc: Bartosz Golaszewski , Hector Bujanda , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List 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 On Mon, May 25, 2020 at 4:22 AM Kent Gibson wrote: > You mention timers for the gpio pins that cannot provide debounce, > so I'm confused. Could you clarify which strategy you have in mind? My idea is that the callback gpiod_set_debounce() for in-kernel consumers should more or less always return success. Either the hardware does the debounce, or gpiolib sets up a timer. > I've also had a quick look at the possibility of providing the software > debounce for in-kernel consumers. That is where I think it should start. > Are you anticipating new API for > that? e.g. allowing consumers to request gpio events? Cos, gpio_keys > grabs the irq itself - and that would bypass the software debouncer, > or even conflict with it. It may be hard or impossible. I suppose gpiolib would have to steal or intercept the interrupt by using e.g. IRQF_SHARED and then just return IRQ_HANDLED on the first IRQ so the underlying irq handler does not get called. After the timer times out it needs to retrigger the IRQ. So the consuming driver would se a "debounced and ready" IRQ so when it gets this IRQ it knows for sure there is no bounciness on it because gpiolib already took care of that. The above is in no way trivial, but it follows the design pattern of "narrow and deep" APIs. Failure is an option! Sorry if I push too complex ideas. Yours, Linus Walleij