From patchwork Tue Mar 9 13:19:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 12125275 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 435D1C433DB for ; Tue, 9 Mar 2021 13:39:02 +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 523A164F51 for ; Tue, 9 Mar 2021 13:39:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 523A164F51 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=rBDgtFpJnJd/GOSiyIUtSozawKw+xxeoQ4fh/Zujpp0=; b=ebfDRUb+WB1Zu3KKxz44HqJCc bkH1pSMQC+FI9jHzt1rfm+1wuSZ7NPC1P4HOhnwy93tpXedgLFPwFGXkyCUSCkyUwppOK8kq6JgSe WyZ1u02ltCo8kcM/kSdpT+UrcGnR8xn+7rn5eZq2R8YPKUrc5SSlndAYHpbqq6At6ljVb4yCnZfs0 HhK6qnylgqqXDgnoPaJxu1JPXDqQrli1CcXZgo5y9bLHQA9+JYM1BLlxVigP+VLXd88vnZ1wvYjib pLxjOZIgtG+SQj64IJmwN+NEXHaOLru6MtW07tifd16I0yK9DzSRXR3lOpoElSm4JuwhMuLLMqg7u c2SMVOQrw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJcXR-004gEe-Hx; Tue, 09 Mar 2021 13:36:41 +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 1lJcK2-004b1e-9A for linux-arm-kernel@lists.infradead.org; Tue, 09 Mar 2021 13:23:07 +0000 Received: by mail-pj1-x102a.google.com with SMTP id t9so882077pjl.5 for ; Tue, 09 Mar 2021 05:22:50 -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=PoLaEjlOjTaQwbMALD2RFnapOU7EJm1z/oVIMUH9q/A=; b=LqozAFDFYYNf99e8w+zRIrHgYp9tgzrV/gwm5MRR23X0ip2OyPiTEBzg5H4cGfOD7o laKGsdA3dipNyTrjHXZdYaBDtZyRoaICq/8DphfKjnxTyzZeUxZgkV9PefoLRSRL71GZ oo69ns0+Ntd5zlOsWOirvKcoxqZKDuGgUlH89VdUGiaxg1Uvwt3GJU3GuaRY39BM72k2 LKsdGnQpHRBfmJxwL+qLBBXLCU5/Lh5c5gmZFm9wb3rZdX1v3ZAUTMXWupo5nAnFvXWr 5vc5xIO799jUe+RLiVQzVNc27AQhg/ve/TIPvrbDzhPwxWzACiO3QYFm5gPrmZ5Zg828 yygA== 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=PoLaEjlOjTaQwbMALD2RFnapOU7EJm1z/oVIMUH9q/A=; b=lyfrfm7iZPLJAEQZXRnemJzFE9/QcnYRSUG8UxNQUCB8lbbvVPu+TMFOJelxeaH0F+ otRAgXH9dO03RFGheo8Gbgp0fmEccuvigOsi1a6zKV9Dl53S69VijkWs/mpOPrqjWuEt aZQC6lgArch+R6aKCLnHoIofIM4SmMjjwKkSTJ8h9cZnxeRDhXwr/mQWault4mgQ/Wu6 iN76q/bA//sUy9yvY866TkCCsO6da5xEUiQDFXaTiG7nxZVvTMSWZMCr/HyDCNzevewQ H54+sJOt2AhVltgsNApcdNbh+kaTMIFXXeH8PTNjTKV0JOLafO+aq5Ff7QsPt0b+AREC 0zvQ== X-Gm-Message-State: AOAM533AT+K/Sgq3LIYb0aGtu60ZgVFhedqTy3dOp2QQhnq3bV5MosbW VKfsCiKs+C//RLvLShJAocw= X-Google-Smtp-Source: ABdhPJyEyvfPp8C+VGL/bFry1z9hjf8zNpN00O2FGi3o5Qj7xQPCvy9Z60EXYcCo9fE2IwKHz5RkZw== X-Received: by 2002:a17:90b:3890:: with SMTP id mu16mr4713032pjb.9.1615296168925; Tue, 09 Mar 2021 05:22:48 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:48 -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 30/33] counter: Implement *_component_id sysfs attributes Date: Tue, 9 Mar 2021 22:19:43 +0900 Message-Id: <9bca8f6c4202a0bb61db4f3cc0c0f53a06cde3e6.1615293276.git.vilhelm.gray@gmail.com> 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_132250_889389_D1DFE345 X-CRM114-Status: GOOD ( 14.77 ) 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: , 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 extensions for requests. In order for users to know what component ID belongs to which extension this information must be exposed. The *_component_id attribute provides a way for users to discover what component ID belongs to which respective extension. Cc: David Lechner Cc: Gwendal Grignou Cc: Dan Carpenter Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index bee9289aecd1..57b051ba53a9 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -203,12 +203,26 @@ Description: both edges: Any state transition. +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id +What: /sys/bus/counter/devices/counterX/countY/floor_component_id +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id +What: /sys/bus/counter/devices/counterX/countY/direction_component_id +What: /sys/bus/counter/devices/counterX/countY/enable_component_id +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id +What: /sys/bus/counter/devices/counterX/countY/preset_component_id +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_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. + respective extension or Synapse. What: /sys/bus/counter/devices/counterX/name KernelVersion: 5.2 diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index 8f11499c8ec1..7c1f79766920 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -587,6 +587,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter, int err; struct counter_comp comp; size_t i; + struct counter_comp *ext; /* Create main Signal attribute */ comp = counter_signal_comp; @@ -602,8 +603,13 @@ static int counter_signal_attrs_create(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < signal->num_ext; i++) { - err = counter_attr_create(dev, group, signal->ext + i, scope, - signal); + ext = signal->ext + i; + + err = counter_attr_create(dev, group, ext, scope, signal); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } @@ -694,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter, int err; struct counter_comp comp; size_t i; + struct counter_comp *ext; /* Create main Count attribute */ comp = counter_count_comp; @@ -718,8 +725,13 @@ static int counter_count_attrs_create(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < count->num_ext; i++) { - err = counter_attr_create(dev, group, count->ext + i, scope, - count); + ext = count->ext + i; + + err = counter_attr_create(dev, group, ext, scope, count); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } @@ -783,6 +795,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, struct device *const dev = &counter->dev; int err; size_t i; + struct counter_comp *ext; /* Add Signals sysfs attributes */ err = counter_sysfs_signals_add(counter, group); @@ -815,8 +828,13 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < counter->num_ext; i++) { - err = counter_attr_create(dev, group, counter->ext + i, scope, - NULL); + ext = counter->ext + i; + + err = counter_attr_create(dev, group, ext, scope, NULL); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; }