aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/counter
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2021-09-29 12:16:03 +0900
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-10-17 10:54:48 +0100
commit4bdec61d927b5db25f75fa377504d4e127c3682b (patch)
treeb70d819dcd8990dd9ba721e36746ae9e94a03cd0 /drivers/counter
parentbb6264a61de84320e77a22b4b8f4babf240608c4 (diff)
downloadlinux-4bdec61d927b5db25f75fa377504d4e127c3682b.tar.gz
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: William Breathitt Gray <vilhelm.gray@gmail.com> Link: https://lore.kernel.org/r/8961a11edbb882fc689e468194f5be75f572443e.1632884256.git.vilhelm.gray@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/counter')
-rw-r--r--drivers/counter/counter-sysfs.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
index ee7ff1cde4549..97d8d7c2a2b6f 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;
}