Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4923815pxj; Wed, 9 Jun 2021 05:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ0ErnMN+rhwdnY6Wv/boCsddRNH4u1Lp+UXt0pXBYM0p2W7A21/YKP8R9bZjrsjIjfmlj X-Received: by 2002:a17:907:2149:: with SMTP id rk9mr1130097ejb.229.1623241302962; Wed, 09 Jun 2021 05:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623241302; cv=none; d=google.com; s=arc-20160816; b=KqQfQBl1p3YO7bcH26H4eJY6Ok1HiKW34ndDg4EFaxG3a3yFSy2BDrcrX2kwTzlDAO +UTXRH+/LfhCcunoKSPet2pnXOI8p5BlvpFvuaTwtjqfZcgzPVwl7LPZlpPqxj66BApo e5YOpyG4vY+Y1uyB6exFztX6N1JCdf2mVLh8CLdH6i0AYz5apd1okjGPwtKz8HjLaYbp BCFYHpR//V/9G3CsdpsMK11gq1xQ+zs1/ope6ZTZ+QZNsnfbjOrMP4ya2edOWS5iQYJE tVg70P2uvkqpHgHz1gO+TqhrUaLN1v86B712uWXJ4by6EPjKOntpegVKXNBTCR/H2bd6 1RzQ== 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=aCuW7jGka7YaAB6OGVNNNB5YUCrDqMyCoehChrk05rk=; b=Z6ih0Wnyqcx/wZpUAwlhBzbSsGfBt5I4JDMqk2YY91AwvspopEwFRFu+WK/F71l+bn 3J7KygLEghbNI6WOhp83/S2v807V8WtPHm4LYBEs5JCOYY/ugR0maN/vnsPvxuWFLhq9 LuqYTKAeD66Lur6SQt7/RV2F9RtbCP9nUl7CqSs0j/CYnpERatoPeo3wlMGI7ym3vqFn YBpxyxBshNgNuQgMO7EfuPXj1c4dn5y/w4ozqVtthZ0WTisbRdc+iFR9xE5OGKlM6Jx/ 3ay3UMstjPN8071r8JnvbXZRCA1mOVJ14QctmX6Jq0dVFGB9BDRTON+lqOeBmuARl8ZD CHCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k0Y0w7o6; 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 f5si2121527eja.729.2021.06.09.05.21.19; Wed, 09 Jun 2021 05:21:42 -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=k0Y0w7o6; 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 S236159AbhFIBhe (ORCPT + 99 others); Tue, 8 Jun 2021 21:37:34 -0400 Received: from mail-pj1-f46.google.com ([209.85.216.46]:39626 "EHLO mail-pj1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232102AbhFIBhd (ORCPT ); Tue, 8 Jun 2021 21:37:33 -0400 Received: by mail-pj1-f46.google.com with SMTP id o17-20020a17090a9f91b029015cef5b3c50so427496pjp.4; Tue, 08 Jun 2021 18:35:26 -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=aCuW7jGka7YaAB6OGVNNNB5YUCrDqMyCoehChrk05rk=; b=k0Y0w7o62/ZUCq0H5IBEX46jp7+f9zMlJGF1kfDlbV1wvSK9tLDck1jyKMPeUZINBZ lpMg5+9xbYsxXtIFzDQEEyBCYHdVkAjuwFOrda5Fa04YpMIT+vsNL2KDFH8EiAMx0xAg xzXXgJ8gQLdO7tPuQ9NpUhHEaqdn/sVOmYO5FyMXXkdqLkootWWjXyGvxg3umNZ5f2aG 7ipNHdgsIB5cJzw2Eq58OLXepLrl+g5zZxmATOFUgEUqwYy4WtjI4e5//5stDAQaF4ql zZFSjnV8XO/35PsGCVu6GYuaeccdI+Dsxiq+G7e5rARLsLX+xuOmuX0YMN/W9QGoIW22 I4vA== 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=aCuW7jGka7YaAB6OGVNNNB5YUCrDqMyCoehChrk05rk=; b=BLFodSQ8WnS6jJssda1Rzfzr7y6Cj2JnPPcE2ca/B4UTxgSgaU4lgQhxz774ph3+2a PusdppdnTrstenqZJayz/40XHSPkC5QqOlYEjU26Asla+Z/1l8FcgENJYiOKXXadFWgg dxxl5AYURJHBf4Kjf83o9LPaiNuPQEd2pyD7TvQo3hhc0af0ZaDnH5QRLCCQAq7KUIQ5 20Jbw709qvcGX6W639no1gRm/4fF/ob3YbtFxjfOmaj2lzKiQzPPAS3b7uj7rVhdH3ks fi8KAAk/DW/dm5J/30bRN3Hjtdc4bBTSYGuNUbHRP0lzp5eLRZ2iERusKgKfJbGGtR70 t3RQ== X-Gm-Message-State: AOAM53378KfLgwxGAnL+XfcAuxDldPUrZVOu+q299CiBkqno2FrTrk59 h6rcyZZ1zAGPvkF7/zDclcI= X-Received: by 2002:a17:90b:d95:: with SMTP id bg21mr16917682pjb.115.1623202466237; Tue, 08 Jun 2021 18:34:26 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id v14sm12659815pgl.86.2021.06.08.18.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 18:34:25 -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 v11 30/33] counter: Implement *_component_id sysfs attributes Date: Wed, 9 Jun 2021 10:31:33 +0900 Message-Id: <2032cf9e7bcac003306f4e43bb7552b68c8d24a9.1623201082.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.32.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 | 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 9809d8a47431..e0e99adb0ecc 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.15 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 bb49a10f160b..eb1505bfbd89 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; } -- 2.32.0