From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B26AC433E0 for ; Tue, 9 Mar 2021 13:38:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BD11650ED for ; Tue, 9 Mar 2021 13:38:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BD11650ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BITsg7UzuicTX9yvMrUeiiFW0Yd2rYZ0voqjAOaHULU=; b=F5WPblMM8I0ILqq3nswGy5PcP rgneOmcOSU39hcsDbJ3Pu43/VjiMi25uxNs1EAsGbES471I/Q1Q8zVDO0u1XbasMEwGhleE0S9pFj kbFrPZlhqPj4o/4nGd0t5b2UjvUy0U0tRMkIQYlamu+K8DRnvJFxxSboxxzz3XL746C6d/L52gits H/ndNZInSDeKMi+PmTQOWoKIoV9N0xY0TVB/FGbw259+W9aXltZ37jAwc7Re08XqJXg3P9HN8Xylg NcgT5OzyaHLoY9Ht6P9DHGBjizH6aBf/3xIoVCecMZm0r6Ls0uvLVTt2o/d4QSggIeH80F5MS3Ty8 yuK4yAE7A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJcWo-004g20-Dh; Tue, 09 Mar 2021 13:36:03 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJcJw-004azV-W9 for linux-arm-kernel@lists.infradead.org; Tue, 09 Mar 2021 13:22:58 +0000 Received: by mail-pj1-x102a.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso5189075pjb.3 for ; Tue, 09 Mar 2021 05:22:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pil4P2EiLTeNqa4+JCYgDjTol3Ay4ymexuC8jw3Zjn0=; b=vHWBQdDrLaykvvsgZrbdom6eyYce8unhe7aM985VIl5WEK8HbLU/P7l7zAp9gUfHla qm4eydAHJd2zCHWBhk7YlmHzbJMcMEA+rMSuNUuWhfbgHQxdO0l5YVwhPEm0q1Ks8Zdy wY0Wsf86dR+cd9rBADOg+/+4mxmMo1D6jg4NKIf9SZ+9l6uf4UtMRTZvepPVDUzSutKE FnqKsvZcCf41WMX9NXPp9ZSreVmS1WJPewO11tMj9R1qKp6HmEzMNP/1aDmcWr+wNDGA rSkPw5KDs1l4aGgb/yTNXDEPvFhG2F4Z4a5pL2WbxmBDQ6WcjfULPKl15Th+CClN87DG EM/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pil4P2EiLTeNqa4+JCYgDjTol3Ay4ymexuC8jw3Zjn0=; b=LDFQj5+biCW9rTt/lqyMAhudetPvj79V4m0GyG9gnzrABCYv6OKtmAgRpY4n693+xz sxr/rNpTOu8Zc+GsHikyg/CVRxDpJ11w6A0YGeD1V2kA1nLdE6j4eedw5YqZB2Ctjrvg V7GJAWv5oupHhbT/EfLvQ5KVp7nRRPuHzKaMbAFFgxiogvqtygWrfutqL0yHyNI3rVNe 4Bsz2w0GCk4OLRNNcFjTEeJ1+5d0L6ddCBWlWLNRZvdJDuGeD8yuk6wPyI514EhI5+1k VLJ28vWwavd0uUfTZSmp0eYkgRBu/EOfv9d//2LKdLtrq1K4vHI60IQKzOHp2lYKahaY kjtw== X-Gm-Message-State: AOAM533mI5ZA+nRkS/5cJYZSGF1vEvSn7yVersAwJLoTabwjs+D01bsM UuhQOXBbevgR5Tpe4TptaaQ= X-Google-Smtp-Source: ABdhPJx2+7TMpxmPwB8f2imz2lq/HqwstME+VlB4l/4nqWHUym/jtWDawd5d6s35EUJ0Uz178tNZGA== X-Received: by 2002:a17:902:6bca:b029:e2:c5d6:973e with SMTP id m10-20020a1709026bcab02900e2c5d6973emr25715061plt.40.1615296163745; Tue, 09 Mar 2021 05:22:43 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:43 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, William Breathitt Gray , Dan Carpenter Subject: [PATCH v9 29/33] counter: Implement signalZ_action_component_id sysfs attribute Date: Tue, 9 Mar 2021 22:19:42 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210309_132245_438771_3AADF440 X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Generic Counter chrdev interface expects users to supply component IDs in order to select Synapses for requests. In order for users to know what component ID belongs to which Synapse this information must be exposed. The signalZ_action_component_id attribute provides a way for users to discover what component ID belongs to the respective Synapse. Cc: David Lechner Cc: Gwendal Grignou Cc: Dan Carpenter Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 7 ++++ drivers/counter/counter-sysfs.c | 45 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index 6353f0a2f8f8..bee9289aecd1 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -203,6 +203,13 @@ Description: both edges: Any state transition. +What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id +KernelVersion: 5.13 +Contact: linux-iio@vger.kernel.org +Description: + Read-only attribute that indicates the component ID of the + respective Synapse of Count Y for Signal Z. + What: /sys/bus/counter/devices/counterX/name KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index e65e6039a347..8f11499c8ec1 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -533,6 +533,46 @@ static int counter_name_attr_create(struct device *const dev, return 0; } +static ssize_t counter_comp_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + const size_t id = (size_t)to_counter_attribute(attr)->comp.priv; + + return sysfs_emit(buf, "%zu\n", id); +} + +static int counter_comp_id_attr_create(struct device *const dev, + struct counter_attribute_group *const group, + const char *name, const size_t id) +{ + struct counter_attribute *counter_attr; + + /* Allocate Counter attribute */ + counter_attr = devm_kzalloc(dev, sizeof(*counter_attr), GFP_KERNEL); + if (!counter_attr) + return -ENOMEM; + + /* Generate component ID name */ + name = devm_kasprintf(dev, GFP_KERNEL, "%s_component_id", name); + if (!name) + return -ENOMEM; + + /* Configure Counter attribute */ + counter_attr->comp.priv = (void *)id; + + /* Configure device attribute */ + sysfs_attr_init(&counter_attr->dev_attr.attr); + counter_attr->dev_attr.attr.name = name; + counter_attr->dev_attr.attr.mode = 0444; + counter_attr->dev_attr.show = counter_comp_id_show; + + /* Store list node */ + list_add(&counter_attr->l, &group->attr_list); + group->num_attr++; + + return 0; +} + static struct counter_comp counter_signal_comp = { .type = COUNTER_COMP_SIGNAL_LEVEL, .name = "signal", @@ -627,6 +667,11 @@ static int counter_sysfs_synapses_add(struct counter_device *const counter, COUNTER_SCOPE_COUNT, count); if (err < 0) return err; + + /* Create Synapse component ID attribute */ + err = counter_comp_id_attr_create(dev, group, comp.name, i); + if (err < 0) + return err; } return 0; -- 2.30.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel