From patchwork Sun Sep 18 14:36:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 12979511 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 70328C32771 for ; Sun, 18 Sep 2022 14:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbiIROgu (ORCPT ); Sun, 18 Sep 2022 10:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229794AbiIROgp (ORCPT ); Sun, 18 Sep 2022 10:36:45 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E008220FD for ; Sun, 18 Sep 2022 07:36:43 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id s9so16694445qkg.4 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=0sqLhmvO+ZUcwlivGav7qHxfO3b3HM2Ls7hA7YweoRizcMemeCsAx3gFjfAX4pmfnl UFeFb/RfdeUrRrTVY6LWes2SLm0vvwESnYUluoMo3+VzNcGhH8ANIN++M9hKwPZN2GY4 3sVvnCZsMoqTP9KLERHrBhgAtZoythdAq1g271IQ11YiBHAFm4l6u1DPK8qbCqYU0+1K afDSZFtsdURspwqz/xkgLaOxQaib/AwFb7zVrFmY/fLIKNbfc6PnvCh/jvG1qN4NgRbq AEgL4M4N9gHXuJg7qaFXjMAEJ2Pe5x25R21uhcy7q9Ztx/maGfL6EFRE7FLANLCsfAgq 0CxA== X-Gm-Message-State: ACrzQf0H4fMM5jOodoGdlniUluL0D7LS1hv7S+lHeSAoToGGd0LL1E1E iEk959QPD3dGMSLSVypUpWGVqcWoiqOK4A== X-Google-Smtp-Source: AMsMyM7pfQasD7jkJqYSKPTlg6d4Na6JLJVvUKrDnX/Rzru0o7Iaie995kOt0dsa5d39xUGMoOUn7A== 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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@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