Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3391526ybi; Fri, 5 Jul 2019 06:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqydRfCDuSNobn8Qyk9HGAyA06QWHl2iz//WcmqRHKlfGNZlER6DMD8G1RVRP7Cn1Xh3iVtL X-Received: by 2002:a17:90b:d8a:: with SMTP id bg10mr5775690pjb.92.1562333773820; Fri, 05 Jul 2019 06:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562333773; cv=none; d=google.com; s=arc-20160816; b=DDF+PyKERJy0FxK/PTyQV0R/0kdjuPPtCwHW/d0WnfeBNMrI5usvUqhRwjzHamsqgP pHfdUPCSNfS7boyjRzQsbu1vQtjrtlOdO2cyUV9A9mTvX9JXBzpNL081J79AOELKNz2Z uVxh7z5iY0vhfL+FvCmLvCYRHRri3T51A9WAcOlwGxNwxE+x5CuZd+N3NI6j37hxe05r ud1g1hiYoy9yLpYMB0gPfeh5YWqoPRgrESZ58yoykYTX2L5z+gEZ+fdrAIJXi5oEgmt7 6bRgaQKTP6ujG/l42UlqrZHmL3C/LYVDnMRAV2lJtecXeKugd19+BBeSdwrKi7UuNWR+ swJA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=FIkr57DGKA3Q6AfbFJSXSoEMY5we+AeS4yYazxarf0U=; b=SjhVVapXBmYzqBx00ZTZJaDTxS422jPS1xfEEscqz33pWmO1ZdOAOBE6+/+PYcKTkV 49IYhH/1OPYAYCsbfD0IetsAXurnO+XkayI6R04cNIftMnlFzzpN1GutecsnAV2Wk19Y 0gOXCYamKfEyKtNxgWvErm4R2h4MVV0JSvdQBZj+rpI1r3Vi/xggP0V0MydNh3CaoygH OLGA4LI9DSJqf+scg+/ExUccJM3YcCtJxI3zBZTHc0VQGgEF8Y97G92IwxV3CvYayyk+ Fis377TYGV1C6VZuIyuKX9KaF3o4VNZqBdlA39GG3dC69DPDpX7m7xzXL+7XBfdhakqh 7EkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=HWfTtuHJ; 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 a9si10009808pfn.104.2019.07.05.06.35.58; Fri, 05 Jul 2019 06:36:13 -0700 (PDT) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=HWfTtuHJ; 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 S1728855AbfGEMug (ORCPT + 99 others); Fri, 5 Jul 2019 08:50:36 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:40944 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728738AbfGEMug (ORCPT ); Fri, 5 Jul 2019 08:50:36 -0400 Received: by mail-ot1-f67.google.com with SMTP id e8so8937617otl.7 for ; Fri, 05 Jul 2019 05:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=FIkr57DGKA3Q6AfbFJSXSoEMY5we+AeS4yYazxarf0U=; b=HWfTtuHJMeQk3WvwzFgJoUDwPeD2L4gyga5Xe0xi2YqSuTWn5BVGPJlg2A3PKVFSGs 4NqeXFE/HRzmVmEWZ6HQDeUchtRIjOu4tN5al3dn9ALxyP5fhPhl8jcLvdUOEUMfN+lU 8kfLtM6THhpejbrgtZcCTyiYN3vsG73/vXLuctjR1EZ9s9Q4QJ/YgkQngN5UiGgk2iJy deKfQDtBeUEaS7z9MRb11IE+Fndmb1bmjWv/ABhaBL/l2cIdVYzwWlbhxIhs+h/xsXNY rLa9VpMH+ncbm5BpfAHsXYaJYSqnYedT+E1MGkByGbH8uQQBwpIBhIG6Wr5jz9d5K2yn vaGA== 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:content-transfer-encoding; bh=FIkr57DGKA3Q6AfbFJSXSoEMY5we+AeS4yYazxarf0U=; b=lIMqHIoGDp2Lq1N2HQL9iaIF6sejz1m5pZLt3WoD1l9xnSLqJayT1SIeq1ZkCwnpiL g41801/vNmYMgkfHWP+aIRmcKL+lItAvGSg12gZhXhIAk2Oj3IybGLL1uGa3bBHNkg0b GA3yCLDTNg/3avyHY5JHcf6o6LDxmaP0yl3fWhtYjXzj1v4LWx5X5BDQqoAu62yiHl2U /f4DYwTdJzUiIj9ev69p8cFw6EHBIgE7Kr0vz4RX5kjDrAwLtqzoBoZ6BaKWmW3ouqAQ VVVddrA0euae4oZ2hJy5g6bTD7ONipqv5XbdQRFDbYrtqU8pz/c4/9oSa3sWfIMM5/5O Vcbw== X-Gm-Message-State: APjAAAUKZVEcrFCJlWHuu5KaTNPKZtt99z5nfX6h6I8rloLleQQUIDEl r8IR1jTlkyrZ9e1+B4uejvg9V9KTjXQ1TKb8EFpdFg== X-Received: by 2002:a05:6830:210f:: with SMTP id i15mr2713379otc.250.1562331035267; Fri, 05 Jul 2019 05:50:35 -0700 (PDT) MIME-Version: 1.0 References: <20190705093031.18182-1-michael.wu@vatics.com> <5DB475451BAA174CB158B5E897FC1525920E9FD0@MBS-6F-DAG.vivotek.tw> In-Reply-To: <5DB475451BAA174CB158B5E897FC1525920E9FD0@MBS-6F-DAG.vivotek.tw> From: Bartosz Golaszewski Date: Fri, 5 Jul 2019 14:50:24 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: fix incorrect IRQ requesting of an active-low lineevent To: Michael Wu Cc: Linus Walleij , linux-gpio , LKML , mvp.kutali@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pt., 5 lip 2019 o 12:35 napisa=C5=82(a): > > Hi Bartosz, > > For example, there is a button which drives level to be low when it is pu= shed, and drivers level to be high when it is released. > We want to catch the event when the button is pushed. > > In user space we configure a line event with the following code: > > req.handleflags =3D GPIOHANDLE_REQUEST_INPUT; > req.eventflags =3D GPIOEVENT_REQUEST_FALLING_EDGE; > > and we hope to get "falling" events by reading the device node: > > while (1) { > read(fd, &dat,sizeof(dat)); > if (dat.id =3D=3D 0) { > printf("button pushed\n"); > } > } > > Run the same logic on another board which the polarity of the button is i= nverted. The button drives level to be high when it is pushed. > For the inverted level case, we have to add flag GPIOHANDLE_REQUEST_ACTIV= E_LOW: > > req.handleflags =3D GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_ACTIVE_= LOW; > req.eventflags =3D GPIOEVENT_REQUEST_FALLING_EDGE; > > At the result, there are no any events been caught when the button is pus= hed. > By the way, button releasing will emit a "falling" event. > > > Sincerely, > > Michael Wu First: please don't top-post on the mailing list. Second: have you even built the version you sent? Because I'm getting this: drivers/gpio/gpiolib.c: In function =E2=80=98lineevent_create=E2=80=99: drivers/gpio/gpiolib.c:963:4: error: =E2=80=98IRQ_TRIGGER_RISING=E2=80=99 u= ndeclared (first use in this function) IRQ_TRIGGER_RISING : IRQF_TRIGGER_FALLING; ^~~~~~~~~~~~~~~~~~ And third: after fixing the define, this indeed looks like a bug and I'll need to add a test for that to libgpiod once it's upstream. Strange we didn't catch it before. Please send a fixed version and add a Cc tag for stable. Nice catch! Best regards Bartosz Golaszewski