Received: by 10.213.65.68 with SMTP id h4csp744356imn; Fri, 6 Apr 2018 08:11:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ETp5UBwS/FA8l0oojvCbRtLwafpSadGSZuOEMFHKHuRjg/RwjnwkspOznzZwj3iWyH8Mz X-Received: by 2002:a17:902:7688:: with SMTP id m8-v6mr17210515pll.340.1523027462832; Fri, 06 Apr 2018 08:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523027462; cv=none; d=google.com; s=arc-20160816; b=uruJHjNz0M7yOd7Q3/O+OEDujAWCDrVsVr/RDFruz+i9KNzhTvc9Vtd0aSgUR56pdT IYyHrXn0kFnNW9o3hbG7CqfnbX4p3w9L7z2j/lXQZJlVUHx5Z+RNdPhyI4f6TWuJujTk Xsw87PxSMAX2jUQgOzK9uCfrSCtBuyN6HuikBiRFUR5H1c9Mp6h8JIzaj/rSMCh0enYA r3oAY0miptci15OxsDSmVci29yIa+wkd16+8TXUCqfyjaJbjB5b1Abeteu/XARfYVKSI MMn4bMSkb352rKyI2mqeRxaX2PZRLz004b1MkolPRqwDVc0g49BxVA++d2xgbdhBV+nM ruDg== 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:subject:cc:to:from:date :arc-authentication-results; bh=SUbvO1vo95DzE9NZ3hf7XYdP9T9rlBu8zwhtvwXCFew=; b=mHCzvye8+EmmUjWcPhSm/TvrXGpO010dB/sZtM6HIQtxJlerJEJehhibZAiz4S0nAS twkaiPuGudItcLf03KHRQoygSyDVZ2aU17s3oHBLJD9uRJnShJW5Bk4Kt5vzq79S0I9+ jfP1c/+wXNZk2IeRBc/TKuE+7Gpmgt5fL6X8clGMKi3cu68dyBhGNx2PXuwLEGRXdekY q94BsqMB+NOqiZXMztfn6X16Eh/p5F/kX5kR27eS79o28h5RR1r5eDkJ7Tfw2nmjBvlW lCl7KCj9oFUiOTjM48GgD46Vgi8y9LOoWQBGAOsZuyZRmDqNGBJvzVDsMpiuCImaPiKi dWfg== ARC-Authentication-Results: i=1; mx.google.com; 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 c12si8158910pfe.133.2018.04.06.08.10.49; Fri, 06 Apr 2018 08:11:02 -0700 (PDT) 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; 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 S1751852AbeDFPIb (ORCPT + 99 others); Fri, 6 Apr 2018 11:08:31 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:52217 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751726AbeDFPI1 (ORCPT ); Fri, 6 Apr 2018 11:08:27 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4DDFAB94C5E1E; Fri, 6 Apr 2018 23:08:22 +0800 (CST) Received: from localhost (10.202.226.42) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 6 Apr 2018 23:08:22 +0800 Date: Fri, 6 Apr 2018 16:08:13 +0100 From: Jonathan Cameron To: William Breathitt Gray CC: Jonathan Cameron , , , , , , Subject: Re: [PATCH v5 5/8] counter: 104-quad-8: Documentation: Add Generic Counter sysfs documentation Message-ID: <20180406160813.00007982@huawei.com> In-Reply-To: <20180402194136.GA11724@sophia> References: <20180324172140.382659e2@archlinux> <20180402194136.GA11724@sophia> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.42] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 Apr 2018 15:41:47 -0400 William Breathitt Gray wrote: > On Sat, Mar 24, 2018 at 05:21:40PM +0000, Jonathan Cameron wrote: > >On Fri, 9 Mar 2018 13:43:19 -0500 > >William Breathitt Gray wrote: > > > >> This patch adds standard documentation for the Generic Counter interface > >> userspace sysfs attributes of the 104-QUAD-8 driver. > >> > >> Signed-off-by: William Breathitt Gray > >A few minor comments inline... > >Some of this seems generic and common enough you should just put it in the > >main docs straight away rather that waiting for more devices to use it. > > > >Jonathan > > That sounds reasonable so I'll move some of these into the main Generic > Counter sysfs documentation file. > > Some comments inline follow. > > William Breathitt Gray > > > > >> --- > >> .../ABI/testing/sysfs-bus-counter-104-quad-8 | 115 +++++++++++++++++++++ > >> MAINTAINERS | 1 + > >> 2 files changed, 116 insertions(+) > >> create mode 100644 Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 > >> > >> diff --git a/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 b/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 > >> new file mode 100644 > >> index 000000000000..4269b438185a > >> --- /dev/null > >> +++ b/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 > >> @@ -0,0 +1,115 @@ > >> +What: /sys/bus/counter/devices/counterX/countY_count_mode > >> +KernelVersion: 4.17 > >> +Contact: linux-iio@vger.kernel.org > >> +Description: > >> + Count mode for channel Y. The preset value for channel Y is used > >> + by the count mode where required. The following count modes are > >> + available: > >> + > >> + Normal: > >> + Counting is continuous in either direction. > >> + > >> + Range Limit: > >> + An upper or lower limit is set, mimicking limit switches > >> + in the mechanical counterpart. The upper limit is set to > >> + the preset value, while the lower limit is set to 0. The > >> + counter freezes at count = preset when counting up, and > >> + at count = 0 when counting down. At either of these > >> + limits, the counting is resumed only when the count > >> + direction is reversed. > >> + > >> + Non-recycle: > >> + Counter is disabled whenever a 24-bit count overflow or > >> + underflow takes place. The counter is re-enabled when a > >> + new count value is loaded to the counter via a preset > >> + operation or write to raw. > >> + > >> + Modulo-N: > >> + A count boundary is set between 0 and the preset value. > >> + The counter is reset to 0 at count = preset when > >> + counting up, while the counter is set to the preset > >> + value at count = 0 when counting down; the counter does > >> + not freeze at the bundary points, but counts > >> + continuously throughout. > > > >This worries me a little in that you will end up with all sorts of subtle > >variations around these concepts and hence end up with an impossible to > >generalize userspace interface... > > There is a potention for a deal of variations due to the diverse range > of counter devices out there -- in particular, I worry about the > confusion of similar functionality using slightly different names (e.g. > "Normal" may be named "Continuous" in another driver) and vice versa. > Perhaps I should standardize these count modes in the main Generic > Counter sysfs documentation file. I would definitely standardize these. Any new type can then be added. At least for devices that do the same thing we'll have the same naming! > > A difficulty with standardizing these count modes is how to handle > description cases such as "Non-recycle" mode whose limit range is that > of the count register size (24-bit). This limit range would be different > in a device of a different count register size; for example, the LS7366R > is a 32-bit version of this counter device with the same interface, but > which has a 32-bit limit in "Non-recycle" mode. However, this may not be > such a problem since the datasheet for these devices does use a more > generic description of this mode which I can utilize: "counter disabled > with carry or borrow, re-enabled with reset or load." Describe the range as a separate attribute? > > The count_mode attribute is core enough to Generic Counter paradigm that > I expect it to appear in many Counter drivers, so I'll move this to the > main Generic Counter sysfs documentation file for better standardization > of its modes. > Great > > > >> + > >> +What: /sys/bus/counter/devices/counterX/countY_count_mode_available > >> +What: /sys/bus/counter/devices/counterX/countY_noise_error_available > >> +KernelVersion: 4.17 > >> +Contact: linux-iio@vger.kernel.org > >> +Description: > >> + Discrete set of available values for the respective Count Y > >> + configuration are listed in this file. > >> + > >> +What: /sys/bus/counter/devices/counterX/countY_direction > >> +KernelVersion: 4.17 > >> +Contact: linux-iio@vger.kernel.org > >> +Description: > >> + Read-only attribute that indicates the count direction of > >> + Count Y. Two count directions are available: Forward and > >> + Backward. > >Is this telling us which way it is currently counting? I would imagine > >it's generic inversion control, but this description doesn't make that clear. > > The nature of quadrature encoding allows direction of movement to be > determined -- in terms of count data this direction represents whether > the count value is increasing or decreasing. For the 104-QUAD-8 device, > this "direction" is a read-only value provided by the hardware > evaluation of the A and B input lines. Ah fair enough. I would add a bit more text to give that quadrature example (I'd forgotten about that and was thinking of completely differently). > > However, I can imagine some simple counter devices permitting write > operations to configure a direction as a form of inversion control for > the counter. This attribute is generic enough to include in the main > Generic Counter sysfs documentation file, so I'll move it there and add > a more detailed explanation of its read and write functionality. I would be careful about having the same attribute for those two use cases as they aren't really comparable. > > > > >> + > >> +What: /sys/bus/counter/devices/counterX/countY_enable > >> +KernelVersion: 4.17 > >> +Contact: linux-iio@vger.kernel.org > >> +Description: > >> + Whether channel Y inputs A and B are enabled. Valid attribute > >> + values are boolean. > >Why would you disable them? I'm unclear on what userspace would do with this. > > Truthfully, I haven't found much use for this functionality in my > applications, but several devices provide it so I have exposed it here. > I believe the intention is to allow users to pause a counter temporarily > (i.e. by ignoring changes on the A and B inputs) and then pick up where > they left off. > > I think a possible real life use case would look like this: a conveyor > system tracks total movement, reaches the end of a production run and > pauses the counter, rehomes the conveyor belt, then restarts the counter > and continues counting where it left off. > > This count enable functionality is generic enough that I can also move > it to the main Generic Counter sysfs documentation file, but I'll give > it a more generic description without referencing the A and B input > lines. > That's a good enough explanation. I'd add the conveyor example to the docs so people don't wonder what sort of thing it is for in future! > > ...