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>
Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [libgpiod][PATCH 1/4] events: hide the *_read_fd() symbols from the API header
Date: Mon, 21 Jun 2021 21:18:27 +0200	[thread overview]
Message-ID: <20210621191830.10628-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20210621191830.10628-1-brgl@bgdev.pl>

While exposing file descriptors for polling (for use by event loops) is
a common pattern, allowing to read data directly from file descriptors
isn't really a thing in most linux libraries. Sane event loops allow to
associate data with polled file descriptors so users know which object
to use for receiving data when it's available.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 include/gpiod.h  | 24 ------------------------
 lib/edge-event.c |  5 ++---
 lib/info-event.c |  2 +-
 lib/internal.h   |  3 +++
 4 files changed, 6 insertions(+), 28 deletions(-)

diff --git a/include/gpiod.h b/include/gpiod.h
index 50987a3..f3d20d4 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -410,14 +410,6 @@ gpiod_info_event_peek_line_info(struct gpiod_info_event *event);
 struct gpiod_line_info *
 gpiod_info_event_get_line_info(struct gpiod_info_event *event);
 
-/**
- * @brief Read the line info event from a file descriptor.
- * @param fd File descriptor to read from.
- * @return New info event object or NULL on error. The returned object must be
- *         freed using ::gpiod_info_event_free.
- */
-struct gpiod_info_event *gpiod_info_event_read_fd(int fd);
-
 /**
  * @}
  *
@@ -1036,22 +1028,6 @@ gpiod_edge_event_buffer_get_event(struct gpiod_edge_event_buffer *buffer,
 unsigned int
 gpiod_edge_event_buffer_num_events(struct gpiod_edge_event_buffer *buffer);
 
-/**
- * @brief Read GPIO edge events directly from a file descriptor.
- * @param fd File descriptor.
- * @param buffer Line event buffer.
- * @param max_events Maximum number of events to read.
- * @return On success returns the number of events read from the file
- *         descriptor, on failure return -1.
- *
- * Users who directly poll the file descriptor for incoming events can also
- * directly read the event data from it using this routine. This function
- * translates the kernel representation of the event to the libgpiod format.
- */
-int gpiod_edge_event_buffer_read_fd(int fd,
-				    struct gpiod_edge_event_buffer *buffer,
-				    unsigned int max_events);
-
 /**
  * @}
  *
diff --git a/lib/edge-event.c b/lib/edge-event.c
index 4618116..f8aaa33 100644
--- a/lib/edge-event.c
+++ b/lib/edge-event.c
@@ -146,9 +146,8 @@ gpiod_edge_event_buffer_num_events(struct gpiod_edge_event_buffer *buffer)
 	return buffer->num_events;
 }
 
-GPIOD_API int
-gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer,
-				unsigned int max_events)
+int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer,
+				    unsigned int max_events)
 {
 	struct gpio_v2_line_event *curr;
 	struct gpiod_edge_event *event;
diff --git a/lib/info-event.c b/lib/info-event.c
index 587a599..3c55d36 100644
--- a/lib/info-event.c
+++ b/lib/info-event.c
@@ -86,7 +86,7 @@ gpiod_info_event_get_line_info(struct gpiod_info_event *event)
 	return gpiod_line_info_copy(event->info);
 }
 
-GPIOD_API struct gpiod_info_event *gpiod_info_event_read_fd(int fd)
+struct gpiod_info_event *gpiod_info_event_read_fd(int fd)
 {
 	struct gpio_v2_line_info_changed evbuf;
 	ssize_t rd;
diff --git a/lib/internal.h b/lib/internal.h
index 20ef2e4..225e2b0 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -25,8 +25,11 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
 				const unsigned int *offsets);
 struct gpiod_line_request *
 gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf);
+int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer,
+				    unsigned int max_events);
 struct gpiod_info_event *
 gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf);
+struct gpiod_info_event *gpiod_info_event_read_fd(int fd);
 
 int gpiod_poll_fd(int fd, uint64_t timeout);
 
-- 
2.30.1


  reply	other threads:[~2021-06-21 19:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 19:18 [libgpiod][PATCH 0/4] libgpiod v2: C++ bindings Bartosz Golaszewski
2021-06-21 19:18 ` Bartosz Golaszewski [this message]
2021-06-21 19:18 ` [libgpiod][PATCH 2/4] API: drop "peek" functions Bartosz Golaszewski
2021-06-21 19:18 ` [libgpiod][PATCH 3/4] API: add an AS_IS value for bias setting Bartosz Golaszewski
2021-06-21 19:18 ` [libgpiod][PATCH 4/4] bindings: cxx: implement C++ bindings for libgpiod v2.0 Bartosz Golaszewski
2021-06-27  8:47   ` Kent Gibson
2021-06-28 11:30     ` Andy Shevchenko
2021-06-28 11:34       ` Kent Gibson
2021-06-28 11:53         ` Andy Shevchenko
2021-06-28 14:25           ` Kent Gibson
2021-07-02  8:50     ` Bartosz Golaszewski
2021-07-02 11:38       ` Kent Gibson

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=20210621191830.10628-2-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.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).