Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp976112pxb; Thu, 26 Aug 2021 20:53:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymAVprw+ftHoEMACtDnIo42Zu7hFn/6Vn7mli+4RxT+ytnaQpSfe5D2tBqT0Nflg17yLv3 X-Received: by 2002:a05:6402:2d8:: with SMTP id b24mr7580345edx.176.1630036398823; Thu, 26 Aug 2021 20:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630036398; cv=none; d=google.com; s=arc-20160816; b=mEuB2Uy+xDKrkzHbHazAfqn8wDLqsgqp1o6LTtdSOvWiuSjjstzhfTTroHjG87bOn6 rbu7rN0CALqP1YY3FNZaNnHEMexby3AVi+4Xrxydp4PyFM2d4kU7AiwTvwsQkVVyNVl9 CDhGigJZE8OWPimh53sEi87NibcYfJzxV5BN62KfFW/StcDBuhEepATPllYSZ+OLiAVl w3ARX3ExFGZv0Z6YEOONn1vYiquQ1ZY6pEcXsunXfdkNlMulcT9c7bB/vp3mHov3DAlH bNnIfvesHqQkI7YZMXLYccLuWno2JXARuPNftTNBgWboEgyUmeq0v6LGDgFlVGwAqwyt 8rnw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sL9LPCzfu7AdHdSAIzrZRarBLN9KzJsdKMehHJFnQLk=; b=CpnZGALXnJXJnU0UVTVVLdanFsyMBMKHnzZa55q+/skXMdK+hb1AeSExTdQgVmsrF+ I76+Kuvsm81YeUxtnFeEm4lCjUssmtIZkkwsHIZv7gEUE2SDVgBahD3T0lVujCREAOJL 6ujIohXn3eyc80HePWLjynY1MeZoH2jQzx1e11qRBq4MKDk37doSw23f/1S/cZsJS63h kypapOzLmNTcqlk74E68vkLg8q6KdvdLvuMsOd2uzB0zoT8Vdhk1y6z644EuRQCRaqW5 J/33qiantCBSH9T6AhzkZhXHOfIZUsIBWVntiEOJkWXglnIh8tNCoVgPF9kPq30LuOlc /kEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dZpAN53m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z17si5110315edc.582.2021.08.26.20.52.56; Thu, 26 Aug 2021 20:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dZpAN53m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244333AbhH0DuM (ORCPT + 99 others); Thu, 26 Aug 2021 23:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244292AbhH0DuA (ORCPT ); Thu, 26 Aug 2021 23:50:00 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F181C0613CF; Thu, 26 Aug 2021 20:49:12 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id u15so3080313plg.13; Thu, 26 Aug 2021 20:49:12 -0700 (PDT) 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=sL9LPCzfu7AdHdSAIzrZRarBLN9KzJsdKMehHJFnQLk=; b=dZpAN53mqAJT8RlHEZuMwDg9ErculADbWyXkX5cqjTRKH/cld92QDcI3IrtiFgM+Gn WAPRyXDff33WPoQ9hDZ8s2b5LTENCmEGpjkrX9aGj13LN54uP2CjNUtPnc/P5G+e3hJi 12DkhgmjNY+dNdIV2hIN3+sp1aMDXWoNRvlDXY47fq2ZN6wJAl7SbeWrgU8lk5DZO7dK VMmQmJDRKqw763nCGwcb/Z5OUdrhq+fDsB5dH862HAy9i0AvmcwtDfACtSOVjdXTwacu t3mzCDreJqELu7lv9YtIemkOzrKF2xSPzYc0Krf5GBjhXUcHcw4hCavdMktIUuaCrrwu lUGA== 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=sL9LPCzfu7AdHdSAIzrZRarBLN9KzJsdKMehHJFnQLk=; b=AaV5/GHOihfWUloWfKeuymNTfJFBJoCe9AojWzSZnSYx9BQUVbU+4WW/sE5qhtFzgp wT+cmsdku8t6u07raz7S93Oj4NtR3rIoQL7wU92S9kuSQu5quBRCB/n/kpaIlXAyt91R tFX0qUFlpLDtN71ZZ8gLRWKTy9dti02pongMO87vy1t7EoTVueldGvShnvgm+4F/GqXT qAouj2dbvNmG72eUV419yzkVW94CgkBTVNVy7wFiWBG9MNQ2mft4VT/aQxtFk31/oWT2 94W35qxxghfoBgWLRen80AFTVc2kslvHK8Lhlcq54G5niXlk3B4DNxgGzT/6U4Jw3eyw urZw== X-Gm-Message-State: AOAM533siKEELSJj5p5h7knHD4W/JjgO8h3gMGV8oDalIf4ikB15BRYk QATZF3fJROIPNHBZeyZSOPw= X-Received: by 2002:a17:90a:bc49:: with SMTP id t9mr8145413pjv.48.1630036151980; Thu, 26 Aug 2021 20:49:11 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id o6sm4364693pjk.4.2021.08.26.20.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 20:49:11 -0700 (PDT) From: William Breathitt Gray To: jic23@kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, 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, jarkko.nikula@linux.intel.com, William Breathitt Gray , Dan Carpenter Subject: [PATCH v16 11/14] counter: Implement *_component_id sysfs attributes Date: Fri, 27 Aug 2021 12:47:55 +0900 Message-Id: <86be841f8149b6be20cfff6a050ef64b167e37a8.1630031207.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 | 33 +++++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index aa2cd3c10d74..0ce16669157e 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.16 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/countY/spike_filter_ns KernelVersion: 5.14 diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index ee7ff1cde454..97d8d7c2a2b6 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -586,6 +586,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; @@ -601,8 +602,14 @@ 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, cattr_group, signal->ext + i, - scope, signal); + ext = &signal->ext[i]; + + err = counter_attr_create(dev, cattr_group, ext, scope, signal); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, cattr_group, ext->name, + i); if (err < 0) return err; } @@ -693,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; @@ -717,8 +725,14 @@ 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, cattr_group, count->ext + i, - scope, count); + ext = &count->ext[i]; + + err = counter_attr_create(dev, cattr_group, ext, scope, count); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, cattr_group, ext->name, + i); if (err < 0) return err; } @@ -782,6 +796,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, cattr_group); @@ -814,8 +829,14 @@ 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, cattr_group, counter->ext + i, - scope, NULL); + ext = &counter->ext[i]; + + err = counter_attr_create(dev, cattr_group, ext, scope, NULL); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, cattr_group, ext->name, + i); if (err < 0) return err; } -- 2.32.0