summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIwona Winiarska <iwona.winiarska@intel.com>2021-01-06 20:42:03 +0300
committerIwona Winiarska <iwona.winiarska@intel.com>2021-01-07 04:18:44 +0300
commitb1dcf75221f957715cae9698dab46d0c4ccbdb00 (patch)
tree5cd03872557a6da613818f99c20e6cd20a6bab0c
parentfc4c626deff9447cd5453b180826ed4f48fc828d (diff)
downloadlinux-b1dcf75221f957715cae9698dab46d0c4ccbdb00.tar.xz
fixup! soc: aspeed: mctp: Expose internal kernel API
Fixed a missing error handling for case where wait_event_interruptible_timeout() returns -ERESTARTSYS. Renamed the exposed functions to be more consistent with their usage. Added dedicated function to flush client rx queue. Change-Id: I0fd1bfca926b34ae0f4dc18f07e453b3861a4c3e Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>
-rw-r--r--drivers/soc/aspeed/aspeed-mctp.c30
-rw-r--r--include/linux/aspeed-mctp.h18
2 files changed, 33 insertions, 15 deletions
diff --git a/drivers/soc/aspeed/aspeed-mctp.c b/drivers/soc/aspeed/aspeed-mctp.c
index 540c5720b148..453ede400349 100644
--- a/drivers/soc/aspeed/aspeed-mctp.c
+++ b/drivers/soc/aspeed/aspeed-mctp.c
@@ -686,8 +686,8 @@ static int aspeed_mctp_release(struct inode *inode, struct file *file)
return 0;
}
-int aspeed_mctp_write_packet(struct mctp_client *client,
- struct mctp_pcie_packet *tx_packet)
+int aspeed_mctp_send_packet(struct mctp_client *client,
+ struct mctp_pcie_packet *tx_packet)
{
struct aspeed_mctp *priv = client->priv;
int ret;
@@ -704,12 +704,13 @@ int aspeed_mctp_write_packet(struct mctp_client *client,
return ret;
}
-EXPORT_SYMBOL_GPL(aspeed_mctp_write_packet);
+EXPORT_SYMBOL_GPL(aspeed_mctp_send_packet);
-struct mctp_pcie_packet *aspeed_mctp_read_packet(struct mctp_client *client,
- unsigned long timeout)
+struct mctp_pcie_packet *aspeed_mctp_receive_packet(struct mctp_client *client,
+ unsigned long timeout)
{
struct aspeed_mctp *priv = client->priv;
+ struct mctp_pcie_packet *packet;
int ret;
if (priv->pcie.bdf == 0)
@@ -718,12 +719,23 @@ struct mctp_pcie_packet *aspeed_mctp_read_packet(struct mctp_client *client,
ret = wait_event_interruptible_timeout(client->wait_queue,
__ptr_ring_peek(&client->rx_queue),
timeout);
- if (ret == 0)
- return ERR_PTR(-EAGAIN);
+ if (ret < 0)
+ return ERR_PTR(ret);
+ else if (ret == 0)
+ return ERR_PTR(-ETIME);
return ptr_ring_consume_bh(&client->rx_queue);
}
-EXPORT_SYMBOL_GPL(aspeed_mctp_read_packet);
+EXPORT_SYMBOL_GPL(aspeed_mctp_receive_packet);
+
+void aspeed_mctp_flush_rx_queue(struct mctp_client *client)
+{
+ struct mctp_pcie_packet *packet;
+
+ while (packet = ptr_ring_consume_bh(&client->rx_queue))
+ aspeed_mctp_packet_free(packet);
+}
+EXPORT_SYMBOL_GPL(aspeed_mctp_flush_rx_queue);
static ssize_t aspeed_mctp_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
@@ -783,7 +795,7 @@ static ssize_t aspeed_mctp_write(struct file *file, const char __user *buf,
tx_packet->size = count;
- ret = aspeed_mctp_write_packet(client, tx_packet);
+ ret = aspeed_mctp_send_packet(client, tx_packet);
if (ret)
goto out_packet;
diff --git a/include/linux/aspeed-mctp.h b/include/linux/aspeed-mctp.h
index 3cfa8ca927ca..3ec0bb2fad69 100644
--- a/include/linux/aspeed-mctp.h
+++ b/include/linux/aspeed-mctp.h
@@ -81,7 +81,7 @@ struct mctp_client *aspeed_mctp_create_client(struct aspeed_mctp *priv);
void aspeed_mctp_delete_client(struct mctp_client *client);
/**
- * aspeed_mctp_write_packet() - send mctp_packet
+ * aspeed_mctp_send_packet() - send mctp_packet
* @client: pointer to existing mctp_client context
* @tx_packet: the allocated packet that needs to be send via aspeed-mctp
*
@@ -92,11 +92,11 @@ void aspeed_mctp_delete_client(struct mctp_client *client);
* * 0 - success,
* * -ENOSPC - failed to send packet due to lack of available space.
*/
-int aspeed_mctp_write_packet(struct mctp_client *client,
- struct mctp_pcie_packet *tx_packet);
+int aspeed_mctp_send_packet(struct mctp_client *client,
+ struct mctp_pcie_packet *tx_packet);
/**
- * aspeed_mctp_read_packet() - receive mctp_packet
+ * aspeed_mctp_receive_packet() - receive mctp_packet
* @client: pointer to existing mctp_client context
* @timeout: timeout, in jiffies
*
@@ -108,8 +108,14 @@ int aspeed_mctp_write_packet(struct mctp_client *client,
* Returns struct mctp_pcie_packet from or ERR_PTR in case of error or the
* @timeout elapsed.
*/
-struct mctp_pcie_packet *aspeed_mctp_read_packet(struct mctp_client *client,
- unsigned long timeout);
+struct mctp_pcie_packet *aspeed_mctp_receive_packet(struct mctp_client *client,
+ unsigned long timeout);
+
+/**
+ * aspeed_mctp_flush_rx_queue() - remove all mctp_packets from rx queue
+ * @client: pointer to existing mctp_client context
+ */
+void aspeed_mctp_flush_rx_queue(struct mctp_client *client);
void *aspeed_mctp_packet_alloc(gfp_t flags);
void aspeed_mctp_packet_free(void *packet);