Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5538735ybc; Wed, 27 Nov 2019 05:40:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyXnMoHoTE+q4orn+piHJPpkptedhPFhGazNMrHQLZXvkaUb8c8OdOwkZcmQ/E0FnwjqWg/ X-Received: by 2002:a50:ac7c:: with SMTP id w57mr32120513edc.155.1574862055817; Wed, 27 Nov 2019 05:40:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574862055; cv=none; d=google.com; s=arc-20160816; b=nTuS5jUaZmz2N5SH36FSfuC9w1Ela3/k3KjQSykKmQBw7pYPREXMx2aKHjCR25I/DN j1UbINvkZt7yby33FSuDHyE4DL1ioSIZ0cAcA1QrTiV3DHEhgTRYyPTcUMe0X7f3u5w6 x70rABLfB5Vya7kDj5Nn4zaypa4T9sh1ZPQCgTxfjlurfcEOFMJqtMQB8rMqy6gWVkEa oZN7EFa2RB4Am47nh5alKEwBIxmog6T7UTOMwuZP/2S00v9g++stp9PB78TwjGVjXj1M QxNLShat5G1bViG+LnTCf+CxqPCc/MVtgD6Ra5bdiiFt83WnoLQcOOdbffSGQEGGkNs+ eFYg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ycif2CI2BztFtL8UjZ1dZuqTWMkeyaIvGznAKKh93ok=; b=JKJfmjMayzhXxIxxvcdrVVtYJkwmgoHVejVCLOM17oDOTwve+Mes3R/W/Qb/KGucZj LfEO96SnsfAZZFtxpQ51Y9SircQEXaZ/kg7fQb1Wep4HcFwZfb/47JxhjS+UJpMXgHzW JUMCWbqTm/QukGz4Wrlp2/BJVSKy/1Ri4padjbw4zrX79RfDfBXE5mTmCiiEyCk6Udzt dwvwiClHte/v74T0DQ730oXfcwVIYdEiFUH5GLPkrB7EtHMCFRQW8ADHwzfpveY7964V opvsm4bwBGNlniLDjcnR3AggyfiefgUUgGtngdCxsw6HQdf2/Xa002jOuQJO2/tc5U3Z D50g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=JBqmckjB; 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 w10si9761463eja.116.2019.11.27.05.40.32; Wed, 27 Nov 2019 05:40:55 -0800 (PST) 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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=JBqmckjB; 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 S1727051AbfK0NfX (ORCPT + 99 others); Wed, 27 Nov 2019 08:35:23 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51664 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbfK0NfX (ORCPT ); Wed, 27 Nov 2019 08:35:23 -0500 Received: by mail-wm1-f68.google.com with SMTP id g206so7126867wme.1 for ; Wed, 27 Nov 2019 05:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ycif2CI2BztFtL8UjZ1dZuqTWMkeyaIvGznAKKh93ok=; b=JBqmckjBRNdk5FeGal9TmbFsNCpz0NQ07G92pUX8JiEGLCSEy9SUBoCFcLagnyNaGz ejT2+uTlCAzCSwAS6f9Ue/oo9luJhEGTSQcBDD0cRztEOymhK9w2rmtlW11M0LQ9Tg60 sBPxMu0ELDbhLcWEnxJ9R4GphjlfUwDNoAcVggdcRLneL32yQMp86XQPuJCO/0doD+K0 iFZY+VuZ+VUR5yuIxyJ3sV6Jp0I1kdAKl+umtQWOgmv9ZGFwfzjn1vYbBupjVBPvGusx npweITC1Coe8/o3vegVcHXs4JC9z77WtGpqUvGYqN4drI5J2aBVKrBXg4lYAluz3Kiux 5WXw== 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:mime-version :content-transfer-encoding; bh=ycif2CI2BztFtL8UjZ1dZuqTWMkeyaIvGznAKKh93ok=; b=Tt5fcyRbw/7S2Vi3FMWD2ZKswPqfEshxmC1y6d28CX286HsICLP/fccrNTxwVkb5FS m2xWiQbRfZmO6BUNWq4S3pvUb/B3jOP0n/tLkPLuTV5hfqvflk9kbErLjtuad1rh8puZ tHa4WfaOCBmsULNQWrI5kCAEhDF92QhfuGiGM+xyL9x7kGqrhfF4ADzhCrIXskUIeaKu ZAoOunrB0n/uLriq5AekCEsur8f8tXkfMAycrTjYPv3ihC8hN2tUzodWrxC5rnmByLbj 8Aypto7ils+vpOymfQ+nX0sJsOk1EkJZ/n3PFoeHYGL4QFZapqXYqCDAh2TtHlVnHkXO xUlg== X-Gm-Message-State: APjAAAWGhipP+owAqY+W4NFCJBzyuYybxQtRVAaurpB6hVk9RLSnoeqU P/SwBeDNruZq0xXvlotMzSMDRA== X-Received: by 2002:a1c:39c2:: with SMTP id g185mr4345040wma.88.1574861720171; Wed, 27 Nov 2019 05:35:20 -0800 (PST) Received: from debian-brgl.home (lfbn-1-7087-108.w90-116.abo.wanadoo.fr. [90.116.255.108]) by smtp.gmail.com with ESMTPSA id k18sm19663687wrm.82.2019.11.27.05.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 05:35:19 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 0/8] gpiolib: add an ioctl() for monitoring line status changes Date: Wed, 27 Nov 2019 14:35:02 +0100 Message-Id: <20191127133510.10614-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 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 From: Bartosz Golaszewski When discussing the recent user-space changes with Kent and while working on dbus API for libgpiod I noticed that we really don't have any way of keeping the line info synchronized between the kernel and user-space processes. We can of course periodically re-read the line information or even do it every time we want to read a property but this isn't optimal. This series adds a new ioctl() that allows user-space to retrieve a file-descriptor which can then be polled for events emitted by the kernel when the line is requested, released or its status changed. This of course doesn't require the line to be requested. Multiple user-space processes can watch the same lines. The first couple patches just fix some issues I noticed when implementing the new interface. Patch 7/8 provides the actual ioctl() implementation while patch 8/8 adds a simple user-space program to tools that can be used to watch the line info changes. Bartosz Golaszewski (8): gpiolib: use 'unsigned int' instead of 'unsigned' in gpio_set_config() gpiolib: have a single place of calling set_config() gpiolib: convert the type of hwnum to unsigned int in gpiochip_get_desc() gpiolib: use gpiochip_get_desc() in linehandle_create() gpiolib: use gpiochip_get_desc() in lineevent_create() gpiolib: actually protect the line event kfifo with mutex gpiolib: add new ioctl() for monitoring changes in line info tools: gpio: implement gpio-watch drivers/gpio/gpiolib.c | 267 +++++++++++++++++++++++++++++++++--- drivers/gpio/gpiolib.h | 4 +- include/linux/gpio/driver.h | 3 +- include/uapi/linux/gpio.h | 36 +++++ tools/gpio/.gitignore | 1 + tools/gpio/Build | 1 + tools/gpio/Makefile | 11 +- tools/gpio/gpio-watch.c | 114 +++++++++++++++ 8 files changed, 415 insertions(+), 22 deletions(-) create mode 100644 tools/gpio/gpio-watch.c -- 2.23.0