Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3823295ybi; Fri, 5 Jul 2019 14:56:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhpQ7T0l7/DZLxYUDimH7/IKL+pVldnQ+gc5kFfOP/UmnryeuwZsuURFCiEfA7T77vnU+2 X-Received: by 2002:a63:6843:: with SMTP id d64mr7539869pgc.383.1562363774027; Fri, 05 Jul 2019 14:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562363774; cv=none; d=google.com; s=arc-20160816; b=EV3qRYaF+dNbLu/0ovtEciSWEIox+3TRPK47tAnBZCRpYh9wX94dqQfRytDZ+29rnv mf5ELJICH7pu5xj1SqGq49sblK8/MPpt2Ty4LoOMgSXvmCoJmNruSf5/ZegvlPSNbDHr A1kkAVHUrq39AqbrPl1Og6ILBGwFZ1FChp/bqnJw2N2KDNEgUKNd3MyriVJrUNMxd0f8 ogtaE+/vD6cZsAlqKbx1DUJd0hjn3ZHDYfd9yYYeBTATx1qJVeLULzY/AOQCZ3ilymF5 KTYQCD+0lFu0pljk2nMiI+mWstLsjYzRvGrUUJWVl0ehfaC4qeFE74UtL9ze9y9OwiEc xiPQ== 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=1v61oqHX7c1CBf8OKtP/1BsjhM0sQc4mZ5MbznJNlJ0=; b=btKhk9YvlW5XUmF4PHN2p+1ez1j6lxJXBWh/UmJ+Kv1oQ5vyH6QtJnlgdJGEHMtKXz GpOkDPXresXm4ByOEMg1Irde0hjXJhXLtM1sxjVkJXp79//NWjD9OANbt2idzqzzZe58 g4kCtqkZhsNvH/7o5EPdETPRrPQ5hmLDEfycdtvdqESLlYs5jpDW5P1XLDDvo9/ZR1Di BQBwbj6HluBiBy0ii5gnvo0uhTZlHZcPebEtzYLilMKJNoz3AzSljw4T38zjWZ7niHyY ronf/H1IJFV+sM4pKx/cEVF3y4WAuxUMwLy6ftTg8nIrIAUQnlVLybHZ7C8ldft/mHe/ AGNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SXwjy3zb; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si10572184pff.164.2019.07.05.14.55.58; Fri, 05 Jul 2019 14:56:14 -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=@linaro.org header.s=google header.b=SXwjy3zb; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728325AbfGEVqQ (ORCPT + 99 others); Fri, 5 Jul 2019 17:46:16 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:43322 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728143AbfGEVqQ (ORCPT ); Fri, 5 Jul 2019 17:46:16 -0400 Received: by mail-lj1-f196.google.com with SMTP id 16so10449096ljv.10 for ; Fri, 05 Jul 2019 14:46:15 -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=1v61oqHX7c1CBf8OKtP/1BsjhM0sQc4mZ5MbznJNlJ0=; b=SXwjy3zb+x7sxSUBJA93el1BrCvxzsbXimpX7BfJP2R9hBZour6fXhPCbzX2YdN4Xq DJwQmh92LJQ7dlAk8HHwI7Y/DO2z88DU2ocLtKZBRRMdAPx8MkWi536/unIM153tG4W9 uxQW9irsTf0ZLiTEN4IFlVhWEuPbtzKfAUWf/4L6fL9IMymXJIR1U89+33VBZNnUdsOZ n9koVQKlBn8xSKAvUkk8YTMHXzlJWHYng02RtIA2q55duzaZi/zvNFzBnvw3PyB/xYJr cZuJifd1DtiUu80zWejM3NgQPtEp7K/6U87VbCAbmeFjna5DQ/wFRN/XstuS8Lz9wCUN MAGA== 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=1v61oqHX7c1CBf8OKtP/1BsjhM0sQc4mZ5MbznJNlJ0=; b=ATB2Dn6tSLxyX7ez/XQBd038vSd23bNeGT7xNJ+il1IVeSACIlMQ2HI+vuJwz135jE ACvWv+GlOTmfj/qKT8sdFxqfv73edRbtYLVlpPXLfuudFs2M3P1NauAiXdZV+TySX0In 14ufe7NMPDWKssRZE9rFJwiNLb5R1jo5Vfmc6rZvivI6G22qiooVcT52kmlA/XOgLEdZ fyFa+ErATLom3kgb+qUYXlQI/BojagNf+8XJGATsIJkXezOKtuf1HhIHBMByNe7w4V0r 8rtWHQ4gRKwdDcBEySXD45IDcfQt668VsLSj2Y5KQzbtsr977V1hJ+gVBx7qv3AEenUM pQPw== X-Gm-Message-State: APjAAAXD6Uea003Cw4yZVYMs7I+fDvuuTPD1IcpUvRmJOqHLTCJitqNG MFcCxTKEBXAiPrjJokJR4RlwYfWrkXgII5WhFwRbyA== X-Received: by 2002:a2e:9048:: with SMTP id n8mr3271162ljg.37.1562363174296; Fri, 05 Jul 2019 14:46:14 -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: Linus Walleij Date: Fri, 5 Jul 2019 23:46:02 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: fix incorrect IRQ requesting of an active-low lineevent To: Michael.Wu@vatics.com Cc: Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" , mvp.kutali@gmail.com 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 Fri, Jul 5, 2019 at 12:35 PM wrote: > For example, there is a button which drives level to be low when it is pushed, 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 = GPIOHANDLE_REQUEST_INPUT; > req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE; But *THIS* is the case that should have GPIOHANDLE_REQUEST_ACTIVE_LOW, because you push the button to activate it (it is inactive when not pushed). Also this should have GPIOEVENT_REQUEST_RISING_EDGE. > Run the same logic on another board which the polarity of the button is inverted. The button drives level to be high when it is pushed. > For the inverted level case, we have to add flag GPIOHANDLE_REQUEST_ACTIVE_LOW: > > req.handleflags = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_ACTIVE_LOW; > req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE; This one should not be active low. And also have GPIOEVENT_REQUEST_RISING_EDGE. However I agree that the semantic should change as in the patch, it makes most logical sense. The reason it looks as it does is because GPIO line values and interrupts are two separate subsystems inside the kernel with their own flags (as you've seen). But you are right, userspace has no idea about that and should not have to care. Yours, Linus Walleij