Commit 4bdec61d authored by William Breathitt Gray's avatar William Breathitt Gray Committed by Jonathan Cameron

counter: Implement *_component_id sysfs attributes

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 <david@lechnology.com>
Cc: Gwendal Grignou <gwendal@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/8961a11edbb882fc689e468194f5be75f572443e.1632884256.git.vilhelm.gray@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent bb6264a6
...@@ -203,12 +203,26 @@ Description: ...@@ -203,12 +203,26 @@ Description:
both edges: both edges:
Any state transition. 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/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 KernelVersion: 5.16
Contact: linux-iio@vger.kernel.org Contact: linux-iio@vger.kernel.org
Description: Description:
Read-only attribute that indicates the component ID of the 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 What: /sys/bus/counter/devices/counterX/countY/spike_filter_ns
KernelVersion: 5.14 KernelVersion: 5.14
......
...@@ -586,6 +586,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter, ...@@ -586,6 +586,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter,
int err; int err;
struct counter_comp comp; struct counter_comp comp;
size_t i; size_t i;
struct counter_comp *ext;
/* Create main Signal attribute */ /* Create main Signal attribute */
comp = counter_signal_comp; comp = counter_signal_comp;
...@@ -601,8 +602,14 @@ static int counter_signal_attrs_create(struct counter_device *const counter, ...@@ -601,8 +602,14 @@ static int counter_signal_attrs_create(struct counter_device *const counter,
/* Create an attribute for each extension */ /* Create an attribute for each extension */
for (i = 0; i < signal->num_ext; i++) { for (i = 0; i < signal->num_ext; i++) {
err = counter_attr_create(dev, cattr_group, signal->ext + i, ext = &signal->ext[i];
scope, signal);
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) if (err < 0)
return err; return err;
} }
...@@ -693,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter, ...@@ -693,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter,
int err; int err;
struct counter_comp comp; struct counter_comp comp;
size_t i; size_t i;
struct counter_comp *ext;
/* Create main Count attribute */ /* Create main Count attribute */
comp = counter_count_comp; comp = counter_count_comp;
...@@ -717,8 +725,14 @@ static int counter_count_attrs_create(struct counter_device *const counter, ...@@ -717,8 +725,14 @@ static int counter_count_attrs_create(struct counter_device *const counter,
/* Create an attribute for each extension */ /* Create an attribute for each extension */
for (i = 0; i < count->num_ext; i++) { for (i = 0; i < count->num_ext; i++) {
err = counter_attr_create(dev, cattr_group, count->ext + i, ext = &count->ext[i];
scope, count);
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) if (err < 0)
return err; return err;
} }
...@@ -782,6 +796,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, ...@@ -782,6 +796,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter,
struct device *const dev = &counter->dev; struct device *const dev = &counter->dev;
int err; int err;
size_t i; size_t i;
struct counter_comp *ext;
/* Add Signals sysfs attributes */ /* Add Signals sysfs attributes */
err = counter_sysfs_signals_add(counter, cattr_group); err = counter_sysfs_signals_add(counter, cattr_group);
...@@ -814,8 +829,14 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, ...@@ -814,8 +829,14 @@ static int counter_sysfs_attr_add(struct counter_device *const counter,
/* Create an attribute for each extension */ /* Create an attribute for each extension */
for (i = 0; i < counter->num_ext; i++) { for (i = 0; i < counter->num_ext; i++) {
err = counter_attr_create(dev, cattr_group, counter->ext + i, ext = &counter->ext[i];
scope, NULL);
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) if (err < 0)
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment