From nobody Thu Apr 2 21:29:38 2026 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 68C34C54EE9 for ; Tue, 20 Sep 2022 13:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbiITN4W (ORCPT ); Tue, 20 Sep 2022 09:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231405AbiITNzt (ORCPT ); Tue, 20 Sep 2022 09:55:49 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2803686F for ; Tue, 20 Sep 2022 06:54:39 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id z2so3985593edi.1 for ; Tue, 20 Sep 2022 06:54:39 -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=DLUl+3DSxpghb+4XVDEdCI4TXeLI6nIF01m7+R/dTes=; b=I03TMuUOg4ZdeMC99+46z4AfULcPnl4IXNk6St0H/OKqsWPQvEg0sNSTPnFK6EVnGW WGq/s2WMelHwnhwaPR+Ua9DCI+Qq+MM7r3lbbA+55ln63ju/jgAKkISyQHxnr7EQaBjm 528ryRJ+b7y9tYmOGNbKgXB9xC71hNBVCiRyWb9BXk2DOnIy0dmNuUuskKLpxp2BdZe0 W8giLV38QuUgRcofNnkpf42Dw8r/AIIECpxoOoNgrRNK7u0ozVbITGYe2sgY+/2VUP5E HyPfezqZlwFh9nnsPL594U+aEwHaQ6xz38/mxiVbdvummsNAni2pfuoNkc2GIK12gEK6 5F1w== 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=DLUl+3DSxpghb+4XVDEdCI4TXeLI6nIF01m7+R/dTes=; b=GC8oBszxLCX/cv7FtIbT7nNIFsS51QCT2xe39Uqc73l4pV56ANSTQrZZ52ARDsOX6E DsKGIkHFvYipTkgp0L8rGKAzVxlExxhCXAwbygNJHHktLZ7RmVliicKRTbP8FrF+vzRj R5w3fLntr5dRr1Q0T1s2WxAU2AidSbEyalFRTvjzUV5RIcrMqu/TXMELj2zJHqhwwkMN IBWI/dM7KIj2Jc8e1405rmDFepHUyaT7rBxsh8CG51znq3OslkfCu0WvWfXhnq8PxmLV 53+VfPTMhU9y750Z6/Sz0ayxAFxoD5OogLxRjVxN3WsVeLbjG6oQ4X1nkouOPRBGDzFG DSlg== X-Gm-Message-State: ACrzQf3S2wXoq3JVK1zlkYewr36bqYur5YnYOPV3FQARIuy18r7qGBLo 6p4ewrDFr126ntD+ZllpWPLINA== X-Google-Smtp-Source: AMsMyM7CtiJE1Ez0ADzDOiMGkV/6ZNzyWNnYrCEosRVgLIdloLixcmJXoaOoWiAFgtSzL9yBSbudLA== X-Received: by 2002:a05:6402:1f0e:b0:453:a419:b3a0 with SMTP id b14-20020a0564021f0e00b00453a419b3a0mr14412561edb.124.1663682077666; Tue, 20 Sep 2022 06:54:37 -0700 (PDT) Received: from brgl-uxlite.. ([77.241.232.28]) by smtp.gmail.com with ESMTPSA id m23-20020a509317000000b0044f21c69608sm100503eda.10.2022.09.20.06.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:54:37 -0700 (PDT) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH] gpiolib: cdev: add fdinfo output for line request file descriptors Date: Tue, 20 Sep 2022 15:54:35 +0200 Message-Id: <20220920135435.15593-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add fdinfo output for file descriptors created for user-space line requests in GPIO uAPI v2. The fdinfo file now contains the name of the GPIO device that is the "parent" of the request as well as offsets of the lines requested. This allows user-space to parse the /proc/$PID/fdinfo entries and deduct the PID of the process that requested a specific line. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib-cdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index f8041d4898d1..0f7b5562c410 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -1497,6 +1497,21 @@ static int linereq_release(struct inode *inode, stru= ct file *file) return 0; } =20 +#ifdef CONFIG_PROC_FS +static void linereq_show_fdinfo(struct seq_file *out, struct file *file) +{ + struct linereq *lr =3D file->private_data; + struct device *dev =3D &lr->gdev->dev; + u16 i; + + seq_printf(out, "gpio-device:\t%s\n", dev_name(dev)); + + for (i =3D 0; i < lr->num_lines; i++) + seq_printf(out, "gpio-line:\t%d\n", + gpio_chip_hwgpio(lr->lines[i].desc)); +} +#endif + static const struct file_operations line_fileops =3D { .release =3D linereq_release, .read =3D linereq_read, @@ -1507,6 +1522,9 @@ static const struct file_operations line_fileops =3D { #ifdef CONFIG_COMPAT .compat_ioctl =3D linereq_ioctl_compat, #endif +#ifdef CONFIG_PROC_FS + .show_fdinfo =3D linereq_show_fdinfo, +#endif }; =20 static int linereq_create(struct gpio_device *gdev, void __user *ip) --=20 2.34.1