From nobody Thu Apr 9 12:30:22 2026 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 BA6FEC0502E for ; Mon, 29 Aug 2022 15:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbiH2PRx (ORCPT ); Mon, 29 Aug 2022 11:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbiH2PRv (ORCPT ); Mon, 29 Aug 2022 11:17:51 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAB87A51B for ; Mon, 29 Aug 2022 08:17:50 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 6-20020a9d0106000000b0063963134d04so6112854otu.3 for ; Mon, 29 Aug 2022 08:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=TIIRCQTI5+8sTLZAt+gwWaDMEai6TFCESURcivk8sXk=; b=KK0OKRp3n3acJdzvVa/LhTnV+B5ZPpI6IQDH0dJJtD62Txu8eChPpHTKOEBfALLFTx jHrf0VAArpmyKPonV+5EfeXIfRIx38O9wxfNkNw+gbO41t8XTFDAyUNF8+hsvNrLZvil AxSoeUHkbRrx66gw5PVwLE8le7L8X+AmXJ6szuztUq1ODHAhdfu7QrPsli3spdEPnSfR rpo0bPopGMXGWXYG0H2LoNedctn//W2VWmbXKmPvjZ695KpjmuSkh5a8HULNTI6oK7lz YWNtRCEFlFtqESh3QVhqyJK2tJwgLCjERm4zofWNSnB7hP7JUjmH7X8WWQtZalUe7QxN OHyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=TIIRCQTI5+8sTLZAt+gwWaDMEai6TFCESURcivk8sXk=; b=nzJmKiYL5viEg/3yr/gPkpWfrB4KZ86as7kETIZFHiSg7hHTyBYEYPay3UUWhM04eX j5CpaWBrpI3gywJs89fODgG2swKSgMaLdBjXcnflwtspwo7Ad4UpH+sveLPtXEObRgTh KEjH7dNxLzwnVDEsIDzmfbUNrHf5aeLEbVerkKKetj258TYValeReL4VzTSFyIiyCpI4 QPmw4LEtRw+ZWXqaWnfyT38pS66DJvXMCmigFQXfNfQVezXQu+mjuMcRXf0Xggb6brDT n7lHp3Hkrl+bwTLSP2EsJPAvNq+WVGthjOoq0z+u0KlY1eB0luJgrGlzZY9f0SChh0If j4Gw== X-Gm-Message-State: ACgBeo00V/QBL020DJ6582m8NMVGdxIjb0pfFxUcetVwPS+8So+DFD43 WVz8cridWDoQxdzcEXMXzI27MA== X-Google-Smtp-Source: AA6agR5S8o1tT/VGLJaD4FIAtZbeD1r9pbQ+nBZbaDlYAHn6L/xROPC/qny0BhP/cUMbEWleiUT7wA== X-Received: by 2002:a05:6830:1bc4:b0:636:e925:c3b6 with SMTP id v4-20020a0568301bc400b00636e925c3b6mr7049000ota.86.1661786269797; Mon, 29 Aug 2022 08:17:49 -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 z14-20020a056830128e00b006389650374dsm5771320otp.54.2022.08.29.08.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 08:17:49 -0700 (PDT) From: William Breathitt Gray To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mranostay@ti.com, jpanis@baylibre.com, fabien.lahoudere@collabora.com, gwendal@chromium.org, enric.balletbo@collabora.com, bleung@chromium.org, groeck@chromium.org, jic23@kernel.org, david@lechnology.com, robertcnelson@gmail.com, William Breathitt Gray Subject: [RFC PATCH 1/2] counter: Consolidate Counter extension sysfs attribute creation Date: Mon, 29 Aug 2022 11:17:30 -0400 Message-Id: X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Counter extensions are handled for the Device, Counts, and Signals. The code loops through each Counter extension and creates the expected sysfs attributes. This patch consolidates that code into functions to reduce redundancy and make the intention of the code clearer. Signed-off-by: William Breathitt Gray --- drivers/counter/counter-sysfs.c | 98 ++++++++++++++++----------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysf= s.c index 04eac41dad33..026ea094d68e 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -580,6 +580,46 @@ static int counter_comp_id_attr_create(struct device *= const dev, return 0; } =20 +static int counter_ext_attrs_create(struct device *const dev, + struct counter_attribute_group *const group, + const struct counter_comp *const ext, + const enum counter_scope scope, + void *const parent, const size_t id) +{ + int err; + + /* Create main extension attribute */ + err =3D counter_attr_create(dev, group, ext, scope, parent); + if (err < 0) + return err; + + /* Create extension id attribute */ + return counter_comp_id_attr_create(dev, group, ext->name, id); +} + +static int counter_sysfs_exts_add(struct device *const dev, + struct counter_attribute_group *const group, + const struct counter_comp *const exts, + const size_t num_ext, + const enum counter_scope scope, + void *const parent) +{ + size_t i; + const struct counter_comp *ext; + int err; + + /* Create attributes for each extension */ + for (i =3D 0; i < num_ext; i++) { + ext =3D &exts[i]; + err =3D counter_ext_attrs_create(dev, group, ext, scope, parent, + i); + if (err < 0) + return err; + } + + return 0; +} + static struct counter_comp counter_signal_comp =3D { .type =3D COUNTER_COMP_SIGNAL_LEVEL, .name =3D "signal", @@ -593,8 +633,6 @@ static int counter_signal_attrs_create(struct counter_d= evice *const counter, struct device *const dev =3D &counter->dev; int err; struct counter_comp comp; - size_t i; - struct counter_comp *ext; =20 /* Create main Signal attribute */ comp =3D counter_signal_comp; @@ -608,21 +646,9 @@ static int counter_signal_attrs_create(struct counter_= device *const counter, if (err < 0) return err; =20 - /* Create an attribute for each extension */ - for (i =3D 0; i < signal->num_ext; i++) { - ext =3D &signal->ext[i]; - - err =3D counter_attr_create(dev, cattr_group, ext, scope, signal); - if (err < 0) - return err; - - err =3D counter_comp_id_attr_create(dev, cattr_group, ext->name, - i); - if (err < 0) - return err; - } - - return 0; + /* Add Signal extensions */ + return counter_sysfs_exts_add(dev, cattr_group, signal->ext, + signal->num_ext, scope, signal); } =20 static int counter_sysfs_signals_add(struct counter_device *const counter, @@ -707,8 +733,6 @@ static int counter_count_attrs_create(struct counter_de= vice *const counter, struct device *const dev =3D &counter->dev; int err; struct counter_comp comp; - size_t i; - struct counter_comp *ext; =20 /* Create main Count attribute */ comp =3D counter_count_comp; @@ -731,21 +755,9 @@ static int counter_count_attrs_create(struct counter_d= evice *const counter, if (err < 0) return err; =20 - /* Create an attribute for each extension */ - for (i =3D 0; i < count->num_ext; i++) { - ext =3D &count->ext[i]; - - err =3D counter_attr_create(dev, cattr_group, ext, scope, count); - if (err < 0) - return err; - - err =3D counter_comp_id_attr_create(dev, cattr_group, ext->name, - i); - if (err < 0) - return err; - } - - return 0; + /* Add Count extensions */ + return counter_sysfs_exts_add(dev, cattr_group, count->ext, + count->num_ext, scope, count); } =20 static int counter_sysfs_counts_add(struct counter_device *const counter, @@ -838,8 +850,6 @@ static int counter_sysfs_attr_add(struct counter_device= *const counter, const enum counter_scope scope =3D COUNTER_SCOPE_DEVICE; struct device *const dev =3D &counter->dev; int err; - size_t i; - struct counter_comp *ext; =20 /* Add Signals sysfs attributes */ err =3D counter_sysfs_signals_add(counter, cattr_group); @@ -876,19 +886,9 @@ static int counter_sysfs_attr_add(struct counter_devic= e *const counter, if (err < 0) return err; =20 - /* Create an attribute for each extension */ - for (i =3D 0; i < counter->num_ext; i++) { - ext =3D &counter->ext[i]; - - err =3D counter_attr_create(dev, cattr_group, ext, scope, NULL); - if (err < 0) - return err; - - err =3D counter_comp_id_attr_create(dev, cattr_group, ext->name, - i); - if (err < 0) - return err; - } + /* Add device extensions */ + return counter_sysfs_exts_add(dev, cattr_group, counter->ext, + counter->num_ext, scope, NULL); =20 return 0; } --=20 2.37.2 From nobody Thu Apr 9 12:30:22 2026 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 539C8C0502E for ; Mon, 29 Aug 2022 15:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbiH2PR6 (ORCPT ); Mon, 29 Aug 2022 11:17:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiH2PRx (ORCPT ); Mon, 29 Aug 2022 11:17:53 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C717A51B for ; Mon, 29 Aug 2022 08:17:51 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id t11-20020a05683014cb00b0063734a2a786so6089331otq.11 for ; Mon, 29 Aug 2022 08:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=PRU8c/YFFHTSCg7HReScdvPI3HlKG8EkTuSOdJ0Pa/4=; b=k3FqbItsvPd4x+fBpWLJOtyO9uA78jeUH5iX6N+/dBajn/7tAMbkwE3d1mcq2wEip9 dUD2PRRTGbYL7+agwLk8Z0PttFgpm3WJnTIdOY63pfN1KhR+RkQG6ApOjr2NoSLHoqd7 95BFYBWFIvdKQuH9/tMM0VBn6mN3+FpyA9iCGXP6OSQ22t/YC9kSC5zc/1lLbpGzYocQ 7EgfqBBt4OOFUmp1Ba5hAzJGqmVsuNGpMjGHmlgryWV5Z255T+oA9vjN7rwJ8DvtWflW I3tvD5shCpTUI00mamneQlTyss1I6dKutW/OFgqWwH66ZjFhD0MU4s1ry8nkynpKwTP3 Oclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=PRU8c/YFFHTSCg7HReScdvPI3HlKG8EkTuSOdJ0Pa/4=; b=bZ2ZOF9cExB+eaXNUde7CVKekPp8Pru454gCTeSHcGoakf4VK4R9rZzzS6vZ0UIGgs othO1bvGfjx7GhaDl6fdJfNxGKx/k8ZNmak3GB8rNYgUVQmVmVHA0ufXbCqijfbejWzU pKoU6emwLRC3QNdS5hbCNRQNQXK6PRsY825XVqvDYYyBKDToXYnUtWcMZ8VH8tVcps3f xC088LkuEnPWzDTnel4c4qpXUv8Lf1Eo4/BUtkNhwwQ+QE3crruMH/eBaUGUu8WRBkI5 qzSJPfmGNqZqz9yEExK8c6i3BIICdVfarHT6jcOXXPUKHbxzT/PU8CrFaIqYvOSL06zN WDZA== X-Gm-Message-State: ACgBeo3FUnfIVJ3rdClYNcYJkflEnlxko93xdlqrrM+hQqkc2TjxXUNA qLZVD1XZsN5F/5pWYQweeSZTaQ== X-Google-Smtp-Source: AA6agR4ZSqUNxzZ0pX3EIsQOYE/hZXVs5BuS+4pA9yOL9JxxxkJATRPDecjcQduT1ljSc8Dq/D6iYg== X-Received: by 2002:a05:6830:2707:b0:638:9ccc:dadb with SMTP id j7-20020a056830270700b006389cccdadbmr7176616otu.369.1661786271135; Mon, 29 Aug 2022 08:17:51 -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 z14-20020a056830128e00b006389650374dsm5771320otp.54.2022.08.29.08.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 08:17:50 -0700 (PDT) From: William Breathitt Gray To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mranostay@ti.com, jpanis@baylibre.com, fabien.lahoudere@collabora.com, gwendal@chromium.org, enric.balletbo@collabora.com, bleung@chromium.org, groeck@chromium.org, jic23@kernel.org, david@lechnology.com, robertcnelson@gmail.com, William Breathitt Gray Subject: [RFC PATCH 2/2] counter: Introduce the COUNTER_COMP_ARRAY_U64 component type Date: Mon, 29 Aug 2022 11:17:31 -0400 Message-Id: <31a35481813ec26949018888253278a634998a92.1661785438.git.william.gray@linaro.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The COUNTER_COMP_ARRAY_U64 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. Three Counter array component macros are introduced:: COUNTER_COMP_DEVICE_ARRAY_U64(_name, _read, _write, _length) COUNTER_COMP_COUNT_ARRAY_U64(_name, _read, _write, _length) COUNTER_COMP_SIGNAL_ARRAY_U64(_name, _read, _write, _length) Six respective callbacks are introduced as well:: 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_read()`:: COUNTER_COMP_COUNT_ARRAY_U64("capture", foobar_read, NULL, 4) 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_read()` callback, and thus the driver knows which array element to handle. Cc: Julien Panis Signed-off-by: William Breathitt Gray --- drivers/counter/counter-sysfs.c | 116 +++++++++++++++++++++++++++++++- include/linux/counter.h | 78 +++++++++++++++++++++ 2 files changed, 192 insertions(+), 2 deletions(-) diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysf= s.c index 026ea094d68e..464bc4750787 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -341,6 +341,72 @@ static ssize_t counter_comp_u64_store(struct device *d= ev, return len; } =20 +static ssize_t counter_comp_array_u64_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + const struct counter_attribute *const a =3D to_counter_attribute(attr); + struct counter_device *const counter =3D counter_from_dev(dev); + const size_t idx =3D (size_t)a->comp.priv; + int err; + u64 data =3D 0; + + switch (a->scope) { + case COUNTER_SCOPE_DEVICE: + err =3D a->comp.device_array_u64_read(counter, idx, &data); + break; + case COUNTER_SCOPE_SIGNAL: + err =3D a->comp.signal_array_u64_read(counter, a->parent, idx, + &data); + break; + case COUNTER_SCOPE_COUNT: + err =3D a->comp.count_array_u64_read(counter, a->parent, idx, + &data); + break; + default: + return -EINVAL; + } + if (err < 0) + return err; + + return sysfs_emit(buf, "%llu\n", (unsigned long long)data); +} + +static ssize_t counter_comp_array_u64_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + const struct counter_attribute *const a =3D to_counter_attribute(attr); + struct counter_device *const counter =3D counter_from_dev(dev); + const size_t idx =3D (size_t)a->comp.priv; + int err; + u64 data =3D 0; + + err =3D kstrtou64(buf, 0, &data); + if (err < 0) + return err; + + switch (a->scope) { + case COUNTER_SCOPE_DEVICE: + err =3D a->comp.device_array_u64_write(counter, idx, data); + break; + case COUNTER_SCOPE_SIGNAL: + err =3D a->comp.signal_array_u64_write(counter, a->parent, idx, + data); + break; + case COUNTER_SCOPE_COUNT: + err =3D a->comp.count_array_u64_write(counter, a->parent, idx, + data); + break; + default: + return -EINVAL; + } + if (err < 0) + return err; + + return len; +} + static ssize_t enums_available_show(const u32 *const enums, const size_t num_enums, const char *const strs[], char *buf) @@ -488,6 +554,16 @@ static int counter_attr_create(struct device *const de= v, dev_attr->store =3D counter_comp_u64_store; } break; + case COUNTER_COMP_ARRAY_U64: + if (comp->count_array_u64_read) { + dev_attr->attr.mode |=3D 0444; + dev_attr->show =3D counter_comp_array_u64_show; + } + if (comp->count_array_u64_write) { + dev_attr->attr.mode |=3D 0200; + dev_attr->store =3D counter_comp_array_u64_store; + } + break; default: return -EINVAL; } @@ -597,6 +673,38 @@ static int counter_ext_attrs_create(struct device *con= st dev, return counter_comp_id_attr_create(dev, group, ext->name, id); } =20 +static int counter_array_attrs_create(struct device *const dev, + struct counter_attribute_group *const group, + const struct counter_comp *const comp, + const enum counter_scope scope, + void *const parent, const size_t id) +{ + const size_t length =3D (size_t)comp->priv; + struct counter_comp ext =3D *comp; + size_t i; + int err; + + /* Create an attribute for each array element */ + for (i =3D 0; i < length; i++) { + /* Set index for array element extension */ + ext.priv =3D (void *)i; + + /* Generate array element attribute name */ + ext.name =3D devm_kasprintf(dev, GFP_KERNEL, "%s%zu", comp->name, + i); + if (!ext.name) + return -ENOMEM; + + /* Create all attributes associated with the array element */ + err =3D counter_ext_attrs_create(dev, group, &ext, scope, parent, + id + i); + if (err < 0) + return err; + } + + return 0; +} + static int counter_sysfs_exts_add(struct device *const dev, struct counter_attribute_group *const group, const struct counter_comp *const exts, @@ -611,8 +719,12 @@ static int counter_sysfs_exts_add(struct device *const= dev, /* Create attributes for each extension */ for (i =3D 0; i < num_ext; i++) { ext =3D &exts[i]; - err =3D counter_ext_attrs_create(dev, group, ext, scope, parent, - i); + if (ext->type =3D=3D COUNTER_COMP_ARRAY_U64) + err =3D counter_array_attrs_create(dev, group, ext, scope, + parent, i); + else + err =3D counter_ext_attrs_create(dev, group, ext, scope, + parent, i); if (err < 0) return err; } diff --git a/include/linux/counter.h b/include/linux/counter.h index 1fe17f5adb09..8ef4dd9d73dc 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -31,6 +31,7 @@ enum counter_comp_type { COUNTER_COMP_ENUM, COUNTER_COMP_COUNT_DIRECTION, COUNTER_COMP_COUNT_MODE, + COUNTER_COMP_ARRAY_U64, }; =20 /** @@ -68,6 +69,24 @@ enum counter_comp_type { * @signal_u64_read: Signal u64 component read callback. The read value of * the respective Signal u64 component should be passed * back via the val parameter. + * @device_array_u64_read: Device u64 array component read callback. The + * index of the respective Device u64 array + * component element is passed via the idx + * parameter. The read value of the respective + * Device u64 array component element should be + * passed back via the val parameter. + * @count_array_u64_read: Count u64 array component read callback. The + * index of the respective Count u64 array + * component element is passed via the idx + * parameter. The read value of the respective + * Count u64 array component element should be + * passed back via the val parameter. + * @signal_array_u64_read: Signal u64 array component read callback. The + * index of the respective Count u64 array + * component element is passed via the idx + * parameter. The read value of the respective + * Count u64 array component element should be + * passed back via the val parameter. * @action_write: Synapse action mode write callback. The write value of * the respective Synapse action mode is passed via the * action parameter. @@ -98,6 +117,24 @@ enum counter_comp_type { * @signal_u64_write: Signal u64 component write callback. The write valu= e of * the respective Signal u64 component is passed via the * val parameter. + * @device_array_u64_write: Device u64 array component write callback. The + * index of the respective Device u64 array + * component element is passed via the idx + * parameter. The write value of the respective + * Device u64 array component element is passed via + * the val parameter. + * @count_array_u64_write: Count u64 array component write callback. The + * index of the respective Count u64 array + * component element is passed via the idx + * parameter. The write value of the respective + * Count u64 array component element is passed via + * the val parameter. + * @signal_array_u64_write: Signal u64 array component write callback. The + * index of the respective Signal u64 array + * component element is passed via the idx + * parameter. The write value of the respective + * Signal u64 array component element is passed via + * the val parameter. */ struct counter_comp { enum counter_comp_type type; @@ -125,6 +162,14 @@ struct counter_comp { struct counter_count *count, u64 *val); int (*signal_u64_read)(struct counter_device *counter, struct counter_signal *signal, u64 *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); }; union { int (*action_write)(struct counter_device *counter, @@ -148,6 +193,14 @@ struct counter_comp { struct counter_count *count, u64 val); int (*signal_u64_write)(struct counter_device *counter, struct counter_signal *signal, 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); }; }; =20 @@ -452,6 +505,31 @@ struct counter_available { .priv =3D &(_available), \ } =20 +#define COUNTER_COMP_DEVICE_ARRAY_U64(_name, _read, _write, _length) \ +{ \ + .type =3D COUNTER_COMP_ARRAY_U64, \ + .name =3D (_name), \ + .device_array_u64_read =3D (_read), \ + .device_array_u64_write =3D (_write), \ + .priv =3D (void *)(_length), \ +} +#define COUNTER_COMP_COUNT_ARRAY_U64(_name, _read, _write, _length) \ +{ \ + .type =3D COUNTER_COMP_ARRAY_U64, \ + .name =3D (_name), \ + .count_array_u64_read =3D (_read), \ + .count_array_u64_write =3D (_write), \ + .priv =3D (void *)(_length), \ +} +#define COUNTER_COMP_SIGNAL_ARRAY_U64(_name, _read, _write, _length) \ +{ \ + .type =3D COUNTER_COMP_ARRAY_U64, \ + .name =3D (_name), \ + .signal_array_u64_read =3D (_read), \ + .signal_array_u64_write =3D (_write), \ + .priv =3D (void *)(_length), \ +} + #define COUNTER_COMP_CEILING(_read, _write) \ COUNTER_COMP_COUNT_U64("ceiling", _read, _write) =20 --=20 2.37.2