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