Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3213097rwb; Mon, 19 Sep 2022 17:18:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nD1sbgNw93pt2QutVKVoHj/fwn+JhZkMkWtTQIYOfXbIILWirH7+kmOPnJwHM0z9+mmr8 X-Received: by 2002:a05:6a00:4287:b0:543:7bae:55f7 with SMTP id bx7-20020a056a00428700b005437bae55f7mr21648681pfb.58.1663633113873; Mon, 19 Sep 2022 17:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663633113; cv=none; d=google.com; s=arc-20160816; b=SOidP9AbOy/4H3B0fdXHw2oHQykn/JfziBpqeBvYJGOYoGpDLCoDkw1kAiH8pAzEkL QEHW5je0oyxKtmuFDVM/FSavPm6K3bLg7R04ziAga4pdcJgj3NTWp5U827VhcRfAvdDk yvJ4v/YP0/omCLY1e/D3bl7bef8w/9hRAMHZ9I16AfDUH74bhdorgi0hp2/PC/ZdK1lY mu4bwrL8a+o/t0NNZZqOCJzJ+pPC/DERLzgM0HqavmMvZPvEpKOcXKFD773MsTOvhnec NxgBze8g8ruINwErJ21vwTYxAfy6FaHSR/Txskq2BoVaAI/6IQLIYQi50oLefo4DeJAn BQ0A== 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=HEQfTK7qHVjLGiN97ioW09zFTOOgtsYJ7V5eTJpH85Q=; b=xZqiEI7xkkupYorEuW5jKh/tOCL+n1MHmA48kAtXSbR++XKLyABWIelSuTNrFu7LIy ixsEPDGOa3aEZQcN8ZKixe+SuH4zIZ7se15pkUmgukgCX8J1FmHIYxkHTXeBK2iGC/iA 1YnA+phzQRaIa08UR+qMaIEJeltzMR3Q0ulcQZaymY4KfGheeTPoXDTDt3yEqFbvjAKK R6ulNGwwYnAAVCOVCRNo4tl1Xo6zaLKu38fpyWLuXvnug8tYe7fhO47u4uP+5MqJo736 Tep01m9bETSFoQAOs5Hop4f6d3BSW1ralvqL9+VPl5yYW/I4ZEsWXNCmemgm3ry+OJbh oBLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rcj5+E+F; 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 pg14-20020a17090b1e0e00b0020243dc975bsi16773360pjb.116.2022.09.19.17.18.22; Mon, 19 Sep 2022 17:18:33 -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=Rcj5+E+F; 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 S229838AbiISXRl (ORCPT + 99 others); Mon, 19 Sep 2022 19:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbiISXRi (ORCPT ); Mon, 19 Sep 2022 19:17:38 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521BC4B0F6 for ; Mon, 19 Sep 2022 16:17:37 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id cj27so633985qtb.7 for ; Mon, 19 Sep 2022 16:17:37 -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=HEQfTK7qHVjLGiN97ioW09zFTOOgtsYJ7V5eTJpH85Q=; b=Rcj5+E+FXPBHgNjvxOB/OScvkxnPIDT+ujjJkjjIqSe49VFLukNcBkm9Tk4pYDclDd Zk16ab8nMDcHA4ybKEp5awiXeBAr6xwAd+a9Z52mqYH2YrEimDp7iwInBS2twxmDbZGc 6kNZDjdyMhykEBsBHrW+J4lE3BSiHzloZHnTHb+06xX5AZaO6f2VKe3VJ2bKCK58EdgX 4rc9DGXHIGVXuRiF2cjk11JEtHieDkNxCLvNxTEz822TduvZreKxR06HRfEk0706xh6l CPP0a4EQJQ2lFCl4CLw1PzCfcFDHXD1vy03T34oxMOdvfiTlf6STAVrpgqfS+PMxw7yp G2xQ== 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=HEQfTK7qHVjLGiN97ioW09zFTOOgtsYJ7V5eTJpH85Q=; b=w8Xxzfb6Pem4udZCdypJOZt+5rR7JLJrKaMWt9l86U8gLBPUd+mqZ/lNQmHMaVWpwY 3+hs6RDcn14iu6kGLCLWiJzIiAwIeXxwKXPp9KsqyGRBPaij1+yVkchb6UGTAxM3ltwY CbZZ2Ldt0bGilYBO+mY56DTylAqGGniH4nLD69415OdJi9kYlQY6b2OE4Ti2anJLFDjo m/QDg7yBe4vadfE+ALJPuoL8FCy612U8+is3QN3h2q8kGnYJdEuWAFbuq5vy7irqlfal nJJff8n3BEORjLKMIhPDpTEOlvKzSdyM1HVAr5vP7ur3LK6gLWhPiUpIODVAos62DOw3 6uWQ== X-Gm-Message-State: ACrzQf2nlSKrVNW1sdEDf1gAwxGy/MaJeFs3TVpRTtCUY9eXT9s/Ejkd S0J5jBlHJonV1NQCAvF/TVpZpg== X-Received: by 2002:a05:622a:60f:b0:35b:b737:bcbe with SMTP id z15-20020a05622a060f00b0035bb737bcbemr17214118qta.149.1663629456435; Mon, 19 Sep 2022 16:17:36 -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 d4-20020ac80604000000b0035cebb79aaesm2547005qth.18.2022.09.19.16.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:17:35 -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 v4 0/4] Add support for Counter array components Date: Sun, 18 Sep 2022 14:22:03 -0400 Message-Id: X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=no 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 v4: - Handle COUNTER_COMP_SIGNAL_POLARITY type in counter_attr_create() and counter_get_data(); previously was incorrectly treating as invalid - Replace DEFINE_COUNTER_ARRAY macro with DEFINE_COUNTER_ARRAY_U64 and DEFINE_COUNTER_ARRAY_POLARITY macros 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. Six Counter array component macros are introduced:: DEFINE_COUNTER_ARRAY_U64(_name, _length) DEFINE_COUNTER_ARRAY_POLARITY(_name, _enums, _length) COUNTER_COMP_DEVICE_ARRAY_U64(_name, _read, _write, _array) COUNTER_COMP_COUNT_ARRAY_U64(_name, _read, _write, _array) COUNTER_COMP_SIGNAL_ARRAY_U64(_name, _read, _write, _array) COUNTER_COMP_ARRAY_POLARITY(_read, _write, _array) Eight Counter array callbacks are introduced as well:: int (*signal_array_u32_read)(struct counter_device *counter, struct counter_signal *signal, size_t idx, u32 *val); int (*signal_array_u32_write)(struct counter_device *counter, struct counter_signal *signal, size_t idx, u32 val); int (*device_array_u64_read)(struct counter_device *counter, size_t idx, u64 *val); int (*count_array_u64_read)(struct counter_device *counter, struct counter_count *count, size_t idx, u64 *val); int (*signal_array_u64_read)(struct counter_device *counter, struct counter_signal *signal, size_t idx, u64 *val); int (*device_array_u64_write)(struct counter_device *counter, size_t idx, u64 val); int (*count_array_u64_write)(struct counter_device *counter, struct counter_count *count, size_t idx, u64 val); int (*signal_array_u64_write)(struct counter_device *counter, struct counter_signal *signal, size_t idx, u64 val); 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_U64(foobar_capture_array, 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. Counter arrays for polarity elements can be defined in a similar manner as u64 elements:: const enum counter_signal_polarity foobar_polarity_states[] = { COUNTER_SIGNAL_POLARITY_POSITIVE, COUNTER_SIGNAL_POLARITY_NEGATIVE, }; DEFINE_COUNTER_ARRAY_POLARITY(foobar_polarity_array, foobar_polarity_states, 4); COUNTER_COMP_ARRAY_POLARITY(foobar_polarity_read, foobar_polarity_write, foobar_polarity_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 | 48 +++- drivers/counter/counter-sysfs.c | 304 ++++++++++++++++---- include/linux/counter.h | 138 +++++++++ include/uapi/linux/counter.h | 6 + 6 files changed, 492 insertions(+), 52 deletions(-) base-commit: f95ec98139dc58db72e4bd0df049a3097990a8e7 -- 2.37.3