Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp941352rdd; Wed, 10 Jan 2024 04:21:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlyIXQP2JStcCzIcYUQj2dz/YZBMxx6cWwhr7Gy0lhIMULPr1Pp0JA0on+DyhbgA89IXhn X-Received: by 2002:a05:622a:13:b0:429:b786:dc4c with SMTP id x19-20020a05622a001300b00429b786dc4cmr705589qtw.33.1704889267145; Wed, 10 Jan 2024 04:21:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704889267; cv=none; d=google.com; s=arc-20160816; b=Lukmcp//Q9huo525YzYKMpKAco8+ZJFHcVbVTpo4SPMP95pzD7O/KVC6Aj1Th5Ci7T 6Yh4wBk3kAYMJgr8+XTfsHT0ZmJaPRpwQxRnfyPex6uvM0+04c+qjELUZD12+gPo8qy5 OT3lDxc+hLCPt5jITMsTfCmEdAA5Cz3nfUOAIW363Gq/ZXHI8A+2ebhX4aXYSfMOJrWQ aKeHm5RD0yhKXu5cLmtRrI65o86LPTDEMxJQqdelRaG9X0x1kh2lfP8gGcwZO0Ip8+r9 bRRRGhrQakandHolVL+/tUW6B6wm4tiKxPOX1Q75v5C7gXxtL48sYCz/aFe0IFlP9L/S 2QMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=qABraMg1MqzSU9nOWGUzzRUAdQ8CtJE/sRdcl4zrjIQ=; fh=+Mkkx1P9eQaIgnIMq9QhtkCsLxC1VeZTho6ZPreU0oA=; b=fgBw4N3OjUAIkLlvXaGgK+B+LpIZhoOF34wo+NSzmXNf6BBxR/7M2G4hKlMQzxTDaY n8zxqwnc5Pv76xHbcmys+cBEed/6MM64wPniQ0UtyokIIJRTm9y2hhOA61Tz2FKCvYK+ 6hqasSRF13zkIxmh3uYCJweuKgq3r8/gJEogov20DWkfD9HoT2egUCFOy8S4BbXbcRGL LTmoCTtAk+bHosTe2d0EG7fRwmwFZ/TUFLeKfJLo5LrSWDMKZA5PG/2sEnyeXcTxf2BB /aeOq0NMBdBUbNqewgx+9QT5dwaCwsDDAkMxpdtJkK6DrhsxvJ81aW0/upf4G9/DjADc DW5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=WqwrGhw2; spf=pass (google.com: domain of linux-kernel+bounces-22164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u3-20020a05622a17c300b00427f11eda0dsi4248841qtk.525.2024.01.10.04.21.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 04:21:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=WqwrGhw2; spf=pass (google.com: domain of linux-kernel+bounces-22164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DD2481C22203 for ; Wed, 10 Jan 2024 12:21:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EE0482C9; Wed, 10 Jan 2024 12:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WqwrGhw2" Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AA3A3FB07; Wed, 10 Jan 2024 12:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-5e86fc3f1e2so36080527b3.0; Wed, 10 Jan 2024 04:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704889255; x=1705494055; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=u/XOirxmS0fe3j5M8XRku3KwS+azLbDAKTxIaDOOT14=; b=WqwrGhw2XPa5MdOFJUuM/ttuWhal471USxxLd3ygIT/hq5Ziw1GJS8XM/YK2ugjuvs pq3RvDJW7HG6usLiricwvrrlPHPvdHSSsSfD7rOkT0Y+/HKhVkwErDg/fZi/zQ8uGiJZ zFf8Sl2L5AJ6UGkN6QP8FDn7z60P8Fd5K8IxydARoL9VLIbfuXqYFk+dtqdvGY5Y8bU0 y9alE1QJRLGUMn9rwC8mhNV1YnXO8DlzkrBwtzKvRsLbpeXicIN6VNjXS4yEDvaN/+SB hVFDOPx44reBzTortPlHeYMIDVCJ5psz8MYQVMYEDE06723YzWCXWC4iG0bmnUenQkGH ieOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704889255; x=1705494055; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u/XOirxmS0fe3j5M8XRku3KwS+azLbDAKTxIaDOOT14=; b=xJU6CTm3bUlYONNkrT9AHy7c7A0/cgK+xJmxu9p9HVmxCXjB+jqDHFRJU8mhdwfmqp DHFvcX39ISdIpr0fqI+1Meo9whqiIzVj2NQAWwdqGRYgFt4aNaNqoFHB2Gsxj9C/1mE8 DzwgvL4mDVbxJhmOugjrlBy6uzClac3biVe9pULq9ooU/FSWBLkE1axvtvD/WQ/8//zu 1KHBA6/ANHcHBsucx2P4TJSlReSS1/+w61gIr/cWcPfOkfrdTBkO3E6l45iMbWHX9+p4 YoXuX73GaSHdHZOT5Q/cjLNrzQzFrop9GveVsNN9ZBndfaKm5f/CMeweoR/ZclPteGRp ZwPQ== X-Gm-Message-State: AOJu0Yyr+b/izqSXoGx1aEnHAn0A3/3xn1jjxDHmqEjH7zdYuh/ljvAA zGdZTjD61f5H0x1Lv6PNYG9MzPaBFgrZElnKziPM8oLu5Qw= X-Received: by 2002:a81:8885:0:b0:5f1:3298:611 with SMTP id y127-20020a818885000000b005f132980611mr940074ywf.48.1704889255114; Wed, 10 Jan 2024 04:20:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240109135952.77458-1-warthog618@gmail.com> <20240109135952.77458-2-warthog618@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Wed, 10 Jan 2024 14:20:18 +0200 Message-ID: Subject: Re: [PATCH 1/7] Documentation: gpio: add chardev userspace API documentation To: Phil Howard Cc: Kent Gibson , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org, andy@kernel.org, corbet@lwn.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 10, 2024 at 1:40=E2=80=AFPM Phil Howard wr= ote: > On Tue, 9 Jan 2024 at 14:00, Kent Gibson wrote: .. > > + Read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid rei= nventing > > + kernel wheels in userspace. > > I realise this is in part an emotional response, but very much > "citation needed" on > this one. While I believe Kernel drivers for things are a good idea, I > don't believe > userspace libraries are necessarily bad or wrong. They might be the first > experience a future kernel dev has with hardware. Either way there are mu= ltiple > ecosystems of userspace drivers both existing and thriving right now, and= there > are good reasons to reinvent kernel wheels in userspace. > > At least some of these reasons relate to the (incorrectly assumed) > insurmountable > nature of kernel development vs just throwing together some Python. Inclu= ding > this loaded language just serves to reinforce that. > > You catch more flies with honey than with vinegar, so I'd probably soften= to: > > Before abusing userspace APIs to bitbash drivers for your hardware you sh= ould > read Documentation/driver-api/gpio/drivers-on-gpio.rst to see if your dev= ice has > an existing kernel driver. If not, please consider contributing one. I believe this note was motivated by the quite popular pyGPIO for RPi and MRAA for some platforms, which are the examples of how _not_ do things. .. > > +Each chip supports a number of GPIO lines, > > +:c:type:`chip.lines`. Lines on the chip are identified = by an > > +``offset`` in the range from 0 to ``chip.lines - 1``, i.e. `[0,chip.li= nes)`. > > I don't recognise this syntax "`[0,chip.lines)`", typo, or me being cluel= ess? It's called "open interval", a mathematical term. .. > > + - - ``EFAULT`` Wondering if these constants can be referenced via % and if it makes sense. .. > > +The size of the kernel event buffer is fixed at the time of line reque= st > > +creation, and can be influenced by the > > +:c:type:`request.event_buffer_size`. > > +The default size is 16 times the number of lines requested. > > This might explain why I could never quite get high-speed pulse counting = to feel > right. Thank you! GPIO is just not a good tool for this kind of measurement. --=20 With Best Regards, Andy Shevchenko