Commit 0040a390 authored by William Breathitt Gray's avatar William Breathitt Gray Committed by Greg Kroah-Hartman

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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7df95299
...@@ -4054,6 +4054,14 @@ W: http://www.fi.muni.cz/~kas/cosa/ ...@@ -4054,6 +4054,14 @@ W: http://www.fi.muni.cz/~kas/cosa/
S: Maintained S: Maintained
F: drivers/net/wan/cosa* F: drivers/net/wan/cosa*
COUNTER SUBSYSTEM
M: William Breathitt Gray <vilhelm.gray@gmail.com>
L: linux-iio@vger.kernel.org
S: Maintained
F: drivers/counter/
F: include/linux/counter.h
F: include/linux/counter_enum.h
CPMAC ETHERNET DRIVER CPMAC ETHERNET DRIVER
M: Florian Fainelli <f.fainelli@gmail.com> M: Florian Fainelli <f.fainelli@gmail.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
......
...@@ -230,4 +230,6 @@ source "drivers/slimbus/Kconfig" ...@@ -230,4 +230,6 @@ source "drivers/slimbus/Kconfig"
source "drivers/interconnect/Kconfig" source "drivers/interconnect/Kconfig"
source "drivers/counter/Kconfig"
endmenu endmenu
...@@ -187,3 +187,4 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ ...@@ -187,3 +187,4 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/
obj-$(CONFIG_SIOX) += siox/ obj-$(CONFIG_SIOX) += siox/
obj-$(CONFIG_GNSS) += gnss/ obj-$(CONFIG_GNSS) += gnss/
obj-$(CONFIG_INTERCONNECT) += interconnect/ obj-$(CONFIG_INTERCONNECT) += interconnect/
obj-$(CONFIG_COUNTER) += counter/
#
# Counter devices
#
menuconfig COUNTER
tristate "Counter support"
help
This enables counter device support through the Generic Counter
interface. You only need to enable this, if you also want to enable
one or more of the counter device drivers below.
#
# Makefile for Counter devices
#
obj-$(CONFIG_COUNTER) += counter.o
This diff is collapsed.
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Counter interface enum functions
* Copyright (C) 2018 William Breathitt Gray
*/
#ifndef _COUNTER_ENUM_H_
#define _COUNTER_ENUM_H_
#include <linux/types.h>
struct counter_device;
struct counter_signal;
struct counter_count;
ssize_t counter_signal_enum_read(struct counter_device *counter,
struct counter_signal *signal, void *priv,
char *buf);
ssize_t counter_signal_enum_write(struct counter_device *counter,
struct counter_signal *signal, void *priv,
const char *buf, size_t len);
ssize_t counter_signal_enum_available_read(struct counter_device *counter,
struct counter_signal *signal,
void *priv, char *buf);
ssize_t counter_count_enum_read(struct counter_device *counter,
struct counter_count *count, void *priv,
char *buf);
ssize_t counter_count_enum_write(struct counter_device *counter,
struct counter_count *count, void *priv,
const char *buf, size_t len);
ssize_t counter_count_enum_available_read(struct counter_device *counter,
struct counter_count *count,
void *priv, char *buf);
ssize_t counter_device_enum_read(struct counter_device *counter, void *priv,
char *buf);
ssize_t counter_device_enum_write(struct counter_device *counter, void *priv,
const char *buf, size_t len);
ssize_t counter_device_enum_available_read(struct counter_device *counter,
void *priv, char *buf);
#endif /* _COUNTER_ENUM_H_ */
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