/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Userspace ABI for Counter character devices * Copyright (C) 2020 William Breathitt Gray */ #ifndef _UAPI_COUNTER_H_ #define _UAPI_COUNTER_H_ #include <linux/ioctl.h> #include <linux/types.h> /* Component type definitions */ enum counter_component_type { … }; /* Component scope definitions */ enum counter_scope { … }; /** * struct counter_component - Counter component identification * @type: component type (one of enum counter_component_type) * @scope: component scope (one of enum counter_scope) * @parent: parent ID (matching the ID suffix of the respective parent sysfs * path as described by the ABI documentation file * Documentation/ABI/testing/sysfs-bus-counter) * @id: component ID (matching the ID provided by the respective *_component_id * sysfs attribute of the desired component) * * For example, if the Count 2 ceiling extension of Counter device 4 is desired, * set type equal to COUNTER_COMPONENT_EXTENSION, scope equal to * COUNTER_SCOPE_COUNT, parent equal to 2, and id equal to the value provided by * the respective /sys/bus/counter/devices/counter4/count2/ceiling_component_id * sysfs attribute. */ struct counter_component { … }; /* Event type definitions */ enum counter_event_type { … }; /** * struct counter_watch - Counter component watch configuration * @component: component to watch when event triggers * @event: event that triggers (one of enum counter_event_type) * @channel: event channel (typically 0 unless the device supports concurrent * events of the same type) */ struct counter_watch { … }; /* * Queues a Counter watch for the specified event. * * The queued watches will not be applied until COUNTER_ENABLE_EVENTS_IOCTL is * called. */ #define COUNTER_ADD_WATCH_IOCTL … /* * Enables monitoring the events specified by the Counter watches that were * queued by COUNTER_ADD_WATCH_IOCTL. * * If events are already enabled, the new set of watches replaces the old one. * Calling this ioctl also has the effect of clearing the queue of watches added * by COUNTER_ADD_WATCH_IOCTL. */ #define COUNTER_ENABLE_EVENTS_IOCTL … /* * Stops monitoring the previously enabled events. */ #define COUNTER_DISABLE_EVENTS_IOCTL … /** * struct counter_event - Counter event data * @timestamp: best estimate of time of event occurrence, in nanoseconds * @value: component value * @watch: component watch configuration * @status: return status (system error number) */ struct counter_event { … }; /* Count direction values */ enum counter_count_direction { … }; /* Count mode values */ enum counter_count_mode { … }; /* Count function values */ enum counter_function { … }; /* Signal values */ enum counter_signal_level { … }; /* Action mode values */ enum counter_synapse_action { … }; /* Signal polarity values */ enum counter_signal_polarity { … }; #endif /* _UAPI_COUNTER_H_ */