[libgpiod][PATCH v3 1/3] API: add a function for retrieving the capacity of edge event buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a getter for the edge-event buffer capacity property. This is useful
if we want to read the maximum number of events that can be stored in
a buffer object without externally storing its capacity.

Signed-off-by: Bartosz Golaszewski <brgl@xxxxxxxx>
---
 include/gpiod.h  | 9 +++++++++
 lib/edge-event.c | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/include/gpiod.h b/include/gpiod.h
index 66e6c12..8fc20ed 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -989,6 +989,15 @@ unsigned long gpiod_edge_event_get_line_seqno(struct gpiod_edge_event *event);
 struct gpiod_edge_event_buffer *
 gpiod_edge_event_buffer_new(unsigned int capacity);
 
+/**
+ * @brief Get the capacity (the max number of events that can be stored) of
+ *        the event buffer.
+ * @param buffer Edge event buffer.
+ * @return The capacity of the buffer.
+ */
+unsigned int
+gpiod_edge_event_buffer_get_capacity(struct gpiod_edge_event_buffer *buffer);
+
 /**
  * @brief Free the edge event buffer and release all associated resources.
  * @param buffer Edge event buffer to free.
diff --git a/lib/edge-event.c b/lib/edge-event.c
index 4aece4b..ab484ad 100644
--- a/lib/edge-event.c
+++ b/lib/edge-event.c
@@ -109,6 +109,12 @@ gpiod_edge_event_buffer_new(unsigned int capacity)
 	return buf;
 }
 
+GPIOD_API unsigned int
+gpiod_edge_event_buffer_get_capacity(struct gpiod_edge_event_buffer *buffer)
+{
+	return buffer->capacity;
+}
+
 GPIOD_API void
 gpiod_edge_event_buffer_free(struct gpiod_edge_event_buffer *buffer)
 {
-- 
2.30.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux