diff mbox series

[U-Boot,01/13] mailbox: check ops prior calling

Message ID 300f8ca074d22481ec299ddfa29c23887148633e.1569591296.git.michal.simek@xilinx.com
State New
Delegated to: Michal Simek
Headers show
Series arm64: zynqmp: Clean communication with PMUFW | expand

Commit Message

Michal Simek Sept. 27, 2019, 1:34 p.m. UTC
From: Ibai Erkiaga <ibai.erkiaga-elorza@xilinx.com>

Check if request and free operations are present prior calling to the
functions.

Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/mailbox/mailbox-uclass.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c
index 1b4a5863c9e5..809f26b20258 100644
--- a/drivers/mailbox/mailbox-uclass.c
+++ b/drivers/mailbox/mailbox-uclass.c
@@ -63,7 +63,8 @@  int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan)
 		return ret;
 	}
 
-	ret = ops->request(chan);
+	if (ops->request)
+		ret = ops->request(chan);
 	if (ret) {
 		debug("ops->request() failed: %d\n", ret);
 		return ret;
@@ -94,7 +95,10 @@  int mbox_free(struct mbox_chan *chan)
 
 	debug("%s(chan=%p)\n", __func__, chan);
 
-	return ops->free(chan);
+	if (ops->free)
+		return ops->free(chan);
+
+	return 0;
 }
 
 int mbox_send(struct mbox_chan *chan, const void *data)