Lines Matching full:counter
3 * Generic Counter sysfs interface
6 #include <linux/counter.h>
20 #include "counter-sysfs.h"
28 * struct counter_attribute - Counter sysfs attribute
30 * @l: node to add Counter attribute to attribute group list
31 * @comp: Counter component callbacks and data
32 * @scope: Counter scope of the attribute
109 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_u8_show() local
115 err = a->comp.device_u8_read(counter, &data); in counter_comp_u8_show()
118 err = a->comp.signal_u8_read(counter, a->parent, &data); in counter_comp_u8_show()
121 err = a->comp.count_u8_read(counter, a->parent, &data); in counter_comp_u8_show()
141 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_u8_store() local
156 err = a->comp.device_u8_write(counter, data); in counter_comp_u8_store()
159 err = a->comp.signal_u8_write(counter, a->parent, data); in counter_comp_u8_store()
162 err = a->comp.count_u8_write(counter, a->parent, data); in counter_comp_u8_store()
177 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_u32_show() local
184 err = a->comp.device_u32_read(counter, &data); in counter_comp_u32_show()
187 err = a->comp.signal_u32_read(counter, a->parent, &data); in counter_comp_u32_show()
191 err = a->comp.action_read(counter, a->parent, in counter_comp_u32_show()
194 err = a->comp.count_u32_read(counter, a->parent, &data); in counter_comp_u32_show()
242 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_u32_store() local
281 err = a->comp.device_u32_write(counter, data); in counter_comp_u32_store()
284 err = a->comp.signal_u32_write(counter, a->parent, data); in counter_comp_u32_store()
288 err = a->comp.action_write(counter, count, synapse, in counter_comp_u32_store()
291 err = a->comp.count_u32_write(counter, count, data); in counter_comp_u32_store()
306 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_u64_show() local
312 err = a->comp.device_u64_read(counter, &data); in counter_comp_u64_show()
315 err = a->comp.signal_u64_read(counter, a->parent, &data); in counter_comp_u64_show()
318 err = a->comp.count_u64_read(counter, a->parent, &data); in counter_comp_u64_show()
334 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_u64_store() local
344 err = a->comp.device_u64_write(counter, data); in counter_comp_u64_store()
347 err = a->comp.signal_u64_write(counter, a->parent, data); in counter_comp_u64_store()
350 err = a->comp.count_u64_write(counter, a->parent, data); in counter_comp_u64_store()
366 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_array_u32_show() local
375 err = a->comp.signal_array_u32_read(counter, a->parent, element->idx, in counter_comp_array_u32_show()
388 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_array_u32_store() local
403 err = a->comp.signal_array_u32_write(counter, a->parent, element->idx, in counter_comp_array_u32_store()
416 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_array_u64_show() local
423 err = a->comp.device_array_u64_read(counter, element->idx, in counter_comp_array_u64_show()
427 err = a->comp.signal_array_u64_read(counter, a->parent, in counter_comp_array_u64_show()
431 err = a->comp.count_array_u64_read(counter, a->parent, in counter_comp_array_u64_show()
448 struct counter_device *const counter = counter_from_dev(dev); in counter_comp_array_u64_store() local
459 err = a->comp.device_array_u64_write(counter, element->idx, in counter_comp_array_u64_store()
463 err = a->comp.signal_array_u64_write(counter, a->parent, in counter_comp_array_u64_store()
467 err = a->comp.count_array_u64_write(counter, a->parent, in counter_comp_array_u64_store()
543 /* Configure Counter attribute */ in counter_avail_attr_create()
581 /* Configure Counter attribute */ in counter_attr_create()
690 /* Configure Counter attribute */ in counter_name_attr_create()
720 /* Allocate Counter attribute */ in counter_comp_id_attr_create()
730 /* Configure Counter attribute */ in counter_comp_id_attr_create()
840 static int counter_signal_attrs_create(struct counter_device *const counter, in counter_signal_attrs_create() argument
845 struct device *const dev = &counter->dev; in counter_signal_attrs_create()
851 comp.signal_u32_read = counter->ops->signal_read; in counter_signal_attrs_create()
866 static int counter_sysfs_signals_add(struct counter_device *const counter, in counter_sysfs_signals_add() argument
873 for (i = 0; i < counter->num_signals; i++) { in counter_sysfs_signals_add()
875 groups[i].name = devm_kasprintf(&counter->dev, GFP_KERNEL, in counter_sysfs_signals_add()
881 err = counter_signal_attrs_create(counter, groups + i, in counter_sysfs_signals_add()
882 counter->signals + i); in counter_sysfs_signals_add()
890 static int counter_sysfs_synapses_add(struct counter_device *const counter, in counter_sysfs_synapses_add() argument
898 struct device *const dev = &counter->dev; in counter_sysfs_synapses_add()
907 id = synapse->signal - counter->signals; in counter_sysfs_synapses_add()
915 comp.action_read = counter->ops->action_read; in counter_sysfs_synapses_add()
916 comp.action_write = counter->ops->action_write; in counter_sysfs_synapses_add()
940 static int counter_count_attrs_create(struct counter_device *const counter, in counter_count_attrs_create() argument
945 struct device *const dev = &counter->dev; in counter_count_attrs_create()
951 comp.count_u64_read = counter->ops->count_read; in counter_count_attrs_create()
952 comp.count_u64_write = counter->ops->count_write; in counter_count_attrs_create()
964 comp.count_u32_read = counter->ops->function_read; in counter_count_attrs_create()
965 comp.count_u32_write = counter->ops->function_write; in counter_count_attrs_create()
975 static int counter_sysfs_counts_add(struct counter_device *const counter, in counter_sysfs_counts_add() argument
983 for (i = 0; i < counter->num_counts; i++) { in counter_sysfs_counts_add()
984 count = counter->counts + i; in counter_sysfs_counts_add()
987 groups[i].name = devm_kasprintf(&counter->dev, GFP_KERNEL, in counter_sysfs_counts_add()
993 err = counter_sysfs_synapses_add(counter, groups + i, count); in counter_sysfs_counts_add()
998 err = counter_count_attrs_create(counter, groups + i, count); in counter_sysfs_counts_add()
1006 static int counter_num_signals_read(struct counter_device *counter, u8 *val) in counter_num_signals_read() argument
1008 *val = counter->num_signals; in counter_num_signals_read()
1012 static int counter_num_counts_read(struct counter_device *counter, u8 *val) in counter_num_counts_read() argument
1014 *val = counter->num_counts; in counter_num_counts_read()
1018 static int counter_events_queue_size_read(struct counter_device *counter, in counter_events_queue_size_read() argument
1021 *val = kfifo_size(&counter->events); in counter_events_queue_size_read()
1025 static int counter_events_queue_size_write(struct counter_device *counter, in counter_events_queue_size_write() argument
1038 mutex_lock(&counter->events_out_lock); in counter_events_queue_size_write()
1039 spin_lock_irqsave(&counter->events_in_lock, flags); in counter_events_queue_size_write()
1040 kfifo_free(&counter->events); in counter_events_queue_size_write()
1041 counter->events.kfifo = events.kfifo; in counter_events_queue_size_write()
1042 spin_unlock_irqrestore(&counter->events_in_lock, flags); in counter_events_queue_size_write()
1043 mutex_unlock(&counter->events_out_lock); in counter_events_queue_size_write()
1059 static int counter_sysfs_attr_add(struct counter_device *const counter, in counter_sysfs_attr_add() argument
1063 struct device *const dev = &counter->dev; in counter_sysfs_attr_add()
1067 err = counter_sysfs_signals_add(counter, cattr_group); in counter_sysfs_attr_add()
1070 cattr_group += counter->num_signals; in counter_sysfs_attr_add()
1073 err = counter_sysfs_counts_add(counter, cattr_group); in counter_sysfs_attr_add()
1076 cattr_group += counter->num_counts; in counter_sysfs_attr_add()
1079 err = counter_name_attr_create(dev, cattr_group, counter->name); in counter_sysfs_attr_add()
1102 return counter_sysfs_exts_add(dev, cattr_group, counter->ext, in counter_sysfs_attr_add()
1103 counter->num_ext, scope, NULL); in counter_sysfs_attr_add()
1109 * counter_sysfs_add - Adds Counter sysfs attributes to the device structure
1110 * @counter: Pointer to the Counter device structure
1112 * Counter sysfs attributes are created and added to the respective device
1118 int counter_sysfs_add(struct counter_device *const counter) in counter_sysfs_add() argument
1120 struct device *const dev = &counter->dev; in counter_sysfs_add()
1121 const size_t num_groups = counter->num_signals + counter->num_counts + 1; in counter_sysfs_add()
1138 /* Add Counter device sysfs attributes */ in counter_sysfs_add()
1139 err = counter_sysfs_attr_add(counter, cattr_groups); in counter_sysfs_add()