Skip to content

Commit 0040a39

Browse files
William Breathitt Graygregkh
authored andcommitted
counter: Introduce the Generic Counter interface
This patch introduces the Generic Counter interface for supporting counter devices. In the context of the Generic Counter interface, a counter is defined as a device that reports one or more "counts" based on the state changes of one or more "signals" as evaluated by a defined "count function." Driver callbacks should be provided to communicate with the device: to read and write various Signals and Counts, and to set and get the "action mode" and "count function" for various Synapses and Counts respectively. To support a counter device, a driver must first allocate the available Counter Signals via counter_signal structures. These Signals should be stored as an array and set to the signals array member of an allocated counter_device structure before the Counter is registered to the system. Counter Counts may be allocated via counter_count structures, and respective Counter Signal associations (Synapses) made via counter_synapse structures. Associated counter_synapse structures are stored as an array and set to the the synapses array member of the respective counter_count structure. These counter_count structures are set to the counts array member of an allocated counter_device structure before the Counter is registered to the system. A counter device is registered to the system by passing the respective initialized counter_device structure to the counter_register function; similarly, the counter_unregister function unregisters the respective Counter. The devm_counter_register and devm_counter_unregister functions serve as device memory-managed versions of the counter_register and counter_unregister functions respectively. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7df9529 commit 0040a39

8 files changed

Lines changed: 2148 additions & 0 deletions

File tree

‎MAINTAINERS‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,6 +4054,14 @@ W: http://www.fi.muni.cz/~kas/cosa/
40544054
S: Maintained
40554055
F: drivers/net/wan/cosa*
40564056

4057+
COUNTER SUBSYSTEM
4058+
M: William Breathitt Gray <vilhelm.gray@gmail.com>
4059+
L: linux-iio@vger.kernel.org
4060+
S: Maintained
4061+
F: drivers/counter/
4062+
F: include/linux/counter.h
4063+
F: include/linux/counter_enum.h
4064+
40574065
CPMAC ETHERNET DRIVER
40584066
M: Florian Fainelli <f.fainelli@gmail.com>
40594067
L: netdev@vger.kernel.org

‎drivers/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,6 @@ source "drivers/slimbus/Kconfig"
230230

231231
source "drivers/interconnect/Kconfig"
232232

233+
source "drivers/counter/Kconfig"
234+
233235
endmenu

‎drivers/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,4 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/
187187
obj-$(CONFIG_SIOX) += siox/
188188
obj-$(CONFIG_GNSS) += gnss/
189189
obj-$(CONFIG_INTERCONNECT) += interconnect/
190+
obj-$(CONFIG_COUNTER) += counter/

‎drivers/counter/Kconfig‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Counter devices
3+
#
4+
5+
menuconfig COUNTER
6+
tristate "Counter support"
7+
help
8+
This enables counter device support through the Generic Counter
9+
interface. You only need to enable this, if you also want to enable
10+
one or more of the counter device drivers below.

‎drivers/counter/Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# Makefile for Counter devices
3+
#
4+
5+
obj-$(CONFIG_COUNTER) += counter.o

0 commit comments

Comments
 (0)