bindings: Add mctp_*_init_pollfd() API

The new API allows the binding to own the poll(2) parameters, providing
the opportunity for it to properly idle when it's unable to send control
messages. Despite this, we hold off on adjusting the behaviour directly
in this commit, as it would constitute a regression until
mctp-demux-daemon has also been converted to exploit the new API.

Change-Id: Ic5a7c5a943566a0f36695daa64457440886fb2ab
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/serial.c b/serial.c
index ac91eb4..b12fcfb 100644
--- a/serial.c
+++ b/serial.c
@@ -10,8 +10,9 @@
 #endif
 
 #ifdef MCTP_HAVE_FILEIO
-#include <unistd.h>
 #include <fcntl.h>
+#include <poll.h>
+#include <unistd.h>
 #else
 static const size_t write(int fd, void *buf, size_t len)
 {
@@ -41,9 +42,9 @@
 #include "container_of.h"
 
 struct mctp_binding_serial {
-	struct mctp_binding	binding;
-	int			fd;
-	unsigned long		bus_id;
+	struct mctp_binding binding;
+	int fd;
+	unsigned long bus_id;
 
 	mctp_serial_tx_fn	tx_fn;
 	void			*tx_fn_data;
@@ -291,6 +292,15 @@
 	return serial->fd;
 }
 
+int mctp_serial_init_pollfd(struct mctp_binding_serial *serial,
+			    struct pollfd *pollfd)
+{
+	pollfd->fd = serial->fd;
+	pollfd->events = POLLIN;
+
+	return 0;
+}
+
 int mctp_serial_open_path(struct mctp_binding_serial *serial,
 		const char *device)
 {