Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1482863rwb; Sun, 18 Sep 2022 08:08:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NcAdhrwlhximl6Yyr0i0m21EEc9xkuo+QyF8G9kniJK3j8My5X7cZI8dr9TQWQwhyoV8o X-Received: by 2002:a17:906:cc4a:b0:779:ed37:b5a3 with SMTP id mm10-20020a170906cc4a00b00779ed37b5a3mr9854900ejb.626.1663513734631; Sun, 18 Sep 2022 08:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663513734; cv=none; d=google.com; s=arc-20160816; b=hh3RNpJIjLgCBbmx5g4Eex0yzgAhrasggVDLQWwssReIYHbtfPyofLrPC+32VzzNHs s+N6zfWO1PtJhwsj7KqfZDs3nzIgGXrHD5G5ALe0usUOrLd67F9sJ3MHrBLVr7oVT+Jx QFXkmxdJFb2rOgARyoEAsqV/wFA+BtfANP0atWO7naxqqrcilFsh7rtRUpnJkm/hEvT6 oYKZjocQ+DyfpI9/vzBuODEc7JUyLtM3XtBmwaLUdhOp4ku+nvAIMUZ/Qht1/k+BDcgX uAmvxe8rDDcTbogfnWgQWlE+wTKXmE96gFwvyK2HqKdCRNAGFKPfvMqxreQdj5jzUSdl zdGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=13QwewIwzroQU6uQsOD5mJo714A427B3glcmrYb0jfs=; b=gJvnYJrUioAixW7Q4X9S2/N5ijyL9RxsDHSXui/rqJs9zYnxfJiYzNYuEnvMujjOLS Lieze21+lA7bTSP5gPsolHqarNGs68DA7LRaTV/FnceyIviqE8qhQB9UB16l98YzJ2ji cnvlSkcMdaYGLvgFR+f4xstYUUcp2t/ct05rxUxRaT/UJgnTbw35AGMc+WeTBNs2b6/f YOZ4HCMaUP1isuxyittY7/whceXVA7FmSIbCcdFJQbnexpx3jFHbfI6VTVhZ9N5JX5WG 5J6j4mq/8XfqM6WKYZYFNynFz8FPrRgvoUSiDkNjoKF+H60NZVnQXvGhXAoXo0yvMBjR x1OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qr7qp0UR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a508706000000b0044f1d356ab3si6847985edb.350.2022.09.18.08.08.29; Sun, 18 Sep 2022 08:08:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qr7qp0UR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbiIROgy (ORCPT + 99 others); Sun, 18 Sep 2022 10:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbiIROgp (ORCPT ); Sun, 18 Sep 2022 10:36:45 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F96220C0 for ; Sun, 18 Sep 2022 07:36:43 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id k12so18944399qkj.8 for ; Sun, 18 Sep 2022 07:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=13QwewIwzroQU6uQsOD5mJo714A427B3glcmrYb0jfs=; b=Qr7qp0URoDQJLonqKRKVXmRkpDxoBoVE6IGqFVWHgJrtH5v8QvK1akfUJxqfcU4oJJ LFbY+dp0gj2opdgVdyYIoAVRS06DL0SKU0KlCX3KHAjiY+nRjjwxQpcafzHQ6azdYisF gxSqoUI2Vnlb/+crK0xnNpQlXv8ywVJcAPiPrZTVz2Ne7EuVcdBqZFF7l5hcL4kibo5e mP/q/r/ynCUM5zvZcSrpyd0cBesxdawKHtzgo0uK+MQVgIjUdudnFLbkqY7rxPkrwv5r NdEdQ9EXGzncahSKREs9O4jgIsCHretjToBoXQn+u/0NQyWgrPY44mkQk8/xkVt6C/+r 6+LA== 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=13QwewIwzroQU6uQsOD5mJo714A427B3glcmrYb0jfs=; b=ylWnfcVYp4DKi8k9jeiN5WN2y/XtUnTz58aDox7A8Nhs384cqMT+zO+0lg71nArpr1 X67yV66KVg5g8Ima7opF+S20Dhh6QKiOoj+2o767kf7yNZcX6jsMflcvGGAq8lKEzBWb jQYMWaMC+FZ0CgL8orcsuQF9rjm2Vcy0RytDCtajKDknUuV/BBCY1VER0oTKZIFfD6gd UWz29/5SZ1lIiiKTrGcECNuWGJ8g71/nDEVcHNOLI6A+frdeROlykMc3jb3Gm1O/4/OI feCCgtExQZlav6Gldk3lgoquINUjOLF54DmSFn8lAHFHFMXi402kiOQlDaPcAC/tn06I C2ww== X-Gm-Message-State: ACrzQf30oMk9Horip48t+MudSHp5L93jliCku6/tFuGinLLSF2ct+ytK dxktSzqyZDTBZNGchmAhsVfAQQ== X-Received: by 2002:a05:620a:29c5:b0:6ce:b8f3:fd5b with SMTP id s5-20020a05620a29c500b006ceb8f3fd5bmr10344295qkp.107.1663511802512; Sun, 18 Sep 2022 07:36:42 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id q31-20020a05620a2a5f00b006bb0e5ca4bbsm11456215qkp.85.2022.09.18.07.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Sep 2022 07:36:42 -0700 (PDT) From: William Breathitt Gray To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mranostay@ti.com, jpanis@baylibre.com, gwendal@chromium.org, bleung@chromium.org, groeck@chromium.org, jic23@kernel.org, david@lechnology.com, robertcnelson@gmail.com, William Breathitt Gray Subject: [PATCH v3 0/4] Implement support for Counter array components Date: Sun, 18 Sep 2022 10:36:30 -0400 Message-Id: X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes in v3: - Fix array length overwrite by allocating space for each array element - Add support for counter array component reads from Counter chrdev The COUNTER_COMP_ARRAY Counter component type is introduced to enable support for Counter array components. With Counter array components, exposure for buffers on counter devices can be defined via new Counter array component macros. This should simplify code for driver authors who would otherwise need to define individual Counter components for each array element. Driver authors can handle reads/writes for an array component by receiving an element index via the `idx` parameter and processing the respective value via the `val` parameter. For example, suppose a driver wants to expose a Count's read-only capture buffer of four elements using a callback `foobar_capture_read()`:: DEFINE_COUNTER_ARRAY(foobar_capture_array, COUNTER_COMP_U64, NULL, 4) COUNTER_COMP_COUNT_ARRAY_U64("capture", foobar_capture_read, NULL, foobar_capture_array) Respective sysfs attributes for each array element would appear for the respective Count: * /sys/bus/counter/devices/counterX/countY/capture0 * /sys/bus/counter/devices/counterX/countY/capture1 * /sys/bus/counter/devices/counterX/countY/capture2 * /sys/bus/counter/devices/counterX/countY/capture3 If a user tries to read _capture2_ for example, `idx` will be `2` when passed to the `foobar_capture_read()` callback, and thus the driver knows which array element to handle. In addition, this patchset introduces the Signal polarity component, which represents the active level of a respective Signal. There are two possible states: positive (rising edge) and negative (falling edge). The 104-quad-8 driver is updated to expose its index_polarity functionality via this new polarity component. A macro COUNTER_COMP_ARRAY_POLARITY() is provided for driver authors to support Counter arrays of Signal polarity component type; DEFINE_COUNTER_AVAILABLE may be used to define the polarity modes that are passed to DEFINE_COUNTER_ARRAY. The only component types supported for Counter arrays currently are COUNTER_COMP_U64 and COUNTER_COMP_SIGNAL_POLARITY. William Breathitt Gray (4): counter: Introduce the Signal polarity component counter: 104-quad-8: Add Signal polarity component counter: Consolidate Counter extension sysfs attribute creation counter: Introduce the COUNTER_COMP_ARRAY component type Documentation/ABI/testing/sysfs-bus-counter | 13 + drivers/counter/104-quad-8.c | 35 +++ drivers/counter/counter-chrdev.c | 47 ++- drivers/counter/counter-sysfs.c | 303 ++++++++++++++++---- include/linux/counter.h | 131 +++++++++ include/uapi/linux/counter.h | 6 + 6 files changed, 483 insertions(+), 52 deletions(-) base-commit: a12224997bec72d231a8dd642876e6364decdc45 -- 2.37.3