linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Jack Winch <sunt.un.morcov@gmail.com>,
	Helmut Grohne <helmut.grohne@intenta.de>,
	Ben Hutchings <ben.hutchings@essensium.com>
Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [libgpiod][PATCH v2 1/3] API: add a function for retrieving the capacity of edge event buffers
Date: Thu, 15 Jul 2021 22:09:59 +0200	[thread overview]
Message-ID: <20210715201001.23726-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20210715201001.23726-1-brgl@bgdev.pl>

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@bgdev.pl>
---
 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


  reply	other threads:[~2021-07-15 20:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 20:09 [libgpiod][PATCH v2 0/3] libgpiod v2: C++ bindings Bartosz Golaszewski
2021-07-15 20:09 ` Bartosz Golaszewski [this message]
2021-07-15 20:10 ` [libgpiod][PATCH v2 2/3] API: extend the line request functionality Bartosz Golaszewski
2021-07-15 20:10 ` [libgpiod][PATCH v2 3/3] bindings: cxx: implement C++ bindings for libgpiod v2.0 Bartosz Golaszewski
2021-07-15 22:18   ` Ben Hutchings
2021-07-16  7:44     ` Bartosz Golaszewski
2021-07-16  8:56       ` Bartosz Golaszewski
2021-07-16 13:24         ` Bartosz Golaszewski
2021-07-22 10:48           ` Jack Winch
2021-07-22 19:38             ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210715201001.23726-2-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ben.hutchings@essensium.com \
    --cc=helmut.grohne@intenta.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sunt.un.morcov@gmail.com \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).