Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3161351ybi; Fri, 5 Jul 2019 02:58:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPqBXmNf38g8UMbBuhAVlKa5lgTG6XDfQAQb3y3MipMOUyw8Y2EW+JMi1SzKAfwAEF3Cfd X-Received: by 2002:a17:90a:372a:: with SMTP id u39mr4345642pjb.2.1562320736030; Fri, 05 Jul 2019 02:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562320736; cv=none; d=google.com; s=arc-20160816; b=CG/GPlJTz9MAAEi0fNBTOKDePpSbyMDWL1j45cvLUPvCD1lDurtzsxZLMO9Vv/I3tV NXjPVc7HzJsOFV2e03UrePjan6XyKdG5fgORXN6Ch1Vxfo/Kv6+Op5u+MTPxq5iNoNde 1ijUpAyKJOJU6CpWJqQLOxF4eYBEpr0REyLYVid1oXjfmp6V2pYMfBAgJx9xQxhIyx7U Mq4hEdbQmwBGe4YLJl4npuVKUtDsAOUblkY+zGKdly6FfHlqPhalf0JVzZI/GxCoaWTw TTzhmgz7FQnYfkl0fGxIHCeZXzsJU52FJt7vdgYVlkDxUEOc6LyhEZMkgXVt+o4tsnDf blNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=2KaC+3HJMJrzgfZPSWLrMHYp5NlQD1jIP6KCA5l1j4k=; b=WghE037vtWPthdCjqaBzEtc0S4iQ0JAg04zTTDHt317UoqCS8FA+/T0il9J8hvNB1+ AivRWdU4esiDTfvtwaym/FV8VjOyRWkEAEmhojRrXFdq+sy9F6iA72Xy0w29OWUhhuRc 1SBfJ/4Ws3A47Qa2/SRp1HuWbA/qRJ9pZi4U3mLu9r1eXFzxd4w/79RBeYHsYCj4l/ws c55Awg3wmCZ2CuBRFe1OQaPe++SqjxSSR+7XOQ7ySWMUueKayfkfLLgNIiw1FJpYVbF5 68evYPq22hP62R+IBk3L2Zw/VeoCeQXYNzJh3UGrHP7jR41v1LyPgbzcMZJ5WPvjCtK0 7vvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vivotek.com header.s=dkim header.b=MJA5M0X5; 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 l34si8414735pgm.44.2019.07.05.02.58.40; Fri, 05 Jul 2019 02:58:56 -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=@vivotek.com header.s=dkim header.b=MJA5M0X5; 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 S1728246AbfGEJie (ORCPT + 99 others); Fri, 5 Jul 2019 05:38:34 -0400 Received: from mail.vivotek.com ([60.248.39.150]:57218 "EHLO mail.vivotek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727506AbfGEJie (ORCPT ); Fri, 5 Jul 2019 05:38:34 -0400 X-Greylist: delayed 462 seconds by postgrey-1.27 at vger.kernel.org; Fri, 05 Jul 2019 05:38:33 EDT Received: from pps.filterd (vivotekpps.vivotek.com [127.0.0.1]) by vivotekpps.vivotek.com (8.16.0.22/8.16.0.22) with SMTP id x659SCfH015165; Fri, 5 Jul 2019 17:30:41 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivotek.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=dkim; bh=2KaC+3HJMJrzgfZPSWLrMHYp5NlQD1jIP6KCA5l1j4k=; b=MJA5M0X5SbZ8w3EK6kIpRFJbhbqPmgXsudaZJpiP/w7YN7dWurUCaZXIKaFcqJsTsE3a q7oNu5vcFlOOykIxtLjvXIIYkgMptDoIyNB6WKbZQeu4nDYcUvS0CbjUwxCH0x2z6RMW hmrjgJGnl+U7ekp2GeH/4BIfocVmJ2JVDG4= Received: from cas01.vivotek.tw ([192.168.0.58]) by vivotekpps.vivotek.com with ESMTP id 2tj3w0g0a1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 05 Jul 2019 17:30:41 +0800 Received: from localhost.localdomain (192.168.17.134) by CAS01.vivotek.tw (192.168.0.58) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 5 Jul 2019 17:30:40 +0800 From: Michael Wu To: Linus Walleij , Bartosz Golaszewski , , CC: Subject: [PATCH] gpiolib: fix incorrect IRQ requesting of an active-low lineevent Date: Fri, 5 Jul 2019 17:30:31 +0800 Message-ID: <20190705093031.18182-1-michael.wu@vatics.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.17.134] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-05_04:,, signatures=0 X-Proofpoint-Spam-Reason: safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a pin is active-low, logical trigger edge should be inverted to match the same interrupt opportunity. For example, a button pushed trigger falling edge in ACTIVE_HIGH case; in ACTIVE_LOW case, the button pushed trigger rising edge. For user space the IRQ requesting doesn't need to do any modification except to configuring GPIOHANDLE_REQUEST_ACTIVE_LOW. Signed-off-by: Michael Wu --- drivers/gpio/gpiolib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e013d417a936..b98466a05091 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -956,9 +956,11 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) } if (eflags & GPIOEVENT_REQUEST_RISING_EDGE) - irqflags |= IRQF_TRIGGER_RISING; + irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? + IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; if (eflags & GPIOEVENT_REQUEST_FALLING_EDGE) - irqflags |= IRQF_TRIGGER_FALLING; + irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? + IRQ_TRIGGER_RISING : IRQF_TRIGGER_FALLING; irqflags |= IRQF_ONESHOT; INIT_KFIFO(le->events); -- 2.17.1