From patchwork Fri Sep 9 12:13:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 604665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0DE4ECAAA1 for ; Fri, 9 Sep 2022 12:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbiIIMRj (ORCPT ); Fri, 9 Sep 2022 08:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbiIIMRJ (ORCPT ); Fri, 9 Sep 2022 08:17:09 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 764681707D for ; Fri, 9 Sep 2022 05:14:32 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id b17so2421359wrq.3 for ; Fri, 09 Sep 2022 05:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=kU3PArCQqxQipCIfucwesyNxkP/aJS3R0eM5cUNlEUA=; b=Ui/OmfngH60cOIrYZk95zbIeb/2CDhLAf86C5SETenp39ghQqRZG8qx+UR3Hc6R+nU WbPoYPqBmWyiCQA6peYymCZUDHoZZ9M0aQRX2rbmhWaCLgXrJJzi10EyhOHAfIKTC5oa B7yq4PgzU1xJ46WWob3oyz3oMsAhKT6ebysK7pl7dlHAQNK0/8zGIZ3TiU29Tu8Jaj/W VCOB236sZkEshou5uSxp5rhr/EOoBZTeF0L5eyDHKCzgDuzcu7+0LbVNHWuxqcjeJrJ+ ShicXWNe/sBC1TVAKcJCXZaeXLpCTNrwMqsZnPbtG/A0wu+jrLhgGVUkk1CBmiJP+7dC ONVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=kU3PArCQqxQipCIfucwesyNxkP/aJS3R0eM5cUNlEUA=; b=L0HbPkHgquQdAQMuiktEkgHOQo6R7W4/ZzAeZjmPV8cYDUxkKHUG0c+Y6RUIUcsVww SX39OFJp/MuEtEPNwV1uEO4FFcDTOJxBKnvS8EFmFlf5NQregRn5PP7OCi9fRJd9rFpg RSxZV5BcEIrUwu4vU9FvQ02jLrOLA1fYLCQVQL90xbHqXvx/3BdZngiQ9t/0mQI2YOeb qw3lYQrpghJdMkEFBg/DsRRRF46FQiExK6rze7xetO6uJhrNg7sOqwo9FLOaHxmot5LV jn/Dl8FZjIy1Dp0IY8NseUc1PXslaI6RNG0UQgOb1ypgkeL9BEuqxo5Xn7aevuTvgn7p nh6Q== X-Gm-Message-State: ACgBeo3OM+FvU+Dy8RnkwXUx6HocxMKcBeqhmi7Brm8pRnIB+5AY9EOs LoEHa5T1MKwPTQg0Tl7TTouaOQ== X-Google-Smtp-Source: AA6agR7opbqPg1bHkUfjnVa9VnfIISVE6LHws7dw0+EJuCOY33VPET8FWL9UrGbpIzMCSAu0cP0ZYw== X-Received: by 2002:adf:d1ef:0:b0:228:a9ee:8f13 with SMTP id g15-20020adfd1ef000000b00228a9ee8f13mr7523722wrd.686.1662725614654; Fri, 09 Sep 2022 05:13:34 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:a421:c10c:c626:3f52]) by smtp.gmail.com with ESMTPSA id l10-20020adfe58a000000b0022863395912sm379005wrm.53.2022.09.09.05.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 05:13:34 -0700 (PDT) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 0/2] gpiolib: export the consumer's PID to user-space Date: Fri, 9 Sep 2022 14:13:27 +0200 Message-Id: <20220909121329.42004-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org I've been asked several times independently over the course of last months for a way to figure out the PID of the user-space process that's holding a specific GPIO line. This does sound like a valid use-case as the user may create a background process that requests some lines and then want to kill it to release those lines. These patches propose to extend the gpio_v2_line_info struct with the consumer's PID which is set to the process ID for user-space consumers and 0 for kernel-space ones. Bartosz Golaszewski (2): gpiolib: un-inline gpiod_request_user() gpiolib: cdev: export the consumer's PID drivers/gpio/gpiolib-cdev.c | 2 ++ drivers/gpio/gpiolib.c | 33 +++++++++++++++++++++++++++++---- drivers/gpio/gpiolib.h | 14 +++----------- include/uapi/linux/gpio.h | 5 ++++- 4 files changed, 38 insertions(+), 16 deletions(-)