Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3283873ybt; Mon, 22 Jun 2020 21:08:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3htEdir6JTpX7NQ2A4FzS88+MORVbFBvqUk+7zjEbPRs6lA2ZC+xNlZ42gIz+L3/FqqTE X-Received: by 2002:a17:906:c455:: with SMTP id ck21mr18157388ejb.342.1592885290746; Mon, 22 Jun 2020 21:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592885290; cv=none; d=google.com; s=arc-20160816; b=YUJXG64fOUjYtEOtL6tx26p/vZs43bp8J2eH4riWucwixDAW628nspFX5o2QGm3Mny AIaTwD1Gx9igYn6Jx3hJ0z6st5EOzun8bG+OVoLfqzu8ZhiNVbZSA9ANJzpOxHoZzJ0u JTCFWIpYp3mHoEGJodpEe5Kb/ThZ1mDAgLrMonCxsjgsGJOgAWwcpU40yZl+VNHmfBC7 8TJJYZmFXp0r0HYLNnnCGhJANaBreBRd4VOXXPqZN6hwNLsDv/I8hLHPKAo6W6l8b3P1 qG+7QgeO/03Eq7pukQ1QYUWdnlysiOpWjYb6xSrUdfrEK7k0tMrY0h4EqeAU9fmEUWr0 36Cw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gIH44XP+3+d8u/o5onM5jscJ417kAbas5Jl16ovp4QI=; b=YsUZrHHQxC9zXyCRZLHOWFckQ+8YUETeOUSvX9RKw2Pg1+8x67iKpIGa5wCha/aeRe AQ18Fr5QsH2iRR7RjLN8zWN8xqtH/kmop6KTVzRmEyxTbpyUSo1AVRHsWJ9helF8xG8S zqP6Cxt5fSatOvQ9DPaLTrEx15dXmMjqJ3A2sSpVAd5CGsZJu3Y9TUMPYrp+bCA7qF4P L4I1SBbRKp63zrQ6+N5lUJmKWSGT7r+l8+OTno39O5JqjtnbAX44aTN996UM8lkfUT/A rUetghBmnB0gXhkdAvN/8udeXEs421cKQIWnFZfQHvvQqGgsFxEzeVzo70qaYYa80Z50 hrmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QMxmJuYD; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si10439139edr.611.2020.06.22.21.07.48; Mon, 22 Jun 2020 21:08:10 -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=@gmail.com header.s=20161025 header.b=QMxmJuYD; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732350AbgFWEDY (ORCPT + 99 others); Tue, 23 Jun 2020 00:03:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732320AbgFWEDP (ORCPT ); Tue, 23 Jun 2020 00:03:15 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFD0C061573; Mon, 22 Jun 2020 21:03:14 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b7so646056pju.0; Mon, 22 Jun 2020 21:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gIH44XP+3+d8u/o5onM5jscJ417kAbas5Jl16ovp4QI=; b=QMxmJuYDSsMGB3THi0GFjsWzTVsTtKNeQWjpu++s0JBZgTJw/d9Z0lRU3ljYQjn5Hs 08t5p8tjLUQvSV9s4enh2kw6ex9rvCfKwyXyzEnxHmti3gsye2etzlNYyAaAcVhOw+iu tpKfQsXSZOQnWWlw/WxtOr6VI6i9yb2CfXW+nTnZJKfRiWSo2/i6u1pLvQWRhkUHDPRp 10FXo2Ms2sqVIUI/W0WTMwwmdi/6lZAuzS5ccLslonZInG716q9FPSLSHZLcLOHl5xHd iQnuzSEonnFrGbwOjuGPL3+ysZwnKqwkFyus8RNepnYWwAp0xsg8Na5FtgS6jePCHJrF hIjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gIH44XP+3+d8u/o5onM5jscJ417kAbas5Jl16ovp4QI=; b=lEAADc/LMFgY4MKn3UVXtlehKQSBirBxtIAvO6ejfWSXP0Yf7wcH/InJjXoU2F+HEV FzF8IECnjyViLqn0V4GCs4fvxzyfYlg+4+HRpCbui/PyA3TFthNrOKEKp61ISLTOKDLp p9NiqVMmMwRIFJncCZteIC4/O1vcTDyTBehwXH/CMNVIST81JzPG0ltFmnWGTsXupCnO iBzxggLED3Y6sW/yeKpF8s+/cgaDOhH/nXTBGGf4k8SLJYPO6QmH0kFrZTP4+gwau3SN zEx6EYCguco5k2CSlzHxhmuqOYy2/VdBnQCLeZG/9UpNw4NlTfDN6y49YXvK2WMY13Kf TrCw== X-Gm-Message-State: AOAM533fK+4lUAQRgrU6twSsJT1y3KXqoCS9jjFcpIMnN1PHtbHuk4VI rKKzH3tibRYuaPY2nqaJXL6KfksVfss= X-Received: by 2002:a17:90a:5c85:: with SMTP id r5mr21583673pji.40.1592884993354; Mon, 22 Jun 2020 21:03:13 -0700 (PDT) Received: from sol.lan (220-235-126-59.dyn.iinet.net.au. [220.235.126.59]) by smtp.gmail.com with ESMTPSA id n64sm12442315pga.38.2020.06.22.21.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 21:03:12 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH 17/22] gpiolib: cdev: report edge detection in lineinfo Date: Tue, 23 Jun 2020 12:01:02 +0800 Message-Id: <20200623040107.22270-18-warthog618@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623040107.22270-1-warthog618@gmail.com> References: <20200623040107.22270-1-warthog618@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Report the state of edge detection for a line in the gpioline_info_v2 returned by GPIO_GET_LINEINFO_V2_IOCTL, and indirectly for lines watched by GPIO_GET_LINEINFO_WATCH_V2_IOCTL. Signed-off-by: Kent Gibson --- drivers/gpio/gpiolib-cdev.c | 14 ++++++++++++++ drivers/gpio/gpiolib.c | 2 ++ drivers/gpio/gpiolib.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index d4a22d78953f..7ba0929b2741 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -566,6 +566,12 @@ static void edge_detector_stop(struct edge_detector *edet) static int edge_detector_setup(struct edge_detector *edet, struct gpioline_config *lc) { + struct gpio_desc *desc = edge_detector_desc(edet); + + if (lc->edge_detection & GPIOLINE_EDGE_RISING) + set_bit(FLAG_EDGE_RISING, &desc->flags); + if (lc->edge_detection & GPIOLINE_EDGE_FALLING) + set_bit(FLAG_EDGE_FALLING, &desc->flags); if (lc->edge_detection) return edge_detector_start(edet); return 0; @@ -1574,6 +1580,14 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc, } lc->edge_detection = 0; + if (test_bit(FLAG_EDGE_RISING, &desc->flags)) { + lc->flags |= GPIOLINE_FLAG_V2_EDGE_DETECTION; + lc->edge_detection |= GPIOLINE_EDGE_RISING; + } + if (test_bit(FLAG_EDGE_FALLING, &desc->flags)) { + lc->flags |= GPIOLINE_FLAG_V2_EDGE_DETECTION; + lc->edge_detection |= GPIOLINE_EDGE_FALLING; + } spin_unlock_irqrestore(&gpio_lock, flags); } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 517c99ddf6c8..a5f2795e17b7 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2041,6 +2041,8 @@ static bool gpiod_free_commit(struct gpio_desc *desc) clear_bit(FLAG_PULL_UP, &desc->flags); clear_bit(FLAG_PULL_DOWN, &desc->flags); clear_bit(FLAG_BIAS_DISABLE, &desc->flags); + clear_bit(FLAG_EDGE_RISING, &desc->flags); + clear_bit(FLAG_EDGE_FALLING, &desc->flags); clear_bit(FLAG_IS_HOGGED, &desc->flags); #ifdef CONFIG_OF_DYNAMIC desc->hog = NULL; diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 2dee4e1e12dc..1dc6d2b191af 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -114,6 +114,8 @@ struct gpio_desc { #define FLAG_PULL_UP 13 /* GPIO has pull up enabled */ #define FLAG_PULL_DOWN 14 /* GPIO has pull down enabled */ #define FLAG_BIAS_DISABLE 15 /* GPIO has pull disabled */ +#define FLAG_EDGE_RISING 16 /* GPIO CDEV detects rising edge events */ +#define FLAG_EDGE_FALLING 17 /* GPIO CDEV detects falling edge events */ /* Connection label */ const char *label; -- 2.27.0