transport: pldm_transport_poll(): Adjust return value semantics

Prior, a timeout in pldm_transport_poll() would result in a
pldm_transport_recv() call being issued in pldm_transport_send_recv().
That's not the right course of action as it will translate to a blocking
recv() system call for either of the current transport implementations.
As there's no data present the recv() blocks indefinitely, violating the
timeout constraint.

Instead, align the behaviour with POSIX poll(2)[1], which returns the
number of active descriptors. The number of active descriptors is 0 if a
timeout occurs.

[1]: https://www.man7.org/linux/man-pages/man2/poll.2.html#RETURN_VALUE

Fixes: c1b66f420912 ("requester: Add new APIs to support multiple transports")
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Id75e8dad49a0ea6081830d0825896094bff0e827
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c93bf94..87626ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@
 ### Changed
 
 1. pdr: Allow record_handle to be NULL for pldm_pdr_add_check()
+2. transport: pldm_transport_poll(): Adjust return value semantics
 
 ### Deprecated
 
diff --git a/include/libpldm/transport.h b/include/libpldm/transport.h
index 7127335..bea0436 100644
--- a/include/libpldm/transport.h
+++ b/include/libpldm/transport.h
@@ -23,10 +23,10 @@
  *            Specifying a timeout value of zero yields an immediate return.
  *            Specifying a negative value means an indefinite timeout.
  *
- * @return pldm_requester_rc_t (errno may be set)
+ * @return 0 if a timeout occurs, 1 if the transport becomes ready, PLDM_REQUESTER_INVALID_SETUP if
+ * 	   transport is NULL, or PLDM_REQUESTER_POLL_FAIL on failure.
  */
-pldm_requester_rc_t pldm_transport_poll(struct pldm_transport *transport,
-					int timeout);
+int pldm_transport_poll(struct pldm_transport *transport, int timeout);
 
 /**
  * @brief Asynchronously send a PLDM message. Control is immediately returned to
diff --git a/src/transport/transport.c b/src/transport/transport.c
index dd9a4bd..919cc61 100644
--- a/src/transport/transport.c
+++ b/src/transport/transport.c
@@ -30,16 +30,17 @@
 #endif
 
 LIBPLDM_ABI_TESTING
-pldm_requester_rc_t pldm_transport_poll(struct pldm_transport *transport,
-					int timeout)
+int pldm_transport_poll(struct pldm_transport *transport, int timeout)
 {
 	struct pollfd pollfd;
 	int rc = 0;
 	if (!transport) {
 		return PLDM_REQUESTER_INVALID_SETUP;
 	}
+
+	/* If polling isn't supported then always indicate the transport is ready */
 	if (!transport->init_pollfd) {
-		return PLDM_REQUESTER_SUCCESS;
+		return 1;
 	}
 
 	rc = transport->init_pollfd(transport, &pollfd);
@@ -52,7 +53,8 @@
 		return PLDM_REQUESTER_POLL_FAIL;
 	}
 
-	return PLDM_REQUESTER_SUCCESS;
+	/* rc is 0 if poll(2) times out, or 1 if pollfd becomes active. */
+	return rc;
 }
 
 LIBPLDM_ABI_TESTING
@@ -185,10 +187,10 @@
 	do {
 		timersub(&end, &now, &remaining);
 		/* 0 <= `timeval_to_msec()` <= 4800, and 4800 < INT_MAX */
-		rc = pldm_transport_poll(transport,
-					 (int)(timeval_to_msec(&remaining)));
-		if (rc != PLDM_REQUESTER_SUCCESS) {
-			return rc;
+		ret = pldm_transport_poll(transport,
+					  (int)(timeval_to_msec(&remaining)));
+		if (ret <= 0) {
+			break;
 		}
 
 		rc = pldm_transport_recv_msg(transport, tid, pldm_resp_msg,