diff mbox series

[libgpiod,1/4] events: hide the *_read_fd() symbols from the API header

Message ID 20210621191830.10628-2-brgl@bgdev.pl
State New
Headers show
Series [libgpiod,1/4] events: hide the *_read_fd() symbols from the API header | expand

Commit Message

Bartosz Golaszewski June 21, 2021, 7:18 p.m. UTC
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 mbox series

Patch

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);